1-- bit check 2CREATE TABLE bittmp (a bit(33)); 3\copy bittmp from 'data/bit.data' 4SET enable_seqscan=on; 5SELECT count(*) FROM bittmp WHERE a < '011011000100010111011000110000100'; 6 count 7------- 8 249 9(1 row) 10 11SELECT count(*) FROM bittmp WHERE a <= '011011000100010111011000110000100'; 12 count 13------- 14 250 15(1 row) 16 17SELECT count(*) FROM bittmp WHERE a = '011011000100010111011000110000100'; 18 count 19------- 20 1 21(1 row) 22 23SELECT count(*) FROM bittmp WHERE a >= '011011000100010111011000110000100'; 24 count 25------- 26 351 27(1 row) 28 29SELECT count(*) FROM bittmp WHERE a > '011011000100010111011000110000100'; 30 count 31------- 32 350 33(1 row) 34 35CREATE INDEX bitidx ON bittmp USING GIST ( a ); 36SET enable_seqscan=off; 37SELECT count(*) FROM bittmp WHERE a < '011011000100010111011000110000100'; 38 count 39------- 40 249 41(1 row) 42 43SELECT count(*) FROM bittmp WHERE a <= '011011000100010111011000110000100'; 44 count 45------- 46 250 47(1 row) 48 49SELECT count(*) FROM bittmp WHERE a = '011011000100010111011000110000100'; 50 count 51------- 52 1 53(1 row) 54 55SELECT count(*) FROM bittmp WHERE a >= '011011000100010111011000110000100'; 56 count 57------- 58 351 59(1 row) 60 61SELECT count(*) FROM bittmp WHERE a > '011011000100010111011000110000100'; 62 count 63------- 64 350 65(1 row) 66 67-- Test index-only scans 68SET enable_bitmapscan=off; 69EXPLAIN (COSTS OFF) 70SELECT a FROM bittmp WHERE a BETWEEN '1000000' and '1000001'; 71 QUERY PLAN 72--------------------------------------------------------------------- 73 Index Only Scan using bitidx on bittmp 74 Index Cond: ((a >= '1000000'::"bit") AND (a <= '1000001'::"bit")) 75(2 rows) 76 77