RE: Slow query with aggregate and many LEFT JOINS - Mailing list pgsql-performance

From Igor Neyman
Subject RE: Slow query with aggregate and many LEFT JOINS
Date
Msg-id DM5PR17MB15327D949173FD6AD7CC49F1DA7F0@DM5PR17MB1532.namprd17.prod.outlook.com
Whole thread Raw
In response to Slow query with aggregate and many LEFT JOINS  (kimaidou <kimaidou@gmail.com>)
Responses RE: Slow query with aggregate and many LEFT JOINS
List pgsql-performance

From: kimaidou [mailto:kimaidou@gmail.com]
Sent: Friday, February 22, 2019 10:37 AM
To: pgsql-performance@lists.postgresql.org
Subject: Slow query with aggregate and many LEFT JOINS

 

Hi all,

I need to optimize the following query
http://paste.debian.net/hidden/ef08f864/
I use it to create  a materialized view, but I think there is room for optimization.
I tried to
SET join_collapse_limit TO 15;
with to real difference.

Explain shows that the GROUP AGGREGATE and needed sort kill the performance.
Do you have any hint how to optimize this ?
https://explain.depesz.com/s/6nf

Regards
Michaël

 

Try increasing both: join_collapse_limit and from_collapse_limit to 16 (or even 17).

 

Regards,

Igor Neyman

 

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Aggregate and many LEFT JOIN
Next
From: Igor Neyman
Date:
Subject: RE: Slow query with aggregate and many LEFT JOINS