Re: caching of flattened objects

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sun Dec 05 2004 - 15:48:41 EST

  • Next message: Kevin J. Menard, Jr.: "Re: XML Encoder/Decoder Beta"

    Hi Tore,

    The problem in CAY-15 of course is that a query "master" object and a
    prefetched object do not have a direct PK/FK relationship (as their
    join data is stored in a separate table).

    So you are suggesting to cache snapshots from this join table... It
    maybe a good idea - we are filling the gaps in the information
    available to Cayenne runtime, so that we can do smarter matching of
    object and DB layers in memory. But here is my concerns... First we
    will need a new type of key (DataRowId?), second we will have to do
    in-memory DbRelationship traversal of snapshots. This bothers me as it
    will turn Cayenne itself into an in-memory relational database. This
    was never the idea.

    Here is my idea how to fix CAY-15. It is based on implementing support
    for single-query prefetching using joins (in addition to the current
    prefetching mechanism that uses a separate query for each prefetch). So
    Cayenne would generate a query like:

    SELECT t0.fullname, t0.username, t1.name, t1.house_id
       FROM person t0, house t1, person_in_house t2
      WHERE t0.../* whatever qualifier we might have */
        AND t0.username = t2.username
        AND t1.house_id = t2.house_id

    This requires some changes in query translator and also in result
    processing (handling "master" and "dependent" parts within the same
    ResultSet, and also duplicate ids, as this is a many-to-many join).
    This will completely solve the flattened relationships problem, and
    also will serve as an extra optimization parameter for the "normal"
    prefetches. Besides it will probably be used in "flattened attributes"
    implementation.

    Actually this may even turn out to be simpler than creating a new
    mechanism for caching data rows. What do you think?

    Andrus

    On Dec 4, 2004, at 12:00 PM, Tore Halset wrote:
    > Hello.
    >
    > I am thinking about CAY-15, but I am not able to see an easy solution.
    > http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-15
    >
    > Perhaps (shared-)caching of flattened objects should be implemented
    > before prefetch of flattened many-to-many. Agree? I think this would
    > help a lot for long running applications and it would be a nice start
    > for the complete CAY-15 fix.
    >
    > Should this cache be implemented in the ObjectStore or/and the
    > DataRowStore? The DataRowStore store rows by objectId, but the cache
    > of the flattened objects should probably be a Collection of rows for a
    > key. Anyone?
    >
    > Regards,
    > - Tore.



    This archive was generated by hypermail 2.0.0 : Sun Dec 05 2004 - 15:48:49 EST