Re: Query planner wants to use seq scan - Mailing list pgsql-performance

From Tom Lane
Subject Re: Query planner wants to use seq scan
Date
Msg-id 21872.1445947392@sss.pgh.pa.us
Whole thread Raw
In response to Query planner wants to use seq scan  (Bertrand Paquet <bertrand.paquet@doctolib.fr>)
Responses Re: Query planner wants to use seq scan  (Bertrand Paquet <bertrand.paquet@doctolib.fr>)
Re: Query planner wants to use seq scan  (Bertrand Paquet <bertrand.paquet@doctolib.fr>)
List pgsql-performance
Bertrand Paquet <bertrand.paquet@doctolib.fr> writes:
> We have a slow query. After analyzing, the planner decision seems to be
> discutable : the query is faster when disabling seqscan. See below the two
> query plan, and an extract from pg_stats.

> Any idea about what to change to help the planner ?

Neither one of those plans is very good: you're just hoping that the
Filter condition will let a tuple through sooner rather than later.

If you care about the performance of this type of query, I'd consider
creating an index on (organization_id, status, handled_by) so that all
the conditions can be checked in the index.

            regards, tom lane


pgsql-performance by date:

Previous
From: Alex Ignatov
Date:
Subject: Re: Query planner wants to use seq scan
Next
From: Bertrand Paquet
Date:
Subject: Re: Query planner wants to use seq scan