Skip to content

Commit ec2d06c

Browse files
committed
Refactor CollectionCipher stored procedures and update index to include Type column
- Updated [CollectionCipher_ReadSharedByOrganizationId] and migration script to select specific columns with brackets for consistency. - Modified the [IX_Collection_OrganizationId_IncludeAll] index to include the [Type] column for improved query performance.
1 parent 9cffd05 commit ec2d06c

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/Sql/dbo/Stored Procedures/CollectionCipher_ReadSharedByOrganizationId.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ BEGIN
55
SET NOCOUNT ON
66

77
SELECT
8-
CC.CollectionId,
9-
CC.CipherId
8+
CC.[CollectionId],
9+
CC.[CipherId]
1010
FROM
1111
[dbo].[CollectionCipher] CC
1212
INNER JOIN

src/Sql/dbo/Tables/Collection.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ GO
1414

1515
CREATE NONCLUSTERED INDEX [IX_Collection_OrganizationId_IncludeAll]
1616
ON [dbo].[Collection]([OrganizationId] ASC)
17-
INCLUDE([CreationDate], [Name], [RevisionDate]);
17+
INCLUDE([CreationDate], [Name], [RevisionDate], [Type]);
1818
GO
1919

util/Migrator/DbScripts/2025-09-03_00_CollectionCipherManySharedByOrganization.sql

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ BEGIN
55
SET NOCOUNT ON
66

77
SELECT
8-
CC.CollectionId,
9-
CC.CipherId
8+
CC.[CollectionId],
9+
CC.[CipherId]
1010
FROM
1111
[dbo].[CollectionCipher] CC
1212
INNER JOIN
@@ -15,3 +15,16 @@ BEGIN
1515
C.[OrganizationId] = @OrganizationId
1616
AND C.[Type] = 0 -- SharedCollections only
1717
END
18+
GO
19+
20+
-- Update [IX_Collection_OrganizationId_IncludeAll] index to include [Type] column
21+
IF EXISTS(SELECT name FROM sys.indexes WHERE name = 'IX_Collection_OrganizationId_IncludeAll' AND object_id = OBJECT_ID('[dbo].[Collection]'))
22+
BEGIN
23+
DROP INDEX [IX_Collection_OrganizationId_IncludeAll] ON [dbo].[Collection]
24+
END
25+
GO
26+
27+
CREATE NONCLUSTERED INDEX [IX_Collection_OrganizationId_IncludeAll]
28+
ON [dbo].[Collection]([OrganizationId] ASC)
29+
INCLUDE([CreationDate], [Name], [RevisionDate], [Type])
30+
GO

0 commit comments

Comments
 (0)