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 1h3BAE-0007z0-7O for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Mar 2019 02:59:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h3BAC-0005PV-Vg for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Mar 2019 02:59:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h3BAC-0005ON-OA for pgsql-hackers@lists.postgresql.org; Mon, 11 Mar 2019 02:59:40 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h3BAA-00078y-6k for pgsql-hackers@postgresql.org; Mon, 11 Mar 2019 02:59:40 +0000 Received: by mail-wr1-x441.google.com with SMTP id w2so3335926wrt.11 for ; Sun, 10 Mar 2019 19:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=/vlT7xJ4dNc+b0kS+Hb3MB+4ES2M2AC23Ectp0HPyvM=; b=H02oq9nqY1kueyPp3RFTNPOsRGUyWyiYemsSMYU72TrqI9fqCj1f0JV3bnof4a0Kug vBHg1DEytjAUwFXaTbfz/krUKvHe356qTJsXTHvt35fciamsDDBNcsVLBjfK6wbQVQd/ eIzDLWs4GTM4Groi0gijXaw/1Zgel/WoOjYJbyYBoFVxVhq3xd4PUhZGw1nywPVVcyz1 +FoXkjLhVHXV7syi8Eao4qO298PZP5gya1b1BIEb+uAgBVxEmcKLJqoiNSqX389a0/3D CRiju+EWDWlpt0QKeY9c8uXk+uDlnlIPvIQwehMC9dE3AHNclSg8m17ZNWjNGb/H6BuW XpHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/vlT7xJ4dNc+b0kS+Hb3MB+4ES2M2AC23Ectp0HPyvM=; b=do8XmZWANwCP6emeLo1viMvljk4lsHHmxf/+wc85LFPhk8cnulixFur/ewOiXWZAXM oNVGYUFoT6Q1uvC+2jeYnkHuU+X42kc16bt3MssvTvCBRAT6DIKm3CIBQ6R7WEltUcFk blQhLwgzE5EtJdPzJTHJJarr1JZ2ApEwLSNLn+Yyu71JPkEulxRG/SX9mY35tIcZvI6O vcvzioFOJ/j9cJ/Gxx6HpXv6u+38ZYWleBljo3k/7M0jxaxzuqWjAqIexaE6wZY+IE5z onPNA0pJKyQDTsz3iinZxxf/Rj46UaNzRnKgQgy37o5oHvXcb5lJq75sGKYEpKkVFjdZ EXjA== X-Gm-Message-State: APjAAAXTXTmMZhDMzlP3nIp7HvOHb9MNQm5CNT0TapFCM/lnL5V7y4BF g4x4EgpOiAJBZdvkX+L1cnSXRfM1wTAxc7VEOB7GrgPzXZa5xfXoYKt8aBl9j5Id3wN+lE+SWuV TF4pDFwYtL0pOGqme9MAzHHZXRaJwVYtGixbBaqdCg8zgFiQ5JRZWlcR/f4B+n1XqwMm6of9YFq zqdn8BiYpHFpgCwg== X-Google-Smtp-Source: APXvYqyteBpAsBBE3XvzmgKxIKLrhPOGomaV+VCavl0UqF+Kzd4loqNOpPW9m4sAAV/kKKwDrbIwOQ== X-Received: by 2002:adf:a4c9:: with SMTP id h9mr18049397wrb.254.1552273176194; Sun, 10 Mar 2019 19:59:36 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-253-144.net.upcbroadband.cz. [86.49.253.144]) by smtp.gmail.com with ESMTPSA id x17sm17503182wrd.95.2019.03.10.19.59.34 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Sun, 10 Mar 2019 19:59:35 -0700 (PDT) Subject: Re: [HACKERS] PATCH: multivariate histograms and MCV lists To: David Rowley Cc: Dean Rasheed , Alvaro Herrera , Michael Paquier , Andres Freund , Thomas Munro , Bruce Momjian , Mark Dilger , Pg Hackers References: <20190206012140.GA3626@alvherre.pgsql> <53386926-08a6-76f7-6a8f-f36e4ffb1b9d@2ndquadrant.com> <60a3741a-dcd5-4a30-90a2-c427b94524fc@2ndquadrant.com> <5c865c03-9963-c62a-ef0c-c42f3c0e855f@2ndquadrant.com> From: Tomas Vondra Message-ID: Date: Mon, 11 Mar 2019 03:59:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/10/19 11:27 PM, David Rowley wrote: > On Mon, 11 Mar 2019 at 06:36, Tomas Vondra wrote: >> >> On 3/9/19 7:33 PM, Dean Rasheed wrote: >>> I wonder if it's possible to write smaller, more targeted tests. >>> Currently "stats_ext" is by far the slowest test in its group, and I'm >>> not sure that some of those tests add much. It ought to be possible to >>> write a function that calls EXPLAIN and returns a query's row >>> estimate, and then you could write tests to confirm the effect of the >>> new stats by verifying the row estimates change as expected. >> >> Sure, if we can write more targeted tests, that would be good. But it's >> not quite clear to me how wrapping EXPLAIN in a function makes those >> tests any faster? > > I've not looked at the tests in question, but if they're executing an > inferior plan is used when no extended stats exists, then maybe that's > why they're slow. > I don't think the tests are executing any queries - the tests merely generate execution plans, without executing them. > I think Dean might mean to create a function similar to > explain_parallel_append() in partition_prune.sql then write tests that > check the row estimate with EXPLAIN (COSTS ON) but strip out the other > costing stuff instead of validating that the poor plan was chosen. > I'm not opposed to doing that, of course. I'm just not sure it's a way to make the tests faster. Will investigate. >> On 3/10/19 2:09 PM, Dean Rasheed wrote: >>> 12). bms_member_index() should surely be in bitmapset.c. It could be >>> more efficient by just traversing the bitmap words and making use of >>> bmw_popcount(). Also, its second argument should be of type 'int' for >>> consistency with other bms_* functions. >> >> Yes, moving to bitmapset.c definitely makes sense. I don't see how it >> could use bms_popcount() though. > > I think it could be done by first checking if the parameter is a > member of the set, and then if so, count all the bits that come on and > before that member. You can use bmw_popcount() for whole words before > the specific member's word then just bitwise-and a bit mask of a > bitmapword that has all bits set for all bits on and before your > parameter's BITNUM(), and add the bmw_popcount of the final word > bitwise-anding the mask. bms_add_range() has some masking code you > could copy. > Ah, right - that would work. cheers -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services