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 1iXnpb-00045L-Js for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Nov 2019 14:53:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iXnpa-0004w9-Be for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Nov 2019 14:53:14 +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 1iXnpa-0004w2-3f for pgsql-bugs@lists.postgresql.org; Thu, 21 Nov 2019 14:53:14 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iXnpX-00036E-Ab for pgsql-bugs@lists.postgresql.org; Thu, 21 Nov 2019 14:53:13 +0000 Received: by mail-wr1-x443.google.com with SMTP id t2so4806554wrr.1 for ; Thu, 21 Nov 2019 06:53:11 -0800 (PST) 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:in-reply-to; bh=NXmMBN5KAO7MMj7gBsq3hdD2K4zpz+t6UQUBSyOL3dk=; b=snRvaByTap6KkMk5FWRGvpG5yUHyNg7d+PghHDBLq3qtWh/VWSkEqIkb0wq2OrHHZV 0dOjgPOND4oUllQVTM6Id08UhdJ1Tn4CW3tIqpYqkkv0RQyS+Iyl4bC0/X12yu1BtTz+ /SAs1A/Fj6+kf9TFzUlGy6faI5kaQ4wzRN3NJCTtIAESLxQ3+ZKL9weqWQLzeaeGxJ7p ddLkOuLSOFRdqKIr1IX+r2vJ2+fu/tYRvpVvY7JSM0iamxK5JQ2l2MQJZpFJPAh0/aGT Yqwfs8mzgP25octs4aZYeNrqpW5pngxOZjTdjgh2lwBrqcRCA9JTkzdIKyerlubLEF6H SH3w== 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; bh=NXmMBN5KAO7MMj7gBsq3hdD2K4zpz+t6UQUBSyOL3dk=; b=SsBhtxHMh8MXwyxTdwmLsMB0dmfEwotj+dz0aV9aaw+3jmMk5ARQK/X/TIj8f9vchV /cgzT1aeLEJGbULmOGYDMVU0yj5OV/Zbhq6QErP8BthZBgUYwSgZ+UHHzRSiHIObbkfK /e2yJcZ4rDkCMtMkGUs710MzafPtx5Niq8cyflR+/vhG0uTqpX8kWkjQT3n87D0RWWzp DGxiHiFFEyvyn7ogBCLK5FG4d6QFBZiIoxn8EtLQS+g4alUDOQ3Yc1+jFmIAhxHHYwx1 BJizrx47xIfVCx84TsEd/KeHo+6YIevhg0SdQxglZE/szOs3XvG3p3hKCxmayrrORl7W ZuOw== X-Gm-Message-State: APjAAAXpcUWcmBeJYa1GBwQpSaI7tRKrYWYXqzZMJtHu+i0Cgj5Ny5+v YJGArbB51s1SC29FCQN8mquNPg== X-Google-Smtp-Source: APXvYqxj0b5W1MVEEBvGTi3YJUIb8F6fHURx9/0EtTONzy1vjRVjUCHvO8hC57Gg3hRtfZdNaJiVNg== X-Received: by 2002:adf:fd45:: with SMTP id h5mr6865861wrs.388.1574347990345; Thu, 21 Nov 2019 06:53:10 -0800 (PST) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id 76sm3324517wma.0.2019.11.21.06.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 06:53:09 -0800 (PST) Date: Thu, 21 Nov 2019 15:53:08 +0100 From: Tomas Vondra To: Dean Rasheed Cc: Daniel Gustafsson , Dmitry Dolgov <9erthalion6@gmail.com>, Manuel Rigger , PostgreSQL mailing lists Subject: Re: Failed assertion clauses != NIL Message-ID: <20191121145308.zzdcs5uozhtlmcos@development> References: <20191119133839.5qj5zia4pkd3zldt@localhost> <520C6E76-53A5-4EF2-A855-8054582221A5@yesql.se> <20191119150840.nmezhsf2tpip7osh@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Nov 21, 2019 at 12:29:39PM +0000, Dean Rasheed wrote: >On Tue, 19 Nov 2019 at 15:08, Tomas Vondra wrote: >> >> Yes, adding the condition to statext_mcv_clauselist_selectivity() would >> make this go away, and it's about the simplest solution. >> > >It's probably worth going a little further, and verifying that >stat_clauses references at least two attributes. We do that further up >for the original clause list, but it may not be true for the filtered >list. For example, given a WHERE clause like > > c0 > 0 AND c0 < 10 AND (c0 = 0 OR c1 = 1 OR c2 = 2) > >and stats on (c0, c1), stat_clauses would include the first 2 clauses, >but they only reference 1 column, so it would be preferable to not use >the multivariate stats in that case. > Yeah, good point. Not sure what to do about this: (c0 > 0 OR c2 < 10) AND (c0 = 0 OR c1 = 1 OR c2 = 2) In that case we match just the first OR clause, but it references two attributes. I guess we should ignore that too and handle that later just like the regular OR clauses. > >> Ideally, we'd be able to improve the statistics matching to recognize >> it has to match all three attributes to match the clause, which in this >> case would mean the OR clause is passed to clause_selectivity, and we do >> some magic with extended statistics there. >> >> I'll see how complex / backpatchable that would be. >> > >Yes, that seems like a worthwhile thing to do, but I think it goes >beyond what would normally be back-patched. It would really be a >feature enhancement rather than a bug fix. > True. I don't have a patch yet, but it's likely to be a bit more invasive than I'd like to backpatch. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services