Retrieving all objects in code upfront for performance reasons

Posted by ming yeow on Stack Overflow See other posts from Stack Overflow or by ming yeow
Published on 2010-05-20T16:33:57Z Indexed on 2010/05/20 18:20 UTC
Read the original article Hit count: 255

How do you folks retrieve all objects in code upfront?

I figure you can increase performance if you bundle all the model calls together?

This makes for a bigger deal, especially if your DB cannot keep everything in memory

def hitDBSeperately {

get X users ...code

get Y users... code

get Z users... code

}

Versus:

def hitDBInSingleCall {

get X+Y+Z users

code for X code for Y...

}

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about refactoring