Re: Slow select times on select with xpath - Mailing list pgsql-performance

From Kevin Grittner
Subject Re: Slow select times on select with xpath
Date
Msg-id 4A9F9A26020000250002AA3A@gw.wicourts.gov
Whole thread Raw
In response to Slow select times on select with xpath  (astro77 <astro_coder@yahoo.com>)
Responses Re: Slow select times on select with xpath
List pgsql-performance
astro77 <astro_coder@yahoo.com> wrote:

> I've got a table set up with an XML field that I would like to search
on
> with
> 2.5 million records. The xml are serialized objects from my
application
> which are too complex to break out into separate tables. I'm trying
to run a
> query similar to this:
>
>     SELECT  serialized_object as outVal
>      from object  where
>     (
>
    array_to_string(xpath('/a:root/a:Identification/b:ObjectId/text()',
> serialized_object,
>              ARRAY
>              [
>              ARRAY['a',
'http://schemas.datacontract.org/2004/07/Objects'],
>              ARRAY['b',
'http://schemas.datacontract.org/2004/07/Security']
>
>              ]), ' ') = 'fdc3da1f-060f-4c34-9c30-d9334d9272ae'
>
>     )
>     limit 1000;

I would try to minimize how many XML values it had to read, parse, and
search.  The best approach that comes to mind would be to use tsearch2
techniques (with a GIN or GiST index on the tsvector) to identify
which rows contain 'fdc3da1f-060f-4c34-9c30-d9334d9272ae', and use AND
to combine that with your xpath search.

-Kevin

pgsql-performance by date:

Previous
From: Ivan Voras
Date:
Subject: Re: Seeking performance advice and explanation for high I/O on 8.3
Next
From: Andy Colson
Date:
Subject: Re: Seeking performance advice and explanation for high I/O on 8.3