Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Speed of append command - local vs network database
Message
De
21/03/2002 04:39:25
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
20/03/2002 20:06:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00634719
Message ID:
00635368
Vues:
18
>Thanks for the reply.
>I created an entirely new, empty table to test the append code, and got the same time as before. The 'append from' timing goes to 'instant' only if indices and referential triggers are removed. I generated the trigger code from the referential integrity builder. I selected 'restrict' as the rule for inserting child records. There are 5 parent tables with relations to the table being inserted into. I'm reluctant to remove the tigger code, for fear of db corruption.
>Is it common to write your own trigger code, to make it more efficient?
>2 seconds is not a problem for local table appends. 95 seconds will be a problem over the network.

I don't know how common writing your own trigger but I myself tend to write my own.
Then you can try another thing - turn the triggers off, drop checks, append, turn on, set check back (assuming you know that appending wouldn't break RI nor check - you might precheck that appending to a local cursor first). This is what SQL server bulk copy too does when let to do to speed up things.
Below is a sample template :
Use myTable alias '__Table__'
If !empty(cursorgetprop('Database','__Table__'))
  Open database (cursorgetprop('Database','__Table__'))
  lnObjects = adbobjects(arrDBObjects,'TABLE')
  For jx=1 to lnObjects && Find object name in DBC
    If upper(dbgetprop(arrDBObjects[jx],'TABLE','Path')) == upper(arrTables[ix,1])
      lcDbObject = arrDBObjects[jx]
      Exit
    Endif
  Endfor
  * Disable triggers and row rule
  lcDelTrigger = DbGetProp(lcDbObject, 'TABLE', 'DeleteTrigger')
  lcInsTrigger = DbGetProp(lcDbObject, 'TABLE', 'InsertTrigger')
  lcUpdTrigger = DbGetProp(lcDbObject, 'TABLE', 'UpdateTrigger')
  lcRuleExpr   = DbGetProp(lcDbObject, 'TABLE', 'RuleExpression')
  If !empty(lcDelTrigger)
    Delete trigger on (lcDbObject) for delete
  Endif
  If !empty(lcInsTrigger)
    Delete trigger on (lcDbObject) for insert
  Endif
  If !empty(lcUpdTrigger)
    Delete trigger on (lcDbObject) for update
  Endif
  If !empty(lcRuleExpr)
    Alter table (lcDbObject) drop check
  Endif
  * Get data
  Append from ..... && Get data ----------------------------- > appending here
  * Enable triggers and row rule
  If !empty(lcDelTrigger)
    Create trigger on (lcDbObject) for delete as &lcDelTrigger
  Endif
  If !empty(lcInsTrigger)
    Create trigger on (lcDbObject) for insert as &lcInsTrigger
  Endif
  If !empty(lcUpdTrigger)
    Create trigger on (lcDbObject) for update as &lcUpdTrigger
  Endif
  If !empty(lcRuleExpr)
    Alter table (lcDbObject) set check &lcRuleExpr novalidate
  Endif
Else
*Free table append here
  Append from ..... && Get data ----------------------------- > appending here
Endif
Use in '__Table__'
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform