SQL Server / SSMS / Expanding Indexes List Query

SQL Server / SSMS / Expanding Indexes List Query
Same as in previous posts examples Expanding Tables List Query and Expanding Columns List Query I usually do not notice this type of queries working in the background. But recently I end up working with a customer having DB with over 500K indexes, 150K tables and expanding indexes list operation can end up being slower than usual. Here is the code: SELECT i.name AS [Name], 'Server[@Name=' + quotename(CAST( serverproperty(N'Servername') AS sysname),'''') + ']' + '/Database[@Name=' + quotename(db_name(),'''') + ']' + '/Table[@Name=' +...
read more

SQL Server / SSMS / Expanding Columns List Query

SQL Server / SSMS / Expanding Columns List Query
Same as in previous post example Expanding Tables List Query I usually do not notice this type of queries working in the background. But recently I end up working with a customer having DB with 150K tables, some of the tables have more than 500 columns, and expanding columns list operation can end up being slower than usual. Here is the code: SELECT clmns.name AS [Name], 'Server[@Name=' + quotename(CAST( serverproperty(N'Servername') AS sysname),'''') + ']' + '/Database[@Name=' + quotename(db_name(),'''') + ']' + '/Table[@Name=' +...
read more

SQL Server / SSMS / Expanding Tables List Query

SQL Server / SSMS / Expanding Tables List Query
Usually I do not even notice this query working in the background, since this operation is quite fast. But recently I end up working with a customer having DB with 150K tables, and expanding table list operation can be really slow and expensive. Here is the code: SELECT tbl.name AS [Name], SCHEMA_NAME(tbl.schema_id) AS [Schema], 'Server[@Name=' + quotename(CAST( serverproperty(N'Servername') AS sysname),'''') + ']' + '/Database[@Name=' + quotename(db_name(),'''') + ']' + '/Table[@Name=' + quotename(tbl.name,'''') + ' and @Schema=' +...
read more