Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mFcXA-0005ST-92 for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Aug 2021 13:20:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mFcX8-0003Xa-V7 for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Aug 2021 13:20:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mFcX8-0003XR-Bo for pgsql-hackers@lists.postgresql.org; Mon, 16 Aug 2021 13:20:06 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mFcX0-00086j-0x for pgsql-hackers@postgresql.org; Mon, 16 Aug 2021 13:20:05 +0000 Received: by mail-wr1-x432.google.com with SMTP id q6so12092755wrv.6 for ; Mon, 16 Aug 2021 06:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=SVyAf15tWfUhz3dBwFosiMFhzuQgQHOZo+UrTk0Oh0Q=; b=exK+IBAMa77HvxGQ7kRv/m6ENFMvKTDnfrIFzhnckF8s4ZMAdIdzOkvYhQE74My39l nXBHPo+KK/OAXPmKMNkaGiUC3Yo6RKxs9iJohWntjdYbxdk1481uaVfo2V7WuzJtUfSi GvecrMvgrbUNrYqmbtdo893LBnZSy4AjtwMjy2ErNaU5/5EQATYlyRrxWj86XisVCmAQ ve2yPdFUXXr2IYCOuuL05mG1bEdufleR6W0oReP4sx8xB1CEzMmZkzPWGI0ZQu3n3fiV AnfVX5SSMi7yfGbzKVjnyHa9jWf3XdsQ7qk9jGeM9DyoQlHQS2yFWLx7tudqFXhj6/4Z SkZg== 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=SVyAf15tWfUhz3dBwFosiMFhzuQgQHOZo+UrTk0Oh0Q=; b=dLIPy1iwgICGPirlZ9z7ZHur3DkvGnoVjmqzvjz1DUkEejSVdcKaj9ozV4zyfYIT2k ttFwaldDOofSAjcDxvIErl3g0iUQLFJIS5emz5NeO0xKTQA2jnOi4w+OxIWn8JgWlo+D k1OrQ0sH5YhtECaTtgvJiIA49lPTK5YlyujS/H9dvFzOv20lOsXtugdvJxOq88SY58i3 BsB1wU4TKQg4/kFkonAO6sdQhzjLWwpgKVSsZqwqiBHVeV6hPEwgZGtWNzWElX/ZyEM7 P6JxwB6hmAJSkA3iJwUsTsJA6XSB/NCZrNk1I8WTw7AYRHW7hykIJbUuKMiWsFZevLfw f4Hg== X-Gm-Message-State: AOAM531vw7BGtLp2TOLdxlWVPCweBhsi8MH4AtSDE+NJrCCgSRHinIwg C63ylJWU4zznMh3Ra9i9ZuFSrIbMYThiUNUuyyKc85YA1JBK9tG3IeAzY5eAvrNZSWBn6XG8Vgv BGIcBzUMwraiVszmRCwpGMqprQ4WYJz0nCMcFo8c/oX3MpQWBuTMK9f6tiQRYYe7c6ZVsqLP+EU +gAgAUZF8/DdqqFvakyTywv0BAz+Z8Ux7j3Q9wF/4hSXS5GadFcP0hzHQnfCH5pmNrfSCIQOtjh r0MB9IxFu0mMBEbkVevtGfBGpyhftf0w7Kl8Q== X-Google-Smtp-Source: ABdhPJyPTtyXPHeYe8D2Y3VgkTW6aJ46UkvysLanKIWg9QQpmFUPPCxwSb6rZ1e+5r6CnpSircIdPg== X-Received: by 2002:a5d:420c:: with SMTP id n12mr18582901wrq.58.1629119995301; Mon, 16 Aug 2021 06:19:55 -0700 (PDT) Received: from [10.137.0.18] (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id y13sm10586010wmj.27.2021.08.16.06.19.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Aug 2021 06:19:54 -0700 (PDT) Subject: Re: PoC/WIP: Extended statistics on expressions To: Justin Pryzby Cc: Dean Rasheed , pgsql-hackers@postgresql.org References: <2f2a3b3b-93e4-723f-144e-bc21f10d6b61@enterprisedb.com> <20210118045331.GF8560@telsasoft.com> <3f20da4d-89dc-0912-98d2-b6f0ef06c87f@enterprisedb.com> <20210122022958.GC27167@telsasoft.com> <20210122040101.GF27167@telsasoft.com> <04b100f9-201b-0bc8-c613-0f918451b599@enterprisedb.com> <20210816013101.GR10479@telsasoft.com> From: Tomas Vondra Message-ID: <58cbfa74-9356-778b-3e10-94e3075c5807@enterprisedb.com> Date: Mon, 16 Aug 2021 15:19:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210816013101.GR10479@telsasoft.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/16/21 3:31 AM, Justin Pryzby wrote: > On 1/22/21 5:01 AM, Justin Pryzby wrote: >>> In any case, why are there so many parentheses ? > > On Fri, Jan 22, 2021 at 02:09:04PM +0100, Tomas Vondra wrote: >> That's a bug in pg_get_statisticsobj_worker, probably. It shouldn't be >> adding extra parentheses, on top of what deparse_expression_pretty does. >> Will fix. > > The extra parens are still here - is it intended ? > Ah, thanks for reminding me! I was looking at this, and the problem is that pg_get_statisticsobj_worker only does this: prettyFlags = PRETTYFLAG_INDENT; Changing that to prettyFlags = PRETTYFLAG_INDENT | PRETTYFLAG_PAREN; fixes this (not sure we need the INDENT flag - probably not). I'm a bit confused, though. My assumption was "PRETTYFLAG_PAREN = true" would force the deparsing itself to add the parens, if needed, but in reality it works the other way around. I guess it's more complicated due to deparsing multi-level expressions, but unfortunately, there's no comment explaining what it does. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company