explain.depesz.com

PostgreSQL's explain analyze made readable

Result: LAGE

Settings
# exclusive inclusive rows x rows loops node
1. 1.801 101,746.188 ↑ 1.1 321 1

Sort (cost=11,204,560.13..11,204,561.00 rows=348 width=31) (actual time=101,746.123..101,746.188 rows=321 loops=1)

  • Sort Key: courses.name
  • Sort Method: quicksort Memory: 63kB
2. 4.307 101,744.387 ↑ 1.1 321 1

Bitmap Heap Scan on courses (cost=44.40..11,204,545.44 rows=348 width=31) (actual time=277.239..101,744.387 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.002 0.093 ↓ 0.0 0 1

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

4. 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)
5. 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)
6.          

SubPlan (forBitmap Heap Scan)

7. 27.606 1,533.738 ↑ 1.0 1 321

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

8. 256.768 1,506.132 ↓ 1.1 332 321

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

9. 437.844 494.340 ↓ 2.4 1,176 321

Bitmap Heap Scan on logins (cost=52.93..3,428.30 rows=485 width=4) (actual time=0.305..1.540 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.150 48.150 ↓ 1.1 1,202 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.150..0.150 rows=1,202 loops=321)

  • Index Cond: (account_id = 32679)
11.          

SubPlan (forBitmap Heap Scan)

12. 8.346 8.346 ↓ 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.026 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. 83.460 100,206.249 ↑ 1.0 1 321

Aggregate (cost=25,021.55..25,021.56 rows=1 width=0) (actual time=312.169..312.169 rows=1 loops=321)

15. 1,009.874 100,122.789 ↑ 2.4 906 321

Nested Loop (cost=2,311.18..25,016.05 rows=2,200 width=0) (actual time=4.217..311.909 rows=906 loops=321)

16. 29,115.079 97,252.407 ↑ 1.3 2,898 321

Hash Semi Join (cost=2,310.76..22,826.05 rows=3,672 width=4) (actual time=0.721..302.967 rows=2,898 loops=321)

  • Hash Cond: (logins_1.account_id = "ANY_subquery".id)
17. 68,038.518 68,136.102 ↓ 2.0 364,435 321

Seq Scan on logins logins_1 (cost=932.51..20,929.94 rows=181,718 width=8) (actual time=0.397..212.262 rows=364,435 loops=321)

  • Filter: ((NOT (hashed SubPlan 3)) AND (role_id = 11))
  • Rows Removed by Filter: 49510
18.          

SubPlan (forSeq Scan)

19. 97.584 97.584 ↓ 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.108..0.304 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))
20. 0.052 1.226 ↓ 1.0 197 1

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

  • Buckets: 1024 Batches: 1 Memory Usage: 7kB
21. 0.084 1.174 ↓ 1.0 197 1

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

22. 0.490 1.090 ↓ 1.0 197 1

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

  • Sort Key: accounts.name, account_hierarchies.generations
  • Sort Method: quicksort Memory: 40kB
23. 0.115 0.600 ↓ 1.0 197 1

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

24. 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)
25. 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)
26. 1,860.508 1,860.508 ↓ 0.0 0 930,254

Index Scan using index_users_on_login_id on users users_1 (cost=0.42..0.59 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=930,254)

  • Index Cond: (login_id = logins_1.id)
  • Filter: ((deleted_at IS NULL) AND ((status)::text = 'Active'::text))
  • Rows Removed by Filter: 1
Planning time : 1.400 ms
Execution time : 101,746.734 ms