Re: Prefetching and paginated queries

From: Derek Rendall (dere..sure.com)
Date: Wed Oct 27 2004 - 21:39:14 EDT

  • Next message: Andrus Adamchik: "Re: Prefetching and paginated queries"

    >> I noticed that prefetching doesnt work for paginated queries. I guess
    >> this makes sense - I cant think how to get it going nicely.

    >It supposed to work actually. What exactly happens in your case when
    >you are trying to do the prefetch?

    I have tried on inherited and non inherited objects (with the same result).
    With no page size set, I get the select for the main object, and a select
    for the prefetch relationship. With a pagesize set then I only see the
    select for the main object - not the relationship that supposed to be
    prefetched.

    The following code (tries a select with page size followed by one without):

            Expression exp = ExpressionFactory.matchExp("description",
    aee.getDescription());
            SelectQuery query = new SelectQuery(AccountingEventError.class,
    exp);
            query.addPrefetch("accountingEventErrorDetailArray");
            query.setPageSize(10);
            List list = getDataContext().performQuery(query);

            System.out.println("break");

            query = new SelectQuery(AccountingEventError.class, exp);
            query.addPrefetch("accountingEventErrorDetailArray");
            list = getDataContext().performQuery(query);

    results in the following output (some select fields removed for clarity):

    INFO QueryLogger: --- will run 1 query.
    INFO QueryLogger: SELECT t0.DESCRIPTION, ... , t0.ACCT_EVENT_ERROR_ID FROM
    DBA.ACCOUNTINGEVENTERROR t0 WHERE t0.DESCRIPTION = ? [bind: 'Test
    Description 6000'] - prepared in 10 ms.
    INFO QueryLogger: === returned 1 row. - took 40 ms.
    break
    INFO QueryLogger: --- will run 2 queries.
    INFO QueryLogger: --- transaction started.
    INFO QueryLogger: SELECT t0.DESCRIPTION, ... , t0.ACCT_EVENT_ERROR_ID FROM
    DBA.ACCOUNTINGEVENTERROR t0 WHERE t0.DESCRIPTION = ? [bind: 'Test
    Description 6000']
    INFO QueryLogger: === returned 1 row. - took 10 ms.
    INFO QueryLogger: SELECT t0.DETAILS, ... , t0.ACCT_EVENT_ERROR_ID,
    t0.DETAIL_NUMBER FROM DBA.ACCOUNTINGEVENTERRORDETAIL t0,
    DBA.ACCOUNTINGEVENTERROR t1 WHERE t0.ACCT_EVENT_ERROR_ID =
    t1.ACCT_EVENT_ERROR_ID AND (t1.DESCRIPTION = ?) [bind: 'Test Description
    6000']
    INFO QueryLogger: === returned 1 row. - took 10 ms.
    INFO QueryLogger: +++ transaction committed.

    Thanks

    Derek



    This archive was generated by hypermail 2.0.0 : Wed Oct 27 2004 - 21:39:19 EDT