Prefetching

0 views
Skip to first unread message

Michael

unread,
Jul 7, 2010, 2:16:13 AM7/7/10
to Repose PHP ORM General Discussion
Does Repose support prefetching?

What would a prefetch query look like?

Beau Simensen

unread,
Jul 7, 2010, 12:24:49 PM7/7/10
to repos...@googlegroups.com
Hi Michael!

Prefetching of objects that are directly related to each other (the many side of a many to one) is built into Repose and there is actually no way to disable it. For instance, if a Task (many) HAS A Project (one), in selecting a Task, you get the Project for free.

Prefetching of collections is not currently supported. The Query generator (what Repose uses to create the actual SQL queries, not what repose uses to parse user queries) is currently being rewritten with several things in mind, including the possibility of supporting collection prefetching. This process has been more time consuming than I had hoped but I hope to get it finished soon. Once it is, it will open the doors to many things including one to one relationships and the possibility of querying against collections and prefetching collections.

For as flexible as PHP is in some cases, it really isn't in others. Someone smarter than I might be able to solve this problem, but as far as I can tell, there is not really a way to handle not prefetching an object and loading it on demand unless it involves imposing a lot of restrictions on the class (and likely requiring a base class).

If I have misunderstood the question, please let me know!


--

Beau D. Simensen


Dragonfly Development Inc
http://dflydev.com/

s3a - Fresh. Urban. Seattle.
http://s3attle.com/


[blog] http://not-invented-here.com/
[flickr] http://flickr.com/photos/kirkryyn
[facebook] http://facebook.com/simensen


On Tue, Jul 6, 2010 at 11:16 PM, Michael <mbla...@gmail.com> wrote:
Does Repose support prefetching?

What would a prefetch query look like?

--
You received this message because you are subscribed to the Google Groups "Repose PHP ORM General Discussion" group.
To post to this group, send email to repos...@googlegroups.com.
To unsubscribe from this group, send email to repose-php+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/repose-php?hl=en.


Michael Bøcker-Larsen

unread,
Jul 8, 2010, 9:42:22 PM7/8/10
to repos...@googlegroups.com
Hi Beau

I like what you are doing with project - when can we get to some of what you are working on?

Say if a fetch 10 projects I want to be able to prefetch all of their tasks in one go. That is one SQL compared to 10 SQLs.

Keep up the good work
 Michael
--
Michael Bøcker-Larsen

Beau Simensen

unread,
Jul 9, 2010, 2:51:19 PM7/9/10
to repos...@googlegroups.com
I like what you are doing with project - when can we get to some of what you are working on?

I wish I could say. I have several high priority projects that have my attention right now and need to find at least a couple of 5 hour blocks of time that I can devote to the Query code. Might be in a week or so, might be in a month or so?

Knowing other people are waiting on this definitely helps keep it on my mind! Will keep you posted but please feel free to remind me that you're waiting on this functionality.


Say if a fetch 10 projects I want to be able to prefetch all of their tasks in one go. That is one SQL compared to 10 SQLs.

Yes, I'll keep this in mind as I rebuild Repose Query. I do not know if it will be in how the query is built but more likely in how the classes are configured. (the Project to Task relationship will probably be marked as non-lazy loading)

--

Beau D. Simensen


Dragonfly Development Inc
http://dflydev.com/

s3a - Fresh. Urban. Seattle.
http://s3attle.com/


[blog] http://not-invented-here.com/
[flickr] http://flickr.com/photos/kirkryyn
[facebook] http://facebook.com/simensen


Beau Simensen

unread,
Jul 16, 2010, 3:28:09 AM7/16/10
to repos...@googlegroups.com
Repose 0.0.8 is about ready to be pushed out. I've managed to carve out a bit of time to finish up the Repose Query rewrite and 0.0.8 will contain that. I think I have most of the things in place to start supporting prefetching of collections and I'm going to put that down for the 0.0.9 release.

However, I do not think it will be able to be done in one query. I think Repose will need to do the initial query and then a follow up query to find all of the objects related to the objects from the initial results. Not ideal, abd it is possible we could change this someday, but that is probably how it is going to look once we roll this out.

--

Beau D. Simensen


Dragonfly Development Inc
http://dflydev.com/

s3a - Fresh. Urban. Seattle.
http://s3attle.com/


[blog] http://not-invented-here.com/
[flickr] http://flickr.com/photos/kirkryyn
[facebook] http://facebook.com/simensen


Beau D. Simensen

unread,
Sep 2, 2010, 4:58:44 PM9/2/10
to Repose PHP ORM General Discussion
Hi Michael,

I am not sure if you are still trying to use Repose or not, but I
think I have a first pass at non-lazy loading collections finished. It
will be in Repose 0.0.9 when I get that released (hopefully sometime
in the next week).

I need to do some testing on some larger datasets, but I think it will
do what you are looking for. It is not very well optimized right now
but it will still probably be faster than doing 10 individual queries.


On Jul 16, 12:28 am, Beau Simensen <simen...@gmail.com> wrote:
> Repose 0.0.8 is about ready to be pushed out. I've managed to carve out a
> bit of time to finish up the Repose Query rewrite and 0.0.8 will contain
> that. I think I have most of the things in place to start supporting
> prefetching of collections and I'm going to put that down for the 0.0.9
> release.
>
> However, I do not think it will be able to be done in one query. I think
> Repose will need to do the initial query and then a follow up query to find
> all of the objects related to the objects from the initial results. Not
> ideal, abd it is possible we could change this someday, but that is probably
> how it is going to look once we roll this out.
>
> --
>
> Beau D. Simensen
>
> Dragonfly Development Inchttp://dflydev.com/
>
> s3a - Fresh. Urban. Seattle.http://s3attle.com/

Michael Bøcker-Larsen

unread,
Sep 2, 2010, 11:28:17 PM9/2/10
to repos...@googlegroups.com
Hi Beau

Thanks for the update - I'm not trying to use it right now, but I will surely follow the project. 

Best regards
  Michael

--
You received this message because you are subscribed to the Google Groups "Repose PHP ORM General Discussion" group.
To post to this group, send email to repos...@googlegroups.com.
To unsubscribe from this group, send email to repose-php+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/repose-php?hl=en.




--

Michael Bøcker-Larsen

p: +--[ RSA 2048]----+
   |                 |
   |         .       |
   |          *      |
   |         B o     |
   |     .  S *      |
   |    . o. o o     |
   |     = .E        |
   |    . +*+        |
   |     oB*         |
   +-----------------+

Reply all
Reply to author
Forward
0 new messages