Hi all.
I'm trying to optimize some queries that we have written in order to populate some temp tables that provide the data for a form we created for our planning department to gauge demand for certain items in AX. Currently these queries are written as while select statements and I was wondering if there was a performance gain from constructing them in a Query() object instead. I'm certain that when it comes to executing the query in SQL the performance is likely the same, but I am wondering if by employing a Query() object if I can somehow cut down on RPC chatter between AX and SQL when executing the query. I have seen other posts in relation to this topic, but not concerning performance. If anyone has any insight on this I would love to hear it.
Thanks.
Brandt
Hi Brandt,
Query:
Can be changed at runtime and can be packed and have more features than select statement such as union queries. can be added to AOT。
allows you to modify the query dynamically based on business logic.
Query framework gets worse compiler control than select statements.
Select:
More easier to read, it's hard code and it's much less flexble.
Other functions are not much different in nature. What about your query structure and data?
I guess you're wondering the difference of interaction times of ax and sqlserver between query object and while select statement.
Sorry I never tried that.
In your senario, i suggest using the query as the form datasource instead of temp table so you don't need loop the result set one by one and insert in to the temp table which is the main pain point of performance.
The performance of the database call is no different between x++ select statement or Query object. Both are converted to a single T-SQL statement by the AOS and then this statement is queried against the database. So the communication between the AOS and SQL server is exactly the same, assuming your select statement and query object are asking for the same data.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 2,004
André Arnaud de Cal... 865 Super User 2025 Season 2
Sohaib Cheema 582 User Group Leader