[pgsql-jp: 37077] point 型のカラムに対する INDEX の作成方法について

haward99 @ yahoo.co.jp haward99 @ yahoo.co.jp
2006年 5月 22日 (月) 11:55:20 JST


渡辺と申します。

#ver8.1.2使ってます。
point型のカラムにINDEXをはるのに苦戦しております。

=>create table test_tbl (
    keidoido point
);

のようなテーブルに、緯度経度の情報をつっこんであります。

=>select * from test_tbl;
         keidoido
----------------------
 (141.341,43.067)
 (139.3103,35.352)
 (139.019,35.1209)

ここで、create indexすると次のとおりです。
=>create index testindex on test_tbl (keidoido);
ERROR:  data type point has no default operator class for access method "btree"
HINT:  You must specify an operator class for the index or define a default
operator class for the data type.

マニュアル見て「こうかな?」と思ったのですが
=> create index testindex on test_tbl using gist (keidoido circle_ops);
ERROR:  operator class "circle_ops" does not accept data type point

ということでダメでした。gistじゃなくrtreeでも同様。
(rtreeはそろそろサポートされなくなる的なことが書いてあったし)

インデックスの種類はともかく演算子の型も指定しなければ
ならないらしく??です。
どなたかわかる方いらっしゃいませんか?

ちなみに
 select * from test_tbl where circle(keidoido,0.02) ~ point(139.001,35.002);
のように、ある地点から半径xの範囲内にあるレコードを取得するようなことを
考えてます。






pgsql-jp メーリングリストの案内