| From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> | 
|---|---|
| To: | Paul McGarry <paul(at)paulmcgarry(dot)com> | 
| Cc: | pgsql-performance(at)lists(dot)postgresql(dot)org | 
| Subject: | Re: Odd Choice of seq scan | 
| Date: | 2022-12-02 01:21:24 | 
| Message-ID: | 20221202012124.GA14156@telsasoft.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-performance | 
On Fri, Dec 02, 2022 at 11:52:19AM +1100, Paul McGarry wrote:
> Hi there,
> 
> I'm wondering if anyone has any insight into what might make the database
> choose a sequential scan for a query (table defs and plan below) like :
> Plan - seq scan of table:
> =====
> > explain select orders.orderid FROM orders WHERE (orders.orderid IN ('546111') OR orders.orderid IN  (select orderid FROM orderstotrans WHERE (transid IN ('546111'))));
> Plan - Seq scan and filter of index:
> =====
> > explain select orders.orderid FROM orders WHERE (orders.orderid IN ('546111') OR orders.orderid IN  (select orderid FROM orderstotrans WHERE (transid IN ('546111'))));
Could you show explain analyze ?
Show the size of the table and its indexes 
And GUC settings
And the "statistics" here:
https://wiki.postgresql.org/wiki/Slow_Query_Questions#Statistics:_n_distinct.2C_MCV.2C_histogram
Maybe on both a well-behaving instance and a badly-beving instance.
-- 
Justin
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ronuk Raval | 2022-12-02 05:37:50 | Re: Odd Choice of seq scan | 
| Previous Message | Paul McGarry | 2022-12-02 00:52:19 | Odd Choice of seq scan |