Thread: How to make operator class?

How to make operator class?

From
"Kim Yunhan"
Date:
when create indexes, use operator class like this.
CREATE INDEX idx_name ON tbl_name (col_name [operator class]);

so, i made an operator.
but i think that it is different operator class because operator class doesn't work at all.
then, how to make operator class?



==================================================

==================================================
우리 인터넷, Daum
평생 쓰는 무료 E-mail 주소 한메일넷
지구촌 한글 검색서비스 Daum FIREBALL
http://www.daum.net


Re: How to make operator class?

From
Tom Lane
Date:
"Kim Yunhan" <spbear@hanmail.net> writes:
> then, how to make operator class?

See the Programmer's Guide, particularly
http://www.postgresql.org/devel-corner/docs/postgres/xindex.htm

If this is a followup to your previous question about making a
reverse-order index, you'll need to start by making a support function
that delivers the reverse (negative) of what the existing btree
comparison function for the datatype does (see btint4cmp and friends).
The remaining operators to comprise the opclass are the same ones that
exist already, you just need to swap their positions (use '<' for '>'
etc).  Good luck!
        regards, tom lane


Re: How to make operator class?

From
Josh Berkus
Date:
Tom,

> > Hmmm .... thinking about it logically, shouldn't the database engine be
> > able to use an index on a single column either backwards or forwards?
> 
> Sure, but he wanted a sort with the first column in ascending order and
> the second in descending order.  You can't get that by scanning an index
> that has both columns in the same order...

Aha.  I see the problem.  My approach would be to use two seperate
indexes, but maybe that's not sophisticated enough :-)

And, Tom, you're working too hard again.  It's Saturday.  Go home.

-Josh Berkus (Who is home, just VPN'ing into my office).

-- 
______AGLIO DATABASE SOLUTIONS___________________________                                       Josh Berkus  Complete
informationtechnology      josh@agliodbs.com   and data management solutions       (415) 565-7293  for law firms, small
businesses      fax  621-2533   and non-profit organizations.       San Francisco