🧪 Make a nice PostgreSQL environment for use on GitLab
Based upon my psqlrc, but have some bootstrap code to show database information upon login, as well as adding macros and prepared statements for common checks.
Prototype login could look something like:
┌─────────────────────┬─────────┐
│ database │ size │
├─────────────────────┼─────────┤
│ gitlabhq_production │ 247 MB │
│ template1 │ 7649 kB │
│ postgres │ 7641 kB │
│ template0 │ 7497 kB │
└─────────────────────┴─────────┘
(4 rows)
Time: 10.023 ms
gitlab-psql@gitlabhq_production=#
But, showing information such as
- Login time (current time)
- Last login time?
- memory usage
- number of connections
- users logged in?
- listen addresses
- replication status and lag
Some macros which I had from a past life:
:show_database_sizes-
:list_statement()to list a prepared statement's content :show_statements:list_function():show_functions:show_cache_hit_rates:show_index_usage_rates:show_indecies_in_cache:show_deadlocks:show_locks-
:show_master_replication_stats(probably rename) -
:show_slave_replication_stats(ditto) :show_pgsql_data_sizes:show_top_ten_pgsql_files:show_running_queries:show_table_sizes
and maybe some of the string searching functions?
:show_top_ten_tables:do_vacuum