I have a very huge database, 3k+ rows
It takes 4 whole seconds to load the page, with 2 big querys How to speed it up?
First:
SELECT Description
FROM ComputerIdentity JOIN
MakeModelIdentity
ON ComputerIdentity.MakeModelID = MakeModelIdentity.ID
WHERE MakeModelIdentity.DeviceName='Laptop' AND
ComputerIdentity.Description LIKE '%uitleen%' AND
MakeModelIdentity.DeviceName = 'Laptop' AND
MakeModelIdentity.Model = 'Chromebook'
ORDER BY ComputerIdentity.ID ASC
Second:
SELECT Inlognaam,VolledigeNaam FROM PersoneelEnLeerlingen
For this query (which I've "simplified" using table aliases and removing the redundant WHERE
condition):
SELECT ci.Description
FROM ComputerIdentity ci JOIN
MakeModelIdentity mmi
ON ci.MakeModelID = mmi.ID
WHERE mmi.DeviceName = 'Laptop' AND
ci.Description LIKE '%uitleen%' AND
mmi.Model = 'Chromebook'
ORDER BY ci.ID ASC;
You can speed the query with indexes on MakeModelIdentity(DeviceName, Model, ID)
and ComputerIdentity(MakeModelID, Description, ID)
.
The second query is really simple and the speed only depends on the size of the data.
3K rows is miniscule, SQL Server Engine doesn't need your help to optimize it. Still here are some suggestions from the book of optimization. For First :
SELECT ci.Description
FROM ComputerIdentity ci JOIN
MakeModelIdentity mmi
ON ci.MakeModelID = mmi.ID
WHERE mmi.DeviceName = 'Laptop' AND
mmi.Model = 'Chromebook' AND
ci.Description LIKE '%uitleen%' --reordered
ORDER BY ci.ID ASC;
For Second: Create non-clustered indexes on the columns you are selecting, which doesn't have a clustered index
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.