Jump to content

count distinct vs Sum in Ad hoc view - jaspersoft 7.8


paris11

Recommended Posts

I have defined 2 basic metrics in a jasper domain

measure 1 : number of cheques  = count (distinct  cheque id)

measure 2 : amount of cheques  = sum (amount)

 

1st ad hoc view, I select the measure 1, here  is the jasper query :

select count(DISTINCT "cheque"."id_cheque") as "CountDistinct_cheque_id_cheque" 
from "public"."cheque" "cheque"

that s ok

2nd ad hoc view , I select measures 1 and 2, here is the jasper query :

select Sum("cheque"."montant") as "Sum_cheque_montant", 
"cheque"."id_cheque" as "cheque_id_cheque"
from "public"."cheque" "cheque"
group by "cheque"."id_cheque"
 limit 2000001 

Why the jasper query is not like that 

select  

count(distinct id_cheque),
SUM(montant) 
from   cheque

The jasper query works but gets 1 million rows instead of 1 row and uses 30Mo in memory instead of 0.1

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

https://community.jaspersoft.com/wiki/unexpected-results-andor-performance-issues-group-summaries-ad-hoc-v50-and-later

 

I do not understand, it is already like that  in applicationContext-adhoc-dataStrategy.xml

<bean>    <property name="name" value="DistinctCount" />    <property name="functionName" value="distinctCount" />    <property name="calcMethod" value="sqlUnionAll" /></bean>

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...