Aggregate to return values of selected columns

Is it possible to make an aggregate to return the values of selected columns alone?

Like we are able to query selected columns from an entity using SQL, can we do the same thing using aggregate?

Solution

Hi Ananth,

There's absolutely no need to do that. The Platform Optimizer will recognize which columns you use, and only use these in the underlying SELECT.

Solution

Hi Ananth,

In aggregates you don't need to worry about that because outsystems takes care of that for you and only queries the fields of the aggregate that you use/need.

Regards,

Marcelo

@Marcelo: I got there first! ;)

@Kilian Im on smartphone so I write a lot slower ;)

If I want to force the aggregate to return only one column I use group by, but on this case might not be need

Nelson,

The only reason to limit the output would be if you want to pass it as Output Parameter, and you don't want to bother with creating a new Structure. However, using Group By comes with a performance penalty, so use it with care!

Hello All


After the web developer test sample, I was correcting my answers and I'm confused in question 14:


"14. Considering Aggregates in a Web application, which of the following options is false?"


The correct answer is: Aggregates allow hiding columns to reduce the number of attributes returned in the query.

What's the catch? I can hide columns to reduce .... 


Thank's in advance


Ricardo


Hi Ricardo,

That's not true. You can hide the number of columns you are seeing in preview mode, but that's independent of what is actually fetched when the app runs. The optimizer determines what Attributes are retrieved from the database.

Kilian Hekhuis wrote:

Hi Ricardo,

That's not true. You can hide the number of columns you are seeing in preview mode, but that's independent of what is actually fetched when the app runs. The optimizer determines what Attributes are retrieved from the database.


Thank You Kilian :-)

You're most welcome :). It can be a bit confusing I admit, but the takeaway is that the optimizer always minimizes the number of columns to fetch. Just be aware that as soon as you output the Aggregate result in an Action, all Attributes will be fetched, as the optimizer cannot know what you're planning to do with that output. Happy coding!