spadefoot / kohana-orm-leap

An ORM module for the Kohana PHP framework that is designed to work with all major databases.
http://spadefoot.github.io/kohana-orm-leap/
100 stars 25 forks source link

Eager Loading #65

Open CubedEye opened 12 years ago

CubedEye commented 12 years ago

Does LEAP do eager loading at all?

We've just been profiling our application and LEAP is making a extreme number of select statements.

Is there anyway to get LEAP to autoload all the relations when selecting objects, without all the select statements

taai commented 12 years ago

@CubedEye What do you mean by that? I think, that Leap executes SELECT query only once the related model is being accessed. Or may be you want all related models to get loaded in single query, like it's done in Kohana ORM (see $model->with() function)?

CubedEye commented 12 years ago

I know about LEAP loading all the relations when they are required. I am looking for a way for LEAP to load all the relations in a single query, because at the moment we have way to many SELECTs going on.

Also, LEAP doesn't seem to be connected to Kohana's profiler model. I can make this a new ticket and I'll push the code we've used to get it to work.

bluesnowman commented 11 years ago

@CubedEye Do you have any ideas of how we could implement eager loading? I agree this would be a nice addition to the LEAP ORM.

As for the profiler code, that would be totally awesome if you want to contribute that code. I would be nice if we could implement the profiler code in such a way to incorporate dependency injection so that users could choose select their own profiler but have Kohana's Profiler as the default.

taai commented 11 years ago

Look at Kohana ORM's with() function! Maybe we could implement this the same way... https://github.com/kohana/orm/blob/3.3/master/classes/Kohana/ORM.php#L840