Re: Is my text_pattern_ops index working for a LIKE prefix search with column reference?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Seamus Abshere <seamus(at)abshere(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Is my text_pattern_ops index working for a LIKE prefix search with column reference?
Date: 2018-08-24 02:13:30
Message-ID: 26280.1535076810@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Achilleas Mantzios 2018-08-24 06:27:37 Re: Upgrade/Downgrade
Previous Message Raghavendra Rao J S V 2018-08-24 02:03:51 Which are the settings need to be modified inorder to implement only connection pool mechanisam in pgpool