Hi all.

I have a performance action regarding aggregated information.

Let's imagine an appointments list situation. The user has a list of appointments that he/she has to attend. However, we want to display those appointments separated by days. Which is best, regarding performance in OutSystems?

  • Multiple queries 
    • We group the appointments by date, in order to get the list of the days with appointments.
    • We use those days in a ListRecords widget, and inside we have a webblock that queries the appointments for the provided day.
  • Multiple filters
    • We group the appointments by date, in order to get the list of the days with appointments (as in the previous solution).
    • We get all the appointments that the user has to attend.
    • We use those days in a ListRecords widget, and inside we have a webblock that receives both the day and the complete list as input paramenters, and inside the webblock we filter the complete list by the provided day.

Hi mariap

The first case is bad, as you would be doing possible lots of requests to the database.
The second case would require extra logic and, eventually, copying data to local lists in order to show only the desired appointments (if I am not mistaken, lists are passed by reference to web blocks), or you would have to set the StartIndex and LineCount dinamically (I think it would work)

But I think doing something a little different would be possible easier.

Just fetch the data ordering by the days.
Than, adapt your List Records to show the day and related information only if the previous one is different from the actual. 

The logic is much simpler (basicaly is taking care of how to show the "day" information) and you do a single request to the database.

Eduardo Jauch

Hi Eduardo. 

Thanks for your fast reply!

In the second case I was actually just planning to use "ListFilter" in the webblock preparation to get the list filtered by the current day, and therefore I wouldn't need StartIndex and LineCount, I believe.

However, your solution is great and I will most probably implement it.

Many thanks,


Hi again, Eduardo.

I remembered another case, though. Lets imagine that I have several tags, and each tag belongs to a category, and I want to display my information in an aggregated way by using a "Section Expandable" component that displays the tags for each category. 

What solution would you recommend in that case?

Hello mariap,

Depends on what do you want to do with the tags.

If you will only show the tags, without any interaction between them and the user, you can do an advanced query and create an extra "text" field and append them to it. There are a number of ways to do this in the query.

If you need to interact with them, I see a good way of doing this. You do the same way as before, but you use a web block to show the tags and split than inside it. You will have a list you can use as source to a list record.

This way you avoid having to work with two aggregates.

You could also use a single list, and with an if, define if the row has a different category from the previous one. If yes, you show the Line, if not you don't show. And you pass the entire list to the web block, and use the lines you want. If they are ordered, you can pre-process the List to find the start and end line of each category and pass this info. The "problem" with this approach is that you will have ALL the lines in the main list, even if most of them are empty.


Eduardo Jauch

Hi Eduardo. 

I am not sure I understood your suggestions. The goal would be to allow user interaction with the tags, but also to use an already available component called "Section Expandable" (from Silk UI, check it here). The component can be placed inside a ListRecords widget, and has placeholders for title (that would be the category) and content (tags of that category). 

I think that either I have 2 aggregates (one to fetch the categories and to feed the ListRecords, another to fetch all tags, regardless of the category) and I have to filter the tags by current category to fill the component's content, or then again, I just have 1 aggregate to fetch the categories and another one for each categories's content...

Hi mariap

The fact you have an expandable section (or accordion) has no impact on this. The only thing you can't do is the same as in the previous case, because you need explicitly to the tags to be inside the expandable section.

So, the "show everything and just hide the categories when repeated" will not work.

But you don't need the two aggregates.

The idea is to have this as output of your query (this will require a SQL query):

each row  - category #n, other info columns for the category, a single column with all the tags (and possible id's) for this category  

Than, you use the category info in the title of the Expandable section, and a web block in the content, and pass to it all information you need to pass, and inside it, in the preparation, you split (and convert if necessary) the information about the tags. You will have a list of tags, and potentially other info, that you can use as source to a list inside the web block to show the tags info, with links and etc.

List of categories
      |_Expandable Section
              |_ Category in title
              I_ Web Block that receives the Tags info (concatenated)
                        |_ List of tags (after split)

The approach that uses a single list with a line per tag, ordered by category, it is the "show all lines" we talked earlier, but adapted because of the  Expandable Section

List of Tags (ordered by category)
      |_ IF (show only if the category in current line is different than the previous one)
              |_Expandable Section
                       |_ Category in title
                       I_ Web Block that receives the entire List of Tags
                               |_ List of tags (only for the actual category)

In this case, you would have to show in the list of the web block only the tags associated with the category being shown.

The problem here is that the IF will not show the info for repeated categories, but the lines will be there in the HTML. For example, the Current Row Number will not match the "line number" the user is seeing. 

But while both approaches eliminate the need to use a second aggregate, they require extra logic.
but for sure it is simpler to use two aggregates and send the second list for each expandable section web block to show the info. 

In this case, possibly, having two aggregates will have a good performance and it will be easier to mantaing than adopt one of those approaches.


Eduardo Jauch