explain.depesz.com

PostgreSQL's explain analyze made readable

Result: e2pM

Settings
# exclusive inclusive rows x rows loops node
1. 0.003 3.089 ↑ 1.0 25 1

Limit (cost=4,347.93..4,347.99 rows=25 width=574) (actual time=3.085..3.089 rows=25 loops=1)

2. 0.020 3.086 ↑ 1.7 25 1

Sort (cost=4,347.93..4,348.04 rows=42 width=574) (actual time=3.084..3.086 rows=25 loops=1)

  • Sort Key: (GREATEST(chat_messages_cte.max_created, chat_group.created))
  • Sort Method: quicksort Memory: 64kB
3. 0.059 3.066 ↑ 1.0 41 1

WindowAgg (cost=5.31..4,346.80 rows=42 width=574) (actual time=3.048..3.066 rows=41 loops=1)

4. 0.032 3.007 ↑ 1.0 41 1

Nested Loop Left Join (cost=5.31..4,346.17 rows=42 width=558) (actual time=0.211..3.007 rows=41 loops=1)

5. 0.050 0.515 ↑ 1.0 41 1

Nested Loop Left Join (cost=0.29..371.45 rows=42 width=538) (actual time=0.051..0.515 rows=41 loops=1)

6. 0.342 0.342 ↑ 1.0 41 1

Seq Scan on direct_chat_group (cost=0.00..42.53 rows=42 width=24) (actual time=0.041..0.342 rows=41 loops=1)

  • Filter: ((account_id_one = 76) OR (account_id_two = 76))
  • Rows Removed by Filter: 1,928
7. 0.123 0.123 ↑ 1.0 1 41

Index Scan using chat_group_pkey on chat_group (cost=0.29..7.83 rows=1 width=514) (actual time=0.003..0.003 rows=1 loops=41)

  • Index Cond: (id = direct_chat_group.chat_group_id)
8. 0.000 2.460 ↑ 1.0 1 41

Subquery Scan on chat_messages_cte (cost=5.02..94.63 rows=1 width=20) (actual time=0.060..0.060 rows=1 loops=41)

  • Filter: (chat_group.id = chat_messages_cte.chat_group_id)
9. 0.246 2.460 ↑ 10.0 1 41

GroupAggregate (cost=5.02..94.50 rows=10 width=20) (actual time=0.060..0.060 rows=1 loops=41)

  • Group Key: cm.chat_group_id
10. 0.277 2.214 ↓ 1.8 18 41

Nested Loop Left Join (cost=5.02..94.33 rows=10 width=12) (actual time=0.026..0.054 rows=18 loops=41)

  • Join Filter: (cm.chat_group_id = cgr.chat_group_id)
  • Filter: (COALESCE((cm.created > cgr.read_time), false) IS FALSE)
  • Rows Removed by Filter: 2
11. 0.902 1.107 ↑ 1.1 20 41

Bitmap Heap Scan on chat_message cm (cost=4.59..85.48 rows=21 width=12) (actual time=0.008..0.027 rows=20 loops=41)

  • Recheck Cond: (chat_group.id = chat_group_id)
  • Heap Blocks: exact=830
12. 0.205 0.205 ↑ 1.1 20 41

Bitmap Index Scan on chat_message_chat_group_id (cost=0.00..4.58 rows=21 width=0) (actual time=0.005..0.005 rows=20 loops=41)

  • Index Cond: (chat_group_id = chat_group.id)
13. 0.297 0.830 ↓ 0.0 0 830

Materialize (cost=0.43..8.48 rows=1 width=12) (actual time=0.001..0.001 rows=0 loops=830)

14. 0.000 0.533 ↓ 0.0 0 41

Subquery Scan on cgr (cost=0.43..8.47 rows=1 width=12) (actual time=0.013..0.013 rows=0 loops=41)

15. 0.041 0.533 ↓ 0.0 0 41

GroupAggregate (cost=0.43..8.46 rows=1 width=12) (actual time=0.013..0.013 rows=0 loops=41)

  • Group Key: chat_group_read.chat_group_id
16. 0.492 0.492 ↓ 0.0 0 41

Index Scan using blablabla on chat_group_read (cost=0.43..8.45 rows=1 width=12) (actual time=0.012..0.012 rows=0 loops=41)

  • Index Cond: ((chat_group_id = chat_group.id) AND (account_id = 76))
Planning time : 0.536 ms
Execution time : 3.182 ms