forked from mtusi2026/mtusi2026lab2
14 lines
575 B
Plaintext
14 lines
575 B
Plaintext
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
|