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 1lQwl6-0005ta-8C for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Mar 2021 18:37:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lQwkY-0001iM-UE for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Mar 2021 18:36:30 +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 1lQwkY-0001iE-Kk for pgsql-hackers@lists.postgresql.org; Mon, 29 Mar 2021 18:36:30 +0000 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lQwkV-0003sP-Sh for pgsql-hackers@postgresql.org; Mon, 29 Mar 2021 18:36:29 +0000 Received: by mail-qk1-x72e.google.com with SMTP id o5so13436584qkb.0 for ; Mon, 29 Mar 2021 11:36:27 -0700 (PDT) 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:in-reply-to:user-agent; bh=Jy77NDQqjtvaIxWpiiy1yNTCHOk0vGUBMSTfaJ4Jbr0=; b=tB/M8yj4S8s5+D0IEbEt7QWWy8SY3rkOG4c94AJkEQLLFxXBSSZr5YfRqNqfF004fY BQ/25bljQxnhBuW6frCGMGM+vVgHhuBpoekdL76p7yDZlBwpJE7A20ZhOnQA0/C3+BvE yE5X9vQht9XDO4eAnepWt9UfdZ9KWS58vZjmsKPyUueGK7np7AE+xyDbWOFbsfmk3xkp m4/Q1C1CnlASZRumvjbMP3WsMm1ZRHKVSCfH6J2Zurq8uYpRvphu6qQObxnySVfZXRQH 4YSQqT4VBozX5VbMFlISj78DCigox+VuuV3cGYMUHcBetuKg6zfJWlalgATP8hSbDK+N SA6A== 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:in-reply-to:user-agent; bh=Jy77NDQqjtvaIxWpiiy1yNTCHOk0vGUBMSTfaJ4Jbr0=; b=aavvtQbz/a24L7DuVd7kNEIoCqbS3hSV4a+epGu8orMAc59/AYL/FCPBnHcLBzZ3dP VAJNvP2x6ivhDHPF8pW9HRhTTqemjKHK7FL58gIc6YqFVJxnGlzS4zMsWbJYdXF2SA6T vr9ksvCnhyCrynn3CnudsisXlWSkEEBh+MIqFcV59sAAmu/BMlh2IXaRcSoC8YHq1cxM ej4uKcNvFQfkPTbxFhnw4eV2bEhHHbzfUZ2nDsbTP/OjtlYR0SL14vt6GKDMm4dnwjRm 4KiFnmob3JnLvHT876xcHzDNHbl/l+aF0mUuL3dqiZ02TxwEr/ubHJiEtpLbvjaJkhZh G4hA== X-Gm-Message-State: AOAM533CZcuMV6oj75df/Wrm6ifj9dxtM2vVj+K91JZ6rh/JuIMwWa5Z Va82AWSX0szehCaXdG/CtRmLQQ== X-Google-Smtp-Source: ABdhPJzYoAgO0teEg/PhlMihFCoHGUh5KeW++7GuLAI0h3miltRZVk2kZeKTCXpw6oEKlRu594JO/w== X-Received: by 2002:a37:9ed0:: with SMTP id h199mr26817856qke.8.1617042986742; Mon, 29 Mar 2021 11:36:26 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id r13sm11192593qtw.37.2021.03.29.11.36.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Mar 2021 11:36:26 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 1849F801A4D; Mon, 29 Mar 2021 13:36:25 -0500 (CDT) Date: Mon, 29 Mar 2021 13:36:24 -0500 From: Justin Pryzby To: Tomas Vondra Cc: pgsql-hackers@postgresql.org Subject: Re: Merging statistics from children instead of re-sampling everything Message-ID: <20210329183624.GC4431@telsasoft.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks for taking a fresh look at this. As you've written it, this can apply to either/both partitioned or inheritence. I imagine when "MERGE" goes away, this should apply only to partitioned tables. (Actually, personally I would advocate to consider applying it to *both*, but I don't think that's been the tendency over the last 4 years. I wrote here about some arguably-gratuitous differences between inheritence and partitioning. https://www.postgresql.org/message-id/20180601221428.GU5164@telsasoft.com) > + if (*mcv_items > default_statistics_target) > + n = default_statistics_target; It should use any non-default stats target of the parent's column > + * ignore anything but valid leaf relatiins with data, but release sp: relatiins. > + elog(WARNING, "stats for %d %d not found", > + RelationGetRelid(rels[j]), vacattrstats[i]->attr->attnum); should be %u %d This code duplication is undesirable: > + /* Log the action if appropriate */ > + * Determine which columns to analyze