openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Merrill <ch...@webperformance.com>
Subject Re: Query syntax question about COUNT(x) and GROUP BY
Date Fri, 20 Aug 2010 02:37:10 GMT
On 8/19/2010 8:03 PM, Pinaki Poddar wrote:
>   Great to note your appreciation of the progress of ORM (some one once
> said: ORM is the Viet Nam of Computer Science:)

Heh heh...I thought that was Artificial Intelligence :>

> Why a separate count(*) needed in this case?
> Is not the number of result rows returned by the first query is the same as
> the number of customers to make any paging decision? 
> If that is true, the simply q1.getResultList().size() should obviate the
> COUNT(*) query?
> 
> Or have I just got it all wrong? 

That would work but it would be inefficient.  I have to implement a data provider for
the UI component. It will ask my data provider how many total items there are (thus
the need for the count(*) query) and then it will ask me for items N thru N+20, depending
on where the user navigates to.  In theory, there could be tens of thousands of rows, so
fetching them just for the sake of counting them is poor practice and very expensive.

Chris


-- 
------------------------------------------------------------------------ -
Chris Merrill                           |  Web Performance, Inc.
chris@webperformance.com                |  http://webperformance.com
919-433-1762                            |  919-845-7601

Web Performance: Website Load Testing Software & Services
------------------------------------------------------------------------ -

Mime
View raw message