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 1hs2iQ-0003ay-No for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Jul 2019 10:17: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 1hs2iN-0006fG-W4 for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Jul 2019 10:17:11 +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 1hs2iN-0006ZY-Ej for pgsql-hackers@lists.postgresql.org; Mon, 29 Jul 2019 10:17:11 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hs2iJ-0005Rp-UJ for pgsql-hackers@postgresql.org; Mon, 29 Jul 2019 10:17:10 +0000 Received: by mail-wm1-x342.google.com with SMTP id p74so53267330wme.4 for ; Mon, 29 Jul 2019 03:17:07 -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:user-agent; bh=ZOt5hE/uxyA9w1xYZJIeVEUl3PBvnQqKZQ6lkWGDUZc=; b=ZvijlJQ9+sWJgaZ0abT5D00KrH8MLy7EkRUFPUzyQru88m21IN9BD7HQHwIaR97GGO vxI0uZ3LDGpGor9Z8qk6bn6YXi/kj+4iRfGY0cU6ogcjneL0vUZGL6BjxOsY1MmA1klb Ebcr85LWrYMnJyR46YHZprZIW8vwq3nHBaaar1BJatUNrcFYQPlVnpHZiQgfJgypnF80 zqUWNtIKsB943jKDPjS/cuC6qETtKihKCU4ByBlSXWt7Upg7WHKnqjjzW5PkgEjDMkvU nj6T637VoKMifHdDAuEYaXRq3u9b2uTB7+yWJi1mfCxy7xgFM5NxVZy8qdqWlY2OLa5a rv2g== 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:user-agent; bh=ZOt5hE/uxyA9w1xYZJIeVEUl3PBvnQqKZQ6lkWGDUZc=; b=BWHACFy60s5NCkLb8rIoDMxYzOHMBfCx1kYr/Fk5JQfue0blXKHEVmDS3JW29eSoP7 nDKFniqZuSnMI9fSzhJ7hS8DUv/qHnKG3MjEHt9bQ0e2VD9cUWA4yzjL3SD0F/uc9aeQ ElmCCcsYp23vXWrYzePcXNMelhPTWX3LxfBdvJ9/GFhAxNW4ut3fwl85zqk/cqeOHU86 /sEUjI33cNjNdp9z4FH3NEuYHTkVK0Q2237WU+PmU0hRWOT2OmwkiTClGgi6LVGzVqDF nh4GPl7T+bvxtP+72JIptHGWxt+oFwgJ8+ZTZcvRlZo2tt8ZOKO9hNs7QrS1a9lKceVg AcWw== X-Gm-Message-State: APjAAAUGpBVxkhzQMN4ZV/ztgT6Mio0r+lxhMK2t18Dyf1pYodQZTtcv /Q0uURbDWvFRA2qkb+yLCTj9Ag== X-Google-Smtp-Source: APXvYqyX8To/LLv/uMs/aO2TxNh7/hT47miA7SIcO+10/B+PWF76YX/NlEqAuvhuBxZfpYMYpdlAIg== X-Received: by 2002:a1c:63c4:: with SMTP id x187mr93705387wmb.4.1564395425579; Mon, 29 Jul 2019 03:17:05 -0700 (PDT) Received: from localhost (ip-86-49-253-160.net.upcbroadband.cz. [86.49.253.160]) by smtp.gmail.com with ESMTPSA id h14sm58729768wrs.66.2019.07.29.03.17.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 03:17:04 -0700 (PDT) Date: Mon, 29 Jul 2019 12:17:03 +0200 From: Tomas Vondra To: Dean Rasheed Cc: Andres Freund , Justin Pryzby , Tomas Vondra , PostgreSQL Hackers Subject: Re: ANALYZE: ERROR: tuple already updated by self Message-ID: <20190729101703.j6rv73ezol3d3wkh@development> References: <20190618231233.GA27470@telsasoft.com> <20190618234858.GK16019@telsasoft.com> <20190619000837.awy6j7h45ahd4vop@alap3.anarazel.de> <20190723200127.moumhmj3z4b4dohg@alap3.anarazel.de> <20190728101520.da5nptiftmsnmv7c@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Jul 29, 2019 at 10:15:36AM +0100, Dean Rasheed wrote: >On Sun, 28 Jul 2019 at 11:15, Tomas Vondra wrote: >> >> Attached is a patch fixing the error by not building extended stats for >> the inh=true case (as already proposed in this thread). That's about the >> simplest way to resolve this issue for v12. It should add a simple >> regression test too, I guess. >> > >Seems like a reasonable thing to do for 10, 11 and possibly also 12 >(actually, as you noted, I think it's the only thing that can be done >for 10 and 11). > OK, will do. >> To fix this properly we need to add a flag similar to stainherit >> somewhere. And I've started working on that, thinking that maybe we >> could do that even for v12 - it'd be yet another catversion bump, but >> there's already been one since beta2 so maybe it would be OK. >> > >Yeah, I think that makes sense, if it's not too hard. Since v12 is >where the stats definition is split out from the stats data, this >might work out quite neatly, since the inh flag would apply only to >the stats data. > Agreed, we need to add the inh flag to the pg_statistic_ext_data catalog. The trouble is this makes the maintenance somewhat more complicated, because we suddenly don't have 1:1 mapping :-( But if we want to address this in master only, I think that's fine. >> But it's actually a bit more complicated than just adding a column to >> the catalog, for two reasons: >> >> 1) The optimizer part has to be tweaked to pick the right object, with >> the flag set to either true/false. Not trivial, but doable. >> > >Isn't it just a matter of passing the inh flag to >get_relation_statistics() from get_relation_info(), so then the >optimiser would get the right kind of stats data, depending on whether >or not inheritance was requested in the query. > Yes, you're right. I've only skimmed how the existing code uses the inh flag (for regular stats) and it seemed somewhat more complex, but you're right for extended stats it'd be much simpler. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services