@@ -1028,8 +1028,8 @@ private function createTable(string $tableName, string $type, array $indexes): v
10281028 /**
10291029 * Create the events daily SummingMergeTree table.
10301030 *
1031- * Minimal schema: only metric, value, time, resource, resourceId , tenant.
1032- * No path/status/userAgent/country/tags — those don't aggregate .
1031+ * Minimal schema: metric, value, time, tenant.
1032+ * Resource-level breakdown uses the raw events table .
10331033 *
10341034 * @throws Exception
10351035 */
@@ -1042,8 +1042,6 @@ private function createDailyTable(): void
10421042 'metric String ' ,
10431043 'value Int64 ' ,
10441044 'time DateTime64(3) ' ,
1045- 'resource Nullable(String) ' ,
1046- 'resourceId Nullable(String) ' ,
10471045 ];
10481046
10491047 if ($ this ->sharedTables ) {
@@ -1053,14 +1051,12 @@ private function createDailyTable(): void
10531051 $ indexes = [
10541052 'INDEX index_metric (metric) TYPE bloom_filter GRANULARITY 1 ' ,
10551053 'INDEX index_time (time) TYPE bloom_filter GRANULARITY 1 ' ,
1056- 'INDEX index_resource (resource) TYPE bloom_filter GRANULARITY 1 ' ,
1057- 'INDEX index_resourceId (resourceId) TYPE bloom_filter GRANULARITY 1 ' ,
10581054 ];
10591055
10601056 $ columnDefs = implode (", \n " , $ columns );
10611057 $ indexDefsStr = ", \n " . implode (", \n " , $ indexes );
10621058
1063- $ dailyOrderBy = $ this ->sharedTables ? '(tenant, metric, resource, resourceId, time) ' : '(metric, resource, resourceId , time) ' ;
1059+ $ dailyOrderBy = $ this ->sharedTables ? '(tenant, metric, time) ' : '(metric, time) ' ;
10641060
10651061 $ createDailyTableSql = "
10661062 CREATE TABLE IF NOT EXISTS {$ escapedDailyTable } (
@@ -1091,13 +1087,13 @@ private function createDailyMaterializedView(): void
10911087 $ escapedDailyMv = $ this ->escapeIdentifier ($ this ->database ) . '. ' . $ this ->escapeIdentifier ($ dailyMvName );
10921088
10931089 if ($ this ->sharedTables ) {
1094- $ innerSelect = "metric, resource, resourceId, tenant, sum(value) as value, toStartOfDay(time) as d " ;
1095- $ innerGroupBy = "metric, resource, resourceId, tenant, d " ;
1096- $ outerSelect = "metric, value, d as time, resource, resourceId, tenant " ;
1090+ $ innerSelect = "metric, tenant, sum(value) as value, toStartOfDay(time) as d " ;
1091+ $ innerGroupBy = "metric, tenant, d " ;
1092+ $ outerSelect = "metric, value, d as time, tenant " ;
10971093 } else {
1098- $ innerSelect = "metric, resource, resourceId, sum(value) as value, toStartOfDay(time) as d " ;
1099- $ innerGroupBy = "metric, resource, resourceId, d " ;
1100- $ outerSelect = "metric, value, d as time, resource, resourceId " ;
1094+ $ innerSelect = "metric, sum(value) as value, toStartOfDay(time) as d " ;
1095+ $ innerGroupBy = "metric, d " ;
1096+ $ outerSelect = "metric, value, d as time " ;
11011097 }
11021098
11031099 $ createDailyMvSql = "
@@ -1610,7 +1606,7 @@ public function findDaily(array $queries = []): array
16101606 $ parsed = $ this ->parseQueries ($ queries , Usage::TYPE_EVENT );
16111607 $ whereData = $ this ->buildWhereClause ($ parsed ['filters ' ], $ parsed ['params ' ]);
16121608
1613- $ dailyColumns = ['metric ' , 'value ' , 'time ' , ' resource ' , ' resourceId ' ];
1609+ $ dailyColumns = ['metric ' , 'value ' , 'time ' ];
16141610 if ($ this ->sharedTables ) {
16151611 $ dailyColumns [] = 'tenant ' ;
16161612 }
0 commit comments