pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Clarity in partial index example.
4+ messages / 3 participants
[nested] [flat]

* Clarity in partial index example.
@ 2019-04-03 20:20  PG Doc comments form <noreply@postgresql.org>
  0 siblings, 1 reply; 4+ messages in thread

From: PG Doc comments form @ 2019-04-03 20:20 UTC (permalink / raw)
  To: pgsql-docs@lists.postgresql.org; +Cc: droptablestar@gmail.com

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/11/indexes-partial.html
Description:

The example illustrating when a partial index can and cannot be used is a
little misleading. The query which can use the partial index is:
SELECT *
FROM access_log
WHERE url = '/index.html' AND client_ip = inet '212.78.10.32';

and the query which can't use the partial index is:
SELECT *
FROM access_log
WHERE client_ip = inet '192.168.100.23';

Maybe I am misunderstanding the concept here but url = '/index.html' doesn't
have any effect on this? If that's the case I would suggest either removing
it from the first query or adding it to the second query.


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Clarity in partial index example.
@ 2019-04-03 22:00  Jonathan S. Katz <jkatz@postgresql.org>
  parent: PG Doc comments form <noreply@postgresql.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Jonathan S. Katz @ 2019-04-03 22:00 UTC (permalink / raw)
  To: droptablestar@gmail.com, pgsql-docs@lists.postgresql.org, PG Doc comments form <noreply@postgresql.org>

On 4/3/19 4:20 PM, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
> 
> Page: https://www.postgresql.org/docs/11/indexes-partial.html
> Description:
> 
> The example illustrating when a partial index can and cannot be used is a
> little misleading. The query which can use the partial index is:
> SELECT *
> FROM access_log
> WHERE url = '/index.html' AND client_ip = inet '212.78.10.32';
> 
> and the query which can't use the partial index is:
> SELECT *
> FROM access_log
> WHERE client_ip = inet '192.168.100.23';
> 
> Maybe I am misunderstanding the concept here but url = '/index.html' doesn't
> have any effect on this? If that's the case I would suggest either removing
> it from the first query or adding it to the second query.

You're correct, the url = '/index.html' does not affect if the partial
index is used in the example.

Based on how the example is set up, I'd propose using the "url"
parameter in both examples. I've attached a patch that does this, with
some additional wording around the examples.

Thanks,

Jonathan
From 97198351a066f43823573f7280111d78ee8895e7 Mon Sep 17 00:00:00 2001
From: "Jonathan S. Katz" <jonathan.katz@excoventures.com>
Date: Wed, 3 Apr 2019 17:58:17 -0400
Subject: [PATCH] Use consistent examples of queries demonstrating when a
 partial index is used.

---
 doc/src/sgml/indices.sgml | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/doc/src/sgml/indices.sgml b/doc/src/sgml/indices.sgml
index 3493f482b8..9a3f6d9b9e 100644
--- a/doc/src/sgml/indices.sgml
+++ b/doc/src/sgml/indices.sgml
@@ -814,11 +814,13 @@ SELECT *
 FROM access_log
 WHERE url = '/index.html' AND client_ip = inet '212.78.10.32';
 </programlisting>
-    A query that cannot use this index is:
+    as the above IP address falls into the range that is covered by the partial
+    index. The following query cannot use the partial as it uses an IP address
+    that is outside the range of the partial index:
 <programlisting>
 SELECT *
 FROM access_log
-WHERE client_ip = inet '192.168.100.23';
+WHERE url = '/index.html' AND client_ip = inet '192.168.100.23';
 </programlisting>
    </para>
 
-- 
2.14.3 (Apple Git-98)



Attachments:

  [text/plain] 0001-Use-consistent-examples-of-queries-demonstrating-whe.patch (1.1K, ../../fbcb4420-881c-c1b3-4ef3-02ca38e29069@postgresql.org/2-0001-Use-consistent-examples-of-queries-demonstrating-whe.patch)
  download | inline diff:
