This commit is contained in:
@@ -227,10 +227,19 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
|
||||
//############# TOP TABLES KB
|
||||
|
||||
int AllTableCount=0;
|
||||
List<MetricNameLongValue> TopTables = new List<MetricNameLongValue>();
|
||||
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
||||
{
|
||||
/*
|
||||
SELECT table_name, pg_total_relation_size(table_name) AS total_size
|
||||
FROM ( SELECT ( table_schema || '.' || table_name )
|
||||
AS table_name FROM information_schema.tables
|
||||
where table_schema not in('pg_catalog','information_schema'))
|
||||
AS all_tables
|
||||
ORDER BY total_size DESC
|
||||
*/
|
||||
|
||||
var cmd = @"SELECT
|
||||
table_name,
|
||||
pg_total_relation_size(table_name) AS total_size
|
||||
@@ -249,6 +258,7 @@ namespace AyaNova.Api.Controllers
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
AllTableCount++;
|
||||
long tableSize = dr.GetInt64(1);
|
||||
string tableName = dr.GetString(0);
|
||||
tableName = tableName.Replace("\"", "").Replace("public.a", "");
|
||||
@@ -265,6 +275,7 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
//trim out tables less than 1kb (the math above sets anything less than 1kb to zero)
|
||||
TopTables = TopTables.Where(z => z.value > 48).ToList();//NOTE: empty tables seem to all be 48kb so that's why this is here
|
||||
int OtherTableCount=AllTableCount-TopTables.Count();
|
||||
|
||||
long DBTotalSize = 0;
|
||||
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
||||
@@ -286,7 +297,7 @@ namespace AyaNova.Api.Controllers
|
||||
{
|
||||
ttSize += tt.value;
|
||||
}
|
||||
TopTables.Add(new MetricNameLongValue() { name = "other", value = DBTotalSize - ttSize });
|
||||
TopTables.Add(new MetricNameLongValue() { name = $"{OtherTableCount} others", value = DBTotalSize - ttSize });
|
||||
|
||||
var ret = new
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user