Skip to content

Instantly share code, notes, and snippets.

@jcreed
Created May 22, 2019 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcreed/e2fdc61a90be0400a522f6b80a3cc697 to your computer and use it in GitHub Desktop.
Save jcreed/e2fdc61a90be0400a522f6b80a3cc697 to your computer and use it in GitHub Desktop.
old query plan for a local status that is not 200599
Aggregate (cost=25469.67..25469.68 rows=1 width=8)
-> Nested Loop (cost=24712.66..25469.67 rows=1 width=0)
Join Filter: (applicants.id = applicants_2.id)
-> Nested Loop (cost=12438.03..13163.20 rows=1 width=16)
-> Nested Loop (cost=12437.75..13162.28 rows=1 width=20)
-> Nested Loop (cost=12437.32..13160.81 rows=1 width=24)
-> Nested Loop (cost=12436.88..13158.24 rows=1 width=16)
-> Hash Join (cost=12436.45..13156.34 rows=1 width=12)
Hash Cond: (designations.applicant_id = applicants_1.id)
-> Nested Loop (cost=129.98..849.69 rows=45 width=8)
-> HashAggregate (cost=129.55..129.67 rows=12 width=8)
Group Key: programs.id
-> Nested Loop (cost=0.72..129.52 rows=12 width=8)
-> Index Only Scan using index_user_identity_programs_on_user_identity_id_and_program_id on user_identity_programs (cost=0.43..29.65 rows=12 width=4)
Index Cond: (user_identity_id = 209110)
-> Index Scan using programs_pkey on programs (cost=0.29..8.31 rows=1 width=4)
Index Cond: (id = user_identity_programs.program_id)
Filter: ((type)::text = 'Program'::text)
-> Index Scan using index_designations_on_program_id on designations (cost=0.43..59.96 rows=4 width=12)
Index Cond: (program_id = programs.id)
Filter: (local_status_id = 200599)
-> Hash (cost=12292.00..12292.00 rows=1158 width=4)
-> Unique (cost=12274.63..12280.42 rows=1158 width=4)
-> Sort (cost=12274.63..12277.52 rows=1158 width=4)
Sort Key: applicants_1.id
-> Nested Loop (cost=1471.15..12215.70 rows=1158 width=4)
-> HashAggregate (cost=1470.72..1539.11 rows=6839 width=4)
Group Key: applicant_designation_details_mv.applicant_id
-> Nested Loop (cost=30.24..1453.62 rows=6839 width=4)
-> HashAggregate (cost=29.68..29.80 rows=12 width=4)
Group Key: user_identity_programs_1.program_id
-> Index Only Scan using index_user_identity_programs_on_user_identity_id_and_program_id on user_identity_programs user_identity_programs_1 (cost=0.43..29.65 rows=12 width=4)
Index Cond: (user_identity_id = 209110)
-> Index Only Scan using idx_designation_details_on_status_show_program_id_applicant_id on applicant_designation_details_mv (cost=0.56..112.95 rows=570 width=8)
Index Cond: ((status_show = true) AND (program_id = user_identity_programs_1.program_id))
Filter: status_show
-> Index Scan using applicants_pkey on applicants applicants_1 (cost=0.43..1.55 rows=1 width=4)
Index Cond: (id = applicant_designation_details_mv.applicant_id)
Filter: (association_id = 313)
-> Index Only Scan using applicants_pkey on applicants (cost=0.43..1.89 rows=1 width=4)
Index Cond: (id = designations.applicant_id)
-> Index Scan using index_applicants_emails_on_applicant_id on applicants_emails (cost=0.43..2.34 rows=23 width=8)
Index Cond: (applicant_id = applicants.id)
-> Index Scan using emails_pkey on emails (cost=0.43..1.46 rows=1 width=4)
Index Cond: (id = applicants_emails.email_id)
Filter: (user_identity_id = ANY ('{207631,207887,208060,208161,208261,208352,208463,208603,208773,209083,209110,213014,217538,219549,220432,220435,220444,220451,220459,220473,220477,220484,220491,220496,220503,220517,220540,220547,221925,221926,221927,221928,221929,245118}'::integer[]))
-> Index Scan using application_statuses_pkey on statuses (cost=0.28..0.91 rows=1 width=4)
Index Cond: (id = designations.application_status_id)
Filter: (show AND ((type)::text = 'ApplicationStatus'::text))
-> Unique (cost=12274.63..12280.42 rows=1158 width=4)
-> Sort (cost=12274.63..12277.52 rows=1158 width=4)
Sort Key: applicants_2.id
-> Nested Loop (cost=1471.15..12215.70 rows=1158 width=4)
-> HashAggregate (cost=1470.72..1539.11 rows=6839 width=4)
Group Key: applicant_designation_details_mv_1.applicant_id
-> Nested Loop (cost=30.24..1453.62 rows=6839 width=4)
-> HashAggregate (cost=29.68..29.80 rows=12 width=4)
Group Key: user_identity_programs_2.program_id
-> Index Only Scan using index_user_identity_programs_on_user_identity_id_and_program_id on user_identity_programs user_identity_programs_2 (cost=0.43..29.65 rows=12 width=4)
Index Cond: (user_identity_id = 209110)
-> Index Only Scan using idx_designation_details_on_status_show_program_id_applicant_id on applicant_designation_details_mv applicant_designation_details_mv_1 (cost=0.56..112.95 rows=570 width=8)
Index Cond: ((status_show = true) AND (program_id = user_identity_programs_2.program_id))
Filter: status_show
-> Index Scan using applicants_pkey on applicants applicants_2 (cost=0.43..1.55 rows=1 width=4)
Index Cond: (id = applicant_designation_details_mv_1.applicant_id)
Filter: (association_id = 313)
(66 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment