Return-Path: X-Original-To: apmail-cayenne-commits-archive@www.apache.org Delivered-To: apmail-cayenne-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 579199877 for ; Fri, 6 Apr 2012 16:53:46 +0000 (UTC) Received: (qmail 81797 invoked by uid 500); 6 Apr 2012 16:53:46 -0000 Delivered-To: apmail-cayenne-commits-archive@cayenne.apache.org Received: (qmail 81754 invoked by uid 500); 6 Apr 2012 16:53:45 -0000 Mailing-List: contact commits-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list commits@cayenne.apache.org Received: (qmail 81743 invoked by uid 99); 6 Apr 2012 16:53:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Apr 2012 16:53:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Apr 2012 16:53:43 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id E9ACF35C9A4 for ; Fri, 6 Apr 2012 16:53:21 +0000 (UTC) Date: Fri, 6 Apr 2012 16:53:21 +0000 (UTC) From: "Andrei Veprev (Updated) (JIRA)" To: commits@cayenne.apache.org Message-ID: <1493590062.24246.1333731201958.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <660627799.6975.1330603439064.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (CAY-1681) Third prefetch kind - DISJOINT_BY_ID MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAY-1681?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Andrei Veprev updated CAY-1681: ------------------------------- Attachment: CAY-1681-v3.patch Another update. - fixed NPE when parent node is joint - test for long flattened relationships (testing inclusion of dot in join path) - support for joint prefetches in children - still more work is needed here > Third prefetch kind - DISJOINT_BY_ID > ------------------------------------ > > Key: CAY-1681 > URL: https://issues.apache.org/jira/browse/CAY-1681 > Project: Cayenne > Issue Type: Task > Components: Core Library > Reporter: Andrus Adamchik > Assignee: Andrus Adamchik > Attachments: CAY-1681-v2.patch, CAY-1681-v3.patch, CAY-1681-varchar-length.patch > > > (here is a mailing list thread discussing the issue: http://markmail.org/message/zzyd26ucfwhnacfe ) > I keep encountering a common scenario where neither JOINT or DISJOINT prefetch strategies are adequate - queries with fetch limit. It is very common in the application to display X most recent entries from a table with millions of rows, and then drill down to the object details. E.g. assume 2 entities - "Order" and "LineItem", with orders having multiple line items. We want 10 most recent orders, with line items prefetched, so you'd so something like this: > SelectQuery q = new SelectQuery(Order.class); > q.addPrefetch("lineItems"); > q.setFetchLimit(10); > "Disjoint" prefetch in this situation would fetch 10 orders and ALL LineItems in DB. > "Joint" prefetch will fetch anywhere between 1 and 10 orders, depending on how many line items the first 10 orders have, i.e. fetch limit is applied to to-many join, not to the query root. And this is certainly not what we want. > Now Cayenne already has something that can solve the problem: > q.setPageSize(10); // same as fetch limit > Paginated query is the most optimal way to prefetch here. Whenever a result list is accessed, Cayenne would execute 2 IN () queries - one for the Orders, another one - for the LineItems. Both queries are matching on a set of Order PKs and are pretty efficient, and only return the objects that we care about. > The problem with this solution is that it is counterintuitive to the user (why should I set "pageSize" to make my prefetches work) and adds one extra query (the IN query resolving the root object list). Would be cool to turn it into a separate type of prefetch. Something like "disjoint by id"? -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira