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 1vHNxt-005daR-LZ for pgsql-performance@arkaria.postgresql.org; Fri, 07 Nov 2025 15:01:26 +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 1vHNxs-00EpZx-Cd for pgsql-performance@arkaria.postgresql.org; Fri, 07 Nov 2025 15:01:24 +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 1vHNxr-00EpZo-VH for pgsql-performance@lists.postgresql.org; Fri, 07 Nov 2025 15:01:24 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vHNxo-006VeN-2I for pgsql-performance@lists.postgresql.org; Fri, 07 Nov 2025 15:01:23 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-429bf011e6cso847766f8f.1 for ; Fri, 07 Nov 2025 07:01:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20230601.gappssmtp.com; s=20230601; t=1762527678; x=1763132478; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Z+GeFNR48L4quXDrTLLacb1NWkZtmq/mNXXbGGsNmr0=; b=E2Gn1jPQO3khrd5pZPEXO/WcoF/l9vevKFkzm0Sd05psZZNJKVSExS0gTyEqawusDL canO8KLSuRXUWVeRybZ7PUbs691oYayUvrCIiYc9PbVXV5hUTPlivKDULQ1Nf8OBzhaZ XTVWbUH3k7l9Pyv220CkXyOd1OLzRSKuns4nMTrDjF3GHVa5kGSEHCsohZkgFzBXGJpe PbUavveGAXyczHvkjCb/z91gCjloa6S3n936yKVeePD/jFlyLDA4fQ+jcZ0LQYLt9yKi zzSNsJgciIC0acLLfzeOxC1406M/32OCQW3dZiG/kaHIpJ3ylSepmKydmz+dAIzE65hJ +P6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762527678; x=1763132478; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Z+GeFNR48L4quXDrTLLacb1NWkZtmq/mNXXbGGsNmr0=; b=lURQWn0LgKFyrez4GPh2US0WSDjrMvRKsz52MAY9b2Cw1qGRM3Cxpy6CVOxQw7cnue rpYuvtHu/PIVh2UsMsvkD1NkBr6wKYtT3042Y13KWorjJqC5xSbhOjXGkhn8cfmF7ppK 4VpgCOoabt/bfHi/I/FIofuLIWWTa9HL9PJ/NqkVIy7Mp1AxsLVNgvtCchegJfRVhlp0 NSWT0PSs2N1LkWnqFuNiBhp+A0ajPBsBjolGzeAi09yIDq5Co49RJsxDYTDCFGIqClun y4mufT3ogXOxsAus5AuBh75DtZrmMHycQfgGuAiY1Qx2DeqiRkuADE/1T1ZMFZ64Y9ns YpAg== X-Gm-Message-State: AOJu0Yx1vj2p5SR8PoxtBPWmniBW8KxphMWOslHFP5SyBl3mrSZEktGJ +X2+razw/gUPshkdcBp3xftUATgcoyPkbm0yQAzo1ZpuGK2AxDL8yCvJA/CB7p2K0SRvQHJKxV3 5E202IyyplS7OCStygsePbhznaKPA6/tmq3peaKu0TI7zrzcMH+4TUDHzbg== X-Gm-Gg: ASbGncsJfh646TuIhNKuSYzbd0bbFR6gvD4oo30UaPIpSOPdU5E8I+xOFS8/qY1d6rq 4+F75NbkKRx5iWdd+JJ4ffyfEd18/mm4GMsD1DCR9dwXGT0KIeAjwV/kXjWYSkKZ7elIhBgEZ80 U9Y0YFkrpkCjuebEXu7O4kZDRBJOS78L3pM73wqjEdiHZS7wGdgYdMZOqjBJrP9aB12cDL6r3G3 JPXBhmgFmbIf4SquO0UNKLm2A0FI0r4fzCv7QzTnghHkyYL8NGnudHZ7LyZLSbr0bI59Gc= X-Google-Smtp-Source: AGHT+IFl9sCgpk8SB0bxNoGDYzhoN2N+EhPiTfsVNodRYNAvyIINmzJkftXglv+2SANuCS+mGnp95v26XaPeO+3KnNQ= X-Received: by 2002:a05:6000:381:b0:429:c965:af5 with SMTP id ffacd0b85a97d-42adc68ab95mr3227257f8f.10.1762527676772; Fri, 07 Nov 2025 07:01:16 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Peter Geoghegan Date: Fri, 7 Nov 2025 10:00:49 -0500 X-Gm-Features: AWmQ_bl8_nAZDB04ts3LROCb8SwcR5n_qmqAEahYNGUSIMutA_P_B0teKP2AOLk Message-ID: Subject: Re: Index Searches higher than expected for skip scan To: Michael Christofides Cc: pgsql-performance@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Nov 7, 2025 at 6:16=E2=80=AFAM Michael Christofides wrote: > Thank you for the incredibly helpful (and fast) replies Peter. You're welcome. > Nice idea. Once it sunk in, I realised I could try the explicit "AND bool= ean_field IN (true, false)" and got it down to 2 index searches: > > EXPLAIN (ANALYZE, BUFFERS, VERBOSE, SETTINGS) > SELECT boolean_field FROM example WHERE integer_field =3D 5432 AND boolea= n_field IN (true, false); That's using the Postgres 17 work. You could also write the query as "SELECT boolean_field FROM example WHERE integer_field =3D 5432 AND boolean_field BETWEEN false AND true" and get 2 index searches. That variant uses what I've called "range skip scan", which is new in Postgres 18. --=20 Peter Geoghegan