Skip to content

Instantly share code, notes, and snippets.

@joevandyk
Created December 3, 2013 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joevandyk/7776710 to your computer and use it in GitHub Desktop.
Save joevandyk/7776710 to your computer and use it in GitHub Desktop.
Limit (cost=1.58..10202285.08 rows=5 width=4) (actual time=1411.210..1661.481 rows=5 loops=1)
-> Unique (cost=1.58..20125024428.69 rows=9863 width=4) (actual time=1411.209..1661.479 rows=5 loops=1)
-> Nested Loop (cost=1.58..20125024404.03 rows=9863 width=4) (actual time=1411.209..1661.473 rows=8 loops=1)
Join Filter: ((SubPlan 8) IS TRUE)
-> Nested Loop (cost=1.29..30771878.73 rows=19726 width=12) (actual time=1360.868..1473.461 rows=8 loops=1)
Join Filter: (ci.sku_id = s.id)
Rows Removed by Join Filter: 781965
-> Nested Loop Anti Join (cost=1.29..514635.91 rows=19726 width=12) (actual time=1335.537..1347.890 rows=8 loops=1)
-> Nested Loop (cost=0.86..476369.46 rows=62559 width=25) (actual time=1329.325..1347.381 rows=14 loops=1)
-> Index Scan using cart_items_cart_id_idx on cart_items ci (cost=0.43..183520.84 rows=95690 width=8) (actual time=1329.300..1347.198 rows=14 loops=1)
Filter: ((created_at >= (now() - '200:00:00'::interval)) AND (created_at <= (now() - '00:20:00'::interval)))
Rows Removed by Filter: 2723516
-> Index Scan using carts_pkey on carts (cost=0.43..3.05 rows=1 width=21) (actual time=0.011..0.011 rows=1 loops=14)
Index Cond: (id = ci.cart_id)
Filter: ((email_address)::text <> ''::text)
-> Index Only Scan using orders_unique_id on orders (cost=0.43..0.60 rows=1 width=11) (actual time=0.035..0.035 rows=0 loops=14)
Index Cond: (uuid = (carts.uuid)::text)
Heap Fetches: 6
-> Materialize (cost=0.00..3337.72 rows=102248 width=8) (actual time=0.002..8.558 rows=97747 loops=8)
-> Seq Scan on skus s (cost=0.00..2826.48 rows=102248 width=8) (actual time=0.006..17.570 rows=102248 loops=1)
-> Index Only Scan using products_pkey on products p (cost=0.29..0.56 rows=1 width=4) (actual time=0.011..0.012 rows=1 loops=8)
Index Cond: (id = s.product_id)
Heap Fetches: 8
SubPlan 8
-> Subquery Scan on product_info (cost=11758.90..1018667.81 rows=21978 width=1) (actual time=23.463..23.486 rows=1 loops=8)
-> HashAggregate (cost=11758.90..1018448.03 rows=21978 width=40) (actual time=23.435..23.458 rows=1 loops=8)
CTE active_channel_ids
-> Bitmap Heap Scan on channels (cost=22.89..130.66 rows=89 width=4) (actual time=0.179..0.494 rows=32 loops=8)
Recheck Cond: (site_id = carts.site_id)
Filter: (((start_at)::timestamp with time zone IS NOT NULL) AND (type = 'sale'::channel_type) AND ((start_at)::timestamp with time zone < now()) AND (((end_at)::timestamp with time zone IS NULL) OR (now() < (end_at)::timestamp with time zone)))
Rows Removed by Filter: 586
-> Bitmap Index Scan on index_channels_on_site_id (cost=0.00..22.87 rows=879 width=0) (actual time=0.128..0.128 rows=2166 loops=8)
Index Cond: (site_id = carts.site_id)
CTE postpone_sales_channel_ids
-> Bitmap Heap Scan on channels channels_1 (cost=27.66..59.38 rows=5 width=4) (actual time=0.135..0.148 rows=31 loops=8)
Recheck Cond: ((start_at > now()) AND (site_id = carts.site_id))
Filter: (postpone_product_sales IS TRUE)
Rows Removed by Filter: 1
-> BitmapAnd (cost=27.66..27.66 rows=11 width=0) (actual time=0.131..0.131 rows=0 loops=8)
-> Bitmap Index Scan on channels_start_at_idx (cost=0.00..4.54 rows=34 width=0) (actual time=0.014..0.014 rows=32 loops=8)
Index Cond: (start_at > now())
-> Bitmap Index Scan on index_channels_on_site_id (cost=0.00..22.87 rows=879 width=0) (actual time=0.115..0.115 rows=2166 loops=8)
Index Cond: (site_id = carts.site_id)
-> Hash Right Join (cost=8706.27..10838.02 rows=36542 width=40) (actual time=16.486..22.683 rows=5 loops=8)
Hash Cond: (channels_products.product_id = products.id)
-> Seq Scan on channels_products (cost=0.00..1126.84 rows=73084 width=8) (actual time=0.004..5.726 rows=73084 loops=8)
-> Hash (cost=8431.55..8431.55 rows=21978 width=40) (actual time=11.291..11.291 rows=1 loops=8)
Buckets: 4096 Batches: 1 Memory Usage: 1kB
-> Hash Join (cost=1227.01..8431.55 rows=21978 width=40) (actual time=1.931..11.288 rows=1 loops=8)
Hash Cond: (products.id = ps.product_id)
-> Seq Scan on products (cost=0.00..6792.45 rows=21978 width=39) (actual time=0.336..9.692 rows=1 loops=8)
Filter: CASE WHEN (p.id IS NOT NULL) THEN (id = p.id) ELSE true END
Rows Removed by Filter: 43955
-> Hash (cost=677.56..677.56 rows=43956 width=5) (actual time=12.713..12.713 rows=43956 loops=1)
Buckets: 8192 Batches: 1 Memory Usage: 1718kB
-> Seq Scan on product_stats ps (cost=0.00..677.56 rows=43956 width=5) (actual time=0.014..5.651 rows=43956 loops=1)
SubPlan 3
-> Hash Join (cost=15.26..17.61 rows=1 width=0) (actual time=0.534..0.534 rows=1 loops=8)
Hash Cond: (c.id = cp.channel_id)
-> CTE Scan on active_channel_ids c (cost=0.00..1.78 rows=89 width=4) (actual time=0.185..0.507 rows=32 loops=8)
-> Hash (cost=15.22..15.22 rows=3 width=4) (actual time=0.014..0.014 rows=5 loops=8)
Buckets: 1024 Batches: 1 Memory Usage: 1kB
-> Index Scan using channels_products_product_id_idx on channels_products cp (cost=0.29..15.22 rows=3 width=4) (actual time=0.010..0.012 rows=5 loops=8)
Index Cond: (product_id = products.id)
SubPlan 4
-> Nested Loop (cost=0.29..15.56 rows=1 width=0) (actual time=0.186..0.186 rows=0 loops=8)
Join Filter: (c_1.id = cp_1.channel_id)
Rows Removed by Join Filter: 143
-> CTE Scan on postpone_sales_channel_ids c_1 (cost=0.00..0.10 rows=5 width=4) (actual time=0.137..0.155 rows=31 loops=8)
-> Materialize (cost=0.29..15.24 rows=3 width=4) (actual time=0.000..0.000 rows=5 loops=248)
-> Index Scan using channels_products_product_id_idx on channels_products cp_1 (cost=0.29..15.22 rows=3 width=4) (actual time=0.002..0.003 rows=5 loops=8)
Index Cond: (product_id = products.id)
SubPlan 7
-> Result (cost=12.60..12.62 rows=1 width=0) (never executed)
InitPlan 5 (returns $6)
-> Aggregate (cost=4.40..4.41 rows=1 width=3) (never executed)
-> Index Scan using purchase_permissions_created_at_idx on purchase_permissions (cost=0.28..4.40 rows=1 width=3) (never executed)
Index Cond: (created_at > (now() - '14 days'::interval))
Filter: ((quantity > 0) AND (product_id = products.id) AND (user_id = CASE WHEN (current_setting('tanga.current_user_id'::text) = ''::text) THEN NULL::integer ELSE (current_setting('tanga.current_user_id'::text))::integer END))
InitPlan 6 (returns $10)
-> Index Scan using users_pkey on users (cost=0.44..8.19 rows=1 width=6) (never executed)
Index Cond: (id = CASE WHEN (current_setting('tanga.current_user_id'::text) = ''::text) THEN NULL::integer ELSE (current_setting('tanga.current_user_id'::text))::integer END)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment