저는 PostgreSQL/PostGIS를 처음 사용합니다. 나는 간단한 알고리즘을 해결하기 위해 그것을 평가하고있다 : 반지름 (미터)의 모든 점을 찾으려고 노력한다. 여기 내 테이블 : 올바른 디자인이면 나는 point
컬럼에 요점 인덱스를 추가postGIS에서 가장 근접하고 공간 인덱스를 사용하는 근접 함수는 무엇입니까?
=> \d+ theuser;
Table "public.theuser"
Column | Type | Modifiers | Storage | Description
----------+------------------------+-----------+----------+-------------
id | bigint | not null | plain |
point | geometry | | main |
Indexes:
"theuser_pkey" PRIMARY KEY, btree (id)
"point_index" gist (point)
Referenced by:
...
Has OIDs: no
, 나도 몰라. 'points'를 모두 삽입하면 SRID=4326
이됩니다.
이 근처에 포인트를 얻을 수 거기 2 가지 방법을 보인다
ST_Distance, ST_Distance_Sphere을. 예를 들어 2을 가지고 :
select * from theuser where
ST_distance_sphere(point , ST_GeomFromText('POINT(120.9982 24.788)',4326)) < 100;
내가 "point_index
"어떤 알고리즘 메이크업 사용 궁금해? 수백만 포인트가 있다면 매우 빠르게 실행할 수 있습니까?
또 다른 질문은 어떻게 셀의 SRID를 쿼리 할 수 있습니까? 내가 할 수있는 전부는 "com.vividsolutions.jts.geom.Point
"을 얻는 hibernate-spatial-postgis이며 리턴 된 포인트에서 SRID를 얻는다. 어떻게 SQL에서 쿼리합니까? 감사.
환경 : 그것을 사용한다면 어떻게 알 수 있습니까
=> explain select * from theuser where
ST_distance_sphere(point , ST_GeomFromText('POINT(120.9982 24.788)',4326)) < 100;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------
Seq Scan on theuser (cost=0.00..1.15 rows=3 width=2644)
Filter: (st_distance_sphere(point, '0101000020E610000080B74082E23F5E407D3F355EBAC93840'::geometry) < 100::double precision)
(2 rows)
:
=> select version();
version
-----------------------------------------------------------------------------------------------------------
PostgreSQL 8.4.9 on i486-pc-linux-gnu, compiled by GCC gcc-4.4.real (Ubuntu 4.4.3-4ubuntu5) 4.4.3, 32-bit
=> SELECT postgis_lib_version();
postgis_lib_version
---------------------
1.4.0
---- 업데이트 ----
덕분에 @filiprem, 나는이 시도 "point_index" gist (point)
? 높은 데이터 볼륨 검색에서 살아남을 수 있습니까?
나는 주요 질문에 대답하지만, SRID 사용 얻기 위해 수 없습니다 ['ST_SRID'] (http://postgis.refractions.net/documentation/manual-1.4/ST_SRID.html) –
감사합니다 @ skyhisi – smallufo
'EXPLAIN SELECT ... '를 실행하여 그들이 사용하는 알고리즘을 확인하십시오. – filiprem