explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ZdIW

Settings
# exclusive inclusive rows x rows loops node
1. 0.131 186.043 ↓ 9.2 37 1

Sort (cost=6,937.59..6,937.60 rows=4 width=715) (actual time=186.041..186.043 rows=37 loops=1)

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

Subquery Scan on t4 (cost=6,935.13..6,937.55 rows=4 width=715) (actual time=185.685..185.912 rows=37 loops=1)

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

WindowAgg (cost=6,935.13..6,936.42 rows=11 width=791) (actual time=185.683..185.885 rows=242 loops=1)

4. 0.256 185.691 ↓ 22.0 242 1

Sort (cost=6,935.13..6,935.15 rows=11 width=618) (actual time=185.677..185.691 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.395 185.435 ↓ 22.0 242 1

Nested Loop (cost=777.49..6,934.93 rows=11 width=618) (actual time=128.858..185.435 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.145 185.037 ↓ 13.4 242 1

Nested Loop (cost=777.49..6,932.95 rows=18 width=739) (actual time=128.847..185.037 rows=242 loops=1)

8. 0.028 127.517 ↓ 7.5 135 1

Subquery Scan on t2 (cost=720.16..732.99 rows=18 width=446) (actual time=127.170..127.517 rows=135 loops=1)

  • Filter: (t2.group_rn <= 1)
  • Rows Removed by Filter: 8
9. 0.302 127.489 ↓ 2.6 143 1

WindowAgg (cost=720.16..727.45 rows=54 width=535) (actual time=127.170..127.489 rows=143 loops=1)

10. 0.305 127.187 ↓ 2.6 143 1

Sort (cost=720.16..720.30 rows=54 width=430) (actual time=127.162..127.187 rows=143 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: 117kB
11. 0.160 126.882 ↓ 2.6 143 1

Nested Loop (cost=119.49..718.61 rows=54 width=430) (actual time=120.674..126.882 rows=143 loops=1)

12. 0.244 125.864 ↓ 2.6 143 1

Nested Loop Left Join (cost=119.23..707.15 rows=54 width=605) (actual time=120.476..125.864 rows=143 loops=1)

  • Filter: COALESCE((true), false)
  • Rows Removed by Filter: 465
13. 0.342 123.188 ↓ 5.6 608 1

Nested Loop (cost=118.79..606.79 rows=108 width=604) (actual time=120.363..123.188 rows=608 loops=1)

14. 0.097 120.695 ↓ 6.6 717 1

Subquery Scan on t (cost=118.38..130.09 rows=108 width=30) (actual time=120.351..120.695 rows=717 loops=1)

  • Filter: (t.mode <> 'EXCLUSION'::delivery_mode)
  • Rows Removed by Filter: 19
15. 0.145 120.598 ↓ 6.8 736 1

Unique (cost=118.38..118.92 rows=109 width=46) (actual time=120.350..120.598 rows=736 loops=1)

16. 0.394 120.453 ↓ 6.8 746 1

Sort (cost=118.38..118.65 rows=109 width=46) (actual time=120.350..120.453 rows=746 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.351 120.059 ↓ 6.8 746 1

Nested Loop (cost=0.98..114.69 rows=109 width=46) (actual time=2.013..120.059 rows=746 loops=1)

18. 117.072 117.072 ↓ 659.0 659 1

Index Scan using polygons_geom_idx on polygons pol (cost=0.55..4.90 rows=1 width=16) (actual time=2.002..117.072 rows=659 loops=1)

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

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=659)

  • Index Cond: (pol_id = pol.pol_id)
20. 2.151 2.151 ↑ 1.0 1 717

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

  • Index Cond: (merchant_id = t.owner_id)
21. 2.432 2.432 ↓ 0.0 0 608

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=608)

  • 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: 241
22. 0.858 0.858 ↑ 1.0 1 143

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

23. 0.675 57.375 ↓ 2.0 2 135

Bitmap Heap Scan on catalog_items catalog_item (cost=57.33..344.34 rows=1 width=736) (actual time=0.422..0.425 rows=2 loops=135)

  • 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. 56.700 56.700 ↑ 66.5 2 135

Bitmap Index Scan on catalog_items_merchant_short_id_fts_idx (cost=0.00..57.33 rows=133 width=0) (actual time=0.420..0.420 rows=2 loops=135)

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