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