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 1lRf2r-0004eq-DA for pgsql-committers@arkaria.postgresql.org; Wed, 31 Mar 2021 17:54:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lRf2q-00054s-AL for pgsql-committers@arkaria.postgresql.org; Wed, 31 Mar 2021 17:54:20 +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 1lRf2q-00054l-5I for pgsql-committers@lists.postgresql.org; Wed, 31 Mar 2021 17:54:20 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lRf2n-0004Zi-4h for pgsql-committers@lists.postgresql.org; Wed, 31 Mar 2021 17:54:19 +0000 Received: by mail-ed1-x52a.google.com with SMTP id e7so23284358edu.10 for ; Wed, 31 Mar 2021 10:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-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=2sUdUhgkjxLexVoagDYns5Ww337TzU+FP5AmEdYGOK0=; b=DfLd77QQmGnaGxum323cLzQ8iwiKwdDSwEsQnlbp4uAHO0QyboVfFJxkjx1yWRuF8h x5b9zyztCT+vcAqx+ZDA4nkjKjOQ9qL6hJV9KhB+28dZzfyzU61mcgCun7QJfN3kEE2y vuvYJfudelUoVESFkIB7Gpk1SojZoyt+QsGgkGmv4rN0ptPlxeU4/w+WzVAFSwyn9Ghr VtCTOa88xLK/LAIT/M6KiCM8WtJbX7FC8YKoMItr6g9/N5PpXwVvUBMW3f5CqIq+uKkm Brvvr56e5Wmffo9NUeEuMBvb8Ax08PbKvkhyfneVj7Nkd89exgsIrguhwq65Q6FdVgMA SXmA== 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=2sUdUhgkjxLexVoagDYns5Ww337TzU+FP5AmEdYGOK0=; b=RlWd6xqolCcpmccHjSIEsHE7Q1RGrACZ8gkE66RU20h7TwV7/00HCYm4YvpZ/jaWoK 3NvLZvjVniMTykQ53vvD2su4JbSiEbkqWEGuUhIALiUyC+9sG9r68QApLPnsUhJdrU8d RZ8Ed5HLYdpd1dhyGZaN+5woHTzH4LtJ9ETgbp8TpnqpdDoygaiWMSwmGK3TTZcKmfXk 9A3J562/u9tjxLWF0/FVmCThF271uIa3xi4JM+nzPVseGOGCDkGMpQoLF/jP8/M9a1XT Q2ga2my0US0ZpmNLpYDmYSus7HYP+sKEs4JPwlFSnJtYlcbFkrosKt+RtxUDO2xAEI5F XGBg== X-Gm-Message-State: AOAM5316qDfKpYGn5dsmFlawy2nP38RhA4I0K633WBkYMK2I2HJTAwwZ PdCSdv88vQkgBqCTyF1wlCqgslbPmM5i7zK6CafXzHeVcqfyF8vMfOk5p392HseRg2fCouL384r 2Ex91C6+hyt6PQOd1Wvz8N36AhKE8vzyydic70bPFbCqr9WdSiTXlr7rzU9tSbab2gUPM5Y3b4g 4c8gRWSTaWSosqc176ekdb7YbjL1rFEjFWLJqTYwmWOs38rldYhOpVZCA1ADUActQf5qyZVoQVq mzjwRgtzCr4vjd933JbpyXD4h1CJdQLYA67bE9V1PHfkXTCIjobaAdonS1qmg== X-Google-Smtp-Source: ABdhPJz1+cNZ4x2Kv2nhlcagpJTu8zcTi2fTLzNHc7BbZY32XWaTs1t8d0phmlh5w5y/OSs4iAuL6g== X-Received: by 2002:a50:fd15:: with SMTP id i21mr5136657eds.384.1617213255798; Wed, 31 Mar 2021 10:54:15 -0700 (PDT) Received: from [10.137.0.20] (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id b18sm1632976ejb.77.2021.03.31.10.54.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 31 Mar 2021 10:54:15 -0700 (PDT) Subject: Re: pgsql: Extended statistics on expressions To: Alvaro Herrera Cc: pgsql-committers@lists.postgresql.org References: <20210331170828.GA26795@alvherre.pgsql> From: Tomas Vondra Message-ID: Date: Wed, 31 Mar 2021 19:54:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210331170828.GA26795@alvherre.pgsql> Content-Type: text/plain; charset=utf-8 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 3/31/21 7:08 PM, Alvaro Herrera wrote: > On 2021-Mar-31, Tomas Vondra wrote: > >> Thanks for the report, I'll take a look. You're right this seems like an >> out-of-bounds access, but mcv_match_expression is only expected to be >> run on expressions we know are in the statistics (because we pick the >> statistics like that). Clearly, that does not happen here, not sure why. >> >> It's quite weird that we end up running textlike(), when the statistics >> is on (double precision, boolean) columns ... > > Uninitialized values somewhere? Maybe valgrind would help. > Unlikely, I've ran it through valgrind repeatedly, including right before commit (both on x86_64 and arm). FWIW I'm unable to reproduce it, so not sure what's going on. David, what configure option are you using? Anything special? It's a bit strange, because statext_mcv_clauselist_selectivity should only estimate "matching" clauses on the statistics. So how come this estimates such a complex expression using textlike(), when neither of those columns is text? It'd be interesting to know what's happening in the code after stat = choose_best_statistics(...); i.e. what clauses it considers "compatible" with the statistics and why. In fact, I wouldn't have expected the statistics to be used at all. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company