Ticket T657646
Visible to All Users

Custom Refresh Action to improve performance through prefetching related object details

created 7 years ago

[DevExpress Support Team: CLONED FROM Q558707: How do I prefetch related details data to increase performance for calculated fields]
Dear Dennis,

we improved the loading performance for our application using Prefetch similar as described here.
You mentioned here: "Take special note that this code affects only initial loading and we do not have a good solution for the scenario when the ListView is refreshed via an Action or in code in an XAF Web application."

So that worked well for people using the windows application using UIType SingleWindowSDI, because each load is an initial load and Reload is not used.
However we have now the case, that people want to use the TabbedMDI mode and then they are using the Refresh Action.
While inital loading for example was improved to 6 seconds loading time, the Refresh takes about 30 seconds or longer.
We did analyse the queries using XpoProfiler and put a breakpoint into the PreFetch code.
PreFetch code is executed, only if the ListView is newly opened from the NavigationItem.
Refresh iterates trough all shown shown records and executes by far more queries resulting in the slow loading time.

So the question would be, could we provide a custom Refresh for some ListViews, so that it would use the same loading, as happening inital from the NavigationItem?

You find attached a screen recording, where we first click on the Orders NavigationItem for inital load, which takes 6 seconds, then we click Refresh, which takes till the end of the screen recording (much longer).
If we first remove the filter, then Refresh and after that we add the filter back, the total loading time is the same like the Refresh.
It is fast only with the loading from NavigationItem.

We also attached the logs from XpoProfiler for both cases.

Thank you very much ahead

Answers approved by DevExpress Support

created 7 years ago (modified 7 years ago)

Hello Fabio,

You can substitute the default refreshing mechanism by handling the RefreshController.RefreshAction.Executing or IObjectSpace.CustomRefresh event. However, we do not have ready implementation of these event handlers for your case. In XAF, the IObjectSpace.Refresh method is called at this moment. It recreates XPObjectSpace's Session (this guarantees that all changes are reloaded) and Collection Source's collection. Records should be pre-fetched after the Session is recreated and before the collection is bound to the grid control. You may need to use our sources to implement an appropriate solution.
You have also mentioned that records are loaded faster when the end-user filter is not applied. I suggest that you profile the application's behavior with and without the filter to determine the cause of this behavior. It may help to set breakpoints to the OrderDetails, Lieferschein and LieferDetails constructors and consult the Call Stacks to determine when and why these objects are loaded.
Also, consider using other ways to improve performance. For example, if the calculated property is implemented with the help of the PersistentAlias attribute, try setting the ListView's DataAccessMode to DataView. See How to measure and improve the application's performance for details.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.