SETFILTER/SETRANGE vs manual loop (on large data set)

kareshi
Member Posts: 9
Does anybody here have expirience with real DB (big one) with altering data in multi access case?
The question is:
Target: need to modify some set of records in 'big' table (Value Entry for example).
Fields to filter is decimal and there is no keys that contain these fields.
What approach will be faster and safer? :
1 - SetFilter on this field: Setfilter("My Field",'> X') then findset then modify (or modifyall?)
2 - loop for all records in table, if one is maches then modify.
On db with single user the 1st one is greatly faster.
But what about db with multi access case?
Does anybody here provide experiments with real life patients?
PS Locktable is used
The question is:
Target: need to modify some set of records in 'big' table (Value Entry for example).
Fields to filter is decimal and there is no keys that contain these fields.
What approach will be faster and safer? :
1 - SetFilter on this field: Setfilter("My Field",'> X') then findset then modify (or modifyall?)
2 - loop for all records in table, if one is maches then modify.
On db with single user the 1st one is greatly faster.
But what about db with multi access case?
Does anybody here provide experiments with real life patients?
PS Locktable is used
0
Comments
-
native or SQL?Do you make it right, it works too!0
-
If this is the only field you filter then I think the Filter option is better.
If you can filter with other fields down to a small set of records and loop those records looking for just a couple of them then you could use the loop approach. I think it depends on the size of the resulting filtered set...0 -
kapamarou wrote:If this is the only field you filter then I think the Filter option is better.
If you can filter with other fields down to a small set of records and loop those records looking for just a couple of them then you could use the loop approach. I think it depends on the size of the resulting filtered set...
Resulting set is undefined. It can be small or all records in table.
//Actually in my case there is 2 such fields. And only them i can use to make selection.
My concern is about db locks actually.0 -
I would use the MODIFYALL-solution with the correct SETRANGE-SETFILTER.
A way to avoid locking others is to make your updates as fast as possible. The MODIFYALL is the best solution for it.
In case you know that the resultset takes most of the records, I would think about looping the recordset, putting the record I want to change in another buffer and modifying that. After about 3 seconds, I would do a COMMIT. Of course if you use COMMIT's you need to create your code so that in can continue after the last COMMIT if there is an error (this is not always so easy to program).Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
only one comment to that was Alain said.
If you make a "big" updatetransaction with blocking other users (because u update many recs and there processes must wait -> Lockqueue) and u use the commit in your statement (for this u must know what you do, so that you don't create inconsistence datas) , you can also use after it a sleep to give other processes the chance to reduce the queue.
i saw someware also a BLOG about these "modify" theme. Maybe it was Waldos Blog or Krikis Blog.
RegardsDo you make it right, it works too!0 -
I created a how-to or a tips&tricks on that, but it is only for the native DB.
I didn't find yet a good trick for the SQL-DB.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!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