pgcat
pgcat copied to clipboard
Optimize Rails/ActiveRecord health checks
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:
- ActiveRecord issues a
SELECT 1(or some other health check query). - PgCat parses incoming query, sees that it's a health check and returns the hardcoded result (
1). - All other queries are routed to the DB as before.