explain.depesz.com

PostgreSQL's explain analyze made readable

Result: oaN3

Settings
# exclusive inclusive rows x rows loops node
1. 0.005 134.241 ↑ 1.0 10 1

Limit (cost=21,449.66..21,449.69 rows=10 width=36) (actual time=134.238..134.241 rows=10 loops=1)

2. 0.047 134.236 ↑ 662.4 10 1

Sort (cost=21,449.66..21,466.22 rows=6,624 width=36) (actual time=134.236..134.236 rows=10 loops=1)

  • Sort Key: (sum(invoice_line_items.subtotal)) DESC NULLS LAST
  • Sort Method: top-N heapsort Memory: 25kB
3. 4.771 134.189 ↑ 301.1 22 1

HashAggregate (cost=21,223.72..21,306.52 rows=6,624 width=36) (actual time=134.177..134.189 rows=22 loops=1)

  • Group Key: CASE WHEN (invoices.user_id IS NOT NULL) THEN invoices.user_id ELSE vendor_orders.user_id END
4. 4.789 129.418 ↑ 1.1 19,723 1

Hash Left Join (cost=4,168.80..21,110.51 rows=22,642 width=9) (actual time=14.536..129.418 rows=19,723 loops=1)

  • Hash Cond: (invoices.vendor_order_id = vendor_orders.id)
  • Filter: ((invoices.user_id IS NOT NULL) OR (vendor_orders.user_id IS NOT NULL))
  • Rows Removed by Filter: 6464
5. 51.671 122.217 ↓ 1.2 26,187 1

Hash Join (cost=3,703.99..20,555.46 rows=22,642 width=13) (actual time=12.105..122.217 rows=26,187 loops=1)

  • Hash Cond: (invoice_line_items.invoice_id = invoices.id)
6. 59.280 59.280 ↑ 1.0 536,804 1

Seq Scan on invoice_line_items (cost=0.00..14,612.04 rows=536,804 width=9) (actual time=0.092..59.280 rows=536,804 loops=1)

7. 2.303 11.266 ↓ 1.2 8,397 1

Hash (cost=3,614.46..3,614.46 rows=7,162 width=12) (actual time=11.266..11.266 rows=8,397 loops=1)

  • Buckets: 16384 (originally 8192) Batches: 1 (originally 1) Memory Usage: 451kB
8. 7.445 8.963 ↓ 1.2 8,397 1

Bitmap Heap Scan on invoices (cost=551.63..3,614.46 rows=7,162 width=12) (actual time=1.666..8.963 rows=8,397 loops=1)

  • Recheck Cond: (vendor_id = 815)
  • Filter: (invoice_date > '2017-12-04'::date)
  • Rows Removed by Filter: 14423
  • Heap Blocks: exact=665
9. 1.518 1.518 ↓ 1.0 23,506 1

Bitmap Index Scan on index_invoices_on_vendor_id (cost=0.00..549.84 rows=22,589 width=0) (actual time=1.518..1.518 rows=23,506 loops=1)

  • Index Cond: (vendor_id = 815)
10. 0.986 2.412 ↓ 1.0 11,967 1

Hash (cost=315.47..315.47 rows=11,947 width=8) (actual time=2.412..2.412 rows=11,967 loops=1)

  • Buckets: 16384 Batches: 1 Memory Usage: 596kB
11. 1.426 1.426 ↓ 1.0 11,967 1

Seq Scan on vendor_orders (cost=0.00..315.47 rows=11,947 width=8) (actual time=0.008..1.426 rows=11,967 loops=1)