Overview
One of the current limitations of SQL Database in Microsoft Fabric is the lack of support for partition switching.
For DBA who use partition switching in SQL Server or Azure SQL Database to implement sliding-window retention patterns, archival processes, or large-scale data cleanup operations, this limitation can create challenges when migrating workloads to Fabric.
This article describes a practical approach that significantly improved delete performance in a real-world scenario where partition switching was not available.
The Challenge
A customer needed to remove a subset of data from a large table based on a specific business filter (filter_id= 2).
In traditional SQL Server environments, partition switching is often used for this type of workload because it is a metadata-only operation and can move or remove large volumes of data almost instantly.
However, SQL Database in Microsoft Fabric currently does not support partition switching, as documented in the Microsoft Learn article below:
Limitations for SQL database – Microsoft Fabric
Switch partition is a limitation in SQL Database in Fabric
As a result, the customer had to rely on a standard DELETE operation.
Symptoms
Although only a relatively small number of rows were being removed, the delete operation consistently required more than an hour to complete.
Investigation showed that the issue was not caused by the delete predicate itself. Instead, the target table was referenced by multiple foreign key relationships.
During the delete operation, SQL had to validate referential integrity across all dependent tables, introducing significant overhead and causing the query to run much longer than expected.
Root Cause
The performance degradation was due to the presence of multiple foreign key constraints referencing the table, which required validation during the DELETE operation. See this picture for the FKs tables:
This resulted in:
- Row-by-row constraint validation across multiple dependent tables
- Additional overhead during data modification operations
- Increased execution time for DELETE queries.
Alternative Approach
Since partition switching was unavailable, the following strategy was used:
- Temporarily disable or remove foreign key constraints on dependent tables. We used this command:
— Disable all FK constraints referencing the table
ALTER TABLE dbo.ChildTable1 NOCHECK CONSTRAINT FK_ChildTable1_sales_orders;
— … repeat for all the constraints (Foreign Keys) - Delete related data from child tables first.
— Perform DELETE
DELETE FROM dbo.ChildTable1 WHERE order_id = 2; - Execute the delete operation on the parent table.
— Perform DELETE
DELETE FROM dbo.SalesOrders WHERE order_id = 2; - Re-enable and validate the foreign key constraints.
— Re-enable constraints
ALTER TABLE dbo.ChildTable1 WITH CHECK CHECK CONSTRAINT FK_ChildTable1_sales_orders;
This approach reduced the amount of referential integrity work performed during the delete process.
Results
After the foreign key dependencies were removed from the execution path, the delete operation completed in seconds instead of more than an hour.
While this approach does not provide the same metadata-only efficiency as partition switching, it can be an effective workaround for large data cleanup operations in Fabric SQL Database when foreign key enforcement becomes the primary bottleneck.
Key Takeaways
- Partition switching is currently not supported in SQL Database in Microsoft Fabric.
- Workloads that rely on sliding-window retention patterns may require alternative implementation strategies.
- Foreign key constraints can have a significant impact on delete performance.
- For controlled maintenance activities, temporarily disabling or dropping foreign key constraints, performing the cleanup, and then restoring and validating the constraints may dramatically improve performance.
- Always validate the impact on application behavior and data integrity before implementing this approach in production.
Conclusion
The absence of partition switching in SQL Database in Microsoft Fabric does not prevent large-scale data cleanup operations, but it may require a different design approach. By identifying foreign key validation as the true performance bottleneck and restructuring the delete process accordingly, substantial performance improvements can often be achieved while maintaining data integrity.
This can serve as a practical alternative until native partition switching support becomes available in Fabric SQL Database.
