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