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 1kX7ew-00064n-Q8 for pgsql-performance@arkaria.postgresql.org; Mon, 26 Oct 2020 18:55:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kX7ev-0004XB-Nh for pgsql-performance@arkaria.postgresql.org; Mon, 26 Oct 2020 18:55:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kX7ev-0004X4-DL for pgsql-performance@lists.postgresql.org; Mon, 26 Oct 2020 18:55:57 +0000 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kX7eo-000834-P1 for pgsql-performance@postgresql.org; Mon, 26 Oct 2020 18:55:56 +0000 Received: by mail-qk1-x734.google.com with SMTP id z6so9415136qkz.4 for ; Mon, 26 Oct 2020 11:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=americanefficient-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=OFKJX75LLkCbUffH6k8MjrY1nR54O8o+CXKnC3ACP/s=; b=xdNzwcS9B65MOoL+RcRtHZHBcnl0zNzFvmQHp2koqg0DAW0OkBIU5b+wKgVi98J0Lv wA3/eF1lRPrzscjYkEo7cKPQOvenYxCuF5qB35KMbmZZgGJPNnVfGFNQckXQ/cw6DYeZ UAYAvKVXIy0dWv453DMeLzUQj7xqSiPr35QlGy+yDwjvx0Ib5Ho3Avu6LG8HjeQLn2KG 0ncnyTxT++tk0KT48TLrRpduA8xmPhMGSmp/jeUiUqA5ZVo8D/mHPvPo0PlgXMn+T+j7 aJn+zRm4oov651JNjHVNILNwcamaheakUKpvorOyv0oEPuWvKrJqSnh86N8tdryaEOaM bVJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=OFKJX75LLkCbUffH6k8MjrY1nR54O8o+CXKnC3ACP/s=; b=nJDLYEz4R1Iq2vL0xfvD5NvgXJv+PgF/vLiw3sYXKvO3pF2gmBeuYB0HshTX4LwRK7 PJ0Hiq+a1M7DTPbzoVJeOKzK4pVC9EC3IW2xl3ssfG3TsYq/Pzo78eUoTuB1su/1ZIwX GYY3mSNPB+nqpQgVmO+6YmVq17+0UBOCPB9VeiuOaMLaJDxaNYn6jWcvunKu7RCqb0Ov 4aDaT/fyqayzidWs7LAqRal3/cJNOKOP3hC89xEK7de3LAsNEmuDENgvyzTOmXi3J2HT PQdnaI+vAKLhvjBt8W3c8lOsivOIsQDvg5wZsi8ohxlaBQiFvGP0jo/Mpfhx9/sCxGHm bDJQ== X-Gm-Message-State: AOAM532E52oeixuWqUj2q257QpXUoptfDMxCUjoK2i7EGV1dwmyu6I2r AwNYs5SB/9i+Dhyw9jAOIWQQ5A== X-Google-Smtp-Source: ABdhPJypIV93FLLKos1yt3WVVZldqFSvn5wfCXaQ0wN2ge7kKynBFPBZWBrQLSQpU4AWXRrV9iHzyg== X-Received: by 2002:a37:c49:: with SMTP id 70mr16001988qkm.345.1603738548398; Mon, 26 Oct 2020 11:55:48 -0700 (PDT) Received: from [10.0.1.7] (user-10lff1p.cable.mindspring.com. [65.87.188.57]) by smtp.gmail.com with ESMTPSA id i22sm7085782qki.74.2020.10.26.11.55.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Oct 2020 11:55:47 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: Understanding bad estimate (related to FKs?) From: Philip Semanchuk In-Reply-To: Date: Mon, 26 Oct 2020 14:55:46 -0400 Cc: Justin Pryzby , postgres performance list Content-Transfer-Encoding: quoted-printable Message-Id: <553742C5-85E6-48C1-997F-3BFE2FD81FC4@americanefficient.com> References: <7AC7104E-E233-4CCA-B99E-12197D61A4DD@americanefficient.com> <20201026170405.GT9241@telsasoft.com> To: Michael Lewis X-Mailer: Apple Mail (2.3608.120.23.2.4) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Oct 26, 2020, at 1:20 PM, Michael Lewis wrote: >=20 > On Mon, Oct 26, 2020 at 11:14 AM Philip Semanchuk = wrote: > >> The item I'm focused on is node 23. The estimate is for 7 rows, = actual is 896 (multiplied by 1062 loops). I'm confused about two things = in this node. > >>=20 > >> The first is Postgres' estimate. The condition for this index scan = contains three expressions -- > >>=20 > >> (five_uniform =3D zulu_five.five_uniform) AND > >> (whiskey_mike =3D juliet_india.whiskey_mike) AND > >> (bravo =3D 'mike'::text) >=20 > Are the columns correlated? Have you tried to create extended = statistics and see if the estimate changes? I believe that extended = stats will not directly help with joins though, only group bys and = perhaps choosing an index scan vs table scan when comparing the = correlated columns to static values rather than joining up tables. = Wouldn't be much effort to try it though. There=E2=80=99s not a lot of correlation between whiskey_mike and bravo = -- stxkind stxndistinct stxdependencies ['d', 'f'] {"7, 12": 42} {"12 =3D> 7": 0.000274} Those stats didn=E2=80=99t help the planner.=20 I should have mentioned that five_uniform has ~63k unique values, = whereas whiskey_mike has only 3, and bravo only 19. Cheers Philip=