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 1kXqbq-0003gX-Tn for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Oct 2020 18:55:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kXqbp-00042f-I9 for pgsql-hackers@arkaria.postgresql.org; Wed, 28 Oct 2020 18:55:45 +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 1kXqbp-00042Y-BR for pgsql-hackers@lists.postgresql.org; Wed, 28 Oct 2020 18:55:45 +0000 Received: from mail-ej1-x644.google.com ([2a00:1450:4864:20::644]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kXqbm-0004SP-ON for pgsql-hackers@lists.postgresql.org; Wed, 28 Oct 2020 18:55:44 +0000 Received: by mail-ej1-x644.google.com with SMTP id dt13so309825ejb.12 for ; Wed, 28 Oct 2020 11:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-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; bh=zK0EFP9G1ebuXvi8UawwyBUO8wVfWU3YsiairizSsss=; b=jr457/z9PBNryIsMWS0x0zVjWAq2VGRgHVmLj83zQS/uQnGIQFkFzt0AcPQO8/nMV7 l7qDeye8v8Z3nGQFawvqxJauOJMxUkKNAr9axY+fjdhOxp5fgTqkPXpkR0QSzAPY8ce5 DV2/41LJ9HvJOioDRRASGIbAiZlxHy/QLhLhadxGWY0dA9JZWb3EVyIACij6FQ7rIhD8 GuTfPBQ8bKNpdMqSpJmkg7v1MjA27xY3jWgx+xgezeEyHE4Klixb8BXZH2ciNSuHsK0V lPMjFdbp41BO/0YmKY1EGDGpjCY1LO7GXgNdNHOB0FifYywqUjAV42RlmwrnlEFASmEd bTyg== 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; bh=zK0EFP9G1ebuXvi8UawwyBUO8wVfWU3YsiairizSsss=; b=QTZGUa5GZmvS39+Lz1HmBUtiOEBTOgHczV/9UOdUfSSy1YgmZLq7Z82wgPL+e0sQ74 YaVbndRLcg8OllHOQmzWyActrmHIVha8eG4ge/nVJmYdn2F4O16SLEFI35hel9mqFwrl zOCavvgm8cJz57tHNqhtp2+Z01doEOn8KYyO/EhhbR3yMtGOD+M/JqH11MuIoki3fX6s OYQa95HM1T6AzMYi38WftSS/UxO3SeZ9nDpFVbWHEGy0GlAuqZsjZ+A3trdxOv8G5pik g7+vVM4VYseO63mawJQMdKA4mX9N8H8i+gCvCekknnatUdkU/aZMouW1YvF8OdDMaY8F gJhA== X-Gm-Message-State: AOAM533o8FPHpXg2W1Wct3l+bgOT3QwWoMq3Ca/Nr6e92pSDyoGnXYh/ FoQWD8bdKIJX7slPj4VkJDxl+A== X-Google-Smtp-Source: ABdhPJwtIoGmbP5RrowVc3EcsjmPun+YPwIbY4Im5SKGD3XYK6FKeSqqXUbUhc2Q1kRN+WtgY4BA4g== X-Received: by 2002:a17:906:b841:: with SMTP id ga1mr490487ejb.29.1603911341981; Wed, 28 Oct 2020 11:55:41 -0700 (PDT) Received: from localhost (ip-86-49-245-76.net.upcbroadband.cz. [86.49.245.76]) by smtp.gmail.com with ESMTPSA id 64sm290348eda.63.2020.10.28.11.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 11:55:41 -0700 (PDT) Date: Wed, 28 Oct 2020 19:55:38 +0100 From: Tomas Vondra To: "David G. Johnston" Cc: =?utf-8?B?RmFicsOtemlv?= Mello , PostgreSQL Hackers Subject: Re: Add important info about ANALYZE after create Functional Index Message-ID: <20201028185538.fzux2lhim472h46o@development> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Oct 26, 2020 at 03:46:10PM -0700, David G. Johnston wrote: >On Mon, Oct 26, 2020 at 3:08 PM Fabrízio de Royes Mello < >fabriziomello@gmail.com> wrote: > >> Hi all, >> >> As you all already know Postgres supports functions in index expressions >> (marked as immutable ofc) and for this special index the ANALYZE command >> creates some statistics (new pg_statistic entry) about it. >> >> The problem is just after creating a new index or rebuilding concurrently >> (using the new REINDEX .. CONCURRENTLY or the old manner creating new one >> and then swapping) we need to run ANALYZE to update statistics but we don't >> mention it in any part of our documentation. >> >> Last weekend Gitlab went down because the lack of an ANALYZE after >> rebuilding concurrently a functional index and they followed the >> recommendation we have into our documentation [1] about how to rebuild it >> concurrently, but we don't warn users about the ANALYZE after. >> >> 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) >> >> Thoughts? >> >> [1] >> https://gitlab.com/gitlab-com/gl-infra/production/-/issues/2885#note_436310499 >> > >It would seem preferable to call the lack of auto-analyzing after these >operations a bug and back-patch a fix that injects an analyze side-effect >just before their completion. It doesn't have to be smart either, >analyzing things even if the created (or newly validated) index doesn't >have statistics of its own isn't a problem in my book. > I agree the lack of stats may be quite annoying and cause issues, but my guess is the chances of backpatching such change are about 0.000001%. We have a usable 'workaround' for this - manual analyze. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services