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 1vIJOz-003KX1-Bw for pgsql-performance@arkaria.postgresql.org; Mon, 10 Nov 2025 04:21:13 +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 1vIJOy-00DsBv-29 for pgsql-performance@arkaria.postgresql.org; Mon, 10 Nov 2025 04:21:12 +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 1vIJOx-00DsBn-Jd for pgsql-performance@lists.postgresql.org; Mon, 10 Nov 2025 04:21:11 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vIJOs-006uvH-35 for pgsql-performance@lists.postgresql.org; Mon, 10 Nov 2025 04:21:11 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-477775d3728so9194635e9.2 for ; Sun, 09 Nov 2025 20:21:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20230601.gappssmtp.com; s=20230601; t=1762748465; x=1763353265; 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=wcSyWMOzRNwETPZAVCEmWC0rabMNAP6J/8g8FEU0VDs=; b=1h76bJ5yANDgjuqP1ZTzfo6+4s2M1MHZ1n0UmPwmZ7Cbn+pbeRGMVOR8fMGY5QPVDo h0kOJSUMnrjUl6FC1VP14bx8Ni8zJxWI4zHEH9SH+Uk/GRXLDIeirsyzHAOvvm6WgNjl hrGkD6umsSFc0FzRJWb2Hg3HuOjMZ8PNZTmAKDhOKvf+yby0joS3HnWfHKhThmc8mRA5 MQbBQiTowJ0zofc0GUzp9IWO8nkDMx4muhmT/hyWXm9VqalAuRRuKHF+aroAZ06DP9yd Yaf4nuEsuGMgf770DIH+OmvoGQ4D5NsYCAFddr/vwJgAHWJs4SFipJtDOssCVfaorA+P 865Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762748465; x=1763353265; 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=wcSyWMOzRNwETPZAVCEmWC0rabMNAP6J/8g8FEU0VDs=; b=bxA4uddTPvUnrhcNAy7qKnHraBRKF1y2LIz1Tt/tBggcFJi9ZZ9lvlvROivepYc7ns ZcKGrPMdpUPr/0umSs5iQ1kp7ATtBVmDsat1lonFle+j8nWAYdN7RxDO2w+sO6wlbVlE yk+axLU++cUUb4VO+YukS2bmVUQbE5A4obIjDe0cStDGoc5i01/3+DoKTZQ6lFgtna/u gqEFfwZdXov1oG2hWYIfUFrkYBG4bb323TXO4wo9MTB9jWzPgabuwrzY180kSvp17Cvp yCuPbv1Z4PPjl2Kyh0ymCWd/qbnUpaGQ9WVl4Dr7P17q3GJT/gT5fCGE5ebPF2AxbazR RK2A== X-Gm-Message-State: AOJu0Yz5ABs+W59gAzbaM80sxiRl7VZNZsetkNaURGZjsy7wNzlikloA aUNtwrVrbu/dt5K9j1VqDokRWgd2Bd7XErYsEkbcBvpA8QV3Is75SdQGWUzQy5LACZRqmIFjOCQ ujWu1s9oNtDRE7xi100GB2xMV+U8UCA48Id7mconLYw== X-Gm-Gg: ASbGncti07hO+TPC1u0leA6OHVQ4VuYgCwaQyc+UFjBLlmm8ZyJMl/r/8WIoOoZShWU TjnLIVZJSlHTryafaP3kflRCcFyGmWW/Jmj7fyLIUAeb/BV9GkSbeUwHIsQzntLmZsUX5frG9FH 9ANoohOacmtCfP0ROKRXvc8iWiu+klrggq8pH8qjCukS9Obwrylt8imXizQ/a6rDNO7T3FsqKxC cwVwqUP7hjpVHma5Yfn5EeuULIsuM5tVALN/ulFUdu3NTNBx3MVik6IMyg+ X-Google-Smtp-Source: AGHT+IF61czG72rSrcil9zZd+oHnyv4u0YTQzEI+CzlaZ5oOHgjYg66YtWs4zuf1aVYYdSo4FC2hUmkgHYVeN58Mplk= X-Received: by 2002:a05:6000:1a8a:b0:429:cd3f:f43b with SMTP id ffacd0b85a97d-42b2dc16be6mr4629258f8f.4.1762748465491; Sun, 09 Nov 2025 20:21:05 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Peter Geoghegan Date: Sun, 9 Nov 2025 23:20:39 -0500 X-Gm-Features: AWmQ_blFt0DSroEzd1F3ZY9ejBFjofmua9hqsNRDCacvbw5fc69r06l9WvW4Oh4 Message-ID: Subject: Re: Multicolumn index scan efficiency To: Vitalii Tymchyshyn 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 Sun, Nov 9, 2025 at 9:44=E2=80=AFPM Vitalii Tymchyshyn wrot= e: > I am wondering about 2 things: > 1) Does anyone know which specific change / version made it fast? > 2) What was the proper way to do a range index scan like WHERE (a,b,c) be= tween (x1,y1,z1) and (x2,y2,z2) before the improvement. > Note that my tests can mostly be rewritten as equality at least for some = columns (and this is what we'll do), but sometimes we do need a range scan = like above, so understanding it would be important. Also I am curious :). This improvement you're seeing here is down to work in commit bd3f59fd. The short version is that the way we used to decide when a condition like "WHERE (a,b,c) <=3D (x2,y2,z2)" was needlessly conservative. If there were many "a" values equal to x2, we'd have to scan the index until we got to the next distinct/non-equal "a" value -- without realizing that we're already past the point where there cannot possibly be any more matches. See the discussion on this thread which complained about the problem, particularly my response to the complaint: https://www.postgresql.org/message-id/flat/CAH2-WzmLREy6r68A6SEHXnstg01kNs1= HiQtOvSO5cTvWuaducw%40mail.gmail.com#62e393ac8bbf06f0f73598ba2ceeab69 -- Peter Geoghegan