Demonstration — illustrative, not a historical claim

SQL Performance & Data Modeling

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.

Executive Summary

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.

6 tables
Dimensional model
~80%
Query latency reduction (illustrative)
100%
ETL SLA adherence (illustrative)
SCD 2
Full dimension history

01 Problem — example scenario

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.

02 Constraints

03 Diagnosis — SQL Profiler & execution plans

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.

Illustrative capture. Click a column header to sort; click a query to see its plan.

SQL Server Profiler · Slow-query capture6 EVENTS · SORT: DURATION ▼
TextData Duration ms CPU ms Reads Event

04 Dimensional model — star schema

Two conformed fact tables share the same dimensions, so claims and encounters reconcile against one set of members, providers, and dates.

Claims star schema ERD — DimMember and DimProvider (SCD Type 2), DimDate, DimDiagnosis, DimServiceLine and DimPayer joined one-to-many to the FactClaims fact, showing primary keys, foreign keys, and measures

05 Solution demonstration

The redesign centers on set-based T-SQL, targeted indexing, and partitioning:

usp_Load_DimProvider_SCD2.sqlT-SQL
-- 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

06 Before / after — execution plan comparison

The comparison (illustrative) shows expensive scans and key lookups collapsing into seeks after indexing and model changes.

Execution Plan · Claims by plan typeTRACKS THE SELECTED QUERY

07 Outcome — demonstration

This example shows how SQL tuning and modeling can, in practice:

← Previous01 · Power BI + SOX Next →03 · ETL + Governance