简体   繁体   中英

PostgreSQL query is taking too long to execute on LINUX server

I have recently deployed PostgreSQL database to Linux server and one of the stored procedure is taking around 24 to 26 second to fetch the result. 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,.. etc.

While executing my stored procedure in Linux server CPU usages goes to 100%.

Execution Plan for Windows:

**在此处输入图片描述**

Execution Plan for Linux:

在此处输入图片说明

Let me know if you have any solution for the same.

It also might be because of JIT coming into play in the Linux server and not on windows. Check if the query execution plan on the linux server includes information about JIT. If yes, check if that's the same in windows version. If not, than I suspect that is the case.

JIT might be adding more overhead, hence try changing the jit parameters like jit_above_cost, jit_inline_above_cost to appropriate values as per your system requirements or disable those completely by setting

jit=off

or

jit_above_cost = -1

The culprit seems to be on

billservice.posid = pos.posid

More specificly its doing a Sequence Scan on pos table. It should be doing Index scan.

在此处输入图片说明

Check if you have indexes on these two fileds in the database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM