explain.depesz.com

PostgreSQL's explain analyze made readable

Result: NcDB : 1

Settings
# exclusive inclusive rows x rows loops node
1. 75.417 4,296.963 ↑ 20.9 360,323 1

Merge Join (cost=70,743.22..184,962.02 rows=7,540,499 width=4) (actual time=4,018.351..4,296.963 rows=360,323 loops=1)

  • Merge Cond: (c.id = items.company_id)
2. 2.575 5.165 ↑ 1.0 4,501 1

Group (cost=0.56..216.21 rows=4,515 width=4) (actual time=0.357..5.165 rows=4,501 loops=1)

  • Group Key: c.id
3. 1.169 2.590 ↑ 1.0 4,504 1

Merge Left Join (cost=0.56..204.92 rows=4,515 width=4) (actual time=0.303..2.590 rows=4,504 loops=1)

  • Merge Cond: (c.id = company_groups.company_id)
  • Filter: ((company_groups.has_restriction IS NULL) OR (NOT company_groups.has_restriction) OR (company_groups.company_id = 1,999) OR (company_groups.group_id = ANY ('{3,2}'::integer[])))
  • Rows Removed by Filter: 10
4. 0.941 0.941 ↑ 1.0 4,508 1

Index Only Scan using companies_pkey on companies c (cost=0.28..128.10 rows=4,521 width=4) (actual time=0.155..0.941 rows=4,508 loops=1)

  • Heap Fetches: 3
5. 0.480 0.480 ↑ 1.0 878 1

Index Scan using index_company_groups_on_company_id on company_groups (cost=0.28..50.14 rows=879 width=9) (actual time=0.141..0.480 rows=878 loops=1)

6. 76.213 4,216.381 ↓ 1.1 362,180 1

Materialize (cost=70,742.66..72,421.11 rows=335,690 width=8) (actual time=4,017.964..4,216.381 rows=362,180 loops=1)

7. 551.534 4,140.168 ↓ 1.1 362,180 1

Sort (cost=70,742.66..71,581.89 rows=335,690 width=8) (actual time=4,017.955..4,140.168 rows=362,180 loops=1)

  • Sort Key: items.company_id
  • Sort Method: external merge Disk: 6,352kB
8. 141.270 3,588.634 ↓ 1.1 362,180 1

Hash Left Join (cost=1.05..35,339.74 rows=335,690 width=8) (actual time=0.617..3,588.634 rows=362,180 loops=1)

  • Hash Cond: (items.id = favs.item_id)
9. 3,447.355 3,447.355 ↓ 1.1 362,180 1

Seq Scan on items (cost=0.00..34,079.84 rows=335,690 width=8) (actual time=0.504..3,447.355 rows=362,180 loops=1)

  • Filter: (visibility AND (NOT is_hidden) AND ((type)::text = 'Fashion'::text) AND (company_id <> ALL ('{199,200,201}'::integer[])) AND ((depth IS NULL) OR ((depth >= '0'::numeric) AND (depth <= '100'::nume (...)
  • Rows Removed by Filter: 5,814
10. 0.001 0.009 ↓ 0.0 0 1

Hash (cost=1.04..1.04 rows=1 width=4) (actual time=0.009..0.009 rows=0 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 8kB
11. 0.008 0.008 ↓ 0.0 0 1

Seq Scan on favs (cost=0.00..1.04 rows=1 width=4) (actual time=0.008..0.008 rows=0 loops=1)

  • Filter: (is_visible AND (user_id = 999))
  • Rows Removed by Filter: 3
Planning time : 3.526 ms
Execution time : 4,397.849 ms