I'll start by saying I'm not a DB guy, so I'm lost a bit. I've probably got a poorly designed schema to boot, but things have been working for the most part so far. Until now.
I've got a database of race results that I'm am crunching numbers on to compare performances between races. Now that I am pushing 40k results in the result table, performance has become highly variable.
From the MySQL prompt if I run the following query twice in a row, the first time it returns 1000 rows in less than a second. The second time the query times out after 30 seconds. (Yes I realize this example is "comparing" a race against itself)
Googling has not helped me, perhaps because I'm just not familiar enough with how the database functions.
Any insight to push me down the right path would be appreciated.
I've got a database of race results that I'm am crunching numbers on to compare performances between races. Now that I am pushing 40k results in the result table, performance has become highly variable.
From the MySQL prompt if I run the following query twice in a row, the first time it returns 1000 rows in less than a second. The second time the query times out after 30 seconds. (Yes I realize this example is "comparing" a race against itself)
Code:
SELECT Racer.FirstName, Racer.LastName, r1.TimeInSec as "Race 1 Time", r2.TimeInSec as "Race 2 Time" FROM Racer, Result r1, Result r2 WHERE r1.EventID=174 AND r2.EventID=174 AND r1.RacerID=r2.RacerID AND Racer.RacerID=r1.RacerID LIMIT 1000;
Googling has not helped me, perhaps because I'm just not familiar enough with how the database functions.
Any insight to push me down the right path would be appreciated.
