Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8uSA-00081N-Pw for pgsql-docs@arkaria.postgresql.org; Thu, 29 Jul 2021 01:03:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m8uS8-0004rU-Mz for pgsql-docs@arkaria.postgresql.org; Thu, 29 Jul 2021 01:03:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8uS8-0004rL-Gx for pgsql-docs@lists.postgresql.org; Thu, 29 Jul 2021 01:03:12 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8uS6-0003ad-E4 for pgsql-docs@postgresql.org; Thu, 29 Jul 2021 01:03:11 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1m8uS4-0004fH-AW; Wed, 28 Jul 2021 21:03:08 -0400 Date: Wed, 28 Jul 2021 21:03:08 -0400 From: Bruce Momjian To: Laurenz Albe Cc: Nikolay Samokhvalov , PostgreSQL-documentation Subject: Re: Indexes on Expressions - a note to remind users to run ANALYZE after creation Message-ID: <20210729010308.GB9600@momjian.us> References: <77bbd451633a2852181fc6259baf9796361ce2a1.camel@cybertec.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <77bbd451633a2852181fc6259baf9796361ce2a1.camel@cybertec.at> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jul 19, 2021 at 12:59:10PM +0200, Laurenz Albe wrote: > On Fri, 2021-07-16 at 22:00 -0700, Nikolay Samokhvalov wrote: > > diff --git a/doc/src/sgml/indices.sgml b/doc/src/sgml/indices.sgml > > index 671299ff059d972ff95bdb1d67ed4c89bf5040b2..c7eaf9a608e995ef9957b4e0f677b36a8303be55 100644 > > --- a/doc/src/sgml/indices.sgml > > +++ b/doc/src/sgml/indices.sgml > > @@ -741,6 +741,15 @@ CREATE INDEX people_names ON people ((first_name || ' ' || last_name)); > > query. Thus, indexes on expressions are useful when retrieval speed > > is more important than insertion and update speed. > > > > + > > + > > + Note > > + > > + Once an index on an expression is successfully created, it is important to > > + run ANALYZE on the corresponding table to gather > > + statistics for the expression. > > + > > + > > > > I agree in principle. It should be "has been created" rather than "is created", > and I would say something less drastic like "usually a good idea" rather than > "important". Uh, CREATE INDEX already has this mentioend: The system regularly collects statistics on all of a table's columns. Newly-created non-expression indexes can immediately use these statistics to determine an index's usefulness. For new expression indexes, it is necessary to run ANALYZE or wait for the autovacuum daemon to analyze the table to generate statistics for these indexes. Do we need it here too? -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.