explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 37W7

Settings
# exclusive inclusive rows x rows loops node
1. 0.005 34.151 ↑ 1.0 20 1

Limit (cost=1,179.03..1,179.08 rows=20 width=915) (actual time=34.142..34.151 rows=20 loops=1)

  • Buffers: shared hit=1,262 read=107
2. 0.659 34.146 ↑ 25.0 20 1

Sort (cost=1,179.03..1,180.28 rows=500 width=915) (actual time=34.14..34.146 rows=20 loops=1)

  • Sort Key: ((power(LEAST('1'::double precision, GREATEST('0'::double precision, ('1'::double precision - ('2.5'::double precision * (GREATEST(restaurants.rating, '3.6'::double precision) - '3.6'::double precision))))), '0.25'::double precision) * (((LEAST('1'::double precision, GREATEST('0'::double precision, (COALESCE(restaurants.rating, '3'::double precision) - '3'::double precision))) + ('0.5'::double precision * LEAST('1'::double precision, GREATEST('0'::double precision, ('-1.25'::double precision * (('12742'::double precision * asin(sqrt((power(sin((((('35.6895'::double precision - restaurants.latitude) * '3.14159265358979'::double precision) / '180'::double precision) / '2'::double precision)), '2'::double precision) + (('0.812190452766995'::double precision * cos(((restaurants.latitude * '3.14159265358979'::double precision) / '180'::double precision))) * power(sin((((('139.6917'::double precision - restaurants.longitude) * '3.14159265358979'::double precision) / '180'::double precision) / '2'::double precision)), '2'::double precision)))))) - '1.3'::double precision)))))) + (((0.5 * (((('x'::text || lpad(substr(md5(((restaurants.id)::text || '2020-09-28'::text)), 1, 1), 8, '0'::text)))::bit(32))::integer)::numeric) / 15.0))::double precision) + (CASE WHEN (restaurants.max_price <= 2,000) THEN '-1.0'::numeric ELSE 0.0 END)::double precision))) DESC, restaurants.id
  • Sort Method: top-N heapsort Memory: 62kB
  • Buffers: shared hit=1,262 read=107
3. 2.211 33.487 ↑ 1.0 500 1

Subquery Scan on restaurants (cost=1,095.72..1,165.72 rows=500 width=915) (actual time=30.963..33.487 rows=500 loops=1)

  • Buffers: shared hit=1,256 read=107
4. 0.112 31.276 ↑ 1.0 500 1

Unique (cost=1,095.72..1,098.22 rows=500 width=907) (actual time=30.855..31.276 rows=500 loops=1)

  • Buffers: shared hit=1,256 read=107
5. 1.172 31.164 ↑ 1.0 500 1

Sort (cost=1,095.72..1,096.97 rows=500 width=907) (actual time=30.853..31.164 rows=500 loops=1)

  • Sort Key: restaurants_1.id
  • Sort Method: quicksort Memory: 493kB
  • Buffers: shared hit=1,256 read=107
6. 0.080 29.992 ↑ 1.0 500 1

Limit (cost=0.42..1,068.31 rows=500 width=907) (actual time=0.066..29.992 rows=500 loops=1)

  • Buffers: shared hit=1,256 read=107
7. 29.912 29.912 ↑ 274.6 500 1

Index Scan using index_restaurants_on_rating_and_id on restaurants restaurants_1 (cost=0.42..293,292.19 rows=137,324 width=907) (actual time=0.066..29.912 rows=500 loops=1)

  • Filter: ((restaurants_1.status = ANY ('{1,2}'::integer[])) AND (restaurants_1.city_id = ANY ('{629,631,632,633,635,636,637,639,640,641,642,644,645,646,648,649,650,652,653,654,655,656,658,659,660,661,663,664,666,667,668,669,671,672,673,675,676,677,679,680,681,683,684,685,687,688,628,630,634,638,643,647,651,657,662,665,670,674,678,682,686,689}'::integer[])))
  • Buffers: shared hit=1,256 read=107
Planning time : 2.217 ms
Execution time : 34.304 ms