Performance / INSERT(FALSE) etc

boywonderboywonder Member Posts: 179
Just read this...

"Try to structure the code so that it does not have to examine the
return values of the INSERT, MODIFY, or DELETE functions.
When using the return value, the server has to be notified right away
so that a response can be obtained. Therefore, if they are not
necessary, do not look at these return values."

So help I'm not 100% clear what this is saying (my english!) -

Does it mean...

MODIFY(FALSE) is bad and instead it should be just MODIFY...


I hope so because that's what I've always done unless the OnModify trigger is needed in which case MODIFY(TRUE) :mrgreen:

Comments

  • kapamaroukapamarou Member Posts: 1,152
    boywonder wrote:
    it does not have to examine the
    return values of the INSERT, MODIFY, or DELETE functions.

    It has nothing to do with (TRUE) or (FALSE). These two parameters change the business logic. INSERT(FALSE) will perform an insert without executing any validation code.

    What this means is that you should avoid writing IF INSERT THEN... or IF NOT MODIFY THEN...

    IF COMMAND returns a boolean value indicating a successful / unsuccessful command.
  • matttraxmatttrax Member Posts: 2,309
    It says only use
    IF Record.INSERT THEN;
    IF Record.MODIFY THEN;
    IF Record. DELETE THEN;
    

    when you have to. When you do the code like this the server has to send a response in order to know how to move forward. When you just do a normal INSERT/MODIFY/DELETE it moves to the next line of code without waiting.
  • boywonderboywonder Member Posts: 179
    makes perfect sense now - thank you so much :D:D
  • BeliasBelias Member Posts: 2,998
    i'm just "adding a cherry on the cake"...
    there's no problem in using
    IF NOT mytemptable.INSERT THEN
      mytemptable.MODIFY
    
    structure (supposing that mytemptable IS a temporary table variable) as it does not imply any server call/response.
    This is obvious, but it's useful to know, as it is a comfortable way of managing temptables, if you need it
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • bbrownbbrown Member Posts: 3,268
    Checking the return value of INSERT disables the use of bulk inserts.
    Microsoft Dynamics NAV automatically buffers inserts in order to send them to SQL Server at one time.

    By using bulk inserts the number of server calls is reduced, thereby improving performance.

    Bulk inserts also improve scalability by delaying the actual insert until the last possible moment in the transaction. This reduces the amount of time that tables are locked; especially tables that contain SIFT indexes.

    Application developers who want to write high performance code that utilizes this feature should understand the following bulk insert constraints.
    There are no bugs - only undocumented features.
Sign In or Register to comment.