Re: querying both text and non-text properties

From: Rob Nikander <rob(dot)nikander(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: querying both text and non-text properties
Date: 2018-12-05 14:01:57
Message-ID: 98C9D9E1-D404-47E2-A04A-B41EC2A025E3@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Dec 4, 2018, at 4:59 PM, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:
>
> You have two options:
>
> A combined index:
>
> CREATE EXTENSION btree_gin;
> CREATE INDEX ON fulltext USING gin (to_tsvector('english', doc), color);
>
> That is the perfect match for a query with
>
> WHERE color = 'red' AND to_tsvector('german', doc) @@ to_tsquery('english', 'word');
>
> But you can also create two indexes:
>
> CREATE INDEX ON fulltext USING gin (to_tsvector('english', doc));
> CREATE INDEX ON fulltext (color);
>
> Then you don't need the extension, and PostgreSQL can still use them for the search,
> either only one of them if the condition is selective enough, or a "BitmapAnd" of both.

Thanks! I will try both these methods and compare the performance.

Rob

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dejan Petrovic 2018-12-05 14:10:13 Database corruption in cascaded replica, "pg_xact/003A" doesn't exist, reading as zeroes"
Previous Message Raymond Brinzer 2018-12-05 13:32:55 Re: simple division