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 1mYF2q-0001HK-2z for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Oct 2021 22:05:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mYF2p-0002wx-1V for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Oct 2021 22:05:47 +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 1mYF2o-0002wp-Pm for pgsql-hackers@lists.postgresql.org; Wed, 06 Oct 2021 22:05:46 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mYF2l-0002mp-O1 for pgsql-hackers@postgresql.org; Wed, 06 Oct 2021 22:05:46 +0000 Received: by mail-ed1-x532.google.com with SMTP id p13so15693981edw.0 for ; Wed, 06 Oct 2021 15:05:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=xUrZtATO5Jf/Qm4pSTIpRH+MhTGYu9TKOMurtsAjYZY=; b=PafEYDSypXeexr8MZsYefEHK/TGz7gtf+51GnWMiTDWZFVTy7hbP4ZXB6R1VqahS9T 14AuEUewMFXrYe8QFa4iJbuhgY9zC5n8BNgcjqMSHeO5qz77qzh3rc9wqo4AmE8XJz4t B6KiScLyNOujpKQlhbVdq7oklG1YvZ7t2w1uhTyeunwS45h7DENA64xmga/BoV8mugsE SXfi+97HEEQv+LVusYUzlGlh7Kr1FpVmjLvzg3Bm1g8AiYqF/8SdGFiYlegBUvjuOgul 5jtKm4kQDM6A3zHZU5yPhBhjFIosFO8kxK2dCvqC8Siq7S8VHwEs4aWTHzAvhyR1qi8h lLOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=xUrZtATO5Jf/Qm4pSTIpRH+MhTGYu9TKOMurtsAjYZY=; b=H5ZlQEM6NLEg1A88CL4PxjHQNYKpOlG7YoniFfxgORe8Hiad72STNP8fmvpFcq+SV9 cqFZK/Y1JLzAo39P8Ijk0tEvvYVZfbQnSjjljL3KqPnBM13UKffTBUWvRCAEgiDon41G symMtY08E0ZMLSrL8+VG8n+cF+oBliOyIQVmRsPBl59SmtiK5ckx0n2mBNSS76Oppy5H /48SRLlLxY7viNLiZmlj06ewow8nr9XH/N7PxEU3UODBGKb89dOHMcJnvrhbg0u3KtPJ TMiUvzN5A9klUNbrtfk3mnXm2U58U5nWvoI+nkp/k4sOaWLYoMIC9L1w4vpvZYg/kY0y rwdQ== X-Gm-Message-State: AOAM53327MP9PNksmtQLWQFMpKNrUszZ0KBfQZcH7Q0h9k0e8uIrB5S8 IYOnUfAf5I+5vHdWMdCeHzL5NX9gSNH9Isr1ZRRMbCWh7/3DapdRzZ8WfCyTMl/inpwTHLt4yjf gx4nwUzTXnMeAQVA2Nu3ddttC6XSqU5LlnkF3ef26itfiWvl1+l/17hqhzisQplXItE+9+MIJ4O GXqKuSL1LAW7/sJ9Weuyo+Uz5bCy6tlntlZVZe X-Google-Smtp-Source: ABdhPJwTtrgbv3LGGQGON2RVy4EY1w26uPzt2fUe4fT/lJQ1nsjK8CzXvHsezl7RFSN9C2/b60drwA== X-Received: by 2002:a17:907:3312:: with SMTP id ym18mr953071ejb.370.1633557942886; Wed, 06 Oct 2021 15:05:42 -0700 (PDT) Received: from [10.137.0.18] (ip-86-49-251-104.net.upcbroadband.cz. [86.49.251.104]) by smtp.gmail.com with ESMTPSA id v10sm2649400edw.96.2021.10.06.15.05.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Oct 2021 15:05:42 -0700 (PDT) Message-ID: <3aa13399-8dac-e13a-5ce9-d528ab93efb8@enterprisedb.com> Date: Thu, 7 Oct 2021 00:05:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: using extended statistics to improve join estimates Content-Language: en-US To: Zhihong Yu Cc: pgsql-hackers References: <2ed75657-e084-9539-c6de-597e5675014c@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 10/6/21 23:03, Zhihong Yu wrote: > Hi, > > +       conditions2 = statext_determine_join_restrictions(root, rel, mcv); > + > +       /* if the new statistics covers more conditions, use it */ > +       if (list_length(conditions2) > list_length(conditions1)) > +       { > +           mcv = stat; > > It seems conditions2 is calculated using mcv, I wonder why mcv is > replaced by stat (for conditions1 whose length is shorter) ? > Yeah, that's wrong - it should be the other way around, i.e. if (list_length(conditions1) > list_length(conditions2)) There's no test with multiple candidate statistics yet, so this went unnoticed :-/ regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company