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 1oaCnB-0007qm-3I for pgsql-general@arkaria.postgresql.org; Mon, 19 Sep 2022 09:10:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oaCn9-0007wW-Sn for pgsql-general@arkaria.postgresql.org; Mon, 19 Sep 2022 09:10:15 +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 1oZwA2-0007yf-DP for pgsql-general@lists.postgresql.org; Sun, 18 Sep 2022 15:24:46 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oZw9w-0002QI-Dg for pgsql-general@lists.postgresql.org; Sun, 18 Sep 2022 15:24:45 +0000 Received: by mail-lf1-x12c.google.com with SMTP id f9so42297187lfr.3 for ; Sun, 18 Sep 2022 08:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:subject:to:message-id:from :date:from:to:cc:subject:date; bh=Imj2Jui9yYqxgrN6ZJmU6M8wwo/vxVZa+MFkNn4ZhiU=; b=QzRtNC9hzliXvAV1IyHumcq9Ic6+PfDjWQsl01E2uM9VyLArIkVtARLhVCtkhN7J3x JDugWUhxAak0Lo07T+PyT6cDelbBQ15bJUTnKR5wOmlzmxCmAJ0f114P1WD8u5pKOXat M2MWG35V8aLnblWWfES+hqctgbsqe0Cb3k+iWbU1qpIsv2g5tjqDiakSQonUgpqnEyqD 5ww1TP/UQNfzV/Wo/dlqkzsVHxTETHEnNJwbbCVyX+6//Nina3tl+4BIkEJyZxiKISQx qvXn61h6oI65Fe4ZbGYnL4v9IfFO4jjc2nBJWyunj8At4wC0hxawuwKaXHVAWFyDKxUO xfpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:subject:to:message-id:from :date:x-gm-message-state:from:to:cc:subject:date; bh=Imj2Jui9yYqxgrN6ZJmU6M8wwo/vxVZa+MFkNn4ZhiU=; b=J76jk36tBK1s/UDP7LRipPRJHKA2ZidUwK/wrj4yt2iQtQX+k8RODXCUyY10DFbvVm IkeliL3sFTAxzf4BMr0WVfASL5/HkYzowuKXmMuT+OizrYXTHVN1G/2AExfyibAw+cgI O90W9dMgEaRt7yqF49St+j8K0cA7579jxIUqXepcJSMh26GUzN4rLFYq6aeNWBuisNFq Q9IIl4cDZ71uRbVBNb2e5Y0zRCO6wFOJs0fwTW5ffa1YMXZIJR2oldDgv2Ndk149nb2x Ulns4KQ50GiOzF2UjdcWmVVXwS3nc9D1VbZOQYtgSJ5nUTk6s50oBSn2mecjiv+b9FfA nZKQ== X-Gm-Message-State: ACrzQf1YQKuOoegiutn0rQ6u/5wzmyBYjeNs+HjVwHXk3giZAHMhM0a5 wQiQUaecSk6Mc3/0XvNLci4BweQuVQo= X-Google-Smtp-Source: AMsMyM6sqoNXdSi4jlMxg6gMiC/H2Mfi7HrAGBhqfLQdy/yUuf8PVkVCOKOU5U6L1UF1fZjXT1jqug== X-Received: by 2002:ac2:5e3c:0:b0:49c:9cc3:a530 with SMTP id o28-20020ac25e3c000000b0049c9cc3a530mr4767889lfg.486.1663514678266; Sun, 18 Sep 2022 08:24:38 -0700 (PDT) Received: from [192.168.10.58] ([83.149.249.84]) by smtp.gmail.com with ESMTPSA id cf11-20020a056512280b00b00499b232875dsm4617398lfb.171.2022.09.18.08.24.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Sep 2022 08:24:37 -0700 (PDT) Date: Sun, 18 Sep 2022 18:24:35 +0300 From: =?windows-1251?B?xeLj5e3o6SDP6+jx6ujt?= Message-ID: <519561082.20220918182435@gmail.com> To: pgsql-general@lists.postgresql.org Subject: Suggest using boolean index with (bflag is true) condition for the query with (bflag = true) clause MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1251 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =0D=0AThis is not a bug report but rather a suggestion. Suppose database contains an index on a boolean column like this: create table1(id int, amount float, best_record boolean); create index index1 on table1(best_record) where best_record is true; And suppose we issue a query like this: select * from table1 where best_record =3D true; The planner does not try to use an index for this query because an index co= ndition (bflag is true) does not literally match the query (bflag =3D true)= .=20 But is that reasonable? The index does not cover records where "best_record" is FALSE or NULL. And similarly the query is not interested in any records where "best_record= " is FALSE or NULL. So why not use this index for this query? Thank you.