Client Statistics Explanations...

The attached image shows Execution Plan/ Client Statistics for this query:
select distinct AnalyteCode, Analyte
from LabAnalyteData
Order By AnalyteCode

Open in new window

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
LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
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.
0
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
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);
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
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.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Mike EghtebasDatabase and Application DeveloperAuthor Commented:
To better state what I have. Assuming I already have:

CREATE INDEX index_FK_IDinAccess_LabAnalyteData ONLabAnalyteData (IDinAccess, AnalyteCode, Analyte, ConcentrationLevelUnit);

Is it still necessary to have:
CREATE INDEX index_Analyte_LabAnalyteData ON LabAnalyteData (AnalyteCode, Analyte);
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
If you already have that index, you can see by the execution plan you posted that the engine chose to use the Cluster Index from PK instead of that one so I'ld say that the index index_FK_IDinAccess_LabAnalyteData is useless for this query.
By the name the index index_FK_IDinAccess_LabAnalyteData is intended to be the index for the FK? If so, means that you have a FK with 4 fields? I would review that.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Arifhusen AnsariBusiness Intelligence Developer and AnalystCommented:
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.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.