Search Postgresql Archives

index on user defined type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think I created a type that was compatible with the btree index, and
everything seems fine, except that it doesn't actually use the index. I
created the operators and the opclass as well.

=> create type type2 as (i int);
=> create operator = (leftarg=type2,rightarg=type2,procedure=type2_eq);
=> create operator < (leftarg=type2,rightarg=type2,procedure=type2_lt);
=> create operator <=(leftarg=type2,rightarg=type2,procedure=type2_lte);
=> create operator >=(leftarg=type2,rightarg=type2,procedure=type2_gte);
=> create operator > (leftarg=type2,rightarg=type2,procedure=type2_gt);
=> create operator class type2_opclass default for type type2 using
btree as operator 1 <, operator 2 <=, operator 3 =, operator 4 >=,
operator 5 >, function 1 type2_cmp(type2,type2);
=> create table test(t type2 unique);
... insert '(1)', '(2)', and '(3)';
... enable_seqscan is off
=> explain select * from test where t = '(2)';
                             QUERY PLAN
---------------------------------------------------------------------
 Seq Scan on test  (cost=100000000.00..100000002.54 rows=1 width=32)
   Filter: ((t).i = ('(2)'::type2).i)
(2 rows)

Is there something obvious that I'm doing wrong? The operators'
functions are pretty basic sql functions that just do the obvious thing,
and those operators seem to work correctly when used in queries. If I
make a table except with an int instead of a type2, it uses the index as
soon as I turn seqscan off.

Regards,
	Jeff Davis


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@xxxxxxxxxxxxxx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux