Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Using Select Aggregate Statements

former_member207873
Participant
0 Kudos

Hi Experts,

     I am getting mixed response regarding the use of aggregate statements in select query. My concerns are:

1) Using aggregate function in select query or processing in internal table is more efficient ?

2) If it is database dependent (as some may argue ), for which databases we have to use aggregate function and for which we should avoid to use it ?

3) Is there any relevant study regarding this topic,  I mean some statistics with the no of records, and the underlying database used.

Sam.

9 REPLIES 9

former_member207873
Participant
0 Kudos

Any inputs on this ?

0 Kudos

Hi Sam,

             It really depends on volume of data and requirement, what i would recommend is to process the internal table instead of using aggregate, most of the time you would be using some kind of loop after select for manipulating data so what you are trying to achieve can easily be achieved in the existing loop and keep select query simple. but again it depends on requirement

Thanks

Former Member
0 Kudos

Hi Sam,

I agree with Aarif, but you can make use of aggregate functions while writing select query rather than using loops on internal tables to find Max. Value for example as this is more efficient.

Please refer to the link below for more information on Aggregate statements.

ABAP Keyword Documentation

Regards,

Ashvin

0 Kudos

Hi Ashvin,

But my question is when and where to use aggregate functions since we can do all the functions performed in an aggregate statement inside internal table loop. If using aggregate functions have perform problem why do they exist ?

0 Kudos

This message was moderated.

UweFetzer_se38
Active Contributor
0 Kudos

Hi Sam,

I don't know where you found this nonsense, but the rule of thumb is: don't transport (DB -> Application Server) data if you don't need it. Means: if you just need the maximum value or a sum of a database query why you want to read and transfer all the data to the application server?

Let do the DB do all the work for you, especialy if it's already a HANA installation.

0 Kudos

Hi Fetzer,

Thanks for your answer. But just have a look on to the answers I received, they are not appreciating the use of aggregate statements. Many of my colleagues also belong to the school of thought that using aggregate statements will have performance problems. So what I have to take ?

0 Kudos

And noone has explained WHY they believe it is so yet, because it's not possible...

(see also Urban legend - Wikipedia, the free encyclopedia )

So what I have to take


Just think about arguments pro and contra. I already gave you some (unnecessary transfer of data).

0 Kudos

Hi Fetzer,

                I just wrote  blog on this may be you can share your thoughts

Regards,