From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | neslişah demirci <neslisah(dot)demirci(at)gmail(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Query Performance Issue |
Date: | 2018-12-28 15:32:05 |
Message-ID: | 20181228153205.GM30382@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Thu, Dec 27, 2018 at 10:25:47PM +0300, neslişah demirci wrote:
> Have this explain analyze output :
>
> *https://explain.depesz.com/s/Pra8a <https://explain.depesz.com/s/Pra8a>*
Row counts are being badly underestimated leading to nested loop joins:
|Index Scan using product_content_recommendation_main2_recommended_content_id_idx on product_content_recommendation_main2 prm (cost=0.57..2,031.03 ROWS=345 width=8) (actual time=0.098..68.314 ROWS=3,347 loops=1)
|Index Cond: (recommended_content_id = 3371132)
|Filter: (version = 1)
Apparently, recommended_content_id and version aren't independent condition,
but postgres thinks they are.
Would you send statistics about those tables ? MCVs, ndistinct, etc.
https://wiki.postgresql.org/wiki/Slow_Query_Questions#Statistics:_n_distinct.2C_MCV.2C_histogram
I think the solution is to upgrade (at least) to PG10 and CREATE STATISTICS
(dependencies).
https://www.postgresql.org/docs/10/catalog-pg-statistic-ext.html
https://www.postgresql.org/docs/10/sql-createstatistics.html
https://www.postgresql.org/docs/10/planner-stats.html#PLANNER-STATS-EXTENDED
https://www.postgresql.org/docs/10/multivariate-statistics-examples.html
Justin
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2018-12-29 06:58:28 | Re: Query Performance Issue |
Previous Message | Alexey Bashtanov | 2018-12-28 14:53:58 | Re: Query Performance Issue |