Re: Xpath Index in PostgreSQL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris Roffler <croffler(at)earthlink(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Xpath Index in PostgreSQL
Date: 2010-03-05 13:22:32
Message-ID: 29360.1267795352@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Chris Roffler <croffler(at)earthlink(dot)net> writes:
> I am trying to setup an index on an xpath expression but the query never
> uses the index.
> Could someone enlighten me please ?

> Here is the setup :

> CREATE INDEX xml_index
> ON time_series
> USING btree
> ((xpath('/AttributeList/Attributes/Attribute/Name/text()'::text,
> external_attributes)::text[]));

> And here is the query :

> select id, name
> from
> time_series
> where
> (xpath('/AttributeList/Attributes/Attribute/Name/text()',
> external_attributes))[1]::text='Attribute100'

Doesn't work that way --- subscripting isn't an indexable operation.
To make that query fast with a standard index, you'd need the index to
be on
(xpath('/AttributeList/Attributes/Attribute/Name/text()',
external_attributes))[1]::text

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-03-05 13:29:55 Re: ERROR: row is too big: size 8176, maximum size 8160
Previous Message Chris Roffler 2010-03-05 12:43:29 Xpath Index in PostgreSQL