Announcements
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
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.
Hi Brandt,
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.
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?
André Arnaud de Cal...
294,251
Super User 2025 Season 1
Martin Dráb
232,984
Most Valuable Professional
nmaenpaa
101,158
Moderator