I have been trying to check the performance of different types of database designs, but I am not sure if the results I get are correct.
I have two databases, with the different tables, but meant to store the same information.
See the image for more detailed information:
When I run the query below against first database it executes in 0.03 sec.
SELECT
a.[idPerson], a.[Id], a.[Description], a.[LastName], a.[nme],
a.[Email], a.[Phone], a.[grp]
FROM
[Student] a
WHERE
a.[grp] = 'R3PU56'
AND a.[nme] = 'tZv5oxqSDEoXPnU'
AND a.[Email] = 'gyRpWWCopv'
When I run the query below against second database it executes in 0.03 sec too.
SELECT
a.[Id], a.[grp], b.[Email], b.[Phone],
c.[Description], c.[LastName], c.[nme]
FROM
[Student2] a
JOIN
[AdvancedPerson2] AS b ON (a.[Id] = b.[Id])
JOIN
[Person2] AS c ON (a.[Id] = c.[Id])
WHERE
a.[grp] = 'R3PU56'
AND b.[Email] = 'gyRpWWCopv'
AND c.[nme] = 'tZv5oxqSDEoXPnU'
I was expecting the second query will take much more than first query because of joins. My question is, why both quesries are takingsame amount of time? If they are the same which database strucure should I use? Some people might say that second structure is complicated because of multiple tables, but I don't care. I am using Telerik ORM and both seems the same in C# code.
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
CREATE INDEX student_idx_grp_nme_email ON Student (grp,nme,Email);
SELECT
a.[idPerson],
a.[Id],
a.[Description],
a.[LastName],
a.[nme],
a.[Email],
a.[Phone],
a.[grp]
FROM
[Student] a
WHERE
a.[grp] = 'R3PU56'
AND a.[nme] = 'tZv5oxqSDEoXPnU'
AND a.[Email] = 'gyRpWWCopv'