pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Julien Rouhaud <rjuju123@gmail.com>
Cc: Dominique Devienne <ddevienne@gmail.com>
Cc: Matthias Apitz <guru@unixarea.de>
Cc: Josef Šimánek <josef.simanek@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: SELECT with LIKE clause makes full table scan
Date: Wed, 26 Jan 2022 10:03:48 -0500
Message-ID: <2438893.1643209428@sss.pgh.pa.us> (raw)
In-Reply-To: <20220126135139.uik5gbuzyxybxq4x@jrouhaud>
References: <YfEoqiHQikgT82PB@c720-r368166>
	<CAFp7QwrVFvMr9VOEsEQRBLhAcg9vG1AQwrg8S+mTmJ_f4Dp3sQ@mail.gmail.com>
	<YfEy7Y4gpoMbKlkB@pureos>
	<20220126121306.k6ilsxl7vy2ppmjn@jrouhaud>
	<CAFCRh--nsj2afcFP0iFU6_n9Hb4bSBmGu+YktkkZ8GwDXf1rYQ@mail.gmail.com>
	<20220126135139.uik5gbuzyxybxq4x@jrouhaud>

Julien Rouhaud <rjuju123@gmail.com> writes:
> On Wed, Jan 26, 2022 at 02:34:21PM +0100, Dominique Devienne wrote:
>> On Wed, Jan 26, 2022 at 1:13 PM Julien Rouhaud <rjuju123@gmail.com> wrote:
>>> That index can't be used with a LIKE that has a trailing wildcard.

>> So what makes you say that? --DD

> This part of the documentation you mentioned:

>> However, if your database does not use the C locale you will need to create
>> the index with a special operator class to support indexing of
>> pattern-matching queries; see Section 11.10 below.

Note that declaring the index with C collation should also work,
and might be preferable to using the pattern_ops opclass.
C collation has at least some chance of being used explicitly
in queries, whereas a pattern_ops index is basically never going
to match anything but LIKE/regex searches.

			regards, tom lane





view thread (12+ messages)  latest in thread

Message-ID: <2438893.1643209428@sss.pgh.pa.us>
Permalink:  ../2438893.1643209428@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2438893.1643209428@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, rjuju123@gmail.com, ddevienne@gmail.com, guru@unixarea.de, josef.simanek@gmail.com
  Subject: Re: SELECT with LIKE clause makes full table scan
  In-Reply-To: <2438893.1643209428@sss.pgh.pa.us>
  References: <YfEoqiHQikgT82PB@c720-r368166> <CAFp7QwrVFvMr9VOEsEQRBLhAcg9vG1AQwrg8S+mTmJ_f4Dp3sQ@mail.gmail.com> <YfEy7Y4gpoMbKlkB@pureos> <20220126121306.k6ilsxl7vy2ppmjn@jrouhaud> <CAFCRh--nsj2afcFP0iFU6_n9Hb4bSBmGu+YktkkZ8GwDXf1rYQ@mail.gmail.com> <20220126135139.uik5gbuzyxybxq4x@jrouhaud> <2438893.1643209428@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