1-- float4 check 2CREATE TABLE float4tmp (a float4); 3\copy float4tmp from 'data/float4.data' 4SET enable_seqscan=on; 5SELECT count(*) FROM float4tmp WHERE a < -179.0; 6 count 7------- 8 244 9(1 row) 10 11SELECT count(*) FROM float4tmp WHERE a <= -179.0; 12 count 13------- 14 245 15(1 row) 16 17SELECT count(*) FROM float4tmp WHERE a = -179.0; 18 count 19------- 20 1 21(1 row) 22 23SELECT count(*) FROM float4tmp WHERE a >= -179.0; 24 count 25------- 26 303 27(1 row) 28 29SELECT count(*) FROM float4tmp WHERE a > -179.0; 30 count 31------- 32 302 33(1 row) 34 35SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3; 36 a | ?column? 37------------+----------- 38 -179 | 0 39 -189.02386 | 10.023865 40 -158.17741 | 20.822586 41(3 rows) 42 43CREATE INDEX float4idx ON float4tmp USING gist ( a ); 44SET enable_seqscan=off; 45SELECT count(*) FROM float4tmp WHERE a < -179.0::float4; 46 count 47------- 48 244 49(1 row) 50 51SELECT count(*) FROM float4tmp WHERE a <= -179.0::float4; 52 count 53------- 54 245 55(1 row) 56 57SELECT count(*) FROM float4tmp WHERE a = -179.0::float4; 58 count 59------- 60 1 61(1 row) 62 63SELECT count(*) FROM float4tmp WHERE a >= -179.0::float4; 64 count 65------- 66 303 67(1 row) 68 69SELECT count(*) FROM float4tmp WHERE a > -179.0::float4; 70 count 71------- 72 302 73(1 row) 74 75EXPLAIN (COSTS OFF) 76SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3; 77 QUERY PLAN 78---------------------------------------------------- 79 Limit 80 -> Index Only Scan using float4idx on float4tmp 81 Order By: (a <-> '-179'::real) 82(3 rows) 83 84SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3; 85 a | ?column? 86------------+----------- 87 -179 | 0 88 -189.02386 | 10.023865 89 -158.17741 | 20.822586 90(3 rows) 91 92