Last active
October 27, 2023 14:13
-
-
Save msdousti/3332bf1ba7c08482f67f24f655204814 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table test | |
as | |
select id, random() > 0.5 as to_be | |
from generate_series(1, 10000000) as id; | |
CREATE INDEX IF NOT EXISTS idx_1 | |
ON test (id) | |
WHERE to_be = true; | |
CREATE INDEX IF NOT EXISTS idx_2 | |
ON test (id) | |
WHERE to_be = false; | |
-- Without to_be or not to_be | |
explain | |
select * | |
from test | |
where id = 1; | |
-- With to_be or not to_be | |
explain | |
select * | |
from test | |
where id = 1 and (to_be or not to_be); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment