mirror of
https://github.com/discourse/discourse.git
synced 2025-08-21 19:11:18 +08:00
DEV: upgrade mini_sql (#12465)
* DEV: upgrade mini_sql Even though we are not planning on using this quite yet, mini_sql now supports prepared statements. Would like this upgrade merged so we can do some benchmarking. Note, this will not work with pg_bouncer, but sites that are not using it may benefit from the feature. * implement multisite friendly prepared statements
This commit is contained in:
parent
f3eab6a86a
commit
5a1318e3c3
3 changed files with 20 additions and 1 deletions
|
@ -82,6 +82,20 @@ class MiniSqlMultisiteConnection < MiniSql::Postgres::Connection
|
|||
ActiveRecord::Base.connection.raw_connection
|
||||
end
|
||||
|
||||
# make for a multisite friendly prepared statement cache
|
||||
def prepared(condition = true)
|
||||
if condition
|
||||
conn = raw_connection.instance_variable_get(:@mini_sql_prepared_connection)
|
||||
if !conn
|
||||
conn = MiniSql::Postgres::PreparedConnection.new(self)
|
||||
raw_connection.instance_variable_set(:@mini_sql_prepared_connection, conn)
|
||||
end
|
||||
conn
|
||||
else
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def build(sql)
|
||||
CustomBuilder.new(self, sql)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue