Skip to content

Instantly share code, notes, and snippets.

@onderkalaci
Created September 7, 2021 15:17
Show Gist options
  • Select an option

  • Save onderkalaci/c83f38dd71aaf02afc999d92af25e59c to your computer and use it in GitHub Desktop.

Select an option

Save onderkalaci/c83f38dd71aaf02afc999d92af25e59c to your computer and use it in GitHub Desktop.
CREATE TABLE columnar_test(col_int integer, col_text text, col_text_compressed text COMPRESSION pglz, col_json_b jsonb) USING COLUMNAR;
BEGIN;
insert into columnar_test SELECT i, i::text, i::text, test_jsonb() FROM generate_series(0,1000000)i;
CREATE INDEX i1 ON columnar_test(col_int, col_text, col_text_compressed, col_json_b);
set enable_seqscan to off; set columnar.enable_custom_scan to off;
EXPLAIN SELECT count(*) FROM columnar_test WHERE col_int = random();
-- works fine
SELECT count(*) FROM columnar_test WHERE col_int = random();
-- works fine
insert into columnar_test SELECT i, i::text, i::text, test_jsonb() FROM generate_series(0,1000000)i;
-- never finishes
SELECT count(*) FROM columnar_test WHERE col_int = random();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment