{ "messages_in_chat": 10000, "page_limit": 50, "index": "messages_chat_created_id_idx", "cases": { "first": { "after_message": 0, "sql": "SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id=%s ORDER BY created_at, id LIMIT %s", "plan": { "Plan": { "Node Type": "Limit", "Parallel Aware": false, "Async Capable": false, "Startup Cost": 0.29, "Total Cost": 5.58, "Plan Rows": 51, "Plan Width": 70, "Actual Startup Time": 0.009, "Actual Total Time": 0.017, "Actual Rows": 51, "Actual Loops": 1, "Shared Hit Blocks": 3, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0, "Plans": [ { "Node Type": "Index Scan", "Parent Relationship": "Outer", "Parallel Aware": false, "Async Capable": false, "Scan Direction": "Forward", "Index Name": "messages_chat_created_id_idx", "Relation Name": "messages", "Alias": "messages", "Startup Cost": 0.29, "Total Cost": 1038.88, "Plan Rows": 10000, "Plan Width": 70, "Actual Startup Time": 0.008, "Actual Total Time": 0.014, "Actual Rows": 51, "Actual Loops": 1, "Index Cond": "(chat_id = '24b671da-2531-454f-9569-2d97c3d3b45e'::uuid)", "Rows Removed by Index Recheck": 0, "Shared Hit Blocks": 3, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0 } ] }, "Planning": { "Shared Hit Blocks": 107, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0 }, "Planning Time": 0.214, "Triggers": [], "Execution Time": 0.036 } }, "middle": { "after_message": 5000, "sql": "SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id=%s AND (created_at, id) > (%s, %s) ORDER BY created_at, id LIMIT %s", "plan": { "Plan": { "Node Type": "Limit", "Parallel Aware": false, "Async Capable": false, "Startup Cost": 0.29, "Total Cost": 7.15, "Plan Rows": 51, "Plan Width": 70, "Actual Startup Time": 0.019, "Actual Total Time": 0.029, "Actual Rows": 51, "Actual Loops": 1, "Shared Hit Blocks": 4, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0, "Plans": [ { "Node Type": "Index Scan", "Parent Relationship": "Outer", "Parallel Aware": false, "Async Capable": false, "Scan Direction": "Forward", "Index Name": "messages_chat_created_id_idx", "Relation Name": "messages", "Alias": "messages", "Startup Cost": 0.29, "Total Cost": 665.89, "Plan Rows": 4945, "Plan Width": 70, "Actual Startup Time": 0.018, "Actual Total Time": 0.025, "Actual Rows": 51, "Actual Loops": 1, "Index Cond": "((chat_id = '24b671da-2531-454f-9569-2d97c3d3b45e'::uuid) AND (ROW(created_at, id) > ROW('2026-10-30 21:30:51.163748+00'::timestamp with time zone, '49e8083b-b366-420a-a42e-7dd94e84e990'::uuid)))", "Rows Removed by Index Recheck": 0, "Shared Hit Blocks": 4, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0 } ] }, "Planning": { "Shared Hit Blocks": 0, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0 }, "Planning Time": 0.044, "Triggers": [], "Execution Time": 0.05 } }, "late": { "after_message": 9900, "sql": "SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id=%s AND (created_at, id) > (%s, %s) ORDER BY created_at, id LIMIT %s", "plan": { "Plan": { "Node Type": "Limit", "Parallel Aware": false, "Async Capable": false, "Startup Cost": 0.29, "Total Cost": 83.03, "Plan Rows": 51, "Plan Width": 70, "Actual Startup Time": 0.006, "Actual Total Time": 0.017, "Actual Rows": 51, "Actual Loops": 1, "Shared Hit Blocks": 4, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0, "Plans": [ { "Node Type": "Index Scan", "Parent Relationship": "Outer", "Parallel Aware": false, "Async Capable": false, "Scan Direction": "Forward", "Index Name": "messages_chat_created_id_idx", "Relation Name": "messages", "Alias": "messages", "Startup Cost": 0.29, "Total Cost": 159.29, "Plan Rows": 98, "Plan Width": 70, "Actual Startup Time": 0.006, "Actual Total Time": 0.014, "Actual Rows": 51, "Actual Loops": 1, "Index Cond": "((chat_id = '24b671da-2531-454f-9569-2d97c3d3b45e'::uuid) AND (ROW(created_at, id) > ROW('2026-10-30 21:30:51.168648+00'::timestamp with time zone, '15bb3004-514a-4d41-b783-327659c3269a'::uuid)))", "Rows Removed by Index Recheck": 0, "Shared Hit Blocks": 4, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0 } ] }, "Planning": { "Shared Hit Blocks": 0, "Shared Read Blocks": 0, "Shared Dirtied Blocks": 0, "Shared Written Blocks": 0, "Local Hit Blocks": 0, "Local Read Blocks": 0, "Local Dirtied Blocks": 0, "Local Written Blocks": 0, "Temp Read Blocks": 0, "Temp Written Blocks": 0 }, "Planning Time": 0.032, "Triggers": [], "Execution Time": 0.025 } } } }