Created
January 12, 2022 21:28
-
-
Save blairanderson/22ee42121b279baea3c95835c762d04f to your computer and use it in GitHub Desktop.
get some data from pg_stats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
result_set = ApplicationRecord.connection.select_all("select * from pg_stat_user_tables") | |
column_types = result_set.column_types.dup | |
columns = result_set.columns.dup | |
results = result_set.rows.map { |row| columns.zip(row).to_h } | |
puts JSON.pretty_generate(results) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment