Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

while select statement used instead of join in ax 2012 r3

(0) ShareShare
ReportReport
Posted on by 6

HI all,

i need tow basic clarifications

1. If i used nested while select statement ( multiple times ) instead of join , So, what will create a problem in the future? like performance issues in PROD server. 

example -- while select field1, filed 2 from table name
                  {  
                         while select field1, field2, filed3 from table 2
                         where table2,accountnum == table1.accountnum
                        {
                               if(table2.recid)
                               {
                                     // todo
                                }
                        }
                  } 

2.QBDS is always preferable t o use? 

kindly confirm

  

  • @rp@n Profile Picture
    6 on at
    RE: while select statement used instead of join in ax 2012 r3

    thanks Nikoloas

  • Verified answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: while select statement used instead of join in ax 2012 r3

    No, it's not true.

    A select statement and a Query() based query will anyway be translated to a T-SQL statement in the AOS, and then this statement is sent to the database. So in the database there is no difference and therefore the performance is the same.

  • @rp@n Profile Picture
    6 on at
    RE: while select statement used instead of join in ax 2012 r3

    thanks Nikoloas,

    finally one thing

    is it true like qbds query is much faster than while select?

  • Verified answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: while select statement used instead of join in ax 2012 r3

    1. Nested statements are bad for performance so use join instead.

    If you use join, exactly one statement is sent to the database and you get one result (which you can then iterate in your code, using while statement). Only one round trip to database is made.

    If you use nested statements you might make dozens or hundreds of database calls which is bad.

    In general you should try to minimize the number of database calls.

    2. No, it's not "always preferable to use".

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.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,280 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,044 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans