forked from mtusi2026/mtusi2026lab2
1.1 KiB
1.1 KiB
Index experiment
Dataset: 300000 messages, 5000 chats, 2000 users. Median of 5 warm-cache runs; plan is the sequence of access nodes.
| state | query | median ms | plan |
|---|---|---|---|
| both | user_chats | 1.379 | Sort>Hash Join>Seq Scan>Index Only Scan |
| both | chat_messages | 0.428 | Index Scan |
| both | user_feed | 35.396 | Sort>Nested Loop>Index Only Scan>Index Scan |
| messages_only | user_chats | 7.360 | Sort>Hash Join>Seq Scan |
| messages_only | chat_messages | 0.469 | Index Scan |
| messages_only | user_feed | 35.218 | Sort>Nested Loop>Seq Scan>Index Scan |
| membership_only | user_chats | 1.402 | Sort>Hash Join>Seq Scan>Index Only Scan |
| membership_only | chat_messages | 57.634 | Sort>Seq Scan |
| membership_only | user_feed | 80.404 | Sort>Hash Join>Seq Scan>Index Only Scan |
Index sizes after restoring both: chat_members_user_idx=3536 kB, messages_chat_created_id_idx=17 MB, messages_table=75 MB
pgbench message-like inserts, 4 clients, 10 s: with messages index 2718.889742 tps; without 2640.028063 tps. The research DB is left with both indexes.