From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Optimize query
Date: Tue, 15 Dec 2020 09:37:21 -0600
Message-ID: <b29a815e-43cc-435e-36aa-224e7abf1739@gmail.com> (raw)
In-Reply-To: <CALhHtcDZ0WWNW_-p58S7eBQB97XHdXuwC9jkxK5a03ODbe9GGA@mail.gmail.com>
References: <CALhHtcDZ0WWNW_-p58S7eBQB97XHdXuwC9jkxK5a03ODbe9GGA@mail.gmail.com>
On 12/15/20 8:17 AM, Yambu wrote:
> Hi
>
> How would you optimize a query with greater than in where clause eg
>
> select * from table1 where id > 1000
>
> and there is an index on id column
The question as written is unanswerable.
- Why do you think it needs to be optimized?
- What is the table cardinality, and the query cardinality?
- What does EXPLAIN say?
- Have you run ANALYZE on table1?
Bottom line: Postgres *might* think that it is more efficient to scan the
whole table.
--
Angular momentum makes the world go 'round.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ronljohnsonjr@gmail.com
Subject: Re: Optimize query
In-Reply-To: <b29a815e-43cc-435e-36aa-224e7abf1739@gmail.com>
References: <CALhHtcDZ0WWNW_-p58S7eBQB97XHdXuwC9jkxK5a03ODbe9GGA@mail.gmail.com> <b29a815e-43cc-435e-36aa-224e7abf1739@gmail.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