{ "track": 2, "hypothesis": "Keyset on (chat_id, created_at, id) reads about one page even deep in a large chat. OFFSET on the same index walks the skipped prefix. An index on created_at alone is also selective at a timestamp that only the largest chat has reached, so it is not a substitute for bounding the walk by chat_id. The extra history index increases insert time. A custom-format dump restored into a second Postgres volume matches the snapshot and omits a row committed after pg_dump started.", "hardware": { "platform": "Windows-11-10.0.22621-SP0", "cpu_count": 16, "ram_gib": 15.3, "api_limit": "2 CPU, 768 MiB" }, "postgres": { "image": "postgres:16.10-alpine", "version": "16.10", "synchronous_commit": "on", "fsync": "on" }, "redis_persistence": "appendonly\nyes\nappendfsync\neverysec", "distribution": { "messages": 100040, "chats": 73, "largest_chat": 70000, "empty_chats": 25, "sizes": [ 70000, 20000, 8000, 1500, 400, 80, 15, 5, 1, 0 ] }, "queries": { "keyset_deep_history_index": { "execution_ms": 0.262, "buffers": "", "shared_hit": 14, "shared_read": 0, "uses_history_index": true, "node": "Index Scan" }, "offset_deep_same_chat": { "execution_ms": 30.49, "buffers": "", "shared_hit": 1124, "shared_read": 0, "uses_history_index": true, "node": "Index Scan" }, "keyset_first_page_at_least_10000": { "execution_ms": 0.191, "buffers": "", "shared_hit": 14, "shared_read": 0, "uses_history_index": true, "node": "Index Scan" }, "keyset_deep_created_at_index_only": { "execution_ms": 0.391, "buffers": "", "shared_hit": 11, "shared_read": 0, "uses_history_index": false, "node": "Index Scan" } }, "write": { "rows": 50000, "primary_key_ms": 118.0, "primary_key_and_history_index_ms": 153.0 }, "backup": { "dump_seconds": 0.466, "restore_seconds": 0.667, "dump_bytes": 2980396, "counts_before_dump": { "users": 2, "chats": 73, "chat_members": 146, "messages": 100040 }, "counts_source_after_extra_commit": { "users": 2, "chats": 73, "chat_members": 146, "messages": 100041 }, "counts_restored": { "users": 2, "chats": 73, "chat_members": 146, "messages": 100040 }, "sample_match": true, "extra_row_in_restore": 0 } }