[XAF] How to improve the application ' s performance

Source: Internet
Author: User
Tags format definition prefetch switches

https://www.devexpress.com/Support/Center/Question/Details/T148978

The best of the determine the precise cause of a performance problem are to profiles your application using a specialized performance Profiler tool, e.g, aqtime, ANTS Performance Profiler (if you were developing a Web app, then Additiona Lly Profile The client side operation using the developer tools of your favorite browser (IE, Chrome)).
Such Tools show what methods take the most time-to-execute, and in conjunction with queries profiling, this allows Debuggi Ng practically all performance issues.
If there is issues with memory consumption in your application, follow the suggestions from we about profiling memory le AKS blog post.

In addition, check this list of the most frequent causes of performance issues and make sure that is following all th E Advice from the This list in your application.

General Issues:

1. the application or a certain View is loaded slowly for the first time, but subsequent loads was performed sign ificantly faster.

Solution : The majority of this was likely required to load additional assemblies or compile MSIL code. When the issue occurs in a certain View, this View likely uses a control so is not used by other views, e.g., SCHEDULERC Ontrol, Xtrareport. To improve performance in the case, use NGEN. Refer to what does my code take longer to execute the first time it ' s run? Article for additional information.

2. A View is painted slowly, and the application freezes when it's necessary to redraw this View.

Solution : Check whether any exceptions be thrown when the View is displayed. Even if these exceptions is handled and do not break the application ' s execution, a lot of exceptions may cause noticeabl E freezes, especially during debugging. An example of such a situation was when there was a mistake in the column ' s display format definition. In the case, a FormatException'll be thrown for each cell. To see these exceptions, enable Common Language Runtime Exceptions and disable the Just My Code option in Visual Studio. See how To:break when a Exception is thrown for more details.

3. The ListVIew is loaded slowly if the database table contains a lot of records (e.g., more than 100,000).

Solution 1 : If you don't need to show all these records in a single View, apply a server-side filter to your listview-see filter Li St views.

Solution 2 : Enable Partial data Loading-server mode-to load records dynamically when the ListView ' s control requests them. To does this, the open the model Editor, find the ListView model in the ' Views ' node and set its-Dataaccessmode to Server.

Issues caused by your persistent classes ' specifics:

To debug such issues, check what queries is performed while loading data from the database. Here is ways to does this:

-Using an SQL profiling tool. You can either use a third-party tool like SQL Server Profiler, or, if your is using XPO for your data layer, you can use The XPO Profiler.

-If you is using XPO, you can enable the queries logging. To does this, open the application ' s configuration file and uncomment the XPO diagnostics switch:

[XML]Open in Popup window
<System.Diagnostics><Switches><!--Use the one of predefined Values:0-off, 1-errors, 2-warnings, 3-info, 4-verbose. The default value is 3. -<add name=" expressappframework "value= "3" />    <add name = "XPO" value=" 3 "/>  </switches></system.diagnostics>   

Queries'll is displayed in the Output window and written to the eXpressAppFramework.log file (see log Files).

After configuring one of these approaches, load the problematic ListView and check the logged queries. If Their summary execution time takes the majority of the ListView ' s loading time, query optimization is required. Here is the most frequent cases:

4. server-side filtering, sorting or grouping is performed slowly because the database table does not contain the Necessary indices.

Solution: Check What columns is involved in the WHERE, ORDER by and GROUP by operations and add indices for them. To add a index using XPO, use the Indexed attribute.

5. The main SELECT query takes a long time to execute, although the result does not contain a lot of objects. This could occur if each persistent object selected by this query includes a lot of data, i.e, contains images, long texts, References to large persistent objects, etc.

Solution1: Set the ListView ' s Dataaccessmode to DataView to load only properties displayed in this ListView (is default, all Properti ES is loaded).

Solution2:Make large properties delayed, as described in the delayed Loading topic. Note that delayed properties should is displayed in the ListView and otherwise you'll have a case 7.1 (see below). If you need to display large reference properties in the ListView, use the solution from Case 6.

6.A persistent class contains a lot of reference properties, and additional queries that load referenced objects is execute D for a significant time.
Solution:Include referenced objects to the main SELECT query by applying the explicitloading attribute to the corresponding Propert ies.

Note that normally, all referenced objects of the same type is loaded through a single additional query for all records. If additional queries is performed for each record, see case 7.

7.
XPO or Entity Framework executes a separate query or several queries for each record.

Solution: See what additional queries is executed and analyze your business class to understand what code causes This. Here is examples of such cases:

7.1. Additional queries load a property of the current business class which is not loaded in the main SELECT query .

Solution: This property is likely delayed, and there are a ListView column that displays it. In this case, either does not use delayed loading for the "or" Remove the ListView column (see Change Field Layout And Visibility in a List View). The same issue would occur if the delayed property was accessed in code while loading objects, e.g., in another property ' s G Etter, or in the OnLoaded method.

7.2. Additional Queries Select data from the other tables.

Solution 1 : Check Whether your persistent class executes the code that loads Other persistent objects (E. G., creates an xpcollection or uses a session ' s methods like Session.findobject and Session.getobjectbykey) in proper Ty getters or in the OnLoaded method. In this case, either call this method in another place, e.g., in a getter's a property that's not displayed in the LISTV Iew, or remove the problematic property from the ListView.

Solution 2 : Check Whether there is calculated properties implemented through the Persistentalias attribute th At Use collection properties or joins operands in their expression, e.g., "Orders.sum (Amount)". It's important to remember so to get values of calculated properties, the getters that calls the Evaluatealias method is Called, and the Evaluatealias method evaluates the specified expression on the client side. So, if the Persistentalias expression contains a collection property, this collection would be loaded when calculating the Value. The easiest-resolve this issue is to hide such properties from the ListView. Alternatively, you can improve the performance of these properties by pre-fetching associated collections using the Sessio N.prefetch method. In the this case, all associated objects would be is loaded in a single query. See the example here: how do I prefetch related details data to increase performance for calculated fields.

Solution 3:   change the ListView ' s dataaccessmode to DataView. In this case, queries the can is executed on the server side (Persistentalias expressions) would be included to the main S Elect query, And client-side code that loads data is not being taken into account.

8.  the Applications Periodically perform the same queries that return the same Database records.

Solution: If These records is changed rarely, it makes sense to enable caching on the Data Layer level to prevent the duplicate req Uests, as described in the What to use XPO caching in XAF topic.


IMPORTANT NOTES
This list does not cover all possible cases. There is issues related to a specific database provider or caused by specifics of a legacy database, scenario-specific I Ssues, etc. A General suggestion are to find out what the query or the database table can be modified to improve performance, and then T Ry to modify your persistent objects accordingly.

If None of these suggestions is helpful, feel free to contact our support Team and provide the profiling logs for Analysi S.

[XAF] How to improve the application ' s performance

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.