Skip to Content
Author's profile photo Former Member

Query Creation Checklist

Many places I’ve gone have looked for “Best practices” when writing queries. While this list is not complete, I’ve been building on it as time goes on. Customers usually like having a list of “do’s” and “don’ts” when it comes to query building. This list will help ensure that queries are built well (for performance and maintainability).  Walkthrough Checklist for Query Performance  1. If exclusions exist, make sure they exist in the global filter area. Try to remove exclusions by subtracting out inclusions. 2. Use Constant Selection to ignore filters in order to move more filters to the global filter area. (Use ABAPer to test and validate that this ensures better code) 3. Within structures, make sure the filter order exists with the highest level filter first. 4. Check code for all exit variables used in a report. 5. Move Time restrictions to a global filter whenever possible. 6. Within structures, use user exit variables to calculate things like QTD, YTD. This should generate better code than using overlapping restrictions to achieve the same thing. (Use ABAPer to test and validate that this ensures better code). 7. When queries are written on multiproviders, restrict to InfoProvider in global filter whenever possible. MultiProvider (MultiCube) queries require additional database table joins to read data compared to those queries against standard InfoCubes (InfoProviders), and you should therefore hardcode the infoprovider in the global filter whenever possible to eliminate this problem.  8. Move all global calculated and restricted key figures to local as to analyze any filters that can be removed and moved to the global definition in a query. Then you can change the calculated key figure and go back to utilizing the global calculated key figure if desired  9. If Alternative UOM solution is used, turn off query cache. 10. Set read mode of query based on static or dynamic. Reading data during navigation minimizes the impact on the R/3 database and application server resources because only data that the user requires will be retrieved. For queries involving large hierarchies with many nodes, it would be wise to select Read data during navigation and when expanding the hierarchy option to avoid reading data for the hierarchy nodes that are not expanded. Reserve the Read all data mode for special queries—for instance, when a majority of the users need a given query to slice and dice against all dimensions, or when the data is needed for data mining. This mode places heavy demand on database and memory resources and might impact other SAP BW processes and tasks.  11. Turn off formatting and results rows to minimize Frontend time whenever possible. 12. Check for nested hierarchies. Always a bad idea. 13. If “Display as hierarchy” is being used, look for other options to remove it to increase performance. 14. Use Constant Selection instead of SUMCT and SUMGT within formulas. 15. Do review of order of restrictions in formulas. Do as many restrictions as you can before calculations. Try to avoid calculations before restrictions. 16. Check Sequential vs Parallel read on Multiproviders. 17. Turn off warning messages on queries. 18. Check to see if performance improves by removing text display (Use ABAPer to test and validate that this ensures better code). 19. Check to see where currency conversions are happening if they are used. 20. Check aggregation and exception aggregation on calculated key figures. Before aggregation is generally slower and should not be used unless explicitly needed. 21. Avoid Cell Editor use if at all possible. 22. Make sure queries are regenerated in production using RSRT after changes to statistics, consistency changes, or aggregates.  23. Within the free characteristics, filter on the least granular objects first and make sure those come first in the order. 24. Leverage characteristics or navigational attributes rather than hierarchies. Using a hierarchy requires reading temporary hierarchy tables and creates additional overhead compared to characteristics and navigational attributes. Therefore, characteristics or navigational attributes result in significantly better query performance than hierarchies, especially as the size of the hierarchy (e.g., the number of nodes and levels) and the complexity of the selection criteria increase.  25. If hierarchies are used, minimize the number of nodes to include in the query results. Including all nodes in the query results (even the ones that are not needed or blank) slows down the query processing. The “not assigned” nodes in the hierarchy should be filtered out, and you should use a variable to reduce the number of hierarchy nodes selected. 

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Dear paraksh,

      Thanks for the information it's really helpful.

      Author's profile photo Former Member
      Former Member
      Hi Prakash,

      Itis  very very helpful information especially for beginners like me. Can you please clarify some doubts,
      1)In 3rd point you have mentioned "highest level filter ". I don't get that exactly. What do you mean by highest level filter?
      2)"Do as many restrictions as you can before calculations. Try to avoid calculations before restrictions." what would be the reason for this.

      Thanks
      Tulasi

      Author's profile photo Witalij Rudnicki
      Witalij Rudnicki
      Hi Prakash,
      It is very good list, but it would be fine, if you could elaborate a bit more on some points.

      E.g. could you explain a bit further your point #23? How it works and how this helps?

      Thank you
      Vitaliy

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      This comes down to run schedules that you can see in RSRT. If you want, play around with the order of the select statements generated in the RSRT runschedule and meaure the performance differences. You will see that the order in which you filter makes some small differences in performance...
      Author's profile photo Witalij Rudnicki
      Witalij Rudnicki
      One more thing to clarify: when you mention the order - is it an order in Filter, Free Characteristics or Variables Sequence?
      Thank you once again,
      Vitaliy
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      All of the above
      Author's profile photo Witalij Rudnicki
      Witalij Rudnicki
      🙂
      Author's profile photo Former Member
      Former Member
      Hi Prakash, some parameters recomended in RZ10 and Basis ares for get the best performance ?

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      There are no general parameters I would recommend. This is all dependent on your system configuration.
      Author's profile photo Former Member
      Former Member
      ÄãºÃ£¬ÄÇλ¸ßÊÖÄܲ»ÄÜŽÍæ·×g³ÉÖÐÎÄ£¬²¢Ô”¼šµÄ½âጰ¡£¬¶àÖxÁË
      Author's profile photo Kurt Harding
      Kurt Harding
      Should making sure that InfoProvider statistics are up to date be in this list as well? Also, maybe turning on statistics for the query? These would allow the query optimizer to pick a better access path to the data.