This commit is contained in:
2026-10-23 14:47:53 +03:00
parent 65003b6119
commit 84fc48d315
29 changed files with 1940 additions and 24 deletions
+13
View File
@@ -0,0 +1,13 @@
EXPLAIN (ANALYZE, BUFFERS) on 10_000 messages in one chat.
Command (from repo root, stack running):
docker compose run --rm \
-e DATABASE_URL=postgresql://messenger:messenger_dev_only@postgres:5432/messenger \
-e EXPLAIN_MESSAGE_COUNT=10000 \
-v ./scripts:/scripts:ro \
api python /scripts/explain_messages.py
Observed plan uses index messages_chat_history_idx (Bitmap Index Scan on chat_id),
not Seq Scan on all messages. Execution Time ~2.3 ms on local Docker.
Keyset pagination in API: WHERE chat_id = $1 AND (created_at, id) > ($cursor...) LIMIT n+1