Skip to content

Instantly share code, notes, and snippets.

@portnov
Created May 13, 2023 18:36
Show Gist options
  • Save portnov/aeb9c79810fed992ef7c49d13270f934 to your computer and use it in GitHub Desktop.
Save portnov/aeb9c79810fed992ef7c49d13270f934 to your computer and use it in GitHub Desktop.
create table tst_bool (
id bigint primary key generated always as identity,
value numeric,
isgood boolean
);
insert into tst_bool (value, isgood)
select random()*7, round(random()*4) = 1
from generate_series(1, 1000*1000);
analyze tst_bool;
create index idx_tst_bool on tst_bool (isgood);
explain
select id, value from tst_bool where isgood = true;
QUERY PLAN |
-------------------------------------------------------------------------------------+
Index Scan using idx_tst_bool on tst_bool (cost=0.42..14141.58 rows=248800 width=20)|
Index Cond: (isgood = true) |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment