explain.depesz.com

PostgreSQL's explain analyze made readable

Result: malf

Settings
# exclusive inclusive rows x rows loops node
1. 71.663 45,933.301 ↓ 102.5 32,686 1

Hash Left Join (cost=2,305,567.34..2,363,890.73 rows=319 width=811) (actual time=45,058.728..45,933.301 rows=32,686 loops=1)

  • Hash Cond: (log.number_of_classes = number_of_classes.id)
2.          

CTE venue_records

3. 2,326.782 24,034.893 ↓ 1.0 3,000,567 1

WindowAgg (cost=1,378,973.27..1,443,433.79 rows=2,864,912 width=60) (actual time=20,741.652..24,034.893 rows=3,000,567 loops=1)

4. 4,101.030 21,708.111 ↓ 1.0 3,000,567 1

Sort (cost=1,378,973.27..1,386,135.55 rows=2,864,912 width=60) (actual time=20,741.644..21,708.111 rows=3,000,567 loops=1)

  • Sort Key: venue_1.venue_id, venue_source_type.priority, venue_parameters_log.created_on DESC
  • Sort Method: external sort Disk: 170128kB
5. 3,560.747 17,607.081 ↓ 1.0 3,000,567 1

WindowAgg (cost=686,538.27..856,278.61 rows=2,864,912 width=60) (actual time=7,286.960..17,607.081 rows=3,000,567 loops=1)

6. 2,372.900 14,046.334 ↓ 1.0 3,000,567 1

Merge Join (cost=686,538.27..806,142.65 rows=2,864,912 width=60) (actual time=7,286.916..14,046.334 rows=3,000,567 loops=1)

  • Merge Cond: (venue_1.venue_id = venue_parameters_log.venue_id)
7. 934.629 934.629 ↑ 1.0 1,453,566 1

Index Only Scan using venue_id_idx on venue venue_1 (cost=0.43..65,932.59 rows=1,457,639 width=4) (actual time=0.027..934.629 rows=1,453,566 loops=1)

  • Heap Fetches: 1441614
8. 1,435.472 10,738.805 ↓ 1.0 3,000,567 1

Materialize (cost=686,530.96..700,855.52 rows=2,864,912 width=56) (actual time=7,286.881..10,738.805 rows=3,000,567 loops=1)

9. 5,658.872 9,303.333 ↓ 1.0 3,000,567 1

Sort (cost=686,530.96..693,693.24 rows=2,864,912 width=56) (actual time=7,286.878..9,303.333 rows=3,000,567 loops=1)

  • Sort Key: venue_parameters_log.venue_id
  • Sort Method: external merge Disk: 134960kB
10. 2,013.806 3,644.461 ↓ 1.0 3,000,567 1

Hash Join (cost=14,964.64..183,422.30 rows=2,864,912 width=56) (actual time=22.826..3,644.461 rows=3,000,567 loops=1)

  • Hash Cond: (venue_parameters_log.venue_source_id = venue_source.venue_source_id)
11. 1,607.872 1,607.872 ↓ 1.0 3,000,567 1

Seq Scan on venue_parameters_log (cost=0.00..129,065.12 rows=2,864,912 width=24) (actual time=0.026..1,607.872 rows=3,000,567 loops=1)

12. 1.116 22.783 ↑ 1.0 176 1

Hash (cost=14,962.44..14,962.44 rows=176 width=40) (actual time=22.783..22.783 rows=176 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 17kB
13. 0.354 21.667 ↑ 1.0 176 1

Nested Loop (cost=0.15..14,962.44 rows=176 width=40) (actual time=0.022..21.667 rows=176 loops=1)

14. 20.961 20.961 ↑ 1.0 176 1

Seq Scan on venue_source (cost=0.00..14,882.76 rows=176 width=8) (actual time=0.011..20.961 rows=176 loops=1)

15. 0.352 0.352 ↑ 1.0 1 176

Index Scan using venue_source_type_pkey on venue_source_type (cost=0.15..0.44 rows=1 width=40) (actual time=0.001..0.002 rows=1 loops=176)

  • Index Cond: (venue_source_type_id = venue_source.venue_source_type_id)
16.          

CTE venue_reviews

17. 25,915.039 25,915.039 ↓ 185.5 4,451 1

CTE Scan on venue_records (cost=0.00..85,947.36 rows=24 width=20) (actual time=23,510.419..25,915.039 rows=4,451 loops=1)

  • Filter: ((review_count >= 2) AND (created_on <= '2020-01-05 00:00:00'::timestamp without time zone) AND (created_on >= '2020-01-01 00:00:00'::timestamp without time zone) AND (rank = 1))
  • Rows Removed by Filter: 2996116
18.          

CTE filtered_venues

19. 1.047 42,851.257 ↓ 116.8 2,803 1

Limit (cost=657,944.42..657,944.66 rows=24 width=16) (actual time=42,848.964..42,851.257 rows=2,803 loops=1)

20. 10.389 42,850.210 ↓ 116.8 2,803 1

HashAggregate (cost=657,944.42..657,944.66 rows=24 width=16) (actual time=42,848.962..42,850.210 rows=2,803 loops=1)

  • Group Key: venue_reviews.venue_id, venue_reviews.resolved_venue_parameters_log_id, venue_reviews.review_count
21. 1,237.916 42,839.821 ↓ 85.5 24,196 1

Hash Join (cost=333,703.72..657,942.30 rows=283 width=16) (actual time=38,690.713..42,839.821 rows=24,196 loops=1)

  • Hash Cond: (address_2.address_id = venue_reviews.address_id)
22. 4,471.479 15,682.419 ↑ 1.4 5,157,771 1

Seq Scan on address address_2 (cost=333,702.94..630,233.33 rows=7,388,096 width=4) (actual time=11,842.709..15,682.419 rows=5,157,771 loops=1)

  • Filter: (hashed SubPlan 3)
  • Rows Removed by Filter: 9608339
23.          

SubPlan (for Seq Scan)

24. 11,210.940 11,210.940 ↓ 7.1 663,133 1

Seq Scan on address address_1 (cost=0.00..333,470.86 rows=92,831 width=4) (actual time=466.638..11,210.940 rows=663,133 loops=1)

  • Filter: ((address_component_value ~~* 'United States'::text) AND (address_component_name = 'COUNTRY'::text))
  • Rows Removed by Filter: 14102977
25. 1.669 25,919.486 ↓ 185.5 4,451 1

Hash (cost=0.48..0.48 rows=24 width=20) (actual time=25,919.486..25,919.486 rows=4,451 loops=1)

  • Buckets: 8192 (originally 1024) Batches: 1 (originally 1) Memory Usage: 291kB
26. 25,917.817 25,917.817 ↓ 185.5 4,451 1

CTE Scan on venue_reviews (cost=0.00..0.48 rows=24 width=20) (actual time=23,510.421..25,917.817 rows=4,451 loops=1)

27. 23.204 45,796.258 ↓ 102.5 32,686 1

Hash Left Join (cost=118,240.44..170,035.32 rows=319 width=787) (actual time=45,058.668..45,796.258 rows=32,686 loops=1)

  • Hash Cond: (venue_competitor.competitor_id = competitor.competitor_id)
28. 25.352 45,772.988 ↓ 102.5 32,686 1

Nested Loop Left Join (cost=118,237.66..170,028.16 rows=319 width=781) (actual time=45,058.588..45,772.988 rows=32,686 loops=1)

29. 3.987 45,728.716 ↓ 126.1 3,784 1

Hash Left Join (cost=118,237.23..169,988.91 rows=30 width=752) (actual time=45,058.560..45,728.716 rows=3,784 loops=1)

  • Hash Cond: (venue_genre.genre_id = genre.genre_id)
30. 449.332 45,724.676 ↓ 126.1 3,784 1

Hash Right Join (cost=118,236.14..169,987.69 rows=30 width=724) (actual time=45,058.489..45,724.676 rows=3,784 loops=1)

  • Hash Cond: (place_properties.venue_id = venue.venue_id)
31. 429.440 429.440 ↑ 1.0 1,654,177 1

Seq Scan on place_properties (cost=0.00..45,460.73 rows=1,677,473 width=153) (actual time=0.006..429.440 rows=1,654,177 loops=1)

32. 4.841 44,845.904 ↓ 129.9 3,378 1

Hash (cost=118,235.81..118,235.81 rows=26 width=579) (actual time=44,845.904..44,845.904 rows=3,378 loops=1)

  • Buckets: 4096 (originally 1024) Batches: 1 (originally 1) Memory Usage: 1802kB
33. 2.258 44,841.063 ↓ 129.9 3,378 1

Nested Loop Left Join (cost=95,365.13..118,235.81 rows=26 width=579) (actual time=44,526.194..44,841.063 rows=3,378 loops=1)

34. 4.548 44,830.384 ↓ 117.0 2,807 1

Nested Loop Left Join (cost=95,364.70..118,223.41 rows=24 width=575) (actual time=44,526.180..44,830.384 rows=2,807 loops=1)

35. 3.364 44,820.222 ↓ 117.0 2,807 1

Nested Loop Left Join (cost=95,364.27..118,212.36 rows=24 width=567) (actual time=44,526.162..44,820.222 rows=2,807 loops=1)

36. 3.793 44,814.051 ↓ 117.0 2,807 1

Nested Loop Left Join (cost=95,364.12..118,208.04 rows=24 width=539) (actual time=44,526.154..44,814.051 rows=2,807 loops=1)

37. 3.537 44,807.451 ↓ 117.0 2,807 1

Nested Loop Left Join (cost=95,363.97..118,203.90 rows=24 width=534) (actual time=44,526.145..44,807.451 rows=2,807 loops=1)

38. 4.167 44,801.107 ↓ 117.0 2,807 1

Nested Loop Left Join (cost=95,363.82..118,199.58 rows=24 width=506) (actual time=44,526.136..44,801.107 rows=2,807 loops=1)

39. 3.902 44,791.334 ↓ 116.8 2,803 1

Nested Loop Left Join (cost=95,363.39..118,187.96 rows=24 width=502) (actual time=44,526.122..44,791.334 rows=2,803 loops=1)

40. 3.410 44,784.629 ↓ 116.8 2,803 1

Nested Loop (cost=95,363.24..118,177.10 rows=24 width=470) (actual time=44,526.113..44,784.629 rows=2,803 loops=1)

41. 4.326 44,775.613 ↓ 116.8 2,803 1

Nested Loop (cost=95,362.84..118,166.27 rows=24 width=446) (actual time=44,526.102..44,775.613 rows=2,803 loops=1)

42. 57.015 44,762.878 ↓ 116.8 2,803 1

Merge Left Join (cost=95,362.41..117,963.29 rows=24 width=147) (actual time=44,526.063..44,762.878 rows=2,803 loops=1)

  • Merge Cond: (venue.venue_id = scores.venue_id)
43. 3.578 42,865.280 ↓ 116.8 2,803 1

Sort (cost=203.95..204.01 rows=24 width=143) (actual time=42,863.715..42,865.280 rows=2,803 loops=1)

  • Sort Key: venue.venue_id
  • Sort Method: quicksort Memory: 823kB
44. 3.314 42,861.702 ↓ 116.8 2,803 1

Nested Loop (cost=0.43..203.40 rows=24 width=143) (actual time=42,848.994..42,861.702 rows=2,803 loops=1)

45. 42,852.782 42,852.782 ↓ 116.8 2,803 1

CTE Scan on filtered_venues (cost=0.00..0.48 rows=24 width=16) (actual time=42,848.969..42,852.782 rows=2,803 loops=1)

46. 5.606 5.606 ↑ 1.0 1 2,803

Index Scan using venue_id_idx on venue (cost=0.43..8.45 rows=1 width=131) (actual time=0.002..0.002 rows=1 loops=2,803)

  • Index Cond: (venue_id = filtered_venues.venue_id)
47. 105.693 1,840.583 ↓ 65.6 228,051 1

Materialize (cost=95,151.96..117,750.52 rows=3,475 width=12) (actual time=736.513..1,840.583 rows=228,051 loops=1)

48. 201.036 1,734.890 ↓ 65.6 228,051 1

Subquery Scan on scores (cost=95,151.96..117,741.83 rows=3,475 width=12) (actual time=736.509..1,734.890 rows=228,051 loops=1)

  • Filter: (scores."row" = 1)
  • Rows Removed by Filter: 458680
49. 472.361 1,533.854 ↑ 1.0 686,731 1

WindowAgg (cost=95,151.96..109,053.42 rows=695,073 width=20) (actual time=736.498..1,533.854 rows=686,731 loops=1)

50. 844.559 1,061.493 ↑ 1.0 686,731 1

Sort (cost=95,151.96..96,889.64 rows=695,073 width=20) (actual time=736.488..1,061.493 rows=686,731 loops=1)

  • Sort Key: venue_score.venue_id, venue_score.created_time DESC
  • Sort Method: external merge Disk: 20248kB
51. 216.934 216.934 ↑ 1.0 692,475 1

Seq Scan on venue_score (cost=0.00..13,450.73 rows=695,073 width=20) (actual time=0.006..216.934 rows=692,475 loops=1)

52. 8.409 8.409 ↑ 1.0 1 2,803

Index Scan using venue_parameters_log_pkey on venue_parameters_log log (cost=0.43..8.45 rows=1 width=303) (actual time=0.003..0.003 rows=1 loops=2,803)

  • Index Cond: (venue_parameters_log_id = filtered_venues.resolved_venue_parameters_log_id)
53. 5.606 5.606 ↑ 1.0 1 2,803

Index Scan using venue_source_pkey on venue_source source (cost=0.40..0.44 rows=1 width=28) (actual time=0.002..0.002 rows=1 loops=2,803)

  • Index Cond: (venue_source_id = log.venue_source_id)
54. 2.803 2.803 ↑ 1.0 1 2,803

Index Scan using venue_source_type_pkey on venue_source_type source_type (cost=0.15..0.44 rows=1 width=36) (actual time=0.001..0.001 rows=1 loops=2,803)

  • Index Cond: (venue_source_type_id = source.venue_source_type_id)
55. 5.606 5.606 ↑ 1.0 1 2,803

Index Scan using venue_inventory_type_venue_parameters_log_id_idx on venue_inventory_type (cost=0.43..0.47 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=2,803)

  • Index Cond: (venue_parameters_log_id = log.venue_parameters_log_id)
56. 2.807 2.807 ↑ 1.0 1 2,807

Index Scan using inventory_type_pkey on inventory_type inventory (cost=0.15..0.17 rows=1 width=36) (actual time=0.001..0.001 rows=1 loops=2,807)

  • Index Cond: (inventory_type_id = venue_inventory_type.inventory_type_id)
57. 2.807 2.807 ↑ 1.0 1 2,807

Index Scan using scheduling_software_pkey on scheduling_software software (cost=0.14..0.16 rows=1 width=13) (actual time=0.001..0.001 rows=1 loops=2,807)

  • Index Cond: (scheduling_software_id = log.scheduling_software_id)
58. 2.807 2.807 ↑ 1.0 1 2,807

Index Scan using contact_title_pkey on contact_title (cost=0.15..0.17 rows=1 width=36) (actual time=0.001..0.001 rows=1 loops=2,807)

  • Index Cond: (contact_title_id = log.contact_title_id)
59. 5.614 5.614 ↑ 1.0 1 2,807

Index Scan using venue_competitor_venue_parameters_log_id_idx on venue_competitor (cost=0.42..0.45 rows=1 width=12) (actual time=0.002..0.002 rows=1 loops=2,807)

  • Index Cond: (venue_parameters_log_id = log.venue_parameters_log_id)
60. 8.421 8.421 ↑ 2.0 1 2,807

Index Scan using venue_genre_venue_parameters_log_id_idx on venue_genre (cost=0.43..0.50 rows=2 width=8) (actual time=0.002..0.003 rows=1 loops=2,807)

  • Index Cond: (venue_parameters_log_id = log.venue_parameters_log_id)
61. 0.030 0.053 ↓ 14.2 57 1

Hash (cost=1.04..1.04 rows=4 width=36) (actual time=0.053..0.053 rows=57 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 11kB
62. 0.023 0.023 ↓ 14.2 57 1

Seq Scan on genre (cost=0.00..1.04 rows=4 width=36) (actual time=0.006..0.023 rows=57 loops=1)

63. 18.920 18.920 ↑ 2.7 9 3,784

Index Scan using address_address_id_idx on address (cost=0.43..1.07 rows=24 width=29) (actual time=0.003..0.005 rows=9 loops=3,784)

  • Index Cond: (address_id = log.address_id)
64. 0.034 0.066 ↓ 1.3 102 1

Hash (cost=1.79..1.79 rows=79 width=14) (actual time=0.066..0.066 rows=102 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 13kB
65. 0.032 0.032 ↓ 1.3 102 1

Seq Scan on competitor (cost=0.00..1.79 rows=79 width=14) (actual time=0.005..0.032 rows=102 loops=1)

66. 0.003 0.008 ↑ 1.0 4 1

Hash (cost=1.04..1.04 rows=4 width=36) (actual time=0.008..0.008 rows=4 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
67. 0.005 0.005 ↑ 1.0 4 1

Seq Scan on number_of_classes (cost=0.00..1.04 rows=4 width=36) (actual time=0.003..0.005 rows=4 loops=1)

68.          

SubPlan (for Hash Left Join)

69. 0.000 0.000 ↓ 0.0 0

Seq Scan on venue_source_scraper (cost=0.00..3.01 rows=1 width=4) (never executed)

  • Filter: (venue_source_scraper_id = source.source_id)
70. 32.686 65.372 ↑ 1.0 1 32,686

Bitmap Heap Scan on venue_source_admin_user (cost=12.40..16.42 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=32,686)

  • Recheck Cond: (venue_source_admin_user_id = source.source_id)
  • Heap Blocks: exact=32686
71. 32.686 32.686 ↑ 1.0 1 32,686

Bitmap Index Scan on venue_source_admin_user_pkey (cost=0.00..12.40 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=32,686)

  • Index Cond: (venue_source_admin_user_id = source.source_id)
72. 0.000 0.000 ↓ 0.0 0

Seq Scan on venue_source_manual_user (cost=0.00..1.02 rows=1 width=4) (never executed)

  • Filter: (venue_source_manual_user_id = source.source_id)
Planning time : 8.442 ms
Execution time : 46,021.097 ms