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 1kdJsr-0002IY-VG for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Nov 2020 21:11:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kdJsp-00006N-N9 for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Nov 2020 21:11:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdJsp-00006C-D5 for pgsql-hackers@lists.postgresql.org; Thu, 12 Nov 2020 21:11:55 +0000 Received: from mail-il1-x143.google.com ([2607:f8b0:4864:20::143]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kdJsh-0004xT-9H for pgsql-hackers@lists.postgresql.org; Thu, 12 Nov 2020 21:11:54 +0000 Received: by mail-il1-x143.google.com with SMTP id p10so6611505ile.3 for ; Thu, 12 Nov 2020 13:11:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=zi2fZDT2mIkgIfwhwXLYvAPHwNBOF55WGmDvhhtAdAk=; b=I3i7kr725ix4YMxGJw1AQ3g6QSEuRBcp5Ky8hpw46SfElBDMK15H3CtSxi0YN+Lh6b I7wVWubEB3zlYku0KA9QU5YBmn6fnqKEIxSkt3C8S0fk3BTAkIJgbOmnWyK30OUG4uNX WGQkx8vQSc4jJmCc/1v33U9As+EFluKRpNBQVA6q9wCjgShnuORRW4Wrx7nIq3rHS6jI zq9zfe9MwdiafIuRnPXagGHBBrQhyN/t44vYKZMUQBMiNKPxP9gjvzw2peduIQ6HXfE+ mcxCQCETZlcSCd2rKUYpaWYZwIKLr9DgM3SlkNvhFSrh3GEQaqBOTa5gwq8EdfoDmUW7 P5UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=zi2fZDT2mIkgIfwhwXLYvAPHwNBOF55WGmDvhhtAdAk=; b=obv4CL3CycD0I0TvZl8L4HoREpTpuS3uYgeA6XqsA4GuCyT4y4DFYhCQtw65RtyGzL 6CgGQvSepZUUdjmRpg590YKCl7kFRLAcC77KeUCu1evRpzz2GYC11qpL6UJU+u7TDtaJ l90TBnSbhVOhvh8TVxgWceOXpz+JM4Z7JMA8NReX8MsXk8GxPBEsuqWAvvitNawBCDCD W10JZkbwsEEOTtKD+rA6C4y+JPUg8DY/Di7fC2HTp9l9zEcw5t5Xj7evwMRxDF6OYljZ QT/afNgep5/PjkZpCQ8eMX18PMuJLBObYfcHlTMVpvzSUQ1O1cUN1WuxoVNJ4nimhtsJ j4iw== X-Gm-Message-State: AOAM531eSSeQhHR0Dk69g4Af0jjPmP+Lrq0hRDjEJAfaQ5TYi7Ig9Kjh 6C01CLyscG3NqhmATo6zVSkrug== X-Google-Smtp-Source: ABdhPJyNoxYWY+i+dG+npBBB6djguEFD+5n3Uo84SHgy2/tm6dNa4rkhmQ9z3972U1VZJ9t/RZaATQ== X-Received: by 2002:a05:6e02:e08:: with SMTP id a8mr1210247ilk.169.1605215505345; Thu, 12 Nov 2020 13:11:45 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id j85sm3690729ilg.82.2020.11.12.13.11.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Nov 2020 13:11:44 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 830A18005BB; Thu, 12 Nov 2020 15:11:43 -0600 (CST) Date: Thu, 12 Nov 2020 15:11:43 -0600 From: Justin Pryzby To: Bruce Momjian Cc: Nikolay Samokhvalov , fabriziomello@gmail.com, pgsql-hackers@lists.postgresql.org Subject: Re: Add important info about ANALYZE after create Functional Index Message-ID: <20201112211143.GL30691@telsasoft.com> References: <20201109232720.GA8930@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201109232720.GA8930@momjian.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Nov 09, 2020 at 06:27:20PM -0500, Bruce Momjian wrote: > On Tue, Oct 27, 2020 at 12:12:00AM -0700, Nikolay Samokhvalov wrote: > > On Mon, Oct 26, 2020 at 3:08 PM Fabrízio de Royes Mello wrote: > > > > Would be nice if add some information about it into our docs but not sure > > where. I'm thinking about: > > - doc/src/sgml/ref/create_index.sgml > > - doc/src/sgml/maintenance.sgml (routine-reindex) > > > > > > Attaching the patches for the docs, one for 11 and older, and another for 12+ > > (which have REINDEX CONCURRENTLY not suffering from lack of ANALYZE). > > > > I still think that automating is the right thing to do but of course, it's a > > much bigger topic that a quick fix dor the docs. > > I see REINDEX CONCURRENTLY was fixed in head, but the docs didn't get > updated to mention the need to run ANALYZE or wait for autovacuum before > expression indexes can be fully used by the optimizer. Instead of > putting this mention in the maintenance section, I thought the CREATE > INDEX page make more sense, since it is more of a usability issue, > rather than "why use expression indexes". Patch attached, which I plan > to apply to all supported branches. The commited patch actually says: --- a/doc/src/sgml/ref/create_index.sgml +++ b/doc/src/sgml/ref/create_index.sgml @@ -745,6 +745,16 @@ Indexes: sort high, in queries that depend on indexes to avoid sorting steps. + + The regularly system 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 about new expression indexes. + + I guess it should say "The system regularly ..." Also, the last sentence begins "For new expression indexes" and ends with "about new expression indexes", which I guess could instead say "about the expressions". > diff --git a/doc/src/sgml/ref/create_index.sgml b/doc/src/sgml/ref/create_index.sgml > new file mode 100644 > index 749db28..48c42db > *** a/doc/src/sgml/ref/create_index.sgml > --- b/doc/src/sgml/ref/create_index.sgml > *************** Indexes: > *** 746,751 **** > --- 746,761 ---- > > > > + The system 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 + linkend="sql-analyze">ANALYZE or wait for > + the autovacuum daemon to analyze > + the table to generate statistics about new expression indexes. > + > + > + > For most index methods, the speed of creating an index is > dependent on the setting of . > Larger values will reduce the time needed for index creation, so long -- Justin Pryzby System Administrator Telsasoft +1-952-707-8581