Re: Clarity in partial index example.

"Jonathan S. Katz" <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.documentation
Message-ID <[email protected]>
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
0001-Use-consistent-examples-of-queries-demonstrating-whe.patch (text/plain, 1.1 KB)
From 97198351a066f43823573f7280111d78ee8895e7 Mon Sep 17 00:00:00 2001
From: "Jonathan S. Katz" <[email protected]>
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)
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEE+oS2la8r95ogZD/x8QSccp8cZScFAlylLPIACgkQ8QSccp8c
ZScjeQ//VS8qO07uhvtXMBK6b0ci2yIdfiVzGQ9cynplqw0cZPLJQLcq+DRRwF6m
sfPE47M7m2nIPLlElbfzmB7d1xdvZam7jlX07Ps5boAknuKg/h6VblZ7R0zPW+Tj
BWWekYIqMoAMjUuki9ET2wXLXrNlJhsnNveHmqnc2GLhDQgYvvp+RxOFopy3gPRk
387Y48D2Nc+ACOIoTrE8W6PKcQfgo6pgtllr9jn2ChxJHQcpIml0LoTAFSpJoL85
B25XAlcNK+OfJBgezZdFvEDnzy8tDV5Z4bK9cu1wlPb5s89fVluuYew61LTl5rDN
w+/wvoZY6ZRoFtabAYcLLm+YuKTNEJs+kGoT9Qi+8u63htu22L4DW+Rjxj/0Jpxg
VNDs08CqRkVrATBPe25bYERXA3tXV++W7toBewjpRAOoE1Tzu4/5EhxQf3UibD4w
/yRIZRcuTExEGDwj0x7xDwuOVIEBSbQm2XciF70NDXLLLvPRy/SPPHr+eOQgdrLO
BYJS8+ExK0Iu/ae6tBA5Fh0Exs1BJNgwwvHfhL008IER0bFrnKOeha4qsl+SrCPo
TunB+S1hOb2Z/336gthOIaxT1EkewV+x6N+f86w8udYfKKbRrKe8J7Lcl2zEM6xq
1THSbwKpG3kSmWEQ+e02NuMuyhHOtPkpdL8+LkqR0n+JlJ89FrQ=
=FlzI
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.