Return-Path: Mailing-List: contact ibatis-user-java-help@incubator.apache.org; run by ezmlm Delivered-To: mailing list ibatis-user-java@incubator.apache.org Received: (qmail 50410 invoked by uid 99); 9 Feb 2005 15:32:41 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from ctb-mesg6.saix.net (HELO ctb-mesg6.saix.net) (196.25.240.78) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 09 Feb 2005 07:32:41 -0800 Received: from [192.168.0.2] (rndf-146-3-12.telkomadsl.co.za [165.146.3.12]) by ctb-mesg6.saix.net (Postfix) with ESMTP id 1BBB825E4 for ; Wed, 9 Feb 2005 17:32:36 +0200 (SAST) Message-ID: <420A2D14.7000504@isanusi.com> Date: Wed, 09 Feb 2005 17:32:36 +0200 From: Abdullah Kauchali User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: ibatis-user-java@incubator.apache.org Subject: Re: R: What is N+1 References: <420A1FFC.2030400@friendvu.com> <16178eb10502090704550bda0e@mail.gmail.com> In-Reply-To: <16178eb10502090704550bda0e@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked Clinton, I can see the point when friendlyVU (???) spoke about getting details of the appropriate parent. "Appropriate" being the operative word. (Lazy loading) In all our database applications, we have *seldom* required the need to work off a list of Categories then require to display (use) all the children of the different Categories viz. all the different products of the *different* Categories. We never needed it somehow. What we have required, however, is the proces the other way round. Where we work off a list of Products and while busy with them we require the details of their Categories. So, it is n+1 the other way round??? Currently we are using a second select with a IN statement containing a comma delimited entries of the unique parents. We then do the "mapping" in code. What are your thoughts on this? Kind regards Abdullah Clinton Begin wrote: >Vic, > >I'm not sure what you're point was, but N+1 selects is THE most common >relational databases performance problem caused by application >developers today. > >Understanding it is critical if you want to avoid making this mistake. > Not every application will have the luxury of simply being 1:1 >Table:Screen. In fact, I've almost never seen this to be the case in >enterprise applications. > >Consider a 3 tier hierarchy like in JPetStore: Categories -1---M- >Products -1----M- Items. > >For illustration purposes, the number of queries to load this data >with an immediate or lazy load strategy is: > >1 * count(categories) * count(Products) > > > >