Обсуждение: Slow Running Queries in Azure PostgreSQL
Hi Team,
Greetings,
We are facing an issue with long running queries in PostgreSQL Database. We recently migrated the database from Oracle to PostgreSQL and we found that there are approx. 4 to 5 queries which was running in oracle in 5 mins and it is taking more than 50 mins in PostgreSQL. We checked every parameter in PostgreSQL, but it is not helping.
I am attaching the query and explain plan with Analyze option in the attachment, but it is not helping.
Request you to please help and assist on this as it is hampering the productivity and effecting the business.
Thanks and Regards,
Mukesh Kumar
Вложения
On Tue, Feb 22, 2022 at 02:11:58PM +0000, Kumar, Mukesh wrote: > -> Hash Join (cost=6484.69..43117.63 rows=1 width=198) (actual time=155.508..820.705 rows=52841 loops=1)" > Hash Cond: (((lms_doc_property_rights_assoc.doc_sid_c)::text = (lms_doc_propright_status_assoc.doc_sid_c)::text)AND ((lms_property_rights_base.property_sid_k)::text = (lms_doc_propright_status_assoc.property_sid_c)::text))" Your problem seems to start here. It thinks it'll get one row but actually gets 53k. You can join those two tables on their own to understand the problem better. Is either or both halves of the AND estimated well ? If both halves are individually estimated well, but estimated poorly together with AND, then you have correlation. Are either of those conditions redundant with the other ? Half of the AND might be unnecessary and could be removed. -- Justin
Hi Justin , Thanks for your help , After committing 1 parameter , the whole query executed in less than 1 min. Thanks and Regards, Mukesh Kumar -----Original Message----- From: Justin Pryzby <pryzby@telsasoft.com> Sent: Wednesday, February 23, 2022 2:57 AM To: Kumar, Mukesh <MKumar@peabodyenergy.com> Cc: pgsql-performance@postgresql.org Subject: Re: Slow Running Queries in Azure PostgreSQL On Tue, Feb 22, 2022 at 02:11:58PM +0000, Kumar, Mukesh wrote: > -> Hash Join (cost=6484.69..43117.63 rows=1 width=198) (actual time=155.508..820.705 rows=52841 loops=1)" > Hash Cond: (((lms_doc_property_rights_assoc.doc_sid_c)::text = (lms_doc_propright_status_assoc.doc_sid_c)::text)AND ((lms_property_rights_base.property_sid_k)::text = (lms_doc_propright_status_assoc.property_sid_c)::text))" Your problem seems to start here. It thinks it'll get one row but actually gets 53k. You can join those two tables on theirown to understand the problem better. Is either or both halves of the AND estimated well ? If both halves are individually estimated well, but estimated poorly together with AND, then you have correlation. Are either of those conditions redundant with the other ? Half of the AND might be unnecessary and could be removed. -- Justin