From: Tom Lane <tgl@sss.pgh.pa.us>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Seamus Abshere <seamus@abshere.net>
Cc: pgsql-general@postgresql.org
Subject: Re: Is my text_pattern_ops index working for a LIKE prefix search with column reference?
Date: Thu, 23 Aug 2018 22:13:30 -0400
Message-ID: <26280.1535076810@sss.pgh.pa.us> (raw)
In-Reply-To: <d599d4592b68dbac18beab4daf15358a4bfa9b64.camel@cybertec.at>
References: <1535036221.3796184.1483854296.64E1B683@webmail.messagingengine.com>
<d599d4592b68dbac18beab4daf15358a4bfa9b64.camel@cybertec.at>
Laurenz Albe <laurenz.albe@cybertec.at> writes:
> Seamus Abshere wrote:
>> I created an index with text_pattern_ops because I want fast prefix search [1] [2].
>> ...but I don't think it's working when I use a column reference || '%'...
> An index can only be used for expressions like
> <indexed expression> <operator from the opclass> <constant>
> and you have a column refrence on the right side.
"constant" is a bit too strong here, but it definitely can't be
"expression using another column from the same table". It has to
be an expression that will hold stable throughout a scan of the
table you wish to index.
regards, tom lane
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: tgl@sss.pgh.pa.us, laurenz.albe@cybertec.at, seamus@abshere.net
Subject: Re: Is my text_pattern_ops index working for a LIKE prefix search with column reference?
In-Reply-To: <26280.1535076810@sss.pgh.pa.us>
References: <1535036221.3796184.1483854296.64E1B683@webmail.messagingengine.com> <d599d4592b68dbac18beab4daf15358a4bfa9b64.camel@cybertec.at> <26280.1535076810@sss.pgh.pa.us>
* 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