explain.depesz.com

PostgreSQL's explain analyze made readable

Result: q46r

Settings
# exclusive inclusive rows x rows loops node
1. 0.108 213.897 ↓ 9.2 37 1

Sort (cost=8,053.70..8,053.71 rows=4 width=714) (actual time=213.896..213.897 rows=37 loops=1)

  • Sort Key: t4.open DESC, t4.term_score DESC, t4.merchant_short_id
  • Sort Method: quicksort Memory: 60kB
2. 0.020 213.789 ↓ 9.2 37 1

Subquery Scan on t4 (cost=8,051.24..8,053.66 rows=4 width=714) (actual time=213.618..213.789 rows=37 loops=1)

  • Filter: (t4.catalog_items_rn <= 2)
  • Rows Removed by Filter: 205
3. 0.147 213.769 ↓ 22.0 242 1

WindowAgg (cost=8,051.24..8,052.54 rows=11 width=790) (actual time=213.616..213.769 rows=242 loops=1)

4. 0.251 213.622 ↓ 22.0 242 1

Sort (cost=8,051.24..8,051.27 rows=11 width=617) (actual time=213.611..213.622 rows=242 loops=1)

  • Sort Key: t2.merchant_id, (NULLIF((ts_rank_cd(catalog_item.fts, q.tsquery))::double precision, '0'::double precision))
  • Sort Method: quicksort Memory: 294kB
5. 0.405 213.371 ↓ 22.0 242 1

Nested Loop (cost=839.49..8,051.05 rows=11 width=617) (actual time=121.041..213.371 rows=242 loops=1)

6. 0.003 0.003 ↑ 1.0 1 1

Function Scan on q (cost=0.00..0.10 rows=1 width=32) (actual time=0.002..0.003 rows=1 loops=1)

7. 0.296 212.963 ↓ 13.4 242 1

Nested Loop (cost=839.49..8,049.07 rows=18 width=738) (actual time=121.030..212.963 rows=242 loops=1)

8. 0.035 118.815 ↓ 7.3 132 1

Subquery Scan on t2 (cost=720.16..732.99 rows=18 width=445) (actual time=118.365..118.815 rows=132 loops=1)

  • Filter: (t2.group_rn <= 1)
  • Rows Removed by Filter: 7
9. 0.388 118.780 ↓ 2.6 139 1

WindowAgg (cost=720.16..727.45 rows=54 width=534) (actual time=118.364..118.780 rows=139 loops=1)

10. 0.314 118.392 ↓ 2.6 139 1

