On Mon, 2005-12-19 at 17:30 -0500, John Siracusa wrote:
> >> I think you misunderstand what the tests are doing.  They're meant to
> >> highlight exactly the features that you're describing.  Fetching objects 
> >> and
> >> some of their associated objects in other tables is a common task.  Many of
> >> the tests revolve around this task (with various twists).  There are other,
> >> earlier tests that measure the performance of single-row loads, and so on.
> > Well, I still think it's timing of the wrong thing
> What should it be timing?  The particular test you were looking at (search
> products and categories and code names) represents a common, practical
> task, and does in fact reward ORMs that can accomplish this task with as few
> queries as possible.

OK, it's just been my experience that the common, practical tasks are
only indirectly a performance problem - in that, if the simple task ends
up being run 1,000 times in a transaction, it is obviously far too many
- and so it should be easy to translate that into some code that does
all the stuff it needs to up front.

Say, you have a multi-level data structure.  A ship holds containers
which holds items, and you want to go through all the items on a ship.
If you were to let lazy loading do this, then you would end up with one
select per traversal.  However, if you have a good way of specifying
that you want to prefetch the relations you will be following, then you
only need three selects.  The total time may be longer or shorter, the
the important thing is that the database is doing less work, and
therefore the application will scale further.

With Tangram, you basically pass the same filter object to prefetch that
you can use for select - this makes this kind of code very simple.

for instance, the code would look something like this:

  my $ship = $storage->load($ship_id);  # Query 1
  my ($r_item, $r_container) = $storage->remote("Item", "Container");
  my $filter = ($r_container->{ship} == $ship);

  $storage->prefetch($r_container, "items", $filter); # Query 2

  for my $container ($ship->containers   # query 3
                    ) {
      for my $item ($container->items) {

      }
  }

The code works without the prefetch, it just uses more selects.  The
objects themselves are not built until they are "demanded" from the
cached data.

> > but I'll be happy to participate.
> Good :)  I'll work on integrating Tangram into the bench for the next
> release.

Cool.  If you are using Benchmark, you might also want to read this
thread ("Re: goto-& Speed"):

 http://xrl.us/i9zx (Link to hop.perl.plover.com)

Sam.



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to