pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Nikander <rob.nikander@gmail.com>
To: Postgres General <pgsql-general@postgresql.org>
Subject: Re: querying both text and non-text properties
Date: Wed, 5 Dec 2018 09:01:57 -0500
Message-ID: <98C9D9E1-D404-47E2-A04A-B41EC2A025E3@gmail.com> (raw)
In-Reply-To: <917ede32e461b787966bf1825724edc0bd2787ca.camel@cybertec.at>
References: <BE65D660-2C05-47A3-8A0B-6D33DDE71826@gmail.com>
	<917ede32e461b787966bf1825724edc0bd2787ca.camel@cybertec.at>



> On Dec 4, 2018, at 4:59 PM, Laurenz Albe <laurenz.albe@cybertec.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



view thread (4+ messages)  latest in thread

Message-ID: <98C9D9E1-D404-47E2-A04A-B41EC2A025E3@gmail.com>
Permalink:  ../98C9D9E1-D404-47E2-A04A-B41EC2A025E3@gmail.com/
Also on:    postgresql.org/message-id/98C9D9E1-D404-47E2-A04A-B41EC2A025E3@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: rob.nikander@gmail.com
  Subject: Re: querying both text and non-text properties
  In-Reply-To: <98C9D9E1-D404-47E2-A04A-B41EC2A025E3@gmail.com>
  References: <BE65D660-2C05-47A3-8A0B-6D33DDE71826@gmail.com> <917ede32e461b787966bf1825724edc0bd2787ca.camel@cybertec.at> <98C9D9E1-D404-47E2-A04A-B41EC2A025E3@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox