HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to set indexes on a table with a FILESTREAM ROWGUID?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
filestreamwithsetindexesrowguidhowtable

Problem

I'm confused with the requirement for a ROWGUID column on a table with FILESTREAM. How is this column going to be used?

Would it be okay if I used a different primary key (clustered) on the same table while letting that ROWGUID column "just be there" without a clustered index?

Like this:

CREATE TABLE Sample
{
    -- This is going to be clustered
    [Id] int NOT NULL,

    -- What shall I do with it index-wise?
    [RowGuid] uniqueidentifier ROWGUIDCOL NOT NULL UNIQUE
}

Solution

UPDATE: I found something of potential relevance:
http://msdn.microsoft.com/en-us/library/cc949109%28d=printer%29.aspx

They've got a similar example:

CREATE TABLE DocumentStore (
       DocumentID INT IDENTITY PRIMARY KEY,
       Document VARBINARY (MAX) FILESTREAM NULL,
       DocGUID UNIQUEIDENTIFIER NOT NULL ROWGUIDCOL
              UNIQUE DEFAULT NEWID () ON Data_FG1)
ON DocPartScheme (DocumentID)
FILESTREAM_ON DocFSPartScheme;
GO


With a remark:


Notice that to use the DocumentID column as the partitioning column, the underlying nonclustered index that enforces the UNIQUE constraint on the DocGUID must be explicitly placed on a filegroup so that the DocumentID column can be the partitioning column. This means that partition switching is only possible if the UNIQUE constraints are disabled before performing the partition switch, as they are unaligned indexes, and then re-enabled afterwards.

I suppose I'll then leave ROWGUID be as it is, a UNIQUE nonclustered index.

Code Snippets

CREATE TABLE DocumentStore (
       DocumentID INT IDENTITY PRIMARY KEY,
       Document VARBINARY (MAX) FILESTREAM NULL,
       DocGUID UNIQUEIDENTIFIER NOT NULL ROWGUIDCOL
              UNIQUE DEFAULT NEWID () ON Data_FG1)
ON DocPartScheme (DocumentID)
FILESTREAM_ON DocFSPartScheme;
GO

Context

StackExchange Database Administrators Q#15751, answer score: 3

Revisions (0)

No revisions yet.