-- Migrated from DuckDB test: test/sql/limit/test_preserve_insertion_order.test CREATE TABLE integers(i INTEGER, ts TIMESTAMP TIME INDEX); Affected Rows: 0 INSERT INTO integers VALUES (1, 1000), (1, 2000), (1, 3000), (1, 4000), (1, 5000), (2, 6000), (3, 7000), (4, 8000), (5, 9000), (10, 10000); Affected Rows: 10 SELECT MIN(i), MAX(i), COUNT(*) FROM integers; +-----------------+-----------------+----------+ | min(integers.i) | max(integers.i) | count(*) | +-----------------+-----------------+----------+ | 1 | 10 | 10 | +-----------------+-----------------+----------+ SELECT * FROM integers ORDER BY ts LIMIT 5; +---+---------------------+ | i | ts | +---+---------------------+ | 1 | 1970-01-01T00:00:01 | | 1 | 1970-01-01T00:00:02 | | 1 | 1970-01-01T00:00:03 | | 1 | 1970-01-01T00:00:04 | | 1 | 1970-01-01T00:00:05 | +---+---------------------+ SELECT * FROM integers ORDER BY ts LIMIT 3 OFFSET 2; +---+---------------------+ | i | ts | +---+---------------------+ | 1 | 1970-01-01T00:00:03 | | 1 | 1970-01-01T00:00:04 | | 1 | 1970-01-01T00:00:05 | +---+---------------------+ SELECT * FROM integers WHERE i IN (1, 3, 5, 10) ORDER BY i; +----+---------------------+ | i | ts | +----+---------------------+ | 1 | 1970-01-01T00:00:01 | | 1 | 1970-01-01T00:00:02 | | 1 | 1970-01-01T00:00:03 | | 1 | 1970-01-01T00:00:04 | | 1 | 1970-01-01T00:00:05 | | 3 | 1970-01-01T00:00:07 | | 5 | 1970-01-01T00:00:09 | | 10 | 1970-01-01T00:00:10 | +----+---------------------+ SELECT * FROM integers WHERE i IN (1, 3, 5, 10) ORDER BY i, ts LIMIT 3; +---+---------------------+ | i | ts | +---+---------------------+ | 1 | 1970-01-01T00:00:01 | | 1 | 1970-01-01T00:00:02 | | 1 | 1970-01-01T00:00:03 | +---+---------------------+ -- Clean up DROP TABLE integers; Affected Rows: 0