{ "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.85, "Plan Rows": 51, "Plan Width": 71, "Actual Startup Time": 0.024, "Actual Total Time": 0.033, "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": 1091.76, "Plan Rows": 10000, "Plan Width": 71, "Actual Startup Time": 0.023, "Actual Total Time": 0.029, "Actual Rows": 51, "Actual Loops": 1, "Index Cond": "(chat_id = '77be5bc0-11e0-4330-a660-198fe31253f8'::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": 117, "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.485, "Triggers": [], "Execution Time": 0.068 } }, "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.76, "Plan Rows": 51, "Plan Width": 71, "Actual Startup Time": 0.018, "Actual Total Time": 0.034, "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": 707.54, "Plan Rows": 4827, "Plan Width": 71, "Actual Startup Time": 0.017, "Actual Total Time": 0.027, "Actual Rows": 51, "Actual Loops": 1, "Index Cond": "((chat_id = '77be5bc0-11e0-4330-a660-198fe31253f8'::uuid) AND (ROW(created_at, id) > ROW('2026-11-01 13:55:23.37413+00'::timestamp with time zone, '8527233a-bd37-41c0-92ab-a83710dbaf42'::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": 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.121, "Triggers": [], "Execution Time": 0.082 } }, "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": 87.97, "Plan Rows": 51, "Plan Width": 71, "Actual Startup Time": 0.016, "Actual Total Time": 0.024, "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": 165.33, "Plan Rows": 96, "Plan Width": 71, "Actual Startup Time": 0.016, "Actual Total Time": 0.02, "Actual Rows": 51, "Actual Loops": 1, "Index Cond": "((chat_id = '77be5bc0-11e0-4330-a660-198fe31253f8'::uuid) AND (ROW(created_at, id) > ROW('2026-11-01 13:55:23.37903+00'::timestamp with time zone, '2cb28284-13ea-47b3-9eda-45aeb4bda794'::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.073, "Triggers": [], "Execution Time": 0.035 } } } }