Sort (cost=720.16..720.30 rows=54 width=429) (actual time=118.355..118.392 rows=139 loops=1)

  • Sort Key: merc.group_id, (COALESCE((true), false)) DESC, d.distance, t.delivery_fee, (((merc.evaluations #>> '{IFOOD,avg}'::text[]))::real) DESC, merc.merchant_short_id
  • Sort Method: quicksort Memory: 115kB
11. 0.212 118.078 ↓ 2.6 139 1

Nested Loop (cost=119.49..718.61 rows=54 width=429) (actual time=111.282..118.078 rows=139 loops=1)

12. 0.498 116.893 ↓ 2.6 139 1

Nested Loop Left Join (cost=119.23..707.14 rows=54 width=602) (actual time=111.055..116.893 rows=139 loops=1)

  • Filter: COALESCE((true), false)
  • Rows Removed by Filter: 468
13. 0.532 113.967 ↓ 5.6 607 1

Nested Loop (cost=118.79..606.79 rows=108 width=601) (actual time=110.937..113.967 rows=607 loops=1)

14. 0.105 111.287 ↓ 6.6 716 1

Subquery Scan on t (cost=118.38..130.09 rows=108 width=30) (actual time=110.924..111.287 rows=716 loops=1)

  • Filter: (t.mode <> 'EXCLUSION'::delivery_mode)
  • Rows Removed by Filter: 19
15. 0.155 111.182 ↓ 6.7 735 1

Unique (cost=118.38..118.92 rows=109 width=46) (actual time=110.923..111.182 rows=735 loops=1)

16. 0.401 111.027 ↓ 6.8 745 1

Sort (cost=118.38..118.65 rows=109 width=46) (actual time=110.922..111.027 rows=745 loops=1)

  • Sort Key: dels.owner_id, ((dels.mode <> 'EXCLUSION'::delivery_mode)), dels.zipcode COLLATE "C", dels.priority
  • Sort Method: quicksort Memory: 83kB
17. 0.307 110.626 ↓ 6.8 745 1

Nested Loop (cost=0.98..114.69 rows=109 width=46) (actual time=0.360..110.626 rows=745 loops=1)

18. 107.687 107.687 ↓ 658.0 658 1

Index Scan using polygons_geom_idx on polygons pol (cost=0.55..4.90 rows=1 width=16) (actual time=0.350..107.687 rows=658 loops=1)

  • Index Cond: (geom && '0101000020E61000008EDF2582828647C06D945055FCDA36C0'::geometry)
  • Filter: _st_intersects(geom, '0101000020E61000008EDF2582828647C06D945055FCDA36C0'::geometry)
  • Rows Removed by Filter: 225
19. 2.632 2.632 ↑ 110.0 1 658

Index Scan using deliveries_pol_id_idx on deliveries dels (cost=0.43..98.51 rows=110 width=61) (actual time=0.004..0.004 rows=1 loops=658)

  • Index Cond: (pol_id = pol.pol_id)
20. 2.148 2.148 ↑ 1.0 1 716

Index Scan using merchants_pkey on merchants merc (cost=0.42..4.41 rows=1 width=587) (actual time=0.003..0.003 rows=1 loops=716)

  • Index Cond: (merchant_id = t.owner_id)
21. 2.428 2.428 ↓ 0.0 0 607

Index Only Scan using merchant_shifts_pkey on merchant_shifts shift (cost=0.43..0.83 rows=1 width=31) (actual time=0.004..0.004 rows=0 loops=607)

  • Index Cond: ((merchant_short_id = merc.merchant_short_id) AND (dow = (date_part('dow'::text, timezone((merc.timezone)::text, now())))::integer))
  • Filter: (shift_range @> timerange((timezone((merc.timezone)::text, now()))::time without time zone, (timezone((merc.timezone)::text, now()))::time without time zone, '[]'::text))
  • Rows Removed by Filter: 1
  • Heap Fetches: 246
22. 0.973 0.973 ↑ 1.0 1 139

Function Scan on round d (cost=0.26..0.36 rows=1 width=32) (actual time=0.007..0.007 rows=1 loops=139)

23. 0.660 93.852 ↓ 2.0 2 132

Bitmap Heap Scan on catalog_items catalog_item (cost=119.33..406.35 rows=1 width=736) (actual time=0.709..0.711 rows=2 loops=132)

  • Recheck Cond: ((merchant_short_id = t2.merchant_short_id) AND (fts @@@ q.tsquery))
  • Filter: (((range_of_times IS NULL) OR ((timezone((t2.timezone)::text, to_timestamp((trunc((date_part('epoch'::text, now()) / '900'::double precision)) * '900'::double precision))))::time without time zone = ANY (range_of_times))) AND (date_part('dow'::text, now()) = ANY ((COALESCE(days, '{0,1,2,3,4,5,6}'::integer[]))::double precision[])))
  • Rows Removed by Filter: 0
  • Heap Blocks: exact=158
24. 93.192 93.192 ↑ 66.5 2 132

Bitmap Index Scan on catalog_items_merchant_short_id_fts_idx (cost=0.00..119.33 rows=133 width=0) (actual time=0.706..0.706 rows=2 loops=132)

  • Index Cond: ((merchant_short_id = t2.merchant_short_id) AND (fts @@@ q.tsquery))