pgcat icon indicating copy to clipboard operation
pgcat copied to clipboard

Optimize Rails/ActiveRecord health checks

Open levkk opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe. Frameworks like Rails/ActiveRecord issue a health check on the connection before making it available to the rest of the app. This health check is redundant because we already check if the DB is healthy with our own health checks. It also causes additional latency.

Describe the solution you'd like We should catch this health check query in PgCat and return a result without it reaching the database. This should save a round trip to the DB and the query parser time in Postgres.

Describe alternatives you've considered N/A.

Additional context

The flow would look like this:

  1. ActiveRecord issues a SELECT 1 (or some other health check query).
  2. PgCat parses incoming query, sees that it's a health check and returns the hardcoded result (1).
  3. All other queries are routed to the DB as before.

levkk avatar Aug 13 '22 18:08 levkk