Differences in using FINDSET, FINDFIRST and FIND('-')
jensthomsen
Member Posts: 173
Hi
Could anyone explain the differences (mainly performance) in using
FINDSET, FINDFIRST and FIND('-') ? I know that there are some (especially on SQL) but what are the "guidelines"? Code examples would be great:-)
Could anyone explain the differences (mainly performance) in using
FINDSET, FINDFIRST and FIND('-') ? I know that there are some (especially on SQL) but what are the "guidelines"? Code examples would be great:-)
0
Comments
-
FIND('-'): don't use this anymore, it really has not purpose anymore.
FINDSET: retrieves a set of records
FINDFIRST: retrieves only one record, the first one within the filter, sorted ascendingly
FINDLAST: retrieves only one record, the last one within the filter, sorted ascendingly
If you want to know if records exist within a certain filter, use ISEMPTY.
Check out the C/SIDE reference guide for more information, and code samples. If you need real life code samples, check out the posting codeunits in standard NAV.0 -
Here some more explanations with examples:
http://www.stryk.info/PFG_79_81.pdf
(Taken from "The NAV/SQL Performance Field Guide", ISBN: 978-3-8370-1442-6, http://www.stryk.info/fieldguide.html (c) STRYK System Improvement)
Best regards,
JörgJörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
-
One difference between FIND('-') and FINDSET(TRUE) is when the transaction begins. With FIND('-') the transaction begins when the call to update the database (INSERT, MODIFY, DELETE) is made. With FINDSET(TRUE) the transaction begins with the FINDSET command.There are no bugs - only undocumented features.0
-
I might also add that findset, findfirst, findlast are more typically used if you're using SQL database. This is implemented to enhance performance.
If you're using C/SIDE, find('-') will work fine.Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
Some advice : ALWAYS use FINDSET,FINDFIRST,FINDLAST. Even if you work on a Navision-DB. At least if the customer decides to convert to SQL, this is already ok.Alex Chow wrote:I might also add that findset, findfirst, findlast are more typically used if you're using SQL database. This is implemented to enhance performance.
If you're using C/SIDE, find('-') will work fine.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Yes, elmininate the use of FIND('-') as a habit is a good idea.Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
Nice, but in the very bottom you have an Wrong/Correct code. In the Correct section you have this statement:stryk wrote:Here some more explanations with examples:
http://www.stryk.info/PFG_79_81.pdf
Rec2.GET(Rec1.PrimaryKey);
Wouldn't it be just as good and even faster to simply:
Rec2 := Rec1;
Is there any reason to retrieve it from the db again?Regards
Peter0 -
[quote="pdjNice, but in the very bottom you have an Wrong/Correct code. In the Correct section you have this statement:
Rec2.GET(Rec1.PrimaryKey);
Wouldn't it be just as good and even faster to simply:
Rec2 := Rec1;
Is there any reason to retrieve it from the db again?[/quote]
The direct assignment Rec2 := Rec1; is also fine; maybe even better as you save one query. I think I will change this example in the edition of the PFG
Jörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
Question to the experts:
Is there a performance difference (assuming a correct key is chosen) between GET and FINDFIRST?0 -
the question was, if there's a performance difference. Assuming a primary key is used.0
-
You can only compare the two statements when you search a value based on the primary key. The difference in statements will be:
GET : SELECT * FROM table WHERE PrimaryKey = Value
FINDFIRST : SELECT TOP 1 * FROM table WHERE PrimaryKey = Value
In this case, the TOP 1 is no necessary, so I would go for the GET.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 328 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

