Q1: What indexes would you recommend to be added to improve its performance?
Maybe: CREATE INDEX index_Analyte_LabAnalyteData ON LabAnalyteData (Analyte);
But what if I add the following index; is there still a need to add additional indexes?
CREATE INDEX index_FK_IDinAccess_LabAnalyteData ONLabAnalyteData (IDinAccess, AnalyteCode, Analyte, ConcentrationLevelUnit);
Q2: On the Client Statistics, what do Trial 1, Trial 2, and Trial 3 mean? Client-Statistics.png
Microsoft SQL ServerMicrosoft SQL Server 2005Microsoft SQL Server 2008
Last Comment
Vitor Montalvão
8/22/2022 - Mon
Vitor Montalvão
Q1: What indexes would you recommend to be added to improve its performance?
CREATE INDEX index_Analyte_LabAnalyteData ON LabAnalyteData (AnalyteCode, Analyte);
Q2: On the Client Statistics, what do Trial 1, Trial 2, and Trial 3 mean?
Means how many times you ran the query. Trial 2 used the cache since data still accessible from Trial 1.
Mike Eghtebas
ASKER
Vitor,
But what if I add the following index; is there still a need to add additional indexes?
CREATE INDEX index_FK_IDinAccess_LabAnalyteData ONLabAnalyteData (IDinAccess, AnalyteCode, Analyte, ConcentrationLevelUnit);
Do we still need:
CREATE INDEX index_Analyte_LabAnalyteData ON LabAnalyteData (AnalyteCode, Analyte);
Vitor Montalvão
You should add only the strictly necessary columns. Why add columns that aren't used by the query?
Also, I'm commenting only based on the query you posted. I don't know the schema of your table and also don't know the rest of the queries that table are part of.
what i think is, if you are not providing any criteria in where clause.
Query execution plan will use clustered index by default because at the it need to get all the row.
So it's better to scan clustered index.
And in your case index_FK_IDinAccess_LabAnalyteData might not be clustered index and in fact "PK_labAnalyteID" is clustered.
Even if you create CREATE INDEX index_Analyte_LabAnalyteData ON LabAnalyteData (Analyte) and do not provided any where clause. It will use that "PK_labAnalyteID" index.
Vitor Montalvão please have some comment on this.
Vitor Montalvão
It depends. The engine will always calculate and chose the operation with less cost. If you increase exponentially the number of records the engine may chose another index. Usually with very few records a scan is chosen instead of seek and this could be the case.
Means how many times you ran the query. Trial 2 used the cache since data still accessible from Trial 1.