explain.depesz.com

PostgreSQL's explain analyze made readable

Result: WxYI

Settings
# exclusive inclusive rows x rows loops node
1. 0.007 996.681 ↑ 1.0 18 1

Limit (cost=6,051,801.75..6,051,801.80 rows=18 width=734) (actual time=996.671..996.681 rows=18 loops=1)

2. 0.909 996.674 ↑ 19.3 18 1

Sort (cost=6,051,801.75..6,051,802.62 rows=348 width=734) (actual time=996.670..996.674 rows=18 loops=1)

  • Sort Key: courses.name
  • Sort Method: top-N heapsort Memory: 42kB
3. 905.472 995.765 ↑ 1.1 321 1

Bitmap Heap Scan on courses (cost=44.40..6,051,792.76 rows=348 width=734) (actual time=6.617..995.765 rows=321 loops=1)

  • Recheck Cond: ((owner_id IS NULL) OR (owner_id = 32679))
  • Filter: (active AND (((available_for_subscription OR (available_for_subscription IS NULL)) AND (owner_id IS NULL) AND ((NOT private) OR (private IS NULL))) OR (owner_id = 3267
  • Rows Removed by Filter: 701
  • Heap Blocks: exact=311
4. 0.001 0.092 ↓ 0.0 0 1

BitmapOr (cost=44.40..44.40 rows=1,022 width=0) (actual time=0.092..0.092 rows=0 loops=1)

5. 0.067 0.067 ↑ 1.0 750 1

Bitmap Index Scan on index_courses_on_owner_id (cost=0.00..29.91 rows=750 width=0) (actual time=0.067..0.067 rows=750 loops=1)

  • Index Cond: (owner_id IS NULL)
6. 0.024 0.024 ↓ 1.0 279 1

Bitmap Index Scan on index_courses_on_owner_id (cost=0.00..14.32 rows=272 width=0) (actual time=0.024..0.024 rows=279 loops=1)

  • Index Cond: (owner_id = 32679)
7.          

SubPlan (forBitmap Heap Scan)

8. 0.321 4.815 ↑ 1.0 1 321

Aggregate (cost=24.14..24.15 rows=1 width=0) (actual time=0.015..0.015 rows=1 loops=321)

9. 4.494 4.494 ↑ 1.0 1 321

Index Scan using index_train_sessions_on_account_id_and_course_id on train_sessions (cost=0.42..24.14 rows=1 width=0) (actual time=0.006..0.014 rows=1 loops=321)

  • Index Cond: ((account_id = 32679) AND (course_id = courses.id))
  • Filter: (((status)::text = 'Assigned'::text) OR ((status)::text = 'Live'::text))
  • Rows Removed by Filter: 20
10. 9.309 85.386 ↑ 1.0 1 321

Aggregate (cost=932.56..932.57 rows=1 width=0) (actual time=0.266..0.266 rows=1 loops=321)

11. 76.077 76.077 ↓ 1.3 4 321

Index Scan using index_train_sessions_on_account_id_and_course_id on train_sessions train_sessions_1 (cost=0.67..932.55 rows=3 width=0) (actual time=0.191..0.237 rows=4 loops=321)

  • Index Cond: ((account_id = ANY ('{35671,35371,35374,32679,35707,35615,35677,35628,35541,35538,35630,35592,35530,35616,35710,35670,35634,35730,35708,35583,35625,35738,35723,35347,35637,35352,36182,35789,35790,35791,35716,36183,35362,35544,35539,35731,35537,35709,35606,35354,35651,35894,35691,35653,35652,35655,35656,35706,35568,35693,35694,35570,35576,35577,35533,35596,35695,35532,35696,35376,35373,35742,36188,35722,35627,35536,35567,35737,35623,35618,36198,36199,35635,35729,35728,35893,35631,35372,35355,35572,35681,35569,35574,35575,35605,35542,35721,35351,35640,35361,35642,35360,35641,35582,35584,35571,35624,35609,35713,35608,35714,35700,35676,35674,35678,35754,35755,35357,35358,35711,35715,35356,35375,35664,35661,35662,35377,36184,35663,35591,35699,35679,35683,35820,35366,35976,35369,36200,35735,35611,35349,35638,35689,35724,35819,35675,35666,35649,35690,35985,35658,35657,35659,36206,36205,35573,35654,35650,35585,35587,35588,35586,35610,35725,35726,35579,35580,35578,36185,35617,35607,35712,35702,35668,35669,35665,35672,35543,35632,35626,35535,35633,36186,35612,36769,36187,35667,35350,35660,35718,35717,35368,35821,35594,35684,35581,35719,35720,35736,35629,35595,35704,35359,35703,35727,35685,35680}'::integer[])) AND (course_id = courses.id))
  • Filter: (((status)::text = 'Assigned'::text) OR ((status)::text = 'Live'::text))
  • Rows Removed by Filter: 44