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

Deployment results in non-clustered index being rebuilt on table with partitioned index #202

Closed
zijchen opened this issue Jan 4, 2023 · 0 comments
Assignees
Labels
bug Something isn't working fixed-pending-release Fix in upcoming release performance Impacts DacFx interaction perf or efficiency

Comments

@zijchen
Copy link
Member

zijchen commented Jan 4, 2023

When a table has a partitioned index and a non-clustered index, deploying the dacpac without any changes still result in the non-clustered index being rebuilt.

Repro by creating a sqlproj with this script:

ALTER DATABASE [$(DatabaseName)]
  ADD FILEGROUP [Negative];
GO

ALTER DATABASE [$(DatabaseName)]
  ADD FILEGROUP [Zero];
GO

ALTER DATABASE [$(DatabaseName)]
  ADD FILEGROUP [Positive];
GO

CREATE PARTITION FUNCTION [PartitionFunctionBySign](INT)
  AS RANGE
  FOR VALUES (0, 1);
GO

CREATE PARTITION SCHEME [SignedPartitions]
  AS PARTITION [PartitionFunctionBySign]
  TO ([Negative], [Zero], [Positive]);
GO

CREATE TABLE [dbo].[Table1]
(
  [Id] INT NOT NULL,
  [Quantity] INT NOT NULL,
  [Quantity2] INT NOT NULL,
    CONSTRAINT [PK_Table1] PRIMARY KEY 
        CLUSTERED ([Id], [Quantity])
        ON [SignedPartitions] ([Quantity])
);
GO

CREATE NONCLUSTERED INDEX IX_Table1
  ON [dbo].[Table1] ([Quantity2])
  WITH (DATA_COMPRESSION = ROW);
GO

Deploying the same dacpac a second time without any changes, sqlpackage will still generate a script to rebuild the non-clustered index. Deployment is successful however it adds an unnecessary step and is problematic for large tables.

PRINT N'Altering SqlIndex [dbo].[Table1].[IX_Table1]...';


GO
ALTER INDEX [IX_Table1]
    ON [dbo].[Table1] REBUILD WITH(DATA_COMPRESSION = ROW);


GO

I suspect the bug lies within the Reverse Engineering logic as the extracted dacpac has some differences to the original dacpac built from sqlproj.

@zijchen zijchen added the bug Something isn't working label Jan 4, 2023
@zijchen zijchen self-assigned this Jan 4, 2023
@llali llali added this to the Next Release + 1 milestone Feb 9, 2023
@dzsquared dzsquared added the performance Impacts DacFx interaction perf or efficiency label Feb 9, 2023
@zijchen zijchen added the fixed-pending-release Fix in upcoming release label Feb 23, 2023
@zijchen zijchen closed this as completed May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed-pending-release Fix in upcoming release performance Impacts DacFx interaction perf or efficiency
Projects
None yet
Development

No branches or pull requests

3 participants