0

we have a quite powerful PostgreSQL-Instance running in a Kubernetes cluster with actually quite low usage. We are facing the problem that every fifth/sixth/seventh time we run the query it is significantly slower (5s instead of 100ms). You can find an example query, but we are facing the same problem with several other queries as well. The query planner (EXPLAIN ANALYSE) show all the time the same execution plan.

SELECT count(*) AS "count"
FROM "administrative_areas"."flurstuecke" AS "flurstuecke"
WHERE "flurstuecke"."flur_id" = 8554

Our storage is based on Netapp and integrated into Kubernetes with Trident. We can not see any high IOPS values, high CPU load or memory consumption.

Does anyone have an idea or can point us in the right direction?

eth4io
  • 288
  • 4
  • 15
GIS Friend
  • 101
  • 1
  • 2
  • See [this post](https://stackoverflow.com/questions/59603244/first-postgres-query-is-very-slow-50x-slower-than-subsequent) – clamp Jan 07 '20 at 19:41
  • 1
    It's possible there's resource contention. Is something locking the table or rows? Check for [locking](https://github.com/heroku/heroku-pg-extras/blob/master/commands/locks.js#L20) and [blocking](https://github.com/heroku/heroku-pg-extras/blob/master/commands/blocking.js#L8) queries. – Schwern Jan 08 '20 at 03:28
  • Are you using prepared statements or PL/pgSQL functions? – Laurenz Albe Jan 08 '20 at 07:24

0 Answers0