SELECT *...

ioannidisv
Member Posts: 7
in General Chat
Hi, I've always wondered why in SQL traces I see Dynamics NAV always shooting SELECT * FROM... commands. Is this a developer problem or a platform problem? If is the latter, can this behavior change without the creation of additional objects i.e. Views?
0
Best Answers
-
In most circumstances where NAV fetches data from the database, it offers you all the data in a corresponding Record variable. There, all fields are present, therefore NAV needs to fetch all fields. The only exception beeing the FlowFields, which you (mostly) need to fetch explicitly by calling CALCFIELDS.
Query objects are NAV's way to let you (as a developer) access your data in a more efficient way.5 -
Hello, BLOB fields need CALCFIELDS, otherwise they return NULL. Like this it is efficient.5
-
The NAV as a platform does not know if you are going to need a field or not. the FIND* command is the platform command, what are you going do do with the record later is not a platform concern. In one place you may use one field down the code, in another place few other fields. How the FIND platform command is supposed to know which field are you going to use after it, later in the code ?
As for the BLOB fields - it is not efficient, but a good NAV developer knows that and does not put a BLOB into table which needs to be frequently accessed. He/she puts the BLOB into separated, integer-keyed table instead, and in frequently accessed table keeps only the reference to the blob field holding table.
See the Interaction Log Entry / Attachment table for example.
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-035
Answers
-
In most circumstances where NAV fetches data from the database, it offers you all the data in a corresponding Record variable. There, all fields are present, therefore NAV needs to fetch all fields. The only exception beeing the FlowFields, which you (mostly) need to fetch explicitly by calling CALCFIELDS.
Query objects are NAV's way to let you (as a developer) access your data in a more efficient way.5 -
Well, I wouldn't call that "efficient" but it's definitely a way. How is it efficient if for example you have blob fields in your table, that you don't need for, let's say, 80% of the times?
But anyway, thanks @vaprog for taking the time to answer this one0 -
Hello, BLOB fields need CALCFIELDS, otherwise they return NULL. Like this it is efficient.5
-
Good to know that. Thanks @thomasbarbut !
As you have already probably understood, I'm not a Dynamics NAV developer , I'm a DBA0 -
The NAV as a platform does not know if you are going to need a field or not. the FIND* command is the platform command, what are you going do do with the record later is not a platform concern. In one place you may use one field down the code, in another place few other fields. How the FIND platform command is supposed to know which field are you going to use after it, later in the code ?
As for the BLOB fields - it is not efficient, but a good NAV developer knows that and does not put a BLOB into table which needs to be frequently accessed. He/she puts the BLOB into separated, integer-keyed table instead, and in frequently accessed table keeps only the reference to the blob field holding table.
See the Interaction Log Entry / Attachment table for example.
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-035 -
Ahh, i haven't noticed. It had the same difficulties like you. I started with Dynamics NAV by looking/reporting at/from SQL, but as soon as I started developing C/AL everything began to make sense. . .
Also if you want to create new Indexes,Keys for performance do it in Dynamics NAV because if Objects in Dynamics are compiled every operation made on SQL for the obejct is lost.
I had to learn it the hard way.
best regards,1 -
> @Slawek_Guzek said:
> The NAV as a platform does not know if you are going to need a field or not. the FIND* command is the platform command, what are you going do do with the record later is not a platform concern. In one place you may use one field down the code, in another place few other fields. How the FIND platform command is supposed to know which field are you going to use after it, later in the code ?
>
> As for the BLOB fields - it is not efficient, but a good NAV developer knows that and does not put a BLOB into table which needs to be frequently accessed. He/she puts the BLOB into separated, integer-keyed table instead, and in frequently accessed table keeps only the reference to the blob field holding table.
>
> See the Interaction Log Entry / Attachment table for example.
>
> Slawek
Hi Slawek,
Thanks for your reply. I understand your point, I just thought that it could be something like a SELECT statement where you can ask for the fields you need. As this seems to be predefined in NAV C/AL, there's not much anyone can do on that side.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions