Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Server Index options SortInTempDB and DataCompression #30408

Closed
hmajerus opened this issue Mar 5, 2023 · 4 comments · Fixed by #30831
Closed

SQL Server Index options SortInTempDB and DataCompression #30408

hmajerus opened this issue Mar 5, 2023 · 4 comments · Fixed by #30831
Assignees
Labels
area-migrations area-sqlserver closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Milestone

Comments

@hmajerus
Copy link
Contributor

hmajerus commented Mar 5, 2023

I want to be able to use Fluent API to specify more index options. I have a particular interest in SORT_IN_TEMPDB and DATA_COMPRESSION.

Want something like:

indexBuilder.IsSortedInTempDb(true);

indexBuilder.HasDataCompression(DataCompression.Page);

This can be done by following the pattern set by the fill factor option - #20634.

SORT_IN_TEMPDB can be ON or OFF
DATA_COMPRESSION has the options NONE, ROW, and PAGE (link)

I could work this if determined it would be a good first issue.

@roji
Copy link
Member

roji commented Mar 7, 2023

Sure, this qualifies as a good first issue - feel free to work on it.

HasDataCompresion should probably be named UseDataCompression.

@hmajerus
Copy link
Contributor Author

Starting this now. Will take less than a month, but more than a few days depending on my availability.

@BrianMikinski
Copy link

Looking forward to tracking this issue and learning from your work. There are a couple more fluent API items i might attempt to implement if I get some spare time

@hmajerus
Copy link
Contributor Author

hmajerus commented May 5, 2023

When an index has multiple partitions, SQL Server let's you individually specify which data compression methods you want to apply to which partitions:
ALTER INDEX <index_name> ON <table_name>
REBUILD WITH(DATA_COMPRESSION = PAGE ON PARTITIONS(1, 2), DATA_COMPRESSION = ROW ON PARTITIONS(3, 4, 5))

When no partitions are specified, the data compression method is applied to all partitions:
ALTER INDEX <index_name> ON <table_name>
REBUILD WITH(DATA_COMPRESSION = PAGE)

My implementation currently only supports the latter right now. I did not add the partitions yet partially for simplicity, and partially because selfishly it doesn't really apply to me. I can update it now to consider it if desired.

One approach to support both would be to have the data compression annotation either be a DataCompressionType or a Lookup<DataCompressionType, int> depending on which of the above SQL outcomes the user desires. If this were to be added as a future iteration it would not be a breaking change on my current implementation.

@bricelam bricelam self-assigned this Sep 14, 2023
@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Sep 14, 2023
@bricelam bricelam modified the milestones: Backlog, 8.0.0-rc2 Sep 14, 2023
@ajcvickers ajcvickers modified the milestones: 8.0.0-rc2, 8.0.0 Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migrations area-sqlserver closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants