explain.depesz.com

PostgreSQL's explain analyze made readable

Result: RHr6

Settings
# exclusive inclusive rows x rows loops node
1. 1.801 93,534.979 ↑ 1.1 321 1

Sort (cost=11,628,402.19..11,628,403.06 rows=348 width=31) (actual time=93,534.918..93,534.979 rows=321 loops=1)

  • Sort Key: courses.name
  • Sort Method: quicksort Memory: 63kB
2. 4.536 93,533.178 ↑ 1.1 321 1

Bitmap Heap Scan on courses (cost=44.40..11,628,387.50 rows=348 width=31) (actual time=297.886..93,533.178 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 = 32679)))
  • Rows Removed by Filter: 701
  • Heap Blocks: exact=311
3. 0.000 0.156 ↓ 0.0 0 1

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

4. 0.112 0.112 ↑ 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.112..0.112 rows=750 loops=1)

  • Index Cond: (owner_id IS NULL)
5. 0.044 0.044 ↓ 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.044..0.044 rows=279 loops=1)

  • Index Cond: (owner_id = 32679)
6.          

SubPlan (forBitmap Heap Scan)

7. 27.285 1,518.330 ↑ 1.0 1 321

Aggregate (cost=7,173.70..7,173.71 rows=1 width=0) (actual time=4.730..4.730 rows=1 loops=321)

8. 249.064 1,491.045 ↓ 1.1 332 321

Nested Loop (cost=53.35..7,172.98 rows=291 width=0) (actual time=0.353..4.645 rows=332 loops=321)

9. 429.498 486.957 ↓ 2.4 1,176 321

Bitmap Heap Scan on logins (cost=52.93..3,428.30 rows=485 width=4) (actual time=0.306..1.517 rows=1,176 loops=321)

  • Recheck Cond: (account_id = 32679)
  • Filter: ((NOT (hashed SubPlan 1)) AND (role_id = 11))
  • Rows Removed by Filter: 26
  • Heap Blocks: exact=220848
10. 48.792 48.792 ↓ 1.1 1,204 321

Bitmap Index Scan on "index_ole_core.logins_on_account_id" (cost=0.00..28.68 rows=1,101 width=0) (actual time=0.152..0.152 rows=1,204 loops=321)

  • Index Cond: (account_id = 32679)
11.          

SubPlan (forBitmap Heap Scan)

12. 8.667 8.667 ↓ 4.4 22 321

Index Scan using index_train_sessions_on_account_id_and_course_id on train_sessions (cost=0.42..24.11 rows=5 width=4) (actual time=0.009..0.027 rows=22 loops=321)

  • Index Cond: ((account_id = 32679) AND (course_id = courses.id))
13. 755.024 755.024 ↓ 0.0 0 377,512

Index Scan using index_users_on_login_id on users (cost=0.42..7.71 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=377,512)

  • Index Cond: (login_id = logins.id)
  • Filter: ((deleted_at IS NULL) AND ((status)::text = 'Active'::text))
  • Rows Removed by Filter: 1
14. 84.102 92,010.156 ↑ 1.0 1 321

Aggregate (cost=26,239.49..26,239.50 rows=1 width=0) (actual time=286.636..286.636 rows=1 loops=321)

15. 168.525 91,926.054 ↑ 4.9 906 321

Hash Anti Join (cost=2,311.35..26,228.49 rows=4,400 width=0) (actual time=3.851..286.374 rows=906 loops=321)

  • Hash Cond: (logins_1.id = train_sessions_1.assignee_login_id)
16. 1,038.756 91,644.858 ↑ 4.8 922 321

Nested Loop (cost=1,378.67..25,240.26 rows=4,400 width=4) (actual time=3.488..285.498 rows=922 loops=321)

17. 29,038.044 88,717.980 ↑ 2.5 2,941 321

Hash Semi Join (cost=1,378.25..21,379.50 rows=7,344 width=4) (actual time=0.379..276.380 rows=2,941 loops=321)

  • Hash Cond: (logins_1.account_id = "ANY_subquery".id)
18. 59,678.715 59,678.715 ↓ 1.0 364,488 321

Seq Scan on logins logins_1 (cost=0.00..18,965.53 rows=363,437 width=8) (actual time=0.002..185.915 rows=364,488 loops=321)

  • Filter: (role_id = 11)
  • Rows Removed by Filter: 49468
19. 0.059 1.221 ↓ 1.0 197 1

Hash (cost=1,375.80..1,375.80 rows=196 width=4) (actual time=1.221..1.221 rows=197 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 7kB
20. 0.078 1.162 ↓ 1.0 197 1

Subquery Scan on ANY_subquery (cost=1,373.35..1,375.80 rows=196 width=4) (actual time=1.043..1.162 rows=197 loops=1)

21. 0.479 1.084 ↓ 1.0 197 1

Sort (cost=1,373.35..1,373.84 rows=196 width=26) (actual time=1.043..1.084 rows=197 loops=1)

  • Sort Key: accounts.name, account_hierarchies.generations
  • Sort Method: quicksort Memory: 40kB
22. 0.120 0.605 ↓ 1.0 197 1

Nested Loop (cost=0.58..1,365.88 rows=196 width=26) (actual time=0.014..0.605 rows=197 loops=1)

23. 0.091 0.091 ↓ 1.0 197 1

Index Scan using index_account_hierarchies_on_ancestor_id on account_hierarchies (cost=0.29..175.16 rows=196 width=8) (actual time=0.009..0.091 rows=197 loops=1)

  • Index Cond: (ancestor_id = 32679)
24. 0.394 0.394 ↑ 1.0 1 197

Index Scan using accounts_pkey on accounts (cost=0.29..6.07 rows=1 width=22) (actual time=0.001..0.002 rows=1 loops=197)

  • Index Cond: (id = account_hierarchies.descendant_id)
25. 1,888.122 1,888.122 ↓ 0.0 0 944,061

Index Scan using index_users_on_login_id on users users_1 (cost=0.42..0.52 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=944,061)

  • Index Cond: (login_id = logins_1.id)
  • Filter: ((deleted_at IS NULL) AND ((status)::text = 'Active'::text))
  • Rows Removed by Filter: 1
26. 15.408 112.671 ↓ 2.8 48 321

Hash (cost=932.47..932.47 rows=17 width=4) (actual time=0.351..0.351 rows=48 loops=321)

  • Buckets: 1024 Batches: 1 Memory Usage: 0kB
27. 97.263 97.263 ↓ 2.8 48 321

Index Scan using index_train_sessions_on_account_id_and_course_id on train_sessions train_sessions_1 (cost=0.67..932.47 rows=17 width=4) (actual time=0.109..0.303 rows=48 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))
Planning time : 2.553 ms
Execution time : 93,535.387 ms