This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -49,7 +49,7 @@
|
|||||||
"AYANOVA_USE_URLS": "http://*:7575;",
|
"AYANOVA_USE_URLS": "http://*:7575;",
|
||||||
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
||||||
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
||||||
"AYANOVA_SERVER_TEST_MODE":"true",
|
"AYANOVA_SERVER_TEST_MODE":"false",
|
||||||
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL":"huge",
|
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL":"huge",
|
||||||
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET":"-7",
|
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET":"-7",
|
||||||
"AYANOVA_BACKUP_PG_DUMP_PATH":"C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\"
|
"AYANOVA_BACKUP_PG_DUMP_PATH":"C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\"
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
private readonly ApiServerState serverState;
|
private readonly ApiServerState serverState;
|
||||||
private const int DEFAULT_MAX_RECORDS = 400;
|
private const int DEFAULT_MAX_RECORDS = 400;
|
||||||
private const long MB = (1024 * 1024);
|
private const long MB = (1024 * 1024);
|
||||||
|
private const long KB = 1024;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -198,6 +199,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
maxRecords ??= DEFAULT_MAX_RECORDS;
|
maxRecords ??= DEFAULT_MAX_RECORDS;
|
||||||
|
|
||||||
|
|
||||||
|
//############ DB SIZE TIME SERIES MB
|
||||||
List<MetricDD> DBMetrics = new List<MetricDD>();
|
List<MetricDD> DBMetrics = new List<MetricDD>();
|
||||||
//touniversal is because the parameters are converted to local time here
|
//touniversal is because the parameters are converted to local time here
|
||||||
//but then sent to the query as local time as well and not universal time which is what it should be
|
//but then sent to the query as local time as well and not universal time which is what it should be
|
||||||
@@ -205,15 +208,14 @@ namespace AyaNova.Api.Controllers
|
|||||||
var dsDBTotalSize = DBMetrics.Select(z => new Tuple<double, double>(z.t.ToOADate(), z.DBTotalSize)).ToList();
|
var dsDBTotalSize = DBMetrics.Select(z => new Tuple<double, double>(z.t.ToOADate(), z.DBTotalSize)).ToList();
|
||||||
dsDBTotalSize = Util.DataUtil.LargestTriangleThreeBuckets(dsDBTotalSize, (int)maxRecords) as List<Tuple<double, double>>;
|
dsDBTotalSize = Util.DataUtil.LargestTriangleThreeBuckets(dsDBTotalSize, (int)maxRecords) as List<Tuple<double, double>>;
|
||||||
|
|
||||||
//table distribution, top 10
|
|
||||||
|
|
||||||
|
//############# TOP TABLES KB
|
||||||
|
|
||||||
List<MetricNameLongValue> TopTables = new List<MetricNameLongValue>();
|
List<MetricNameLongValue> TopTables = new List<MetricNameLongValue>();
|
||||||
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
||||||
{
|
{
|
||||||
/*
|
var cmd = @"SELECT
|
||||||
pg_table_size(table_name) AS table_size,
|
|
||||||
pg_indexes_size(table_name) AS indexes_size,
|
|
||||||
*/
|
|
||||||
var cmd=@"SELECT
|
|
||||||
table_name,
|
table_name,
|
||||||
pg_total_relation_size(table_name) AS total_size
|
pg_total_relation_size(table_name) AS total_size
|
||||||
FROM (
|
FROM (
|
||||||
@@ -223,9 +225,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
) AS all_tables
|
) AS all_tables
|
||||||
ORDER BY total_size DESC";
|
ORDER BY total_size DESC";
|
||||||
command.CommandText = cmd;
|
command.CommandText = cmd;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ct.Database.OpenConnection();
|
ct.Database.OpenConnection();
|
||||||
using (var dr = command.ExecuteReader())
|
using (var dr = command.ExecuteReader())
|
||||||
{
|
{
|
||||||
@@ -235,10 +235,10 @@ namespace AyaNova.Api.Controllers
|
|||||||
{
|
{
|
||||||
long tableSize = dr.GetInt64(1);
|
long tableSize = dr.GetInt64(1);
|
||||||
string tableName = dr.GetString(0);
|
string tableName = dr.GetString(0);
|
||||||
tableName=tableName.Replace("\"","").Replace("public.a","");
|
tableName = tableName.Replace("\"", "").Replace("public.a", "");
|
||||||
if (tableSize > 0)
|
if (tableSize > 0)
|
||||||
{
|
{
|
||||||
tableSize = tableSize / MB;
|
tableSize = tableSize / KB;
|
||||||
}
|
}
|
||||||
TopTables.Add(new MetricNameLongValue() { name = tableName, value = tableSize });
|
TopTables.Add(new MetricNameLongValue() { name = tableName, value = tableSize });
|
||||||
}
|
}
|
||||||
@@ -247,8 +247,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//trim out tables less than 1mb (the math above sets anything less than 1mb to zero)
|
//trim out tables less than 1kb (the math above sets anything less than 1kb to zero)
|
||||||
TopTables = TopTables.Where(z => z.value > 0).OrderByDescending(z => z.value).ToList();
|
TopTables = TopTables.Where(z => z.value > 48).ToList();//NOTE: empty tables seem to all be 48kb so that's why this is here
|
||||||
|
|
||||||
long DBTotalSize = 0;
|
long DBTotalSize = 0;
|
||||||
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
||||||
@@ -259,7 +259,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
{
|
{
|
||||||
if (dr.HasRows)
|
if (dr.HasRows)
|
||||||
{
|
{
|
||||||
DBTotalSize = dr.Read() ? (dr.GetInt64(0) / MB) : 0;
|
DBTotalSize = dr.Read() ? (dr.GetInt64(0) / KB) : 0;
|
||||||
}
|
}
|
||||||
ct.Database.CloseConnection();
|
ct.Database.CloseConnection();
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
var ret = new
|
var ret = new
|
||||||
{
|
{
|
||||||
TopTables = TopTables,
|
TopTables = TopTables.OrderByDescending(z => z.value).ToList(),
|
||||||
totalSize = dsDBTotalSize.Select(z => new MetricLong(DateTime.FromOADate(z.Item1), z.Item2 / MB)).ToArray()
|
totalSize = dsDBTotalSize.Select(z => new MetricLong(DateTime.FromOADate(z.Item1), z.Item2 / MB)).ToArray()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user