Class: SqlGenius::Core::Ai::WorkloadDigest
- Inherits:
-
Object
- Object
- SqlGenius::Core::Ai::WorkloadDigest
- Defined in:
- lib/sql_genius/core/ai/workload_digest.rb
Overview
Produces a high-level executive summary of the query workload by pulling the top statements from performance_schema and asking the LLM to characterize read/write ratio, access patterns, waste concentration, and highest-leverage optimization opportunities.
Construct with:
connection - a Core::Connection implementation
client - a Core::Ai::Client
config - the Core::Ai::Config
Call:
.call() -> Hash with "digest" key containing markdown analysis
Constant Summary collapse
- TOP_N =
30
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(connection, client, config) ⇒ WorkloadDigest
constructor
A new instance of WorkloadDigest.
Constructor Details
#initialize(connection, client, config) ⇒ WorkloadDigest
Returns a new instance of WorkloadDigest.
21 22 23 24 25 |
# File 'lib/sql_genius/core/ai/workload_digest.rb', line 21 def initialize(connection, client, config) @connection = connection @client = client @config = config end |
Instance Method Details
#call ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sql_genius/core/ai/workload_digest.rb', line 27 def call stats = Analysis::QueryStats.new(@connection).call(sort: "total_time", limit: TOP_N) formatted = format_stats(stats) = [ { role: "system", content: system_prompt }, { role: "user", content: user_prompt(formatted, stats.length) }, ] @client.chat(messages: ) end |