Files
mtusi2026lab2/evidence/bench/t2-chat-only/explain-tiny-10.txt
T

71 lines
3.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# План запроса истории: класс tiny, чат 10
Код: src_sha256 8a7e256c540af433, commit fee6f77c3bf1; вариант индекса: chat-only
Страница истории читаемого чата (limit 50); позиция — сколько
сообщений истории до страницы:
- first: после 0
## Планы приложения
auto_explain (ANALYZE, BUFFERS, TIMING): запрос, параметры и план,
с которыми его выполнило приложение (prepared statement asyncpg).
### first
duration: 0.024 ms plan:
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
FROM messages
WHERE messages.chat_id = $1::UUID ORDER BY messages.created_at, messages.id
LIMIT $2::INTEGER
Query Parameters: $1 = 'ff0ec4e6-3bd4-4137-8157-5becc5e43d02', $2 = '51'
Limit (cost=69.39..69.43 rows=17 width=204) (actual time=0.019..0.020 rows=10.00 loops=1)
Buffers: shared hit=12
-> Sort (cost=69.39..69.43 rows=17 width=204) (actual time=0.019..0.019 rows=10.00 loops=1)
Sort Key: created_at, id
Sort Method: quicksort Memory: 27kB
Buffers: shared hit=12
-> Index Scan using ix_messages_chat_id on messages (cost=0.29..69.04 rows=17 width=204) (actual time=0.008..0.015 rows=10.00 loops=1)
Index Cond: (chat_id = 'ff0ec4e6-3bd4-4137-8157-5becc5e43d02'::uuid)
Index Searches: 1
Buffers: shared hit=12
## Страница first в psql: с индексом и без
Тот же текст запроса и те же параметры, что у плана first.
psql планирует их заново (custom plan). DROP INDEX — внутри
транзакции, затем ROLLBACK: индекс остаётся в базе.
### С индексом ix_messages_chat_id
Limit (cost=69.39..69.43 rows=17 width=204) (actual time=0.076..0.080 rows=10.00 loops=1)
Buffers: shared hit=18
-> Sort (cost=69.39..69.43 rows=17 width=204) (actual time=0.076..0.077 rows=10.00 loops=1)
Sort Key: created_at, id
Sort Method: quicksort Memory: 27kB
Buffers: shared hit=18
-> Index Scan using ix_messages_chat_id on messages (cost=0.29..69.04 rows=17 width=204) (actual time=0.016..0.053 rows=10.00 loops=1)
Index Cond: (chat_id = 'ff0ec4e6-3bd4-4137-8157-5becc5e43d02'::uuid)
Index Searches: 1
Buffers: shared hit=12
Planning:
Buffers: shared hit=131
Planning Time: 0.333 ms
Execution Time: 0.099 ms
### Без индекса ix_messages_chat_id
Limit (cost=5327.35..5327.39 rows=17 width=204) (actual time=10.988..10.990 rows=10.00 loops=1)
Buffers: shared hit=3752
-> Sort (cost=5327.35..5327.39 rows=17 width=204) (actual time=10.986..10.988 rows=10.00 loops=1)
Sort Key: created_at, id
Sort Method: quicksort Memory: 27kB
Buffers: shared hit=3752
-> Seq Scan on messages (cost=0.00..5327.00 rows=17 width=204) (actual time=1.312..10.975 rows=10.00 loops=1)
Filter: (chat_id = 'ff0ec4e6-3bd4-4137-8157-5becc5e43d02'::uuid)
Rows Removed by Filter: 125990
Buffers: shared hit=3752
Planning:
Buffers: shared hit=17
Planning Time: 0.149 ms
Execution Time: 11.008 ms