Class: SqlGenius::Core::Analysis::ServerOverview::Postgresql
- Inherits:
-
Object
- Object
- SqlGenius::Core::Analysis::ServerOverview::Postgresql
- Defined in:
- lib/sql_genius/core/analysis/server_overview.rb
Overview
PostgreSQL implementation. Reads connection/database stats from pg_stat_activity and pg_stat_database; reads tunable settings via pg_settings; populates the ‘innodb` block with shared_buffers and the buffer cache hit rate so the existing UI continues to render.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(connection) ⇒ Postgresql
constructor
A new instance of Postgresql.
Constructor Details
#initialize(connection) ⇒ Postgresql
Returns a new instance of Postgresql.
149 150 151 |
# File 'lib/sql_genius/core/analysis/server_overview.rb', line 149 def initialize(connection) @connection = connection end |
Instance Method Details
#call ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/sql_genius/core/analysis/server_overview.rb', line 153 def call version = @connection.select_value("SELECT version()").to_s uptime_seconds = @connection.select_value( "SELECT EXTRACT(EPOCH FROM (now() - pg_postmaster_start_time()))::bigint", ).to_i { server: server_block(version, uptime_seconds), connections: connections_block, innodb: innodb_block, queries: queries_block(uptime_seconds), } end |