From: Noah Misch <noah@leadboat.com>
To: Sam.Mesh <Sam.Mesh@gmail.com>
Cc: Peter Geoghegan <pg@bowt.ie>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: index not used for bigint without explicit cast
Date: Wed, 18 Jan 2023 21:30:47 -0800
Message-ID: <20230119053047.GA1295127@rfd.leadboat.com> (raw)
In-Reply-To: <CACi6F2kMuEM8jnaXPmWrAKzdnGkyvA+9q1x6bh7sPrOzNRw_hw@mail.gmail.com>
References: <CACi6F2nKR=5Tt21jwXcw2PAF_hfQfV7czvY92NT6onTUgR3=tw@mail.gmail.com>
<CAH2-WzkUxnikXJ_MyYgeZWe=J-+xbMgV+MeyL-XayLgRn1dd4w@mail.gmail.com>
<CACi6F2kMuEM8jnaXPmWrAKzdnGkyvA+9q1x6bh7sPrOzNRw_hw@mail.gmail.com>
On Wed, Jan 18, 2023 at 01:43:43PM -0800, Sam.Mesh wrote:
> Peter, thank you for clarification.
> Could you please double check the following reasoning based on
> https://www.postgresql.org/docs/current/btree-behavior.html?
> - Index search by bigint column requires conversion of limiting
> expressions to bigint type.
> - Conversion from number(19,0) to bigint may cause overflow.
> - So, index search is not possible.
Essentially, yes. This is a query planner limitation, not a fundamental
property of the search problem. "bigintcol = '5.1'::numeric" is equivalent to
"bigintcol <> bigintcol" or "CASE WHEN bigintcol IS NULL THEN NULL ELSE false
END". In contexts that don't distinguish "false" from NULL, it's equivalent
to constant "false". Those observations apply to any search value such that
'search_value'::numeric::bigint::numeric <> 'search_value'::numeric does not
return true, including overflow-error cases. Like many datatype-specific
tricks, the planner isn't aware at this time.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noah@leadboat.com, Sam.Mesh@gmail.com, pg@bowt.ie, pgsql-bugs@lists.postgresql.org
Subject: Re: index not used for bigint without explicit cast
In-Reply-To: <20230119053047.GA1295127@rfd.leadboat.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox