Thread: slow query to improve performace

slow query to improve performace

From
Ayub Khan
Date:
Hi,

Could some some verify the attached query to verify the performance and suggest some steps to improve it, this query is created as a view. This view is used to get the aggregates of orders based on its current status

Thanks
Attachment

Re: slow query to improve performace

From
Justin Pryzby
Date:
Please provide some more information, like your postgres version and settings.

Some relevant things are included here.

https://wiki.postgresql.org/wiki/Slow_Query_Questions

-- 
Justin



Re: slow query to improve performace

From
Jeff Janes
Date:
On Fri, Feb 25, 2022 at 3:18 PM Ayub Khan <ayub.hp@gmail.com> wrote:
Hi,

Could some some verify the attached query to verify the performance and suggest some steps to improve it, this query is created as a view. This view is used to get the aggregates of orders based on its current status

I don't see how it is possible for that query to yield that plan. For example, what part of that query could have been transformed into this part of the plan "order_status_code <> ALL ('{T,J,C,D}'::bpchar[])"?

Well, I suppose some of the tables used in that query could themselves be views over the same tables?  In that case, we might need to know the definitions of those views.  As well as knowing the version, and seeing the EXPLAIN (ANALYZE, BUFFERS) for the query, run after track_io_timing is turned on.

Cheers,

Jeff