Question

I have a huge database and my search has been very slow.

In my database has a File table that I like to store to another ndf file?

Anyone ever done this?

Please help me

Was it helpful?

Solution

You did not mention the database engine, so here is an example for MSSQL:

Create a new filegroup:

ALTER DATABASE YourDatabase ADD FILEGROUP FG_FilegroupName;

After that add a new file to the filegroup

ALTER DATABASE YourDatabase ADD FILE (
    NAME = FILE_LogicalName,
    FILENAME = 'Path\To\Data\File.ndf',
    SIZE = 54MB, -- This is the initial size of the file. If you can estimate the size of the file after moving your table, adjust this value to that value.
)

The next step is to drop the clustered index on the table (if exists), then create a new one on the new filegroup you created:

ALTER TABLE YourDatabase.schema.TableName
    ADD CONSTRAINT PK_SchemaName_TableName PRIMARY CLUSTERED (ColumnNames)
        ON [FG_FilegroupName]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top