forked from mtusi2026/mtusi2026lab2
lab2
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user