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 1tyD8k-003qvD-5M for pgsql-general@arkaria.postgresql.org; Fri, 28 Mar 2025 17:05:06 +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 1tyD8i-00DLma-Id for pgsql-general@arkaria.postgresql.org; Fri, 28 Mar 2025 17:05:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tyD8i-00DLk5-77 for pgsql-general@lists.postgresql.org; Fri, 28 Mar 2025 17:05:04 +0000 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tyD8g-001elx-1V for pgsql-general@postgresql.org; Fri, 28 Mar 2025 17:05:03 +0000 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-60245c7309bso537623eaf.3 for ; Fri, 28 Mar 2025 10:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743181501; x=1743786301; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=oPZEMMr3rhc6u8/k8nOx3CvezQ7PIIxu3+yqtTUNzaE=; b=KKyZnHq65tyLq8AtNMXUtsE9f/FEC5wC2SMBD+eMi7K4PVmrnUjVRtrf8VHpTRhZgb 5FqVLOqNZVqcY0EV5nOtXupKZue9dg1mW1LqevNmPPu3LoNVPyo8ObZqCq5LBKtERdGk w2mLaAE2Rpx9A7sn4Q2SasE6um3QZ6r8XEmghXa9GtOt5ZKoH4aYuQUryYuthPogiiqq wbAef37kflCgtHw7W2Q+urR30EiZl2WB3mX03D1EMPHGuVFreJS2RZ4B9DF4zASxZWSv 1GivZUy0KXklNWolgtHktOXUXDTMiNi7oZjzL1gvQmRGWNQzbGfTKEDHp+Z9MuU0fU4l yO4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743181501; x=1743786301; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oPZEMMr3rhc6u8/k8nOx3CvezQ7PIIxu3+yqtTUNzaE=; b=iTAgPPs0CwILzZKCuj8uaTyYbz3N6Mi1JQsKPipKhxv+BTEnE5klyIfHPsJ+lPPSJZ l89X4L87/tZtZamPPmLDnVjZ+4L482pjl1Pz8NqiBo5rSCY23dzGz2FjGQhoTSX7p/x2 SVk/As2Vkc2qrhpj8IRgSSYgcbPfw0MaGT5JaRwBJ/DzDM4P42s9bVC2s0xjxrg13l3p F1KA1Oy+ULz61qgEelW5M126kT5fFfmiSo1yHn7/1l3CNiCKdW0Qp4wUOizE2uy0p5bT PbSYNQYPKiC0YYcODM2lbojfPo6+jRzMEz9tla5XZL9G0mr1fKKM9oiV8JcRsQ6Xw5YI Hh+Q== X-Gm-Message-State: AOJu0YwO07PN+zPaLNYkABe3ny7RXIXdpqCFQwLIJ9DhdjHKhbuZe1x8 ApV92dRJurUCOJ66i6cckGZxhrgqjd610g+O4U9KxtW83znm15sko2ZrVkcmW2FUA71S6XiHKxh bbxNEd/Put6L6SZvKN7oXaWsDC+c= X-Gm-Gg: ASbGncuVxIVhcyj975kMFLRmFGRjls9r4y4VjaSChrNnfy5IbUzo5sL3qZC10JBCetk 8onhCBcV2stFjJRztOWLra/GTPvPyyJLicCtsfACFbOKArSSDsQLkxV6URbSGb10oGB7vxs79si Bes05fH323kU1k+P78+MmiIom5 X-Google-Smtp-Source: AGHT+IGlrorgMVAsduv7bzj87GQr7WXsJ5sh9GARgvvjydS6mrZZxGrrU7HhLWstLQlpR18KVVURUAmmr5osC5OQpfg= X-Received: by 2002:a05:6871:20c:b0:29e:684d:2739 with SMTP id 586e51a60fabf-2c84823c041mr5241626fac.32.1743181500987; Fri, 28 Mar 2025 10:05:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "David G. Johnston" Date: Fri, 28 Mar 2025 10:04:24 -0700 X-Gm-Features: AQ5f1Jq5Lu7IfZKFeNMceDrhDnT99MXexMb3zEegXrrs_tsK-a3aKthjZYaYp9c Message-ID: Subject: Re: BTREE index: field ordering To: Ron Johnson Cc: PostgreSQL mailing lists Content-Type: multipart/alternative; boundary="000000000000253fda06316a1296" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000253fda06316a1296 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 28, 2025 at 10:02=E2=80=AFAM David G. Johnston < david.g.johnston@gmail.com> wrote: > Selectivity is evaluating cardinality with an eye on the frequency of > the values you are actually going to be filtering on. So low cardinality > booleans can be highly selective in usage if you are looking for the rare > false in a sea of trues but low selectivity if looking through those true= s. > And to accommodate the highly-selective case a partial index is much better than indexing the low cardinality boolean column values. David J. --000000000000253fda06316a1296 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Mar 28, 2025 at 10:02=E2=80=AFAM David G. Johnston= <david.g.johnston@gmail.c= om> wrote:
Selectivity is evaluating cardinality with an eye on the frequency = of the=C2=A0values you are actually going to be filtering on.=C2=A0 So low = cardinality booleans can be highly selective in usage=C2=A0if you are looki= ng for the rare false in a sea of trues but low selectivity if looking thro= ugh those trues.

And to acc= ommodate the highly-selective case a partial index is much better than inde= xing the low cardinality boolean column values.

David = J.

--000000000000253fda06316a1296--