Re: Optimize query

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Optimize query
Date: 2020-12-15 15:37:21
Message-ID: b29a815e-43cc-435e-36aa-224e7abf1739@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2020-12-15 15:45:08 Re: pg_ctl.exe deleted on abrupt shutdown of Windows
Previous Message Raul Giucich 2020-12-15 14:27:59 Re: Optimize query