Pager usage is off.
=== PostgreSQL version ===
                                                       version
---------------------------------------------------------------------------------------------------------------------
 PostgreSQL 16.4 (Debian 16.4-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
(1 row)

BEGIN
INSERT 0 1
INSERT 0 1
INSERT 0 10000
COMMIT
ANALYZE
=== Fixture size ===
               chat_id                | message_count | distinct_timestamps
--------------------------------------+---------------+---------------------
 0d8d1cf4-bdfa-47a5-a665-3975e1113d78 |         10000 |                1000
(1 row)

=== History index definition ===
                                              indexdef
----------------------------------------------------------------------------------------------------
 CREATE INDEX messages_chat_created_id_idx ON public.messages USING btree (chat_id, created_at, id)
(1 row)

=== First page: LIMIT 51 ===
                                                                     QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=0.29..4.28 rows=51 width=78) (actual time=0.007..0.015 rows=51 loops=1)
   Buffers: shared hit=3
   ->  Index Scan using messages_chat_created_id_idx on messages  (cost=0.29..783.65 rows=10000 width=78) (actual time=0.006..0.011 rows=51 loops=1)
         Index Cond: (chat_id = '0d8d1cf4-bdfa-47a5-a665-3975e1113d78'::uuid)
         Buffers: shared hit=3
 Planning:
   Buffers: shared hit=9
 Planning Time: 0.067 ms
 Execution Time: 0.025 ms
(9 rows)

=== Middle page: keyset cursor, LIMIT 51 ===
                                                                                                      QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=0.29..5.66 rows=51 width=78) (actual time=0.005..0.017 rows=51 loops=1)
   Buffers: shared hit=9
   ->  Index Scan using messages_chat_created_id_idx on messages  (cost=0.29..527.86 rows=5010 width=78) (actual time=0.005..0.013 rows=51 loops=1)
         Index Cond: ((chat_id = '0d8d1cf4-bdfa-47a5-a665-3975e1113d78'::uuid) AND (ROW(created_at, id) > ROW('2000-01-01 00:00:00.499+00'::timestamp with time zone, 'f53aa6fb-ea52-4332-a211-d239fbf6c885'::uuid)))
         Buffers: shared hit=9
 Planning Time: 0.052 ms
 Execution Time: 0.052 ms
(7 rows)
