Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mowP2-00081a-19 for pgsql-bugs@arkaria.postgresql.org; Sun, 21 Nov 2021 23:37:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mowOz-0000yS-4q for pgsql-bugs@arkaria.postgresql.org; Sun, 21 Nov 2021 23:37:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mowOy-0000yB-Fj for pgsql-bugs@lists.postgresql.org; Sun, 21 Nov 2021 23:37:40 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mowOv-0002F0-8D for pgsql-bugs@lists.postgresql.org; Sun, 21 Nov 2021 23:37:39 +0000 Received: by mail-ed1-x52c.google.com with SMTP id x15so68890793edv.1 for ; Sun, 21 Nov 2021 15:37:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=wj6TpNxNKqmLn4TfutV3AUyKxMytWbvP95Bn3EEM7dI=; b=U2X8GzbIyjPX1ikQVuM5YH4Dn6WKdSg1oyVIzoxJCsAauZ5t3ldLyJG9TtyH/FbKzl UmCshKUE1wdkgXgLko2XaLgkbrCM7Ad08aIlEFIe2Blo5Gi1qjeVsIcpUOYhoAN32byP vI+6n33iXf/56SSGCi2SAiWllD9Cudxi0FYU+3Hpbcvagnu30btcYy8sEoKMG7TdBLO0 n7JR7g7jCEmueBb1yNOT7m1TaNolSt/Rj1fQBy8GzO9wB1e/uZthtIV4PnuWib3FlUfg KNUjFWnAmRrukhUwMHJA2J7mDC9BGO0bXfs3DjNiXAClux6zNH7m+kVi/4Jwu0LdBX0+ DWRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=wj6TpNxNKqmLn4TfutV3AUyKxMytWbvP95Bn3EEM7dI=; b=gd1EhzC5DhNqTnxZqN+0enFyXiP6DYiKHxoOgm7vS4mAQwX2MkA4l8cCVyyKrflwMT ryR+oUMTVVpGuA9BqoMQdmQ80KflYGWn4kbpzDidsSKuAAGxsvecs9agmOj4fWfzq+Vj p83tHCWeGauVWbROgSOubxCAYcmOK60NsaTFwQOR9z9AxtNldmvjbqoBQxU+IUSvgE6X HoAomI8KYU3MnjOByGfsxon8zyT0VThx1bGzM3LMiGiQOAUKpNdVbomwOQwpBGRpzG0w ozPPD9Yuc84kJ662WBjugIldjkYu6vD0o3wFCecE6b1zwPwHHb9gzo49cMN4mFRY+8M9 CnYA== X-Gm-Message-State: AOAM533iYhhjEw805EN0J4YrSpZaUrX3nKmrknXhgEEr6Q+tvpSl+erD 75rbcKyWK7+iW9jdN0X8Da7bWPBN4ALGZAUuIblSu9Wnc9KyCHMepLy4uJm7hnq+H2AtPmgXgQT JZUCy2cE/jlsdEFm9iSq5nlORDP4d13VGI0Jb/OjKUMcFleTzY9yUQ9wOyoYkSVMl5V81lpzCc3 lHhc1O7DujjOtWdjQSMhGnthvj6UWvgz00WlOgAlDsn93K X-Google-Smtp-Source: ABdhPJw0aOyM74gKZ0zIbNr1MTjICI+d23HkH+Ivfm80HURtebkXl1iUPCu1+YhCyQETYBy81CjurQ== X-Received: by 2002:a17:907:1c1f:: with SMTP id nc31mr34592377ejc.210.1637537854913; Sun, 21 Nov 2021 15:37:34 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-251-104.net.upcbroadband.cz. [86.49.251.104]) by smtp.gmail.com with ESMTPSA id t5sm3292865edd.68.2021.11.21.15.37.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 21 Nov 2021 15:37:34 -0800 (PST) Message-ID: Date: Mon, 22 Nov 2021 00:37:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: BUG #17295: Different query plan with Index Only Scan and Bitmap Index Scan. Content-Language: en-US To: udv.mail@gmail.com, pgsql-bugs@lists.postgresql.org, PG Bug reporting form References: <17295-82a33e30e35c0cd5@postgresql.org> From: Tomas Vondra In-Reply-To: <17295-82a33e30e35c0cd5@postgresql.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, I'm not really sure which part you condides a bug? We simply don't translate between IN() and OR-ed conditions, and there may be some costing differences. So we may generate different plans, and the switch between index scan and bitmap index scan may happen at different points. On 11/20/21 17:52, PG Bug reporting form wrote: > > EXPLAIN SELECT * FROM t WHERE a IN (142,147,153,199); > -- Bitmap Heap Scan on t (cost=3739.74..50987.74 rows=200000 width=8) > | > -- Recheck Cond: (a = ANY ('{142,147,153,199}'::integer[])) > | > -- -> Bitmap Index Scan on t_i (cost=0.00..3689.74 rows=200000 > width=0)| > -- Index Cond: (a = ANY ('{142,147,153,199}'::integer[])) > | This is rather strange, though. Why would this have estimate 200000? The other query has estimate 4, so it can't be because of missing stats etc. Or why would it fix after several minutes? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company