On Sat, Jan 9, 2021 at 11:30:12PM +0530, dbatoCloud Solution wrote: > Hi Bodo, > > I have resolved this complex query by doing small changes. What I observed the > optimizer choosing nested loop join and the storage type is in AWS EBS type. So > I decided to make random_page_cost=0 also I collected stats + vacuumed as I > said before plus now the query performing very good and I made it down from 23 > minutes into 3 minutes and 15 sec. We usually recommend random_page_cost=1.1 for storage where the random page cost is similar to the sequential cost (which is 1.0). -- Bruce Momjian <bruce@xxxxxxxxxx> https://momjian.us EnterpriseDB https://enterprisedb.com The usefulness of a cup is in its emptiness, Bruce Lee