Обсуждение: int4 in a GiST index

Поиск
Список
Период
Сортировка

int4 in a GiST index

От
Mike Rylander
Дата:
Hello all,

I am using tsearch2 to (imagine this... :) index a text field.  There
is also a, for lack of a better name, "classification" field called
'field' that will be used to group certain rows together.

CREATE TABLE biblio.metarecord_field_entry (
        record          BIGINT  REFERENCES biblio.metarecord (id)
                                        ON UPDATE CASCADE
                                        ON DELETE SET NULL
                                        DEFERRABLE
                                        INITIALLY DEFERRED,
        field           INT     NOT NULL
                                REFERENCES biblio.metarecord_field_map (id)
                                        ON UPDATE CASCADE
                                        ON DELETE CASCADE
                                        DEFERRABLE
                                        INITIALLY DEFERRED,
        value           TEXT,
        value_fti       tsvector,
        source          BIGINT  NOT NULL
                                REFERENCES biblio.record (id)
                                        ON UPDATE CASCADE
                                        ON DELETE CASCADE
                                        DEFERRABLE
                                        INITIALLY DEFERRED
) WITHOUT OIDS;


Because there will be "or" queries against the 'value_fti' I want to
create a multi-column index across the tsvector and classification
columns as that should help with selectivity.  But because there is no
GiST opclass for INT4 the index creation complains thusly:

  oils=# CREATE INDEX metarecord_field_entry_value_and_field_idx ON
biblio.metarecord_field_entry USING GIST (field, value_fti);
  ERROR:  data type integer has no default operator class for access
method "gist"
  HINT:  You must specify an operator class for the index or define a
default operator class for the data type.

I attempted to give it the 'int4_ops' class, but that also complains:

  oils=# CREATE INDEX metarecord_field_entry_value_and_field_idx ON
biblio.metarecord_field_entry USING GIST (value_fti, field int4_ops);
  ERROR:  operator class "int4_ops" does not exist for access method "gist"

I couldn't find any info in the docs (7.4 and 8.0.0b4) for getting
GiST to index standard integers.  I'm sure this has been done before,
but I've note found the magic spell.  Of course, I may just be barking
up the wrong tree altogether...

Thanks in advance!


--
Mike Rylander
mrylander@gmail.com
GPLS -- PINES Development
Database Developer

Re: int4 in a GiST index

От
George Essig
Дата:
Mike Rylander wrote:

> I want to create a multi-column index across the tsvector and classification
> columns as that should help with selectivity.  But because there is no
> GiST opclass for INT4 the index creation complains thusly:

Install contrib/btree_gist along with contrib/tsearch2 to create a multicolumn index on the in4
and the tsvector columns.  See the following for an example:

http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/oscon_tsearch2/multi_column_index.html

George Essig

Re: int4 in a GiST index

От
Mike Rylander
Дата:
On Wed, 10 Nov 2004 18:50:28 -0800 (PST), George Essig
<george_essig@yahoo.com> wrote:
> Mike Rylander wrote:
>
> > I want to create a multi-column index across the tsvector and classification
> > columns as that should help with selectivity.  But because there is no
> > GiST opclass for INT4 the index creation complains thusly:
>
> Install contrib/btree_gist along with contrib/tsearch2 to create a multicolumn index on the in4
> and the tsvector columns.  See the following for an example:
>
> http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/oscon_tsearch2/multi_column_index.html
>
> George Essig
>


Thanks a million.  I had actually just found the answer after some
more googling, but I hadn't seen that page and it happens to be
exactly what I wanted.

As a side note I'd like to thank everyone here (and especially George,
in this case).   I've been on these lists for quite a while and I'm
always amazed at the speed, accuracy and precision of the answers on
the PG mailing lists.

--
Mike Rylander
mrylander@gmail.com
GPLS -- PINES Development
Database Developer