Re: Optimize query - Mailing list pgsql-general

From Ron
Subject Re: Optimize query
Date
Msg-id b29a815e-43cc-435e-36aa-224e7abf1739@gmail.com
Whole thread Raw
In response to Optimize query  (Yambu <hyambu@gmail.com>)
List pgsql-general
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.

pgsql-general by date:

Previous
From: Raul Giucich
Date:
Subject: Re: Optimize query
Next
From: Adrian Klaver
Date:
Subject: Re: pg_ctl.exe deleted on abrupt shutdown of Windows