Class: SqlGenius::Core::Ai::VariableReviewer
- Inherits:
-
Object
- Object
- SqlGenius::Core::Ai::VariableReviewer
- Defined in:
- lib/sql_genius/core/ai/variable_reviewer.rb
Overview
Reviews MySQL configuration variables against best practices for the observed workload. Gathers SHOW GLOBAL VARIABLES (filtered to ~20 performance-relevant keys) and SHOW GLOBAL STATUS, then asks the LLM to identify misconfigurations.
Constant Summary collapse
- RELEVANT_VARIABLES =
[ "innodb_buffer_pool_size", "innodb_log_file_size", "innodb_flush_log_at_trx_commit", "max_connections", "query_cache_type", "sort_buffer_size", "join_buffer_size", "tmp_table_size", "max_heap_table_size", "thread_cache_size", "table_open_cache", "innodb_file_per_table", "innodb_flush_method", "binlog_format", "sync_binlog", "innodb_io_capacity", "innodb_read_io_threads", "innodb_write_io_threads", "long_query_time", "slow_query_log", "performance_schema", ].freeze
- RELEVANT_STATUS_KEYS =
[ "Innodb_buffer_pool_reads", "Innodb_buffer_pool_read_requests", "Created_tmp_disk_tables", "Created_tmp_tables", "Sort_merge_passes", "Threads_created", "Threads_connected", "Max_used_connections", "Slow_queries", "Questions", "Uptime", ].freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(client, config, connection) ⇒ VariableReviewer
constructor
A new instance of VariableReviewer.
Constructor Details
#initialize(client, config, connection) ⇒ VariableReviewer
Returns a new instance of VariableReviewer.
49 50 51 52 53 |
# File 'lib/sql_genius/core/ai/variable_reviewer.rb', line 49 def initialize(client, config, connection) @client = client @config = config @connection = connection end |
Instance Method Details
#call ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/sql_genius/core/ai/variable_reviewer.rb', line 55 def call if @connection.server_version.postgresql? raise Core::UnsupportedDialect.for_postgresql("Variable Config Reviewer") end variables = fetch_variables status = fetch_status = [ { role: "system", content: system_prompt }, { role: "user", content: user_prompt(variables, status) }, ] @client.chat(messages: ) end |