简体   繁体   English

PostgreSQL 查询在 LINUX 服务器上执行的时间太长

[英]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.我最近将 PostgreSQL 数据库部署到 Linux 服务器,其中一个存储过程需要大约 24 到 26 秒才能获取结果。 Previously i was deployed PostgreSQL database to windows server and the same stored procedure is taking around only 1 to 1.5 second.以前我将 PostgreSQL 数据库部署到 Windows 服务器,并且相同的存储过程只需要大约 1 到 1.5 秒。

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.并且两台服务器都具有相同的配置,如 RAM、处理器等。

While executing my stored procedure in Linux server CPU usages goes to 100%.在 Linux 服务器中执行我的存储过程时,CPU 使用率达到 100%。

Execution Plan for Windows: Windows 执行计划:

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

Execution Plan for Linux: 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.这也可能是因为 JIT 在 Linux 服务器中而不是在 Windows 上发挥作用。 Check if the query execution plan on the linux server includes information about JIT.检查linux服务器上的查询执行计划是否包含有关JIT的信息。 If yes, check if that's the same in windows version.如果是,请检查在 Windows 版本中是否相同。 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 可能会增加更多的开销,因此尝试根据您的系统要求将 jit_above_cost、jit_inline_above_cost 等 jit 参数更改为适当的值,或者通过设置完全禁用这些参数

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.更具体地说,它在 pos 表上进行序列扫描。 It should be doing Index scan.它应该在做索引扫描。

在此处输入图片说明

Check if you have indexes on these two fileds in the database.检查您是否在数据库中的这两个文件上有索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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