web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Difference between fetchmode and firstonly in datasource

(0) ShareShare
ReportReport
Posted on by

In datasource object of query (i.e query of report) there are two properties:

fetchmode

firstonly

I have a case like this:

datasource1 need to retrieve only one record.

datasource2 is after datasource1, and related to datasource1 with exists join.

Only if the relation between datasource1+datasource2 is ok, then data shall be retrieved,

but what if when query is selected - the first record fetch doesn't have data related for datasource2 (existjoin is false), but the second record (of datasource2) has related data.

I need to do the query, that the fetchmode or firstonly will influence after check the whole query as the example (and not fetching the datasource1, and then check for existence for datasource2), so I need to know - what is the major difference between 'fetchmode' and 'firstonly'.

 

Thanks :)

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Ivan (Vanya) Kashperuk Profile Picture
    on at

    FetchMode and FirstOnly are completely unrelated and different settings.

    Maybe you meant? FirstFast?

    FetchMode can be either 1:1 or 1:n. 1:n was used in reports previously, but should generally be avoided going forward. I won't therefore go into trying to explain how it works. 1:1 however is ensuring a regular join like you'd see in SQL.

    FirstOnly will only return the 1 record.

    Your explanation was a bit messy so I am not sure I got your question right, but if you have 2 datasources, DS1 and DS2, where the link is an exists join, that is identical to

    select TOP 1 DS1 where exists (select from DS2 on A=B)

    So you will only get the first available DS1 record where DS2 also exists

  • Community Member Profile Picture
    on at

    OK - if firstfast parsed to some sql, it's fine with me.

    If not (when something in AX that fetched the first datasource, and then the second), then logically it will be wrong.

    i.e : ds2 has 2 records for same record of ds1, and only the second record match for exist join.

    Thanks

  • Verified answer
    Ivan (Vanya) Kashperuk Profile Picture
    on at

    The query keywords are in fact passed in as hints to SQL query planner.

    Ignore what I asked about FirstFast - that does not seem to be related to your question.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans