Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0sUX-0000iS-KJ for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Mar 2018 17:34:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f0sUW-0008Iq-Fk for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Mar 2018 17:34:36 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0sUW-0008IY-8U for pgsql-hackers@lists.postgresql.org; Tue, 27 Mar 2018 17:34:36 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f0sUS-0002He-57 for pgsql-hackers@postgresql.org; Tue, 27 Mar 2018 17:34:35 +0000 Received: by mail-wr0-x244.google.com with SMTP id z73so23232864wrb.0 for ; Tue, 27 Mar 2018 10:34:31 -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=Ryx1ydRia6/EBJk2qw67JXAehzwnaK3YN6C2spt2B9E=; b=CZrcTtVObpL44ctYqv2giK8F69yEUBQZXksu9mMmdBgVUWUn1YBei7P8w3mmIUCqF1 XPkl7llUVqIxcv5te8xh6Qs2Qq3yvN9PlONXr+RWmqbEB3iyNXETfWXQVGKB4Yu7AKyN c3odkReVUVgmBmYukjvJ8e6Xmg8ViuFC+v1k9wUt+mLk8Cn3hsoEHNXtQn+cNWSt3gdl zE/fWoZFWHlLv8C9fPb8sQydJ2tnJ+or+kVadJMKmo2E6rX9z6myYKe8WYT8O+KBPoqd QhEdOdcJCcu6PNgMH3YJDytihP/SZZa/fG1gAzx6Eq07CaNdDvhN8RGuB0Bmmrffm2Q+ KkJA== 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=Ryx1ydRia6/EBJk2qw67JXAehzwnaK3YN6C2spt2B9E=; b=eEOdx+xl1g0sxDZ1akdgRgFg2Gysb2JPJr/Yb45FdCtYrBb0QB0XtHkQXtkVhKa0Mb 6COrUqLeWRr+Dwq2zo2lwwCu5PWif3yxL5Q9OR7VEjA47OqoB7P6M35tHI2aOHYkGV7U QsnbmMM2PbTts7rAIPbMLvyDsN1AIYb7ykt4isXEIVvy+PCwH1iW6UJot14Zw9PHy1ub jeUtXr9soX87kbhntJDyHUfEo/amJMlHe3/r6SS2j/fW03pkp+Ahia7ldrsL85lCHRRB uNcPX0tDpd3CKEHTL1FzLAcbd5Rie+cxzuBTixOEUbbcEofMUI1kbT9s9VY/P3jm1sBx mFbw== X-Gm-Message-State: AElRT7Exeb9b+MjRVJ9vz6fCTKNNioKHtFh6e/cNR4NFV3To7niGryDo kbPv1hdpfGk70u1DBaHtG0C8/ZaeOoWQu3jntsEAbYbDu0WdaKyGKWRVJCeFcw44yRmkKlZ36vD XAjBi+WvMZCXlbo+M/NfdgFVZt5pZvKPFdkqeG2Eybdt6oX3N9FZG/vNyGV6RFyhJxd3OIZgaMh AC8AlsJM4X X-Google-Smtp-Source: AIpwx4+7JHeBqAOGpmnqe1ukvalwoOGgnGpXwPG+imQYWFZPkMWll4ttVGifq8Oje4KhjRDXLedXwQ== X-Received: by 10.223.176.171 with SMTP id i40mr219051wra.246.1522172070870; Tue, 27 Mar 2018 10:34:30 -0700 (PDT) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id t196sm2330420wme.35.2018.03.27.10.34.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 10:34:29 -0700 (PDT) Subject: Re: [HACKERS] PATCH: multivariate histograms and MCV lists To: Dean Rasheed Cc: Alvaro Herrera , Andres Freund , Thomas Munro , Mark Dilger , Adrien Nayrat , Pg Hackers References: <20180310171906.gd6vyz6hnou2n3h7@alvherre.pgsql> <850c3b6b-2641-496c-4efc-500c720f7260@2ndquadrant.com> <66ba9c45-3b07-e5b6-fd11-15e75f6ee8e1@2ndquadrant.com> <49348328-1a02-7e45-e50f-e1d4d0243c5c@2ndquadrant.com> From: Tomas Vondra Message-ID: <1aaa338a-fa70-1b92-988e-498eb996ce57@2ndquadrant.com> Date: Tue, 27 Mar 2018 19:34:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 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 03/27/2018 07:03 PM, Dean Rasheed wrote: > On 27 March 2018 at 14:58, Dean Rasheed wrote: >> On 27 March 2018 at 01:36, Tomas Vondra wrote: >>> 4) handling of NOT clauses in MCV lists (and in histograms) >>> >>> The query you posted does not fail anymore... >>> >> Ah, it turns out the previous query wasn't actually failing for the >> reason I thought it was -- it was failing because it had a >> ScalarArrayOpExpr that was being passed to >> mcv_clauselist_selectivity() because of the wrong list being passed to >> it. I could see from the code that a NOT clause would have tripped it >> up, but most NOT clauses actually get rewritten by negate_clause() so >> they end up not being NOT clauses. >> > > Thinking about that some, I think that the only NOT clauses this needs > to actually worry about are NOTs of boolean Vars. Anything else that > this code supports will have been transformed into something other > than a NOT before reaching this point. Thus it might be much simpler > to handle that as a special case in statext_is_compatible_clause() and > mcv_update_match_bitmap(), rather than trying to support general NOT > clauses, and going through a recursive call to > mcv_update_match_bitmap(), and then having to merge bitmaps. NOT of a > boolean Var could then be treated just like var=false, setting the > appropriate attribute match entry if it's found in the MCV list. This > would allow clauses like (a=1 and NOT b) to be supported, which I > don't think currently works, because fullmatch won't get set. > Yes, I came to the same conclusion ;-) I'll send an updated patch later today. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services