[pgsql-jp: 30151] Re: ユーザ定義型の検索
sugita @ sra.co.jp
sugita @ sra.co.jp
2003年 6月 8日 (日) 23:59:16 JST
杉田です。
From: junji <junji @ gi.k.u-tokyo.ac.jp>
Subject: [pgsql-jp: 30131] ユーザ定義型の検索
Date: Thu, 05 Jun 2003 01:25:12 +0900
;;; 既知だったらすみません。
;;; ユーザ定義型でbtreeをつかってbackwardサーチが
;;; できません。なぜでしょうか?
;;;
;;; int,floatなどではbackwardサーチがうまくつかえるのですが、
;;; postgresql-7.3.2/src/tutorial
;;; の下にあるcomplex型でもうまくいきませんでした。
...
;;; set enable_seqscan to off;
;;; create table test_complex ( a complex);
;;; insert into test_complex values('(2,1)');
;;; .
;;; .
;;; create index test_complex_idx on test_complex(a);
;;; select * from test_complex where a < '(10,1)' order by a desc;
;;; の場合は
;;; Index Scan
;;; で検索されますが、Backwardで検索されません。
データの内容と backward で検索されないクエリーは、どのようですか?
CRATE TABLE class1 (x complex) とするときに、backward でというのが順序に並べ
て後ろ部分という事ならば、0.0 から 10000.0 迄 1.0 おきに順に (n, n) を投入した
場合に以下のように後ろの部分の検索でインデックスが使われました。
=# explain select * from class1 where x > '(9900,9900)' order by x desc;
QUERY PLAN
---------------------------------------------------------------------------------------
Sort (cost=36.16..37.41 rows=500 width=16)
Sort Key: x
-> Index Scan using class1_x_index on class1 (cost=0.00..13.75 rows=500 width=16)
Index Cond: (x > '(9900,9900)'::complex)
(4 rows)
=#
=# explain select * from class1 where x > '(9900,9900)' order by x asc;
QUERY PLAN
---------------------------------------------------------------------------------
Index Scan using class1_x_index on class1 (cost=0.00..13.75 rows=500 width=16)
Index Cond: (x > '(9900,9900)'::complex)
(2 rows)
=#
Kenji Sugita
pgsql-jp メーリングリストの案内