Re: Class::DBI performance issues

[prev] [thread] [next] [Date index for 2004/12/04]

From: Tony Bowden
Subject: Re: Class::DBI performance issues
Date: 18:21 on 04 Dec 2004
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)

Class::DBI performance issues
Jasper Cramwinckel 11:35 on 04 Dec 2004

Re: Class::DBI performance issues
Tony Bowden 18:21 on 04 Dec 2004

Re: Class::DBI performance issues
Tony Bowden 18:22 on 04 Dec 2004

Class::DBI performance issues
Jasper Cramwinckel 13:56 on 06 Dec 2004

Generated at 15:37 on 08 Dec 2004 by mariachi v0.52