From c3c2dfdb31889070f426c5a6c66d599f0204facf Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Mon, 6 Feb 2023 18:21:02 -0800 Subject: [PATCH] handle large databases (#1845) --- .../Connection/ListDatabaseRequestHandler.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/Connection/ListDatabaseRequestHandler.cs b/src/Microsoft.SqlTools.ServiceLayer/Connection/ListDatabaseRequestHandler.cs index 1efb37d3..05eeba8f 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Connection/ListDatabaseRequestHandler.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Connection/ListDatabaseRequestHandler.cs @@ -166,12 +166,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection { get { + // NOTES: Converting the size to BIGINT is need to handle the large database scenarios. + // size column in sys.master_files represents the number of pages and each page is 8 KB + // The end result is size in MB. return @" WITH db_size AS ( - SELECT database_id, CAST(SUM(size) * 8.0 / 1024 AS INTEGER) size + SELECT database_id, CAST(SUM(CAST(size AS BIGINT)) * 8.0 / 1024 AS BIGINT) size FROM sys.master_files GROUP BY database_id ),