Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Optimizing a query

Status
Not open for further replies.

gxpark

Programmer
Aug 10, 2002
19
MX
Hi,

I wonder if someone is willing to help me optimize the following query:

SELECT <somefields>
FROM schools
LEFT JOIN addresses ON addresses.fkSchool = idSchool
LEFT JOIN users ON users.idUser = fkLogin
LEFT JOIN xlevels ON xlevels.fkSchool = idSchool
WHERE fkDep = 1
AND (fkLevel = 2 OR fkLevel = 4)
AND (Address_Street_CH LIKE '%string%' OR Address_Street2_CH Like '%string%')
ORDER BY School_Name_CH

Notes:
* The fk prefix stans for &quot;foreign key&quot;, and id as a primary key.

Well, there are about 3,000 rows in the schools table, and about the same on addresses, and schoolsxlevels. That query takes more than one minute to execute on my PIII 500 Mhz, so I wonder if there's a way to speed up the query...

I'll be really grateful if you can help me! But thanks anyway for reading me!

Sincerely,
Ivan V.
 
nevermind, I just switched the table search order and now it's pretty fast :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top