Skip to content

Commit dfb4221

Browse files
committed
make table ep lookup more performant
1 parent 6b53fcc commit dfb4221

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sp_doc.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ BEGIN
277277
OPEN [obj_cursor]
278278
FETCH NEXT FROM [obj_cursor] INTO @ObjectId
279279
WHILE @@FETCH_STATUS = 0
280-
BEGIN
280+
BEGIN;
281281
282282
INSERT INTO #markdown
283283
SELECT CONCAT(CHAR(13), CHAR(10), ''### '', SCHEMA_NAME(@ObjectId));' +
@@ -389,6 +389,7 @@ BEGIN
389389
INNER JOIN [sys].[extended_properties] AS [ep] WITH(NOLOCK) ON [t].[object_id] = [ep].[major_id]
390390
WHERE [t].[object_id] = @ObjectId
391391
AND [ep].[minor_id] = 0 --On the table
392+
AND [ep].[class] = 1 --Object or col
392393
AND [ep].[name] = @ExtendedPropertyName)
393394
BEGIN;
394395
INSERT INTO #markdown (value)
@@ -401,6 +402,7 @@ BEGIN
401402
INNER JOIN [sys].[extended_properties] AS [ep] WITH(NOLOCK) ON [t].[object_id] = [ep].[major_id]
402403
WHERE [t].[object_id] = @ObjectId
403404
AND [ep].[minor_id] = 0 --On the table
405+
AND [ep].[class] = 1 --Object or col
404406
AND [ep].[name] = @ExtendedPropertyName;
405407
END;';
406408

@@ -412,6 +414,7 @@ BEGIN
412414
INNER JOIN [sys].[extended_properties] AS [ep] WITH(NOLOCK) ON [t].[object_id] = [ep].[major_id]
413415
WHERE [t].[object_id] = @ObjectId
414416
AND [ep].[minor_id] = 0 --On the table
417+
AND [ep].[class] = 1 --Object or col
415418
AND [ep].[name] <> @ExtendedPropertyName)
416419
BEGIN;
417420
INSERT INTO #markdown (value)
@@ -425,6 +428,7 @@ BEGIN
425428
INNER JOIN [sys].[extended_properties] AS [ep] WITH(NOLOCK) ON [t].[object_id] = [ep].[major_id]
426429
WHERE [t].[object_id] = @ObjectId
427430
AND [ep].[minor_id] = 0 --On the table
431+
AND [ep].[class] = 1 --Object or col
428432
AND [ep].[name] <> @ExtendedPropertyName
429433
ORDER BY [ep].[name] ASC;
430434
END;';

0 commit comments

Comments
 (0)