summaryrefslogtreecommitdiffstats
path: root/contrib/btree_gist/sql/bool.sql
blob: 4c2a5392b6ca701b9c63b0add9d2038a22029932 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
-- bool check

CREATE TABLE booltmp (a bool);

INSERT INTO booltmp VALUES (false), (true);

SET enable_seqscan=on;

SELECT count(*) FROM booltmp WHERE a <  true;

SELECT count(*) FROM booltmp WHERE a <= true;

SELECT count(*) FROM booltmp WHERE a  = true;

SELECT count(*) FROM booltmp WHERE a >= true;

SELECT count(*) FROM booltmp WHERE a >  true;

CREATE INDEX boolidx ON booltmp USING gist ( a );

SET enable_seqscan=off;

SELECT count(*) FROM booltmp WHERE a <  true;

SELECT count(*) FROM booltmp WHERE a <= true;

SELECT count(*) FROM booltmp WHERE a  = true;

SELECT count(*) FROM booltmp WHERE a >= true;

SELECT count(*) FROM booltmp WHERE a >  true;

-- Test index-only scans
SET enable_bitmapscan=off;

EXPLAIN (COSTS OFF)
SELECT * FROM booltmp WHERE a;
SELECT * FROM booltmp WHERE a;

EXPLAIN (COSTS OFF)
SELECT * FROM booltmp WHERE NOT a;
SELECT * FROM booltmp WHERE NOT a;