One thing I noticed while looking through the call_log.agi was that the perl scripts do not allow MySQL the chance to cache the compiled queries. For example changing things like this in call_log.agi:
- Code: Select all
$stmtA = "SELECT UNIX_TIMESTAMP(parked_time),UNIX_TIMESTAMP(grab_time) FROM park_log where uniqueid='$unique_id' and server_ip='$VARserver_ip' LIMIT 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
to:
- Code: Select all
$stmtA = "SELECT UNIX_TIMESTAMP(parked_time),UNIX_TIMESTAMP(grab_time) FROM park_log where uniqueid='?' and server_ip='?' LIMIT 1;";
$sthA = $dbhA->prepare_cached($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute($unique_id,$VARserver_ip) or die "executing: $stmtA with uniqueid=$unique_id and server_ip=$VARserver_ip", $dbhA->errstr;
will allow MySQL to cache this query so it will run faster with less load the next time it is run, which with call_log.agi is before and after every call! Having the variable inside the SQL statement makes MySQL think that the statement is different every time it is called. This means that it will not used the cached version. By taking the variables out of the SQL statement and placing ? in their place during the prepare_cached call MySQL will be able to find a cached version. When the execute statement is called MySQL will just replace the ? with the appropriate variables in that cached version.
And as a suggestion, since at least MySQL 3 there has been the ability to add comments to the various table fields. It would be great if these comments were added so that people do not need to pour through the code to see what field does what. For instance this would make writing custom reports much easier.
We plan on writing a reporting script that would parse the database for the names of the fields and then grep the source code for the where those fields were used. It would also do this for the names of the tables. This would generate a nice quick reference on table/field usage. Coupling this with the MySQL comments would produce a very usable data dictionary for the DB.