Question

Slow filter

Hello,

 

I'm trying to filter a lookup based on Contact entity using two conditions. I'm trying to get all the contacts assigned to a certain account or all contacts that are connect to (by a relation) a certain account. I have defined this attribute and it is working fine.

"FilteredContact": {

         dataValueType: Terrasoft.DataValueType.LOOKUP,

         lookupListConfig: {

          filters: [

               function() {

                var accountId = this.get("Account").value;

                var filterGroup = Ext.create("Terrasoft.FilterGroup");

                filterGroup.logicalOperation = this.Terrasoft.LogicalOperatorType.OR;

                filterGroup.add("IdFilter", Terrasoft.createColumnFilterWithParameter(

                                  Terrasoft.ComparisonType.EQUAL, "Account", accountId));

                filterGroup.add("ConnectedFilter", Terrasoft.createColumnFilterWithParameter(

                                        Terrasoft.ComparisonType.EQUAL,

                                        "[VwContactRelationship:Contact].RelatedAccount", accountId));

                return filterGroup;

             }

            ]

  }

}

But it's very slow in many cases. Sometimes the execution lasts more than 30 seconds.

I have checked the generated sql query and the first criteria is translated with a simple where clause but the second criteria is translated to an exists clause. These 2 combined with an OR are executed very slowly. 

Do you have any idea how can I improve the performance of this filter? 

 

Thank you,

Cristian.

 

Like 0

Like

3 comments

Try to check the execution plan. It will help you to see where you need to add indexes.

http://prntscr.com/j0yc5h

Sometimes SQL management studio suggests creating indexes automatically. 

I'm sure indexes will help you a lot.

Eugene Podkovka,

Thank you Eugene for your answer. I've already checked the execution plan and indexes on development environment and all looks good. Unfortunately we experience this issue on production environment and there I can't do much. The indexes are there. I thought maybe there are some hints to force the filter to generate a faster query.

Cristian Galatan,

Unfortunately we experience this issue on production environment and there I can't do much

You can take a copy of the application from the cloud and deploy it on your side. This way you'll see what exactly happens.

Additionally, once you find a script that increases the performance of the filter, you can execute it in the "SQL Scripts" tab.

http://prntscr.com/j19jpa

Show all comments