Class: PgHero::Database

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Methods::Users

#create_user, #drop_user

Methods included from Methods::Tables

#table_caching, #table_hit_rate, #table_stats, #unused_tables

Methods included from Methods::System

#access_key_id, #connection_stats, #cpu_usage, #rds_stats, #read_iops_stats, #region, #replication_lag_stats, #secret_access_key, #system_stats_enabled?, #write_iops_stats

Methods included from Methods::SuggestedIndexes

#autoindex, #autoindex_all, #best_index, #suggested_indexes, #suggested_indexes_by_query, #suggested_indexes_enabled?

Methods included from Methods::Space

#capture_space_stats, #database_size, #relation_sizes

Methods included from Methods::Sequences

#sequence_danger, #sequences

Methods included from Methods::Replica

#replica?, #replication_lag

Methods included from Methods::QueryStats

#capture_query_stats, #disable_query_stats, #enable_query_stats, #historical_query_stats_enabled?, #insert_stats, #query_stats, #query_stats_available?, #query_stats_enabled?, #query_stats_extension_enabled?, #query_stats_readable?, #reset_query_stats, #slow_queries, #supports_query_hash?, #supports_query_stats_user?

Methods included from Methods::Queries

#blocked_queries, #locks, #long_running_queries, #running_queries

Methods included from Methods::Maintenance

#autovacuum_danger, #maintenance_info, #transaction_id_danger

Methods included from Methods::Kill

#kill, #kill_all, #kill_long_running_queries

Methods included from Methods::Indexes

#duplicate_indexes, #index_caching, #index_hit_rate, #index_usage, #indexes, #invalid_indexes, #missing_indexes, #unused_indexes

Methods included from Methods::Explain

#explain

Methods included from Methods::Connections

#connection_sources, #total_connections

Methods included from Methods::Basic

#database_name, #server_version, #settings, #ssl_used?

Constructor Details

#initialize(id, config) ⇒ Database

Returns a new instance of Database.



21
22
23
24
# File 'lib/pghero/database.rb', line 21

def initialize(id, config)
  @id = id
  @config = config || {}
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



19
20
21
# File 'lib/pghero/database.rb', line 19

def config
  @config
end

#idObject (readonly)

Returns the value of attribute id.



19
20
21
# File 'lib/pghero/database.rb', line 19

def id
  @id
end

Instance Method Details

#cache_hit_rate_thresholdObject



38
39
40
# File 'lib/pghero/database.rb', line 38

def cache_hit_rate_threshold
  (config["cache_hit_rate_threshold"] || PgHero.config["cache_hit_rate_threshold"] || PgHero.cache_hit_rate_threshold).to_i
end

#capture_query_stats?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/pghero/database.rb', line 34

def capture_query_stats?
  config["capture_query_stats"] != false
end

#db_instance_identifierObject



30
31
32
# File 'lib/pghero/database.rb', line 30

def db_instance_identifier
  @db_instance_identifier ||= @config["db_instance_identifier"]
end

#long_running_query_secObject



54
55
56
# File 'lib/pghero/database.rb', line 54

def long_running_query_sec
  (config["long_running_query_sec"] || PgHero.config["long_running_query_sec"] || PgHero.long_running_query_sec).to_i
end

#nameObject



26
27
28
# File 'lib/pghero/database.rb', line 26

def name
  @name ||= @config["name"] || id.titleize
end

#slow_query_callsObject



50
51
52
# File 'lib/pghero/database.rb', line 50

def slow_query_calls
  (config["slow_query_calls"] || PgHero.config["slow_query_calls"] || PgHero.slow_query_calls).to_i
end

#slow_query_msObject



46
47
48
# File 'lib/pghero/database.rb', line 46

def slow_query_ms
  (config["slow_query_ms"] || PgHero.config["slow_query_ms"] || PgHero.slow_query_ms).to_i
end

#total_connections_thresholdObject



42
43
44
# File 'lib/pghero/database.rb', line 42

def total_connections_threshold
  (config["total_connections_threshold"] || PgHero.config["total_connections_threshold"] || PgHero.total_connections_threshold).to_i
end