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 2

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
    @rp@n 2 on at
    RE: while select statement used instead of join in ax 2012 r3

    thanks Nikoloas

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 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
    @rp@n 2 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
    nmaenpaa 101,156 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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,309 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans