[stats-dev] Why do we care about date in the load functions?
paul at quakenet.org
Thu Jul 29 05:59:20 EDT 2004
> Looking at the query for tmsummary I'm detecting some wonkyness...
> SELECT *, last_date::DATE - first_date::DATE + 1 AS
> days_working FROM team_rank WHERE team_id = 1828 AND
> project_id = 8 AND last_date = (SELECT MAX(last_date) FROM
> team_rank t2 WHERE t2.team_id = team_rank.team_id AND
> t2.project_id = team_rank.project_id)
> Uhm... huh?!? What's with the (expensive) max() operation?
I'm guessing that thejet originally thought it would be possible to load
previous date stats in that manner. If team_rank will only ever contain the
current days, we can simplify that query.
There's no where in the php that tries to supply a date, so it's safe to
> Looking further, both team.php and participant.php's load
> functions accept a date. Does anyone know why? There's only
> one day's worth of data in the _rank tables. The only thing
> this would do is potentially exclude teams/participants that
> weren't active yesterday, but that doesn't make much sense
> since these functions should only be used for single teams or
> participants, not for something like yesterday listings.
> By the way, the reason I started looking at this is because
> tmsummary is executing at least 15(!!) queries. See
> and http://bugs.distributed.net/show_bug.cgi?id=3729.
That should probably say as a * - we're generating a 'team object' from it.
If in the future we added caching of objects, we'd then have issues with
Would you rather that
SELECT *, last_date::DATE - first_date::DATE + 1 AS days_working FROM
team_rank WHERE team_id IN (4264,1828,28304,28166,4719) AND project_id = 8
AND last_date = (SELECT MAX(last_date) FROM team_rank t2 WHERE t2.team_id =
team_rank.team_id AND t2.project_id = team_rank.project_id)
And a single query?
If so, I'll fix that up for you
>Also, something's wrong with the query reporting. For example,
> is showing only 2 queries, which isn't right by a long-shot.
> (The neighbor and friend queries are missing, at a minimum).
$g_query_array or whatever it's called should be a global, not part of the
class. I'm guessing this is what's causing the issue.
It's a 'bug' that when I first added it was part of the class.
More information about the stats-dev