0

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:

**enter image description here**

Execution Plan for Linux:

enter image description here

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

Nayan Rudani
  • 1,029
  • 3
  • 12
  • 21
  • 2
    Please add 1) the procedure / query, 2) sample data, 3) the table/index structure and 4) an `explain analyze` – Jim Jones Jan 28 '20 at 11:50
  • Can you show the stored procedure. It can be multiple of diffrent reasons why its so slow, but i would start by checking indexes if your doing selects from tables... – Denis D. Jan 28 '20 at 11:53
  • That is unreadable. Please tun `EXPLAIN (ANALYZE, BUFFERS) SELECT ...` and copy and paste the output (formatted) into the question. – Laurenz Albe Jan 28 '20 at 12:43
  • Same [cost configuration](https://www.postgresql.org/docs/current/runtime-config-query.html#RUNTIME-CONFIG-QUERY-CONSTANTS)? – Nick Barnes Jan 28 '20 at 12:45
  • Yes same cost configuration, i did't changes anything for both server. – Nayan Rudani Jan 28 '20 at 13:07

2 Answers2

1

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
mlakhara
  • 235
  • 3
  • 11
0

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.

enter image description here

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

Denis D.
  • 138
  • 1
  • 9