Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u4whw-009rSU-MY for pgsql-bugs@arkaria.postgresql.org; Wed, 16 Apr 2025 06:57:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u4whu-008DEA-GI for pgsql-bugs@arkaria.postgresql.org; Wed, 16 Apr 2025 06:57:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u4whu-008DBc-6f for pgsql-bugs@lists.postgresql.org; Wed, 16 Apr 2025 06:57:15 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u4whr-000LjV-02 for pgsql-bugs@lists.postgresql.org; Wed, 16 Apr 2025 06:57:14 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-39ee651e419so44710f8f.3 for ; Tue, 15 Apr 2025 23:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744786630; x=1745391430; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ZKWviZYjZdgHrBzYnz4NxPBz4KskZCU6tRd4S6fS73U=; b=jBnuh3zwN45Cw/g6q3626YMy2E3X4HE7C/HYeOpuy4X/c2E7DExKKpYsrs/KV6gk/l jCn7HfgcXf4iWL5C0Qu4nwd6dwrxzyUPMk6q69seKfeIUnOU3Xg9f4vhiWgkJwVkZ7c0 DXrISa8U4vjUj5DRlCco5K37a84uZyV0wb9eOeHblEdUOatReU+RGx3/bR5qr3GNoymE c64y7/PZIVYdgJ3No4uh40NqDDrORn8HDgSBQkr0D1bYyTEP11+IdSvDcazi0dobYR9i p3peqL71dKF4mK5mxBTIPvQ/3nY3KsFMeGrUj/zYvCneqpa/lA8hdA7HRJZMlCCA0czC BfzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744786630; x=1745391430; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZKWviZYjZdgHrBzYnz4NxPBz4KskZCU6tRd4S6fS73U=; b=Tl3rJVDCQOXKT7wZtANkJTn3ireVCtv7D2CA/eTf1jKqpr8FqbkHxUqn/xUT0GxXyN 8K2QBdxkwetpwvdMXqcWNNeViD8hSPDScYwpGaGGspWmZbOEJApCf3qeSu91+nm0XVGU Leze7E/ylFGE8e2rJYbxjr3D1RvD7BAy4AAnJCFGjvhDc0qOeiWQaahFCPmpxo1DNGj5 53evHuJGBQVkgVpXnZR7p5m75RG0xBvE+p+Nqkbgf1ujvkkL9EynZwJyP13u+oewTTi9 Bt/JthXxblorvp8g+Yta/xkeF8A7J44uaVCc7n0QpmEQBU6jex6UoUYgLO6Z+crrUdtA bw+Q== X-Forwarded-Encrypted: i=1; AJvYcCUrYkrq2jUg4vZ2QoJNBqtPaxNuTjtlBl1f1Pd9tuWBbp33OWXPoBYOWC5gXjSvYScNPf4MWHo3YXHx@lists.postgresql.org X-Gm-Message-State: AOJu0YziRZAOFQi3wMNFzU2cCGyaZoQi0rKKM93AkXpsm4x7AYrksY2a KYKZoBtCMbV8gKaTVbSVi2i2HNgtfw/J4O6GTx3+Ujf98Nq2wFN1qXBKG4ACnA/Q0A== X-Gm-Gg: ASbGncudcKQbENeAq9o/x6IzPxXQqFCWsk2/J+TmhNvH9wPr+GGsSY9v+zkqeHDo/1p ZvJRLZ0ybXeXcrbUFOh8E4LJ/z4/lXK6sWyUPxQB13LXilDBDRbU9ragNIykJZv45PSbCMphOd7 MTm5UeXnO0ZLDKvfoTYI4f3i0S0SN6D5X/VCIQiCXXfQ8RMBNStATj0egzROVaTLW22d8+B/XcY n+TtI5dykiNd887R+PwYUjPOZBPCj+k87eJWO6w8gjjyfwUAB/8L64OUSE08cNe0/5XMgXyEwLb 0p9vvKM02pke8zwez7Hw1509dFzwcR6/PWn8nhHFrAZGTSxs/Y4qKLdCdmy83Z4iatmHPkgPAYX b31uCTIpqIA== X-Google-Smtp-Source: AGHT+IEEoZwFuI0Jp+5+ievfh8/xruOGKIkQapponQkgX3/o6L0bOWpbPmwokRCvSno5OXrD65TM6Q== X-Received: by 2002:a05:6000:4592:b0:391:3157:7717 with SMTP id ffacd0b85a97d-39ee5b3237amr436519f8f.34.1744786629859; Tue, 15 Apr 2025 23:57:09 -0700 (PDT) Received: from [192.168.0.89] (84.123.232.230.dyn.user.ono.com. [84.123.232.230]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39ed15caa5asm11116672f8f.20.2025.04.15.23.57.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Apr 2025 23:57:09 -0700 (PDT) Message-ID: <1ebbf4dc-2b7e-43b0-a1a5-c0d7799c9ef2@gmail.com> Date: Wed, 16 Apr 2025 08:57:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #18885: ERROR: corrupt MVNDistinct entry - 2 To: Tomas Vondra , David Rowley Cc: tharakan@gmail.com, pgsql-bugs@lists.postgresql.org, PG Bug reporting form , Alexander Korotkov References: <18885-da51324078588253@postgresql.org> <048f142e-18eb-4416-b7c7-b1398e667b3c@gmail.com> <769393be-6fea-435e-8316-66546c6f4a49@vondra.me> Content-Language: en-AU From: Andrei Lepikhov In-Reply-To: <769393be-6fea-435e-8316-66546c6f4a49@vondra.me> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/15/25 15:16, Tomas Vondra wrote: > On 4/15/25 11:41, Andrei Lepikhov wrote: >> What do you think about that? > Not sure we'd want to export GroupVarInfo in the current shape. It was > meant for a short-lived local state (within a single function), which > seems quite different from what RestrictInfo does. > > In any case, such rework seems out of scope for PG18 - it's much more > than a fix for the bug. Of course, it is not for PG 18. I'm working on further GROUP-BY optimisation where columns are re-arranged in a way to put at the first position column with maximum ndistinct estimation. Additional work is needed that may be compensated by distinct caching. One more ongoing project - correcting ndistinct estimation by passing through the EquivalenceClass and looking for a minimum ndistinct. It also needs a kinda cache. That's why I am pondering how to redefine GroupVarInfo to reduce estimation efforts. -- regards, Andrei Lepikhov