PERF: disable prepared statements

see: https://github.com/rails/rails/issues/21992
This commit is contained in:
Sam 2015-10-19 14:02:22 +11:00
parent d8960007ca
commit dfe3ecb914
4 changed files with 19 additions and 3 deletions

View File

@ -4,6 +4,19 @@ class Admin::DiagnosticsController < Admin::AdminController
layout false
skip_before_filter :check_xhr
def dump_statement_cache
statements = Post.exec_sql("select * from pg_prepared_statements").to_a
text = ""
statements.each do |row|
text << "name: #{row["name"]} sql: #{row["statement"]}\n"
end
text << "\n\nCOUNT #{statements.count}"
render text: text, content_type: Mime::TEXT
end
def memory_stats
text = nil

View File

@ -1,4 +1,5 @@
development:
prepared_statements: false
adapter: postgresql
database: discourse_development
min_messages: warning
@ -25,6 +26,7 @@ test:
# profile db is used for benchmarking using the script/bench.rb script
profile:
prepared_statements: false
adapter: postgresql
database: discourse_profile
min_messages: warning

View File

@ -39,9 +39,9 @@ db_username = discourse
# password used to access the db
db_password =
# allow usage of prepared statements, must be disabled for
# pgpool transaction pooling
db_prepared_statements = true
# Disallow prepared statements
# see: https://github.com/rails/rails/issues/21992
db_prepared_statements = false
# hostname running the forum
hostname = "www.example.com"

View File

@ -205,6 +205,7 @@ Discourse::Application.routes.draw do
get "memory_stats"=> "diagnostics#memory_stats", constraints: AdminConstraint.new
get "dump_heap"=> "diagnostics#dump_heap", constraints: AdminConstraint.new
get "dump_statement_cache"=> "diagnostics#dump_statement_cache", constraints: AdminConstraint.new
end # admin namespace