Played around with SQL Profiler and found out how a customer was crashing Cold Fusion on all of our servers.
I realized that it was a DB issue because several servers running Cold Fusion would die. I connected to the SQL server and saw that its
CPU was pegged. Cold Fusion DB drivers must suck because the entire Cold Fusion Application server dies when the DB connection dies.
After running SQL Profiler on the DB server for 10 minutes, I saw about 40 queries sent to it (during this time the performance slowed to
a crawl). The queries were the following :
SELECT *
FROM Users
WHERE Users.UserID IN (SELECT UserID FROM UserSeason WHERE ShowID = 77)
OR Users.UserID IN (SELECT UserID FROM UserBest WHERE ShowID = 77)
OR Users.UserID IN (SELECT UserID FROM UserInd WHERE ShowID = 77)
ORDER BY UserLastName, UserFirstName
I tried the query in Query Analyzer and it peformed at 4-8 seconds per query!!! In less than a minute I optimized it with
the following
SELECT *
FROM Users
WHERE Users.UserID IN ((SELECT UserID FROM UserSeason WHERE ShowID = 77) UNION
(SELECT UserID FROM UserBest WHERE ShowID = 77) UNION
(SELECT UserID FROM UserInd WHERE ShowID = 77))
ORDER BY UserLastName, UserFirstName
This runs for less than a second! What is that? A 500% increase in performance
Anyways... I let the client know and he is pretty happy about it 🙂
I realized that it was a DB issue because several servers running Cold Fusion would die. I connected to the SQL server and saw that its
CPU was pegged. Cold Fusion DB drivers must suck because the entire Cold Fusion Application server dies when the DB connection dies.
After running SQL Profiler on the DB server for 10 minutes, I saw about 40 queries sent to it (during this time the performance slowed to
a crawl). The queries were the following :
SELECT *
FROM Users
WHERE Users.UserID IN (SELECT UserID FROM UserSeason WHERE ShowID = 77)
OR Users.UserID IN (SELECT UserID FROM UserBest WHERE ShowID = 77)
OR Users.UserID IN (SELECT UserID FROM UserInd WHERE ShowID = 77)
ORDER BY UserLastName, UserFirstName
I tried the query in Query Analyzer and it peformed at 4-8 seconds per query!!! In less than a minute I optimized it with
the following
SELECT *
FROM Users
WHERE Users.UserID IN ((SELECT UserID FROM UserSeason WHERE ShowID = 77) UNION
(SELECT UserID FROM UserBest WHERE ShowID = 77) UNION
(SELECT UserID FROM UserInd WHERE ShowID = 77))
ORDER BY UserLastName, UserFirstName
This runs for less than a second! What is that? A 500% increase in performance
Anyways... I let the client know and he is pretty happy about it 🙂