From 97198351a066f43823573f7280111d78ee8895e7 Mon Sep 17 00:00:00 2001
From: "Jonathan S. Katz" <jonathan.katz@excoventures.com>
Date: Wed, 3 Apr 2019 17:58:17 -0400
Subject: [PATCH] Use consistent examples of queries demonstrating when a
 partial index is used.

---
 doc/src/sgml/indices.sgml | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/doc/src/sgml/indices.sgml b/doc/src/sgml/indices.sgml
index 3493f482b8..9a3f6d9b9e 100644
--- a/doc/src/sgml/indices.sgml
+++ b/doc/src/sgml/indices.sgml
@@ -814,11 +814,13 @@ SELECT *
 FROM access_log
 WHERE url = '/index.html' AND client_ip = inet '212.78.10.32';
 </programlisting>
-    A query that cannot use this index is:
+    as the above IP address falls into the range that is covered by the partial
+    index. The following query cannot use the partial as it uses an IP address
+    that is outside the range of the partial index:
 <programlisting>
 SELECT *
 FROM access_log
-WHERE client_ip = inet '192.168.100.23';
+WHERE url = '/index.html' AND client_ip = inet '192.168.100.23';
 </programlisting>
    </para>
 
-- 
2.14.3 (Apple Git-98)



  [application/pgp-signature] signature.asc (832B, ../../fbcb4420-881c-c1b3-4ef3-02ca38e29069@postgresql.org/3-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Clarity in partial index example.
@ 2019-04-03 22:30  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Jonathan S. Katz <jkatz@postgresql.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2019-04-03 22:30 UTC (permalink / raw)
  To: Jonathan S. Katz <jkatz@postgresql.org>; +Cc: droptablestar@gmail.com; pgsql-docs@lists.postgresql.org

"Jonathan S. Katz" <jkatz@postgresql.org> writes:
> On 4/3/19 4:20 PM, PG Doc comments form wrote:
>> Maybe I am misunderstanding the concept here but url = '/index.html' doesn't
>> have any effect on this? If that's the case I would suggest either removing
>> it from the first query or adding it to the second query.

> You're correct, the url = '/index.html' does not affect if the partial
> index is used in the example.

> Based on how the example is set up, I'd propose using the "url"
> parameter in both examples. I've attached a patch that does this, with
> some additional wording around the examples.

Yeah, this seems unnecessarily confusing.  I tweaked your extra wording
a bit --- I didn't like referring to the index as covering a range,
because it's really excluding a range not including one.

Pushed.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Clarity in partial index example.
@ 2019-04-03 22:31  Jonathan S. Katz <jkatz@postgresql.org>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Jonathan S. Katz @ 2019-04-03 22:31 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: droptablestar@gmail.com; pgsql-docs@lists.postgresql.org

On 4/3/19 6:30 PM, Tom Lane wrote:
> "Jonathan S. Katz" <jkatz@postgresql.org> writes:
>> On 4/3/19 4:20 PM, PG Doc comments form wrote:
>>> Maybe I am misunderstanding the concept here but url = '/index.html' doesn't
>>> have any effect on this? If that's the case I would suggest either removing
>>> it from the first query or adding it to the second query.
> 
>> You're correct, the url = '/index.html' does not affect if the partial
>> index is used in the example.
> 
>> Based on how the example is set up, I'd propose using the "url"
>> parameter in both examples. I've attached a patch that does this, with
>> some additional wording around the examples.
> 
> Yeah, this seems unnecessarily confusing.  I tweaked your extra wording
> a bit --- I didn't like referring to the index as covering a range,
> because it's really excluding a range not including one.

You're right, that makes sense.

> Pushed.

Thanks!

Jonathan

Attachments:

  [application/pgp-signature] signature.asc (832B, ../../99a710f1-92e2-e5c7-52ae-a1d61cfacd30@postgresql.org/2-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2019-04-03 22:31 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-04-03 20:20 Clarity in partial index example. PG Doc comments form <noreply@postgresql.org>
2019-04-03 22:00 ` Jonathan S. Katz <jkatz@postgresql.org>
2019-04-03 22:30   ` Tom Lane <tgl@sss.pgh.pa.us>
2019-04-03 22:31     ` Jonathan S. Katz <jkatz@postgresql.org>

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