I have recently deployed PostgreSQL database on Linux server.
One of the stored procedure is taking around 20 to 24second.I have executed same stored procedure in blank database as well(no any row return) and it is taking same time. I found that slowness occurs because of aggregate function.
Here if i removed function ARRAY_TO_JSON(ARRAY_AGG(
then result will be fetch within second.
Below is my code snippet:
SELECT ARRAY_TO_JSON(ARRAY_AGG(ROW_TO_JSON(A))) FROM (
select billservice.billheaderid,billservice.billserviceid AS billserviceid,.....(around 120 columns in select ).....
)A;
Explain Execution Plan:
Previously i was deployed PostgreSQL database to windows server and the same stored procedure is taking around only 1 to 1.5 second.
In both cases i have tested with same database with same amount of data. and also both server have same configuration like RAM, Processor. And also have same PostgreSQL configuration.
While executing my stored procedure in Linux server CPU usages goes to 100%.
Let me know if you have any solution for the same.