N+1 problem

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

N+1 problem

Stephan.Schmidt
Hello,

when I do this:

         def commits = Commit.findAllByRepo( repo, [max:perPage,  
sort:"revision", order:"desc", offset: page*perPage] )

and then access

commit.paths (1:n) I get the N+1 problem.

Idesa to solve this? I  tried using Criteria (as Hibernate can  
define  the fetching  strategy with criterias) but
Grails doesn't support offset, setfetch etc.

bye
-stephan

--
   Stephan Schmidt
   [hidden email]

   PRESS ON. Nothing in the world can take the place of persistence.
   Talent will not; nothing in the world is more common than  
unsuccessful
   men with talent. Genius will not; unrewarded genius is almost a  
proverb.
   Education will not; the world is full of educated derelicts.  
Persistence
   and determination alone are omnipotent. - Calvin Coolidge


Reply | Threaded
Open this post in threaded view
|

Re: N+1 problem

graemer
On 3/27/06, Stephan J. Schmidt <[hidden email]> wrote:

> Hello,
>
> when I do this:
>
>          def commits = Commit.findAllByRepo( repo, [max:perPage,
> sort:"revision", order:"desc", offset: page*perPage] )
>
> and then access
>
> commit.paths (1:n) I get the N+1 problem.
Hi Stephan,

This is related to an issue already in JIRA about the need to all
configuration of the fetching strategy in GORM.

>
> Idesa to solve this? I  tried using Criteria (as Hibernate can
> define  the fetching  strategy with criterias) but
> Grails doesn't support offset, setfetch etc.
It should, so this is another issue to raise (ie supporting these
settings within the Critera Builder)

Sorry I don't have any current solution for you besides doing
something like (i'm guessing your object model here):

Path.findAllByCommit(commit)

to fetch them all explicitly..

this is one of the higher priority issues though

Cheers
Graeme

>
> bye
> -stephan
>
> --
>    Stephan Schmidt
>    [hidden email]
>
>    PRESS ON. Nothing in the world can take the place of persistence.
>    Talent will not; nothing in the world is more common than
> unsuccessful
>    men with talent. Genius will not; unrewarded genius is almost a
> proverb.
>    Education will not; the world is full of educated derelicts.
> Persistence
>    and determination alone are omnipotent. - Calvin Coolidge
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: N+1 problem

Stephan.Schmidt
Ah ok, thanks, well the performance has to go up in 2 months, not  
now :-)

> It should, so this is another issue to raise (ie supporting these
> settings within the Critera Builder)

done

bye
-stephan

> On 3/27/06, Stephan J. Schmidt <[hidden email]> wrote:
>> Hello,
>>
>> when I do this:
>>
>>          def commits = Commit.findAllByRepo( repo, [max:perPage,
>> sort:"revision", order:"desc", offset: page*perPage] )
>>
>> and then access
>>
>> commit.paths (1:n) I get the N+1 problem.
> Hi Stephan,
>
> This is related to an issue already in JIRA about the need to all
> configuration of the fetching strategy in GORM.
>
>>
>> Idesa to solve this? I  tried using Criteria (as Hibernate can
>> define  the fetching  strategy with criterias) but
>> Grails doesn't support offset, setfetch etc.
> It should, so this is another issue to raise (ie supporting these
> settings within the Critera Builder)
>
> Sorry I don't have any current solution for you besides doing
> something like (i'm guessing your object model here):
>
> Path.findAllByCommit(commit)
>
> to fetch them all explicitly..
>
> this is one of the higher priority issues though
>
> Cheers
> Graeme
>
>>
>> bye
>> -stephan
>>
>> --
>>    Stephan Schmidt
>>    [hidden email]
>>
>>    PRESS ON. Nothing in the world can take the place of persistence.
>>    Talent will not; nothing in the world is more common than
>> unsuccessful
>>    men with talent. Genius will not; unrewarded genius is almost a
>> proverb.
>>    Education will not; the world is full of educated derelicts.
>> Persistence
>>    and determination alone are omnipotent. - Calvin Coolidge
>>
>>
>>