[Dbix-class] Search_rs not returning newly created rows

David Cantrell david at cantrell.org.uk
Thu Jun 21 13:13:56 GMT 2012


On Wed, Jun 20, 2012 at 02:49:56PM -0400, Len Jaffe wrote:
> On Wed, Jun 20, 2012 at 2:39 PM, Bill Moseley <moseley at hank.org> wrote:
> > I'd worry less about where your database calls are happening.  Do you
> > really care if [% user.address.city | html %] hits the database in the
> > template or in the controller?
> > ... 
> > One point of the object abstraction is you don't care about the
> > implementation.   The real problem I've seen, though, is doing something
> > stupid like huge nested loops in the template where each one generates a
> > query.
> This is what I meant to about maintenance nightmare.
> I've inherited apps like this where I had to roll nested queries (in
> templates) up into a single query to go from 120 round-trips to the
> database, taking 8 seconds, into one round trip, taking half a second.

Making sure you don't hit the database from the templating layer doesn't
magically make this problem go away.  I recently fixed an application
where we were making over a thousand queries *in a single subroutine*
where one would do the job.

I did it by using prefetch.  That one line I added would have the same
effect regardless of whether the loop was in the same subroutine or a
mile away in a template.

-- 
David Cantrell | top google result for "topless karaoke murders"

  The test of the goodness of a thing is its fitness for use.  If it
  fails on this first test, no amount of ornamentation or finish will
  make it any better, it will only make it more expensive and foolish.
     -- Frank Pick, lecture to the Design and Industries Assoc, 1916



More information about the DBIx-Class mailing list