Re: Class::DBI performance issues
[prev]
[thread]
[next]
[Date index for 2004/12/04]
On Sat, Dec 04, 2004 at 12:35:10PM +0100, Jasper Cramwinckel wrote:
> Am I right, or am I overseeing things? This could be done in one query like
> SELECT
> cd.name, track.name, track.duration_in_seconds
> FROM
> Artist a, CD cd, Track t
> WHERE
> a.id=17 AND cd.artist = a.id AND t.cd = cd.id;
Then why not do it?
package Artist;
__PACKAGE__->set_sql(track_seconds => q{
SELECT SUM(t.duration_in_seconds)
FROM __TABLE(=a)__, __TABLE(CD=c)__, __TABLE(Track=t)__
WHERE __JOIN(a c t)__
AND a.id = ?
});
sub track_seconds {
my $self = shift;
$self->sql_track_seconds($self->id);
}
No need to make all those calls, create all those objects etc.
Class::DBI doesn't try to stop you writing SQL when you need to. It even
tries to make it easy for you ...
Tony
|
(message missing)
|