LLBLGen 4.1, postgresql, subquery with limit and offset

Posts   
 
    
miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 24-Jan-2014 13:16:19   

Hi

How can I achieve the following query (paging inside the subquery)? Pseudo code:

select * 
from A
where id in
  (
  select id
  from A
  where .....
  order by id asc,
  limit 100
  offset 1000
  )

I need to optimize the paging query. The query analizer shows me +- 5x optimization in my case when I do a paging in a subquery.

Best regards, MiloszeS

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Jan-2014 04:32:50   

You should use a FieldCompareSetPredicate in your filter. There is some FieldCompareSetPredicate ctor that accepts a maxItemsToReturn parameter.

David Elizondo | LLBLGen Support Team
miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 27-Jan-2014 09:37:54   

Yes, I've already found the parameter for the limit clause (maxNumberOfItemsToReturn), but I also need the offset parameter.

Best Regards, MiloszeS

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 27-Jan-2014 17:39:31   

Limit and Offset are you used for paging as you have said.

I can't think of a scenario where paging in a sense is used for filtering. Could you please provide a scenario where this might be needed?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39877
Joined: 17-Aug-2003
# Posted on: 28-Jan-2014 09:28:39   

Our framework doesn't allow paging inside subqueries as most databases require extra constructs to perform paging which aren't allowed inside a subquery, plus the use case for paging inside a subquery is unclear...

Could you give the full query you're trying to produce? The query you gave has a select * from wrapper around the real query which is meaningless (it doesn't do anything other than return the inner query's result).

Frans Bouma | Lead developer LLBLGen Pro