Skip to content

Instantly share code, notes, and snippets.

@joevandyk
Created March 28, 2014 17:10
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/9837788 to your computer and use it in GitHub Desktop.
Save joevandyk/9837788 to your computer and use it in GitHub Desktop.
Limit (cost=7171333.18..7171333.18 rows=1 width=244) (actual time=14789.118..14789.119 rows=1 loops=1)
-> Sort (cost=7171333.18..7171504.71 rows=68611 width=244) (actual time=14789.115..14789.115 rows=1 loops=1)
Sort Key: r.created_at
Sort Method: top-N heapsort Memory: 25kB
-> Subquery Scan on r (cost=428255.95..7170990.13 rows=68611 width=244) (actual time=14688.773..14788.721 rows=150 loops=1)
-> HashAggregate (cost=428255.95..7170304.02 rows=68611 width=92) (actual time=14688.769..14788.396 rows=150 loops=1)
-> Nested Loop (cost=223442.35..427569.84 rows=68611 width=92) (actual time=12644.172..14632.360 rows=383 loops=1)
Join Filter: (ac.order_id = acli.order_id)
-> Nested Loop (cost=223441.93..404408.50 rows=46678 width=96) (actual time=12621.925..14603.351 rows=191 loops=1)
Join Filter: (ac.order_id = li.order_id)
-> Nested Loop (cost=223441.50..378069.21 rows=26313 width=84) (actual time=12621.883..14519.718 rows=150 loops=1)
-> Hash Join (cost=223441.07..267995.31 rows=78940 width=59) (actual time=8561.536..11168.052 rows=75101 loops=1)
Hash Cond: (ac.page_view_id = anv.page_view_id)
-> Seq Scan on affiliate_commissions ac (cost=0.00..10630.82 rows=613282 width=21) (actual time=0.014..659.860 rows=612727 loops=1)
-> Hash (cost=179163.88..179163.88 rows=2079775 width=46) (actual time=8557.208..8557.208 rows=2082160 loops=1)
Buckets: 65536 Batches: 4 Memory Usage: 43774kB
-> Bitmap Heap Scan on affiliate_network_visits anv (cost=42614.69..179163.88 rows=2079775 width=46) (actual time=341.395..5527.674 rows=2082160 loops=1)
Recheck Cond: (affiliate_network = 'tanganetwork'::text)
-> Bitmap Index Scan on affiliate_network_visits_affiliate_network_idx (cost=0.00..42094.75 rows=2079775 width=0) (actual time=309.843..309.843 rows=2082160 loops=1)
Index Cond: (affiliate_network = 'tanganetwork'::text)
-> Index Scan using orders_pkey on orders o (cost=0.43..1.38 rows=1 width=25) (actual time=0.042..0.042 rows=0 loops=75101)
Index Cond: (id = ac.order_id)
Filter: ((created_on)::timestamp with time zone >= '2014-03-27 13:51:29-07'::timestamp with time zone)
Rows Removed by Filter: 1
-> Index Scan using index_line_items_on_order_id on line_items li (cost=0.43..0.98 rows=2 width=12) (actual time=0.403..0.552 rows=1 loops=150)
Index Cond: (order_id = o.id)
-> Index Only Scan using affiliate_commissions_line_items_pkey on affiliate_commissions_line_items acli (cost=0.42..0.47 rows=2 width=8) (actual time=0.143..0.145 rows=2 loops=191)
Index Cond: (order_id = li.order_id)
Heap Fetches: 383
SubPlan 1
-> Aggregate (cost=10.22..10.23 rows=1 width=6) (actual time=0.013..0.014 rows=1 loops=150)
-> Index Scan using affiliate_commissions_line_items_pkey on affiliate_commissions_line_items acli_ (cost=0.42..10.22 rows=2 width=6) (actual time=0.006..0.007 rows=1 loops=150)
Index Cond: (order_id = o.id)
SubPlan 2
-> Aggregate (cost=12.43..12.44 rows=1 width=6) (actual time=0.013..0.014 rows=1 loops=150)
-> Index Scan using index_line_items_on_order_id on line_items li_ (cost=0.43..12.42 rows=2 width=6) (actual time=0.006..0.008 rows=1 loops=150)
Index Cond: (order_id = o.id)
SubPlan 3
-> Aggregate (cost=29.32..29.33 rows=1 width=15) (actual time=0.129..0.130 rows=1 loops=150)
-> Nested Loop (cost=0.84..29.31 rows=2 width=15) (actual time=0.019..0.122 rows=1 loops=150)
-> Index Scan using index_line_items_on_order_id on line_items li__1 (cost=0.43..12.42 rows=2 width=8) (actual time=0.004..0.006 rows=1 loops=150)
Index Cond: (order_id = o.id)
-> Index Scan using products_pkey on products p (cost=0.41..8.43 rows=1 width=15) (actual time=0.083..0.085 rows=1 loops=191)
Index Cond: (id = li__1.product_id)
SubPlan 4
-> Aggregate (cost=16.91..16.92 rows=1 width=12) (actual time=0.829..0.830 rows=1 loops=150)
-> Nested Loop (cost=0.86..16.91 rows=1 width=12) (actual time=0.824..0.825 rows=0 loops=150)
-> Index Only Scan using promotion_usages_order_id_promotion_id_key on promotion_usages pu (cost=0.43..8.45 rows=1 width=4) (actual time=0.521..0.521 rows=0 loops=150)
Index Cond: (order_id = o.id)
Heap Fetches: 39
-> Index Scan using promotions_pkey on promotions p_1 (cost=0.43..8.45 rows=1 width=16) (actual time=1.152..1.154 rows=1 loops=39)
Index Cond: (id = pu.promotion_id)
SubPlan 5
-> Aggregate (cost=29.32..29.33 rows=1 width=57) (actual time=0.028..0.029 rows=1 loops=150)
-> Nested Loop (cost=0.84..29.31 rows=2 width=57) (actual time=0.012..0.021 rows=1 loops=150)
-> Index Scan using index_line_items_on_order_id on line_items li__2 (cost=0.43..12.42 rows=2 width=8) (actual time=0.004..0.006 rows=1 loops=150)
Index Cond: (order_id = o.id)
-> Index Scan using products_pkey on products p_2 (cost=0.41..8.43 rows=1 width=57) (actual time=0.004..0.006 rows=1 loops=191)
Index Cond: (id = li__2.product_id)
Total runtime: 14791.117 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment