explain.depesz.com

PostgreSQL's explain analyze made readable

Result: BiGN

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 34.560 ↑ 1.0 25 1

Limit (cost=3,836.97..3,837.03 rows=25 width=574) (actual time=34.555..34.560 rows=25 loops=1)

2. 0.026 34.556 ↑ 1.5 25 1

Sort (cost=3,836.97..3,837.06 rows=37 width=574) (actual time=34.554..34.556 rows=25 loops=1)

  • Sort Key: (GREATEST(chat_messages_cte.max_created, chat_group.created))
  • Sort Method: quicksort Memory: 49kB
3. 0.106 34.530 ↑ 1.0 36 1

WindowAgg (cost=5.31..3,836.01 rows=37 width=574) (actual time=34.509..34.530 rows=36 loops=1)

4. 0.078 34.424 ↑ 1.0 36 1

Nested Loop Left Join (cost=5.31..3,835.45 rows=37 width=558) (actual time=3.420..34.424 rows=36 loops=1)

5. 0.079 2.774 ↑ 1.0 36 1

Nested Loop Left Join (cost=0.29..333.91 rows=37 width=538) (actual time=0.023..2.774 rows=36 loops=1)

6. 0.319 0.319 ↑ 1.0 36 1

Seq Scan on direct_chat_group (cost=0.00..42.53 rows=37 width=24) (actual time=0.013..0.319 rows=36 loops=1)

  • Filter: ((account_id_one = 54) OR (account_id_two = 54))
  • Rows Removed by Filter: 1,933
7. 2.376 2.376 ↑ 1.0 1 36

Index Scan using chat_group_pkey on chat_group (cost=0.29..7.88 rows=1 width=514) (actual time=0.066..0.066 rows=1 loops=36)

  • Index Cond: (id = direct_chat_group.chat_group_id)
8. 0.036 31.572 ↑ 1.0 1 36

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

  • Filter: (chat_group.id = chat_messages_cte.chat_group_id)
9. 0.288 31.536 ↑ 10.0 1 36

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

  • Group Key: cm.chat_group_id
10. 0.647 31.248 ↓ 1.8 18 36

Nested Loop Left Join (cost=5.02..94.33 rows=10 width=12) (actual time=0.296..0.868 rows=18 loops=36)

  • 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. 22.032 27.036 ↑ 1.1 20 36

Bitmap Heap Scan on chat_message cm (cost=4.59..85.48 rows=21 width=12) (actual time=0.183..0.751 rows=20 loops=36)

  • Recheck Cond: (chat_group.id = chat_group_id)
  • Heap Blocks: exact=711
12. 5.004 5.004 ↑ 1.1 20 36

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

  • Index Cond: (chat_group_id = chat_group.id)
13. 0.073 3.565 ↓ 0.0 0 713

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

14. 0.036 3.492 ↓ 0.0 0 36

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

15. 0.036 3.456 ↓ 0.0 0 36

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

  • Group Key: chat_group_read.chat_group_id
16. 3.420 3.420 ↓ 0.0 0 36

Index Only Scan using chat_group_read_main on chat_group_read (cost=0.43..8.45 rows=1 width=12) (actual time=0.094..0.095 rows=0 loops=36)

  • Index Cond: ((chat_group_id = chat_group.id) AND (account_id = 54))
  • Heap Fetches: 7
Planning time : 0.506 ms
Execution time : 34.653 ms