pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add a planner support function for starts_with().
Date: Wed, 17 Nov 2021 21:54:22 +0000
Message-ID: <E1mnSso-00014n-V3@gemulon.postgresql.org> (raw)

Add a planner support function for starts_with().

This fills in some gaps in planner support for starts_with() and
the equivalent ^@ operator:

* A condition such as "textcol ^@ constant" can now use a regular
btree index, not only an SP-GiST index, so long as the index's
collation is C.  (This works just like "textcol LIKE 'foo%'".)

* "starts_with(textcol, constant)" can be optimized the same as
"textcol ^@ constant".

* Fixed-prefix LIKE and regex patterns are now more like starts_with()
in another way: if you apply one to an SPGiST-indexed column, you'll
get an index condition using ^@ rather than two index conditions with
>= and <.

Per a complaint from Shay Rojansky.  Patch by me; thanks to
Nathan Bossart for review.

Discussion: https://postgr.es/m/232599.1633800229@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a148f8bc04b9980f019ea0d4b89311cf0bdc22b7

Modified Files
--------------
src/backend/utils/adt/like_support.c              | 65 ++++++++++++++++-------
src/include/catalog/catversion.h                  |  2 +-
src/include/catalog/pg_operator.dat               |  2 +-
src/include/catalog/pg_proc.dat                   |  8 ++-
src/test/regress/expected/create_index_spgist.out | 33 ++++++++++++
src/test/regress/sql/create_index_spgist.sql      |  8 +++
6 files changed, 95 insertions(+), 23 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1mnSso-00014n-V3@gemulon.postgresql.org>
Permalink:  ../E1mnSso-00014n-V3@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1mnSso-00014n-V3@gemulon.postgresql.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add a planner support function for starts_with().
  In-Reply-To: <E1mnSso-00014n-V3@gemulon.postgresql.org>

* 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