Thread: minimum operators for b-tree, r-tree
When creating a new data type, what are the operators absolutely necessary for that type to particpate in a btree index? I know you need a "compare" that says = < or >= so does that mean that those three operators are the ones required? If you also know that answer for our implementation of R-trees that would also be helpful. I believe it is intersects and overlaps but it would be nice to get confirmation. Thanks, elein ============================================================ elein@varlena.com Varlena, LLC www.varlena.com PostgreSQL Consulting, Support & Training PostgreSQL General Bits http://www.varlena.com/GeneralBits/ ============================================================= I have always depended on the [QA] of strangers.
elein wrote: > When creating a new data type, what are > the operators absolutely necessary for that > type to particpate in a btree index? > > I know you need a "compare" that says = < or >= > so does that mean that those three operators > are the ones required? I don't remember the details, but here is a link to the pgsql-committers post from when I submitted a patch to do the same for bytea. http://archives.postgresql.org/pgsql-committers/2001-08/msg00108.php -------------------------------------------------------------------- CVSROOT: /home/projects/pgsql/cvsroot Module name: pgsql Changes by: tgl ( at ) hub ( dot ) org 01/08/13 14:45:36 Modified files: src/backend/utils/adt: selfuncs.c varlena.c src/include/catalog: catversion.h pg_amop.h pg_amproc.h pg_opclass.h pg_operator.h pg_proc.h src/include/utils: builtins.h Log message: Add comparison operators and btree indexing support for type bytea. From Joe Conway. -------------------------------------------------------------------- You could go through cvs web to find the actual diffs, given the date (13 Aug 2001): http://developer.postgresql.org/cvsweb.cgi/pgsql-server/ Joe
elein <elein@varlena.com> writes: > When creating a new data type, what are > the operators absolutely necessary for that > type to particpate in a btree index? You must supply all the operators described in the standard strategy set: http://www.postgresql.org/docs/7.4/static/xindex.html#XINDEX-STRATEGIES plus the support function(s): http://www.postgresql.org/docs/7.4/static/xindex.html#XINDEX-SUPPORT The system is not designed to cope with an incomplete opclass, and I'm not sure it would work if you tried. BTW, although <> isn't part of a btree opclass it is a good idea to provide it (and link it to the opclass by making it the negator of =). There's at least one place in the system that knows about using this. The way I prefer to handle this stuff for btree is to write a single three-way comparison function (compare a to b, return +1/0/-1). This can be used directly as the btree support function, and then the six comparison-operator functions are one-line wrappers around it. regards, tom lane