Changes between Initial Version and Version 1 of NonClusteredIndexes


Ignore:
Timestamp:
02/08/26 17:25:47 (3 weeks ago)
Author:
185022
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NonClusteredIndexes

    v1 v1  
     1= Некластерирани индекси
     2
     3Некластерираните индекси се избрани според најчестите операции:
     4==== O1: Времеплов на `encounters` по пациент
     5
     6{{{#!sql
     7select *
     8from encounters
     9where patient = @patient
     10    and [start] >= @from and [start] < @to
     11order by [start];
     12go
     13}}}
     14
     15==== O2: `observations` за еден `encounter`
     16
     17{{{#!sql
     18select *
     19from observations
     20where encounter = @encounter
     21order by [date];
     22go
     23}}}
     24
     25==== O3: `conditions` за еден пациент
     26
     27{{{#!sql
     28select *
     29from conditions
     30where patient = @patient
     31order by [start];
     32go
     33}}}
     34
     35==== O4: `medications` за пациент
     36
     37{{{#!sql
     38select *
     39from medications
     40where patient = @patient
     41order by [start];
     42go
     43}}}
     44
     45== `encounters`
     46
     47{{{#!sql
     48create nonclustered index IX_Encounters_Patient_Start
     49on dbo.encounters(patient, [start])
     50include (stop, encounterclass, code, description, payer, provider, organization, base_encounter_cost, total_claim_cost, payer_coverage);
     51go
     52}}}
     53
     54Овој индекс ја поддржува О1 - бара по пациент, опсег по `start`.
     55
     56`include` избегнува пребарување по типични колони.
     57
     58== `observations`
     59
     60{{{#!sql
     61create nonclustered index IX_Observations_Encounters_Date
     62on dbo.observations(encounter, [date])
     63include (patient, category, code, description, value, units, type);
     64go
     65}}}
     66
     67Овој индекс ја поддржува О2 - пребарува по encounter, подредува по датум.
     68
     69== `conditions`
     70
     71{{{#!sql
     72create nonclustered index IX_Conditions_Patient_Start
     73on dbo.conditions(patient, [start])
     74include (stop, encounter, system, code, description);
     75go
     76
     77create nonclustered index IX_Conditions_Encounter
     78on dbo.conditions(encounter)
     79include (patient, [start], stop, system, code, description);
     80go
     81}}}
     82
     83Првиот индекс ја поддржува О3.
     84
     85Вториот индекс поддржува join-ови и филтри според encounter.
     86
     87== `medications`
     88
     89{{{#!sql
     90create nonclustered index IX_Medications_Patient_Start
     91on dbo.medications(patient, [start])
     92include (stop, payer, encounter, code, description, dispenses, base_cost, payer_coverage, totalcost, reasoncode, reasondescription);
     93go
     94
     95create nonclustered index IX_Medications_Encounter
     96on dbo.medications(encounter)
     97include (patient, [start], stop, code, totalcost);
     98go
     99}}}
     100
     101== `procedures`
     102
     103{{{#!sql
     104create nonclustered index IX_Procedures_Encounter_Start
     105on dbo.procedures(encounter, [start])
     106include (patient, system, code, description, base_cost, reasoncode, reasondescription);
     107go
     108}}}