Use an empty query instead of SELECT 1
Using an empty query skips the PG query planner so it is more efficient
This commit is contained in:
parent
2fd78b126c
commit
8325d07976
@ -1,3 +1,9 @@
|
||||
* Use an empty query to check if the PostgreSQL connection is still active
|
||||
|
||||
An empty query is faster than `SELECT 1`.
|
||||
|
||||
*Heinrich Lee Yu*
|
||||
|
||||
* Add `ActiveRecord::Base#previously_persisted?`
|
||||
|
||||
Returns `true` if the object has been previously persisted but now it has been deleted.
|
||||
|
@ -292,7 +292,7 @@ def self.database_exists?(config)
|
||||
# Is this connection alive and ready for queries?
|
||||
def active?
|
||||
@lock.synchronize do
|
||||
@connection.query "SELECT 1"
|
||||
@connection.query ";"
|
||||
end
|
||||
true
|
||||
rescue PG::Error
|
||||
|
Loading…
Reference in New Issue
Block a user