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 1tOLQx-005ieW-OR for pgsql-performance@arkaria.postgresql.org; Thu, 19 Dec 2024 18:39:40 +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 1tOLQw-00FrPa-FH for pgsql-performance@arkaria.postgresql.org; Thu, 19 Dec 2024 18:39:38 +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 1tOLQw-00FrPS-5E for pgsql-performance@lists.postgresql.org; Thu, 19 Dec 2024 18:39:37 +0000 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tOLQs-000d03-U4 for pgsql-performance@lists.postgresql.org; Thu, 19 Dec 2024 18:39:37 +0000 Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-83eb38883b5so37369239f.1 for ; Thu, 19 Dec 2024 10:39:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734633573; x=1735238373; darn=lists.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=x1GwoShpq1KBYmrYZL+hNHNeHFY8yQaNwTy/bXh6vhY=; b=dNFAJoHUUgvcUqPm4o9DHzOz66tbIMSCdfCFZvNzIIYQYOy/tPRm95gki80w/9B4mF omXsCt+3FDgaDNFt9bfeioC1gxJ3mvqI1qxhduN0N7B0Nz4hhJLBifANp6EuVPKQMkTr KtdxPjnnzIMqF4HZAtF7sMwoYDJHzR+aSFykc+/LQAY5cnV8+35TcRRXPe1Yc0EPNFUq 9/qyZZ8j69hn6jRBbpM/3Cvq3zxaG3z5s3cSYzTGRhkif2KYrGmtaGW8/9uRKA6ZgUTD TXCAS98JP3kH5rkbrTQ/yL5Wnm6zkcpA16MF6QOzgIGODUqjJioyVHKxZLmd1YrCN9lQ QILA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734633573; x=1735238373; 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=x1GwoShpq1KBYmrYZL+hNHNeHFY8yQaNwTy/bXh6vhY=; b=DJx6E9nM/fVYtQaUpf+j89FlsBgUwFHJd1J3CmPspP5or8DYg3VETRRyb/pfbOyYMh yc+25Lp0njWhfXLKrVvtWm/SFth6SuBZBPLJuD5N9ycSkSf1nIM1DqSnl9WhrIcxmqpS xtdvyanknjpGqgZhYlyqLkqn+0+9ZATPz7r3QWhZLZoftW1tG+xwU4yuQ0mLBnY476ul Lf2raUbGQhQFTqlveMxRpFU9KIBiju4P/1iziCQD3iUWfIZ0vYLd7mktJst5MjWLDnYw ttbK5Ol9UXH2ury6BI6OdZprcFpQ9Lfz++pU/MSGiWYfYaf5wj/qdr5/dDcIarqgXa2m Eu/Q== X-Gm-Message-State: AOJu0YzmNA6o+TeF1bj9oUHKyJFRVXINwi49hpr8TqLMQhyoIX5d9MVd C6zP+ig7j6OdzRjnq9/YHJHNwmJKvaM3sLdKKKEglAYwACx93E8TiXoUINePyFO+Bk6vvhYlNa2 GyuYAFRDRJhDOxSNdKbWcYX15ito= X-Gm-Gg: ASbGncscACce5KIFJk1wGxIsOM970c6KHlWTGYa3BltGuzSnm9sqc/0CmrCaza4vspR mz+RrEVxxB/rVvQuxXRZbMed78uOi8IKpggVivw== X-Google-Smtp-Source: AGHT+IHeSrfLDyiyotzEpo8aV1SNXJIOjcC9EjTJ4TgQ/o32lkgslMTwCdFhSJRh3RUilbRBsazd78ILrZRzvvkcwtk= X-Received: by 2002:a05:6e02:1a6f:b0:3a7:d672:652d with SMTP id e9e14a558f8ab-3c2d4c834camr1235475ab.16.1734633573570; Thu, 19 Dec 2024 10:39:33 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Thu, 19 Dec 2024 13:38:57 -0500 Message-ID: Subject: Re: Why a bitmap scan in this case? To: Jon Zeppieri Cc: pgsql-performance@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000f7e1a20629a3d9a9" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f7e1a20629a3d9a9 Content-Type: text/plain; charset="UTF-8" > > Why wouldn't it do an index (or, really, an index only) scan in this case Well, it did do an index scan (and a bitmap scan is a pretty good solution here), but as to why no indexonly scan, there is probably not enough assurance that it won't have to hit the heap heavily anyway. Try doing a SET enable_bitmapscan=0; and re-run with EXPLAIN ANALYZE. If you see a large number of "Heap Fetches", that could be why. Vacuum the table and try again after doing SET enable_bitmapscan=1; Cheers, Greg --000000000000f7e1a20629a3d9a9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Why wouldn't it do an index (o= r, really, an index only) scan in this case

Well, it did do an index scan (and a bitmap scan is a pretty=C2=A0good sol= ution here), but as to why no indexonly scan, there is probably not enough = assurance that it won't have to hit the heap heavily anyway. Try doing = a SET enable_bitmapscan=3D0; and re-run with EXPLAIN ANALYZE. If you see a = large number of "Heap Fetches", that could be why. Vacuum the tab= le and try again after doing SET enable_bitmapscan=3D1;

Cheers,
Greg



--000000000000f7e1a20629a3d9a9--