Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j5dlk-0007vy-K8 for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Feb 2020 23:01:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j5dlj-00083p-6D for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Feb 2020 23:01:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j5dli-00083d-Hx for pgsql-hackers@lists.postgresql.org; Sat, 22 Feb 2020 23:01:06 +0000 Received: from mail-yb1-xb41.google.com ([2607:f8b0:4864:20::b41]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j5dld-0007Z8-Q3 for pgsql-hackers@lists.postgresql.org; Sat, 22 Feb 2020 23:01:04 +0000 Received: by mail-yb1-xb41.google.com with SMTP id y18so3932ybj.8 for ; Sat, 22 Feb 2020 15:01:01 -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:in-reply-to:user-agent; bh=EIzFuRDqa2BnOW1nknOs2ksMFww3nt8i3dMlf+rjPxs=; b=lJy4Xw2SdTs2FY5rggjehQSPkzKHwFhkTAN7fG9mRn29XegERHwnOUBaete+6LAO0g +razG7B6JQLl3LCpK74jURbRiXURN0xnKvBwZWj/85wND6YCJPcCLNtD5QkfMyveRyxX pJHuafJrlur9ZhtuhpvqUTzTzGFdLnPLM5e+X8MxinwfRQRI4bU4k5qexii0mFDrwiWf 8YCooj0YJUrEoVvfEKeubiUPTnZKzclxvkN5IyjRjSOmaLl1AkhCg1C0qsAg+NZkYs4/ mrpCzG2ll4lN4iILYP9QtSao5uNSKOT/HW+0dSCc6bI1JelpO8TfEjF07leiAKNDojH6 1SDQ== 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=EIzFuRDqa2BnOW1nknOs2ksMFww3nt8i3dMlf+rjPxs=; b=Gltp5TrHYv+JqbWSKCsC87lsbv0jiYye8LgyyoFdPhaYEJAtY5L+x2oGbtE7kyamkW 2OVkJKzzTl6jdGoX2yOYOguRDqcqsPvDcmVw8O4O5L7L4xNVnZoXr1qP9qW8G+NaN+dz usE7WaC5KkG8+mlttN9Y+z6ghsA9upgjziQz0Rql29QrZAO09Etd4wDWr6A8xQQqu8o9 fdeoOQFYEpLHPsAbqxLjkTh4KRR6ygxOcjBODNiFCXjygkePQfopjqLxl49jHfoEbPCB 7mgbjoskmdzShw7z9T5I8XYQKZulHquK0i3KzHKMy6TalqgY4XEISPKFjbmItL42IVmN j6RA== X-Gm-Message-State: APjAAAW6Smth2l7eJBh5hfKq5+SAnJ2wR2edBjZ6V1GaJthIECCJ0K+I rOk6h7UgNhzosThGwBH1lfaqgA== X-Google-Smtp-Source: APXvYqwzgWQi/hs7KGTcZ1DJ7nm3H8YiC9mHA8GqSTneNFxU0dVKop1lqSxfcIchRjHPWNL14h96wA== X-Received: by 2002:a25:41d3:: with SMTP id o202mr22305784yba.161.1582412460937; Sat, 22 Feb 2020 15:01:00 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id p204sm3268643ywp.14.2020.02.22.15.00.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Feb 2020 15:01:00 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id 9F5E1800897; Sat, 22 Feb 2020 17:00:58 -0600 (CST) Date: Sat, 22 Feb 2020 17:00:58 -0600 From: Justin Pryzby To: Tomas Vondra Cc: Andres Freund , pgsql-hackers@lists.postgresql.org, Jeff Janes Subject: Re: explain HashAggregate to report bucket and memory stats Message-ID: <20200222230058.GT31889@telsasoft.com> References: <20200103161925.GM12066@telsasoft.com> <20200203145301.53mozz7gcdaklnjc@alap3.anarazel.de> <20200216000220.GF31889@telsasoft.com> <20200216175307.GJ31889@telsasoft.com> <20200219201037.GA21433@telsasoft.com> <20200222215335.bu4kky7el4nccls5@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200222215335.bu4kky7el4nccls5@development> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, Feb 22, 2020 at 10:53:35PM +0100, Tomas Vondra wrote: > I've started looking at this patch, because I've been long missing the Thanks for looking I have brief, initial comments before I revisit the patch. > 3) Almost all executor nodes that are modified to include this new > instrumentation struct also include TupleHashTable, and the data are > essentially about the hash table. So my question is why not to include > this into TupleHashTable - that would mean we don't need to modify any > executor nodes, and it'd probably simplify code in explain.c too because > we could simply pass the hashtable. I considered this. From 0004 commit message: | Also, if instrumentation were implemented in simplehash.h, I think every | insertion or deletion would need to check ->members and ->size (which isn't | necessary for Agg, but is necessary in the general case, and specifically for | tidbitmap, since it actually DELETEs hashtable entries). Or else simplehash | would need a new function like UpdateTupleHashStats, which the higher level nodes | would need to call after filling the hashtable or before deleting tuples, which | seems to defeat the purpose of implementing stats at a lower layer. > 4) The one exception to (3) is BitmapHeapScanState, which does include > TIDBitmap and not TupleHashTable. And then we have tbm_instrumentation > which "fakes" the data based on the pagetable. Maybe this is a sign that > TIDBitmap needs a slightly different struct? Hm, I'd say that it "collects" the data that's not immediately present, not fake it. But maybe I did it poorly. Also, maybe TIDBitmap shouldn't be included in the patch.. > Also, I'm not sure why we > actually need tbm_instrumentation()? It just copies the instrumentation > data from TIDBitmap into the node level, but why couldn't we just look > at the instrumentation data in TIDBitmap directly? See 0004 commit message: | TIDBitmap is a private structure, so add an accessor function to return its | instrumentation, and duplicate instrumentation struct in BitmapHeapState. Also, I don't know what anyone else thinks, but I think 0005 is a throwaway commit. It's implemented more nicely in execGrouping.c. > But it's definitely strange that we only print memory info in verbose mode - > IMHO it's much more useful info than the number of buckets etc. Because I wanted to be able to put "explain analyze" into regression tests (which can show: "Buckets: 4 (originally 2)"). But cannot get stable output for any plan which uses Sort, without hacks like explain_sq_limit and explain_parallel_sort_stats. Actually, I wish there were a way to control Sort nodes' Memory/Disk output, too. I'm sure most of regression tests were meant to be run as explain(analyze NO), but it'd be much better if analyze YES were reasonably easy in the general case that might include Sort. If someone seconds that, I will start a separate thread. -- Justin Pryzby