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.92) (envelope-from ) id 1jDIw4-0005QH-16 for pgsql-hackers@arkaria.postgresql.org; Sun, 15 Mar 2020 02:23:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jDIw1-0005a7-PG for pgsql-hackers@arkaria.postgresql.org; Sun, 15 Mar 2020 02:23:25 +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 1jDIw1-0005Zz-Fy for pgsql-hackers@lists.postgresql.org; Sun, 15 Mar 2020 02:23:25 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jDIvu-0003FV-1p for pgsql-hackers@postgresql.org; Sun, 15 Mar 2020 02:23:24 +0000 Received: by mail-wr1-x443.google.com with SMTP id a25so16948469wrd.0 for ; Sat, 14 Mar 2020 19:23:17 -0700 (PDT) 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=GYEZBJWwvE6ARll6NEBZ/FyIak+NB44D2yl4nniwqaE=; b=Iu14ApoacTOTH9v/jyM9R2cJap3k0wmSJF0U5DsJO6cHVjotYhYA3l2cOZhO0s90G2 /nXUYK7MkA+NG2XJo5RbQhOsThuCToatSQA1fawMQVRenr/raU05LWB6PYwoECSIVTOh +LAb0Y0oNo9urhpsfgp+e/0vlWjmY0E71e4+fKeUHEboQD80Lvklg+vAnhxc6lVkXjWP aTKGIbpXiQ2nfErbF2JxGIlanagXbSo/IAct59nvy9n8MahaXoAYI9oWQnyKCiIWDw5t q2617mISHmij7asZJfjp4k0DYJz4XBiZbS7OSoZY3DBWEATotRI6hpUOftEIQ33SZYQ8 GTlg== 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=GYEZBJWwvE6ARll6NEBZ/FyIak+NB44D2yl4nniwqaE=; b=eq8nAAjT0qWfnQTplWGsiP5QwcrtQaT0jccpAfEjnXT/NCwx8/RILbqXnUG5QfYFOZ 1tfRwwKsf2g351CAUQfxb8A2rh9oeTOwxTFx6oZYc1mFKhHgNaqOKBVhr5SrKq4+FtqW V+WqRki6C82CrpJ0tpGRd0FYz43Wgb5qBGr1u5KqXDu0GDyIcEqe0JpvhhNFmNiNmAFV QPlJgdA+lZOPKSOoCGb6ayTi4ghT9HjnC+cnU2P+Nt/fCyOJJsp6DEBrLlxlSHcYhGwx yjEU+AmmN1hMgQe6Rohu6b0VBZUzpLk9EkEM8KXwDkA6Oew60RHWDzg3eIt8f9Kqas4Y bEGg== X-Gm-Message-State: ANhLgQ2vqu3fhYK6ysCwz16zmGUl26MpM3Uf8weDOD0Stlt0mrveDrNh UIVsv4Rbrwu9cRiVZsyaj8oyTg== X-Google-Smtp-Source: ADFU+vtl0ddh+l9eS+TMHTuFKKEKD32lnfG4EC3XKloo5n/nFyw7zLw+725qPAcW8JJULYZUphSuQA== X-Received: by 2002:adf:9d8f:: with SMTP id p15mr26361763wre.160.1584238994587; Sat, 14 Mar 2020 19:23:14 -0700 (PDT) Received: from localhost (ip-86-49-253-92.net.upcbroadband.cz. [86.49.253.92]) by smtp.gmail.com with ESMTPSA id a6sm4346057wrn.49.2020.03.14.19.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Mar 2020 19:23:13 -0700 (PDT) Date: Sun, 15 Mar 2020 03:23:12 +0100 From: Tomas Vondra To: Thomas Munro Cc: Dean Rasheed , PostgreSQL Hackers Subject: Re: Additional improvements to extended statistics Message-ID: <20200315022312.szckoq4na7y4lr66@development> References: <20200113230008.g67iyk4cs3xbnjju@development> <20200306001556.il6altnuqgjxp55z@development> <20200306125800.wln6p5oltgdiqpxy@development> <20200309000157.ig5tcrynvaqu4ixd@development> <20200309000621.3jhvfxphagyf5bhg@development> <20200314165610.s7p2mgaishsujq5s@development> <20200315000809.ruwpx7ktnpnzly7c@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 Sun, Mar 15, 2020 at 02:48:02PM +1300, Thomas Munro wrote: >On Sun, Mar 15, 2020 at 1:08 PM Tomas Vondra > wrote: >> On Sat, Mar 14, 2020 at 05:56:10PM +0100, Tomas Vondra wrote: >> >Attached is a patch series rebased on top of the current master, after >> >committing the ScalarArrayOpExpr enhancements. I've updated the OR patch >> >to get rid of the code duplication, and barring objections I'll get it >> >committed shortly together with the two parts improving test coverage. >> > >> >> I've pushed the two patches improving test coverage for functional >> dependencies and MCV lists, which seems mostly non-controversial. I'll >> wait a bit more with the two patches actually changing behavior (rebased >> version attached, to keep cputube happy). > >Some comment fixes: > >- /* Check if the expression the right shape (one Var, >one Const) */ >- if (!examine_clause_args(expr->args, &var, NULL, NULL)) >+ /* >+ * Check if the expression the right shape (one Var >and one Const, >+ * or two Vars). >+ */ > >Check if the expression "has" or "is of" the right shape. > >- * Attempts to match the arguments to either (Var op Const) or (Const op Var), >- * possibly with a RelabelType on top. When the expression matches this form, >- * returns true, otherwise returns false. >+ * Attempts to match the arguments to either (Var op Const) or (Const op Var) >+ * or (Var op Var), possibly with a RelabelType on top. When the expression >+ * matches this form, returns true, otherwise returns false. > >... match the arguments to (Var op Const), (Const op Var) or (Var op Var), ... > >+ /* >+ * Both variables have to be for the same relation >(otherwise it's >+ * a join clause, and we don't deal with those yet. >+ */ > >Missing close parenthesis. > Thanks, I'll get this fixed. >Stimulated by some bad plans involving JSON, I found my way to your >WIP stats-on-expressions patch in this thread. Do I understand >correctly that it will eventually also support single expressions, >like CREATE STATISTICS t_distinct_abc (ndistinct) ON >(my_jsonb_column->>'abc') FROM t? It looks like that would solve >problems that otherwise require a generated column or an expression >index just to get ndistinct. Yes, I think that's generally the plan. I was also thinking about inventing some sort of special JSON statistics (e.g. extracting paths from the JSONB and computing frequencies, or something like that). But stats on expressions are one of the things I'd like to do in PG14. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services