mirror of
https://github.com/postgres/postgres.git
synced 2025-06-23 14:01:44 +03:00
config
contrib
adminpack
auth_delay
auto_explain
btree_gin
btree_gist
data
expected
bit.out
bytea.out
cash.out
char.out
char_1.out
cidr.out
date.out
float4.out
float8.out
inet.out
init.out
int2.out
int4.out
int8.out
interval.out
macaddr.out
not_equal.out
numeric.out
oid.out
text.out
text_1.out
time.out
timestamp.out
timestamptz.out
timetz.out
varbit.out
varchar.out
varchar_1.out
sql
.gitignore
Makefile
btree_bit.c
btree_bytea.c
btree_cash.c
btree_date.c
btree_float4.c
btree_float8.c
btree_gist--1.0.sql
btree_gist--unpackaged--1.0.sql
btree_gist.c
btree_gist.control
btree_gist.h
btree_inet.c
btree_int2.c
btree_int4.c
btree_int8.c
btree_interval.c
btree_macaddr.c
btree_numeric.c
btree_oid.c
btree_text.c
btree_time.c
btree_ts.c
btree_utils_num.c
btree_utils_num.h
btree_utils_var.c
btree_utils_var.h
chkpass
citext
cube
dblink
dict_int
dict_xsyn
dummy_seclabel
earthdistance
file_fdw
fuzzystrmatch
hstore
intagg
intarray
isn
lo
ltree
oid2name
pageinspect
passwordcheck
pg_archivecleanup
pg_buffercache
pg_freespacemap
pg_standby
pg_stat_statements
pg_test_fsync
pg_test_timing
pg_trgm
pg_upgrade
pg_upgrade_support
pgbench
pgcrypto
pgrowlocks
pgstattuple
seg
sepgsql
spi
sslinfo
start-scripts
tablefunc
tcn
test_parser
tsearch2
unaccent
uuid-ossp
vacuumlo
xml2
Makefile
README
contrib-global.mk
doc
src
.gitignore
COPYRIGHT
GNUmakefile.in
HISTORY
Makefile
README
README.git
aclocal.m4
configure
configure.in
This extends GiST's support for nearest-neighbor searches to many of the standard data types. Teodor Sigaev
92 lines
1.7 KiB
Plaintext
92 lines
1.7 KiB
Plaintext
-- float4 check
|
|
CREATE TABLE float4tmp (a float4);
|
|
\copy float4tmp from 'data/float4.data'
|
|
SET enable_seqscan=on;
|
|
SELECT count(*) FROM float4tmp WHERE a < -179.0;
|
|
count
|
|
-------
|
|
244
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a <= -179.0;
|
|
count
|
|
-------
|
|
245
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a = -179.0;
|
|
count
|
|
-------
|
|
1
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a >= -179.0;
|
|
count
|
|
-------
|
|
303
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a > -179.0;
|
|
count
|
|
-------
|
|
302
|
|
(1 row)
|
|
|
|
SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3;
|
|
a | ?column?
|
|
----------+----------
|
|
-179 | 0
|
|
-189.024 | 10.0239
|
|
-158.177 | 20.8226
|
|
(3 rows)
|
|
|
|
CREATE INDEX float4idx ON float4tmp USING gist ( a );
|
|
SET enable_seqscan=off;
|
|
SELECT count(*) FROM float4tmp WHERE a < -179.0::float4;
|
|
count
|
|
-------
|
|
244
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a <= -179.0::float4;
|
|
count
|
|
-------
|
|
245
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a = -179.0::float4;
|
|
count
|
|
-------
|
|
1
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a >= -179.0::float4;
|
|
count
|
|
-------
|
|
303
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a > -179.0::float4;
|
|
count
|
|
-------
|
|
302
|
|
(1 row)
|
|
|
|
EXPLAIN (COSTS OFF)
|
|
SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3;
|
|
QUERY PLAN
|
|
-----------------------------------------------
|
|
Limit
|
|
-> Index Scan using float4idx on float4tmp
|
|
Order By: (a <-> (-179)::real)
|
|
(3 rows)
|
|
|
|
SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3;
|
|
a | ?column?
|
|
----------+----------
|
|
-179 | 0
|
|
-189.024 | 10.0239
|
|
-158.177 | 20.8226
|
|
(3 rows)
|
|
|