From: Tom Lane <tgl@sss.pgh.pa.us>
To: David E. Wheeler <david@justatheory.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: JSON Path and GIN Questions
Date: Sun, 17 Sep 2023 12:20:50 -0400
Message-ID: <4097442.1694967650@sss.pgh.pa.us> (raw)
In-Reply-To: <EE76F3CF-5C80-49E1-A472-315D54EE5111@justatheory.com>
References: <15DD78A5-B5C4-4332-ACFE-55723259C07F@justatheory.com>
<133696180.303713.1694566807910@office.mailbox.org>
<640942d7-c996-0562-62c9-d69a4c1f9b1e@xs4all.nl>
<C4BBA1CB-9EA1-4124-8CAD-8DDD646C453F@justatheory.com>
<aab40650-d292-3ece-e398-af2da8888e08@xs4all.nl>
<3063408.1694666518@sss.pgh.pa.us>
<D791AD43-8DE9-4358-A77C-5BC5D82AFA73@justatheory.com>
<3802532.1694812485@sss.pgh.pa.us>
<8504C88E-A036-47F4-8FAE-9BA95F55CB03@justatheory.com>
<3826235.1694824574@sss.pgh.pa.us>
<EE76F3CF-5C80-49E1-A472-315D54EE5111@justatheory.com>
"David E. Wheeler" <david@justatheory.com> writes:
> On Sep 15, 2023, at 20:36, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I think that that indicates that you're putting the info in the
>> wrong place. Perhaps the right answer is to insert something
>> more explicit in section 11.2, which is the first place where
>> we really spend any effort discussing what can be indexed.
> Fair enough. How ’bout this?
After thinking about it for awhile, I think we need some more
discursive explanation of what's allowed, perhaps along the lines
of the attached. (I still can't shake the feeling that this is
duplicative; but I can't find anything comparable until you get
into the weeds in Section V.)
I put the new text at the end of section 11.1, but perhaps it
belongs a little further up in that section; it seems more
important than some of the preceding paras.
regards, tom lane
Attachments:v1-document-indexable-clauses-better.patch (text/x-diff, 2.2K) downloaddiff --git a/doc/src/sgml/indices.sgml b/doc/src/sgml/indices.sgmlindex 55122129d5..1a0b003fb0 100644--- a/doc/src/sgml/indices.sgml+++ b/doc/src/sgml/indices.sgml@@ -109,6 +109,39 @@ CREATE INDEX test1_id_index ON test1 (id);
Therefore indexes that are seldom or never used in queries
should be removed.
</para>
++ <para>+ In general, <productname>PostgreSQL</productname> indexes can be used+ to optimize queries that contain one or more <literal>WHERE</literal>+ or <literal>JOIN</literal> clauses of the form++<synopsis>+<replaceable>indexed-column</replaceable> <replaceable>indexable-operator</replaceable> <replaceable>comparison-value</replaceable>+</synopsis>++ Here, the <replaceable>indexed-column</replaceable> is whatever+ column or expression the index has been defined on.+ The <replaceable>indexable-operator</replaceable> is an operator that+ is a member of the index's <firstterm>operator class</firstterm> for+ the indexed column. (More details about that appear below.)+ And the <replaceable>comparison-value</replaceable> can be any+ expression that is not volatile and does not reference the index's+ table.+ </para>++ <para>+ In some cases the query planner can extract an indexable clause of+ this form from another SQL construct. A simple example is that if+ the original clause was++<synopsis>+<replaceable>comparison-value</replaceable> <replaceable>operator</replaceable> <replaceable>indexed-column</replaceable>+</synopsis>++ then it can be flipped around into indexable form if the+ original <replaceable>operator</replaceable> has a commutator+ operator that is a member of the index's operator class.+ </para>
</sect1>
@@ -120,7 +153,7 @@ CREATE INDEX test1_id_index ON test1 (id);
B-tree, Hash, GiST, SP-GiST, GIN, BRIN, and the extension <link
linkend="bloom">bloom</link>.
Each index type uses a different
- algorithm that is best suited to different types of queries.+ algorithm that is best suited to different types of indexable clauses.
By default, the <link linkend="sql-createindex"><command>CREATE
INDEX</command></link> command creates
B-tree indexes, which fit the most common situations.
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-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, david@justatheory.com, pgsql-hackers@lists.postgresql.org
Subject: Re: JSON Path and GIN Questions
In-Reply-To: <4097442.1694967650@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