Re: Using GIN/Gist to search the "union" of two indexes? - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject Re: Using GIN/Gist to search the "union" of two indexes?
Date
Msg-id m2vdd9dvio.fsf@hi-media.com
Whole thread Raw
In response to Using GIN/Gist to search the "union" of two indexes?  (Jesper Krogh <jesper@krogh.cc>)
List pgsql-hackers
Jesper Krogh <jesper@krogh.cc> writes:
> select id from tablea,tableb where tablea.tableb_id = tableb.id and
> tablea.text @@ to_tsquery('ftsquery') or tableb.text @@
> to_tsquery('ftsquery');
>
> This one is doable .. using some "mocking" of queries in the
> application. But if ftsquery is:
>
> "terma & termb" where terma only exists in tablea and termb only exists
> in tableb, then it doesn't work. The path would seem to be to "not use"
> the indexes.

You probably could maintain a separate "materialized" table with a
single tsvector for the two input tables, then query that vector
alone. Given the right foreign keys or copied data you'll get the
matched data easily too.

Hope this helps, regards,
-- 
dim


pgsql-hackers by date:

Previous
From: Mark Kirkwood
Date:
Subject: Re: SQL compatibility reminder: MySQL vs PostgreSQL
Next
From: Andrew Dunstan
Date:
Subject: Re: SQL compatibility reminder: MySQL vs PostgreSQL