RE: Slow query with aggregate and many LEFT JOINS

2019-02-22 Thread Igor Neyman
From: kimaidou [mailto:kimai...@gmail.com] Sent: Friday, February 22, 2019 10:37 AM To: pgsql-performance@lists.postgresql.org<mailto:pgsql-performance@lists.postgresql.org> Subject: Slow query with aggregate and many LEFT JOINS Hi all, I need to optimize the following quer

RE: Slow query with aggregate and many LEFT JOINS

2019-02-22 Thread Igor Neyman
From: kimaidou [mailto:kimai...@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

Slow query with aggregate and many LEFT JOINS

2019-02-22 Thread kimaidou
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 ki