A SQL Server–based healthcare-claims system suffers from slow queries, inconsistent logic, and nightly ETL jobs that miss SLAs. This demonstrates how I diagnose the problem with SQL Profiler and execution plans, then fix it at the model level.
I demonstrate a diagnose-then-redesign approach: capture slow queries, deadlocks, and missing indexes with SQL Profiler; read execution plans for key lookups, scans, and join inefficiencies; then redesign fact/dimension tables with SCD Type 2 history, partition large facts by service date, and consolidate logic into governed SQL views feeding Power BI.
A SQL Server–based healthcare claims system suffers from slow queries, inconsistent business logic across reports, and nightly ETL jobs that miss their SLA windows. Analysts wait minutes for results, and the same metric returns different values depending on which report they open.
The first move is measurement, not guessing: use SQL Profiler to capture slow queries, deadlocks, and missing-index events, then analyze execution plans to pinpoint key lookups, table scans, and join inefficiencies.
Sample capture. Click a column header to sort; click a query to see its plan.
| TextData | Duration ms | CPU ms | Reads | Event |
|---|
Two conformed fact tables share the same dimensions, so claims and encounters reconcile against one set of members, providers, and dates. The design keeps a star schema for query speed rather than a normalized snowflake, and folds natural roll-ups — Provider → Group → Network, Date → Month → Quarter → Year — into dimension hierarchies the semantic model can drill.
The redesign centers on set-based T-SQL, targeted indexing, and partitioning:
MERGE for SCD Type 2 loads.-- SCD Type 2 upsert with MERGE: close old rows, insert new versions MERGE dbo.DimProvider AS tgt USING stg.Provider AS src ON tgt.ProviderBK = src.ProviderBK AND tgt.IsCurrent = 1 WHEN MATCHED AND tgt.HashDiff <> src.HashDiff THEN UPDATE SET tgt.IsCurrent = 0, tgt.EndDate = GETDATE() WHEN NOT MATCHED BY TARGET THEN INSERT (ProviderBK, ProviderName, HashDiff, StartDate, IsCurrent) VALUES (src.ProviderBK, src.ProviderName, src.HashDiff, GETDATE(), 1); -- a partition-switch load for FactClaims by ServiceDate follows the same shape
The comparison shows expensive scans and key lookups collapsing into seeks after indexing and model changes.
This example shows how SQL tuning and modeling can, in practice: