Performance issue post upgrade on Version 13 - Incorrect Estimation Cost choosing Hash Aggregate-Nested Left Loop Join - Mailing list pgsql-bugs

From Prajna Shetty
Subject Performance issue post upgrade on Version 13 - Incorrect Estimation Cost choosing Hash Aggregate-Nested Left Loop Join
Date
Msg-id MAZPR01MB546945FEA4E21EE7C8E532FB92169@MAZPR01MB5469.INDPRD01.PROD.OUTLOOK.COM
Whole thread Raw
Responses Re: Performance issue post upgrade on Version 13 - Incorrect Estimation Cost choosing Hash Aggregate-Nested Left Loop Join  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs

Hello Team,

 

There is change in query plan in 12.4 version and Version 13 resulting in performance slowness post upgrade.

 

  • In 12.4 version, Sort Operation Group Aggregate is selected which results to Merge Join. Query takes ~5 seconds.
  • In 13.5 version, optimizer wrongly estimates and due to new Disk Based Hash Aggregate feature, it prefers Hash Aggregate instead of Sort Operation which finally blocks merge-join and chooses Nested Loop Left Join. Query takes ~5 minutes.

 

When we increase work_mem to 23 MB, Disk Usage gets cleared from Query Plan but still Optimizer estimates Hash Aggregate-Nested Loop Left Join (compared to Sort-Merge Join) causing slowness. Query takes ~22 seconds.

 

Version 13 query plan has lower estimated cost than that of 12.4 which implies 13.5 planner thought it found a better plan, but it is running slower.

 

12.4 Version:

"Merge Right Join  (cost=202198.78..295729.10 rows=1 width=8) (actual time=1399.727..5224.574 rows=296 loops=1)"

 

13.5 version:-

"Nested Loop Left Join  (cost=196360.90..287890.45 rows=1 width=8) (actual time=3209.577..371300.693 rows=296 loops=1)"

 

 

 

Thanks & Regards,

 

Prajna Shetty
Technical Specialist,

Data Platform Support & Delivery




http://www.mindtree.com/email/disclaimer.html
Attachment

pgsql-bugs by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: BUG #17443: Select command does not use brin index when enable_seqscan = on
Next
From: PG Bug reporting form
Date:
Subject: BUG #17444: ERROR: found xmin 215633 from before relfrozenxid 1280585