1set enable_seqscan=off; 2CREATE TABLE test_bool ( 3 i boolean 4); 5INSERT INTO test_bool VALUES (false),(true),(null); 6CREATE INDEX idx_bool ON test_bool USING gin (i); 7SELECT * FROM test_bool WHERE i<true ORDER BY i; 8 i 9--- 10 f 11(1 row) 12 13SELECT * FROM test_bool WHERE i<=true ORDER BY i; 14 i 15--- 16 f 17 t 18(2 rows) 19 20SELECT * FROM test_bool WHERE i=true ORDER BY i; 21 i 22--- 23 t 24(1 row) 25 26SELECT * FROM test_bool WHERE i>=true ORDER BY i; 27 i 28--- 29 t 30(1 row) 31 32SELECT * FROM test_bool WHERE i>true ORDER BY i; 33 i 34--- 35(0 rows) 36 37SELECT * FROM test_bool WHERE i<false ORDER BY i; 38 i 39--- 40(0 rows) 41 42SELECT * FROM test_bool WHERE i<=false ORDER BY i; 43 i 44--- 45 f 46(1 row) 47 48SELECT * FROM test_bool WHERE i=false ORDER BY i; 49 i 50--- 51 f 52(1 row) 53 54SELECT * FROM test_bool WHERE i>=false ORDER BY i; 55 i 56--- 57 f 58 t 59(2 rows) 60 61SELECT * FROM test_bool WHERE i>false ORDER BY i; 62 i 63--- 64 t 65(1 row) 66 67EXPLAIN (COSTS OFF) SELECT * FROM test_bool WHERE i<true ORDER BY i; 68 QUERY PLAN 69------------------------------------------- 70 Sort 71 Sort Key: i 72 -> Bitmap Heap Scan on test_bool 73 Recheck Cond: (i < true) 74 -> Bitmap Index Scan on idx_bool 75 Index Cond: (i < true) 76(6 rows) 77 78EXPLAIN (COSTS OFF) SELECT * FROM test_bool WHERE i<=true ORDER BY i; 79 QUERY PLAN 80------------------------------------------- 81 Sort 82 Sort Key: i 83 -> Bitmap Heap Scan on test_bool 84 Recheck Cond: (i <= true) 85 -> Bitmap Index Scan on idx_bool 86 Index Cond: (i <= true) 87(6 rows) 88 89EXPLAIN (COSTS OFF) SELECT * FROM test_bool WHERE i=true ORDER BY i; 90 QUERY PLAN 91----------------------------- 92 Sort 93 Sort Key: i 94 -> Seq Scan on test_bool 95 Filter: i 96(4 rows) 97 98EXPLAIN (COSTS OFF) SELECT * FROM test_bool WHERE i>=true ORDER BY i; 99 QUERY PLAN 100------------------------------------------- 101 Sort 102 Sort Key: i 103 -> Bitmap Heap Scan on test_bool 104 Recheck Cond: (i >= true) 105 -> Bitmap Index Scan on idx_bool 106 Index Cond: (i >= true) 107(6 rows) 108 109EXPLAIN (COSTS OFF) SELECT * FROM test_bool WHERE i>true ORDER BY i; 110 QUERY PLAN 111------------------------------------------- 112 Sort 113 Sort Key: i 114 -> Bitmap Heap Scan on test_bool 115 Recheck Cond: (i > true) 116 -> Bitmap Index Scan on idx_bool 117 Index Cond: (i > true) 118(6 rows) 119 120