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 1tIDml-00D0W0-NT for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Dec 2024 21:16:51 +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 1tIDmi-003bhu-GD for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Dec 2024 21:16:49 +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 1tIDmi-003bhm-5U for pgsql-hackers@lists.postgresql.org; Mon, 02 Dec 2024 21:16:49 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tIDmg-000iOQ-G2 for pgsql-hackers@postgresql.org; Mon, 02 Dec 2024 21:16:48 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-434a0fd9778so44082095e9.0 for ; Mon, 02 Dec 2024 13:16:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20230601.gappssmtp.com; s=20230601; t=1733174206; x=1733779006; darn=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=YhK5QncRkPf3U3X/+TiXklaq373MOP4dr6S1vMI7lN4=; b=mWlTH1Pazaym1UrRMnGKCqm9pkRvdpxkLSLuJkdvJH/+CyzzL4vloiOplGSAA5cAsW kn4jYfWAUM8r/2lJzN95XT+DvtoP3HCoiTBT5pYZCN1eHsxUxGnIzkq+J26MfhyqxHfy 2THOTRYxm63xMaulfqsdnlzmOnhSUVlWQTaGdwAqrXfHnRpLfxbWRxroT69kpztCqvZT rzdexC4zZe6fhIcEns9oJ54u4x33LR67Z8tf7buuyOSz2foE3awnkFjEKM1VeUDSzStV 7H0bxYHptG1h0pyCiyuXOase27fqyBvvaUrX3u6Bia9lMz2uApQoKnCSwJ2aAAQmKxh0 2w6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733174206; x=1733779006; h=content-transfer-encoding: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=YhK5QncRkPf3U3X/+TiXklaq373MOP4dr6S1vMI7lN4=; b=gLkFYl80wmzJnR5+s8tgFPTNcDoT2pGPpyR1A84op91rDgmcUYamG7Z9OXiAeRGZur 68+OPoKt3McUkCBE+sKI+HuC6vz3wxapWngvwVeY8CfThBtYSmxbeAWXvaXlzH1AoKN2 e/V+uZiQT7f16BSbftDjhL0v4KmdF8HRe2fDaX4BjRVIVGk9OJRgrB/Tu2NWMCSobYP1 jsYCpXY9KiCIjHaqEd3t9ZzMcaPBhsNhxWrxYbCOoB24rvibuIvT5BoDyYLZZCnlB4N0 fnaefaijQq3+awpWjbqUQwvOiy8xRavCAzXXsvMOBBXwqhiwgug4k8QWMEwKjJy73yzb PbAw== X-Forwarded-Encrypted: i=1; AJvYcCVEzgAGF7hFRCM6EBwkbFd4xUl5n9SncTzMdKweBl3RdGCzpnTy8TzSEFQwweWHct6f48+k/5/fxYs2HoiX@postgresql.org X-Gm-Message-State: AOJu0Yz6FYtW62xB7ivO+MbdRPBWkxYUaO6NSevRWCDKmN4bl+KvtTjb kNgrDv4lvEp5nBxUpL6+Uger/OVYq9RSh/v+ENWTUcPLde0cItwWc7BlubgK3XRCAxMneIoIqMY AjM/zNK2z6PbmlPlrW6fHRK9ChTIe3O89QCY1iQ== X-Gm-Gg: ASbGncvvde+pKC51W1SVGC32lmc61UM6N2Sq0PhJ5yFtpaWMgsU2EQSLoWbI/gG+ikE xiV7tcM49Q2aTHAQZUqK5UTHcEFwrpxQ= X-Google-Smtp-Source: AGHT+IHmW3ogLAd0NcO+00vmBbJVLKR1bF3cJKCCg85+neCkepe9t05sJA0compzTK8I/sfuGsPWS8eycOiO3ktho/k= X-Received: by 2002:a05:600c:4f07:b0:431:52da:9d67 with SMTP id 5b1f17b1804b1-434a9dbbfbbmr248518665e9.3.1733174205753; Mon, 02 Dec 2024 13:16:45 -0800 (PST) MIME-Version: 1.0 References: <873c33c5-ef9e-41f6-80b2-2f5e11869f1c@garret.ru> <1643257.1733157822@sss.pgh.pa.us> <1646644.1733158959@sss.pgh.pa.us> <1647379.1733159462@sss.pgh.pa.us> <6nev7zfx57h5pkqpgdp4q37xjcj2dxqilsgbb5ac5lhub4whsb@ap7ptu6yqyj6> In-Reply-To: <6nev7zfx57h5pkqpgdp4q37xjcj2dxqilsgbb5ac5lhub4whsb@ap7ptu6yqyj6> From: Peter Geoghegan Date: Mon, 2 Dec 2024 16:16:19 -0500 Message-ID: Subject: Re: Incorrect result of bitmap heap scan. To: Andres Freund Cc: Tom Lane , Matthias van de Meent , Konstantin Knizhnik , PostgreSQL Hackers 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 Mon, Dec 2, 2024 at 3:55=E2=80=AFPM Andres Freund w= rote: > I suspect one contributor to this avoiding attention till now was that th= e > optimization is fairly narrow: > > /* > * We can potentially skip fetching heap pages if= we do not need > * any columns of the table, either for checking = non-indexable > * quals or for returning data. This test is a b= it simplistic, as > * it checks the stronger condition that there's = no qual or return > * tlist at all. But in most cases it's probably = not worth working > * harder than that. > */ > need_tuples =3D (node->ss.ps.plan->qual !=3D NIL = || > node->ss.ps.plan->targ= etlist !=3D NIL); > > Even an entry in the targetlist that that does not depend on the current = row > disables the optimization. Good point. I agree that that factor is likely to have masked the problem over the past 6 years. --=20 Peter Geoghegan