Re: complex query vs performIteratedQuery vs Prefetching

From: Andrey Razumovsky (razumovsky.andre..mail.com)
Date: Tue Nov 10 2009 - 08:01:51 EST

  • Next message: Hans Pikkemaat: "Re: complex query vs performIteratedQuery vs Prefetching"

    Hi,

    I think the best in your case would be using disjoint prefetching;
    http://cayenne.apache.org/doc20/prefetching.html
    This way both table data will be returned altogether (in same db row), so
    you will be able to iterate though them at the same time.

    I also highly encourage you to try today-released Cayenne3.0 beta. It proved
    to be stable and many prefetching (ant other!) improvements were made. Check
    the main site!

    2009/11/10 Hans Pikkemaat <h.pikkemaa..si-solutions.nl>

    > Hi,
    >
    > My case:
    >
    > I have a complex query which returns a huge amount of data. It returns data
    > from
    > two tables which are joined.
    >
    > Because the amount of data is huge I cannot load all of it into memory.
    > For this reason I want to use an iterated query.
    >
    > I also want to prevent cayenne from executing a query for each detail
    > record
    > so I want to use prefetching.
    >
    > What I tried:
    >
    > - I'm using cayenne 2.0.4.
    > - I use SQLTemplate to instantiate the query.
    > - I set the page size to 1000 to prevent loading the whole db (required
    > for postgres)
    > - I use performIteratedQuery to run the query.
    > - As I get DataRows back from the iterated query I use
    > dataContext.objectFromDataRow(..) to create my objects
    >
    > The Problem:
    >
    > The relation is not automatically setup. This means that for every record
    > I access the detail table a query is executed.
    >
    > My Questions:
    >
    > - How should I use prefetching in combination with SQLTemplate and an
    > iterated query which returns DataRows?
    > - Is there a way to manually setup this relationship (without changing
    > the state of the parent object?)
    > - Is there another way to do what I want using Cayenne?
    >

    -- 
    Andrey
    



    This archive was generated by hypermail 2.0.0 : Tue Nov 10 2009 - 08:02:51 EST