Question

Performance issue in Custom selector attribute

  • 2 January 2023
  • 9 replies
  • 171 views

Good day, everyone.


We customized a requisition (RQ302000) screen Ref Nbr. Selector to load data based on a logged in user's user role.

The selector worked fine when there were few records, but now we have thousands of records and every field on the screen takes time to update the value because of this custom selector.

The code for the custom selector is shown below. What is the best way to avoid this performance problem, and what changes should we make to this custom selector?

 

public class RequisitionEntryRQNbrExt : PXGraphExtension<RQRequisitionEntry>
{
#region Ref nbr attribute override
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRemoveBaseAttribute(typeof(PXSelectorAttribute))]
[RQRequisitionRestrictExt]
protected virtual void RQRequisition_ReqNbr_CacheAttached(PXCache cache)
{

}
public class RQRequisitionRestrictExt : PXCustomSelectorAttribute
{
public RQRequisitionRestrictExt()
: base(typeof(RQRequisition.reqNbr))
{
this.DescriptionField = typeof(RQRequisition.description);
}
protected virtual IEnumerable GetRecords()
{
var graph = this._Graph;
//PXCache cache = null;

//if (graph != null)
//{
// cache = _Graph.GetPrimaryCache();
//}

//if (cache == null)
//{
// yield break;
//}

UsersInRoles roleaccess = PXSelect<
UsersInRoles,
Where2<
Where<UsersInRoles.username, Equal<Required<AccessInfo.userName>>>,
And<Where<UsersInRoles.rolename, Equal<Required<UsersInRoles.rolename>>,
Or<UsersInRoles.rolename, Equal<Required<UsersInRoles.rolename>>,
Or<UsersInRoles.rolename, Equal<Required<UsersInRoles.rolename>>,
Or<UsersInRoles.rolename, Equal<Required<UsersInRoles.rolename>>
>>>>>>>
.Select(graph, graph.Accessinfo.UserName, "Administrator", "POAdmin", "POManager", "RQAdmin");
if (roleaccess != null)
{
foreach (PXResult<RQRequisition, Customer, Vendor> result in PXSelectReadonly2<RQRequisition,
LeftJoinSingleTable<Customer, On<Customer.bAccountID, Equal<RQRequisition.customerID>>,
LeftJoinSingleTable<Vendor, On<Vendor.bAccountID, Equal<RQRequisition.vendorID>>>>,
Where2<Where<Customer.bAccountID, IsNull,
Or<Match<Customer, Current<AccessInfo.userName>>>>,
And<Where<Vendor.bAccountID, IsNull,
Or<Match<Vendor, Current<AccessInfo.userName>>>>>>>.Select(graph))
{
yield return result;
}
}
else
{
EPEmployee employeeDetail = PXSelect<EPEmployee, Where<EPEmployee.userID, Equal<Required<EPEmployee.userID>>>>.Select(this._Graph, this._Graph.Accessinfo.UserID);
if (employeeDetail != null)
{
foreach (PXResult<RQRequisition, Customer, Vendor> result in PXSelectReadonly2<RQRequisition,
LeftJoinSingleTable<Customer,
On<Customer.bAccountID, Equal<RQRequisition.customerID>>,
LeftJoinSingleTable<Vendor,
On<Vendor.bAccountID, Equal<RQRequisition.vendorID>>>>,
Where2<Where<Customer.bAccountID, IsNull,
Or<Match<Customer, Current<AccessInfo.userName>>>>,
And2<Where<Vendor.bAccountID, IsNull,
Or<Match<Vendor, Current<AccessInfo.userName>>>>,
And<Where<RQRequisition.employeeID, Equal<Required<RQRequisition.employeeID>>>>>>>
.Select(this._Graph, employeeDetail.BAccountID))
{
yield return result;
}
}
}

}
}
#endregion

}



Can anyone suggest the solution?

 

Thanks..


9 replies

Userlevel 7
Badge +5

I’d be tempted to load a copy of the data local so you can run SQL traces to see if adding an index would be helpful.

 

Userlevel 7
Badge +17

Hi, @srikanth56  I would suggest you review the Request Profiler and check which queries taking a long time to the details and take those SQL queries and apply Non-Clustered indexes on the respective table and columns, which will solve the performance issue.

Hello @ddunn  and @Naveen Boga 

The request profiler showing below tables and attached file query (The file contains the highlighted tables query).

However, the RQRequisition table already has indexes on the NoteID column, and I have added NC indexes on the VendorID and CustomerID fields, but the problem persists.

We added some custom columns to the RQRequisition table (Project, Project Task, Employee selectors), and I tried creating NC indexes on these columns as well, but no luck.

 

Could you please look over the attached query? Is there anything I'm missing?

Also, do you think any changes to the code in the custom selector will help here?

 

Userlevel 7
Badge +17

Hi @srikanth56  As per your screenshot, these queries are not taking more than 1 second (Taking only 520 MS). I don’t think are these queries are correct?

 

 

 

@Naveen Boga  Is PMProject table causing issue here? 
 

 

 

Userlevel 7
Badge +17

Yes, @srikanth56  That is correct, these queries are causing the performance issue. Let me check the attached file and let you know if I found anything.

Userlevel 7
Badge +17

@srikanth56  Have you added any NC indexes for the tables and verified the performance issue?

Yes, @Naveen Boga. I added an NC index to the RQrequistion table's VendorID and EmployeeID, but there has been no change, and the table also contains my custom columns (Project, Project Task, and Employee field selectors). I've also created NC indexes for these custom columns, but the performance hasn't improved.

Hi @srikanth56 ,

Have you got any solution for this issue?

We have also faced same kind of issue and our finding is that looping and “yield return result” is main cause of performance issues.

We have removed that custom selector and used standard pxselector to improve performance.

However still looking for some solution with custom selector.

If anyone can help.

thanks in advance

 

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved