1

I am debugging a high CPU load issue with Azure PostgreSQL flexible server. In the time window where CPU usage spikes I am seeing a lot of utility queries. They don't take long to process but there are hundred thousands of them.

enter image description here

The queries are all DISCARD ALL queries. What are those queries for and is it normal to see so much of them?

1 Answers1

3

DISCARD resets your database connection to "factory default".

I guess you're using some form of connection pooling. That's a good thing because opening a connection consumes a significant amount of CPU. However, before reusing a connection, it has to be reset, which is what DISCARD does.

The high number of DISCARDs is probably just a consequence of a high number of clients getting connections from the pool to do some work. So, a symptom of your issue, but not the cause.

If you're seeing a huge number of DISCARD's compared to other queries, then... maybe you have something that opens and closes a connection in a loop, or opens a connection every time it wants to do a query instead of keeping it open.

bobflux
  • 1,776
  • 1
  • 9
  • 7