-- Column engine L1 (src/col/enc.c): schema, dictionaries, batches, chunks, zones, predicates and unit records, against a naive -- evaluation of the same random rows. Prints only counts and ok flags, so the output is the same on every machine. CREATE EXTENSION pg_sift; CREATE EXTENSION pg_sift_test; -- Small and large batches, many seeds: every storage class, NULLs, overflow values, arrays, dense and sparse pages, strings, every -- chunk encoding (encodings = 3839: every width class of CONST, PACK and FOR written, the chunk codec blobs, string lists and inline text), every predicate operator, zones, merges, corrupt records SELECT sum(checks) > 10000 AS ran, sum(failures) AS failures, bit_or(encodings) = 3839 AS all_encodings FROM generate_series(1, 10) s, LATERAL sift._test_col_enc_roundtrip(s, 300, 10); ran | failures | all_encodings -----+----------+--------------- t | 0 | t (1 row) SELECT checks > 10000 AS ran, failures FROM sift._test_col_enc_roundtrip(2, 5000, 10); ran | failures -----+---------- t | 0 (1 row) SELECT checks > 1000 AS ran, failures, encodings & 256 = 256 AS wide_dictionary FROM sift._test_col_enc_roundtrip(3, 74496, 1); ran | failures | wide_dictionary -----+----------+----------------- t | 0 | t (1 row) SELECT checks > 1000 AS ran, failures, encodings & 256 = 256 AS wide_dictionary FROM sift._test_col_enc_roundtrip(14, 74496, 1); ran | failures | wide_dictionary -----+----------+----------------- t | 0 | t (1 row) SELECT checks > 1000 AS ran, failures FROM sift._test_col_enc_roundtrip(4, 1, 60); ran | failures -----+---------- t | 0 (1 row) SELECT sum(failures) AS failures, count(*) AS runs FROM generate_series(10, 24) s, LATERAL sift._test_col_enc_roundtrip(s, 1 + (s * 997) % 4000, 3); failures | runs ----------+------ 0 | 15 (1 row) -- The same rows through every SIMD level of the column kernels: the answers do not depend on it SET sift.simd = scalar; SELECT checks AS scalar_checks, failures FROM sift._test_col_enc_roundtrip(5, 2000, 8) \gset SELECT failures FROM sift._test_col_enc_roundtrip(5, 2000, 8); failures ---------- 0 (1 row) SET sift.simd = avx2; SELECT checks = :scalar_checks AS avx2_same, failures FROM sift._test_col_enc_roundtrip(5, 2000, 8); avx2_same | failures -----------+---------- t | 0 (1 row) SET sift.simd = avx512; SELECT checks = :scalar_checks AS avx512_same, failures FROM sift._test_col_enc_roundtrip(5, 2000, 8); avx512_same | failures -------------+---------- t | 0 (1 row) RESET sift.simd; -- Sizes of a full superblock (74,496 rows): a dictionary of 20 values takes 5 bits per row, a month-clustered date 5, a boolean 1, a -- constant nothing, a float or a random timestamp 8 bytes; the row directory of 256 dense pages is 1.6 kB SELECT shape, bytes_per_row < limit_ AS small_enough FROM sift._test_col_enc_sizes() s JOIN (VALUES ('status, dictionary of 20 values', 0.7), ('order date, clustered in one month', 0.7), ('quantity, 1..5', 0.45), ('boolean', 0.2), ('constant', 0.03), ('sequential id', 2.2), ('price, float8 with 2 decimals', 8.1)) v(name, limit_) ON s.shape = v.name ORDER BY shape COLLATE "C"; shape | small_enough ------------------------------------+-------------- boolean | t constant | t order date, clustered in one month | t price, float8 with 2 decimals | t quantity, 1..5 | t sequential id | t status, dictionary of 20 values | t (7 rows) DROP EXTENSION pg_sift_test; DROP EXTENSION pg_sift;