On Wed, 26 May 2004, Pix wrote:

>Hi,
>I'm using triggers to perform some operations on my SQLite DB.
>Particularly I'm using them to easily maintain DB coerency (e.g. if I
>delete an item from a table, the trigger will delete all rows from
>another table that are referencig to that item).
>
>My question is: how much performant the triggers are?
>Is it bettere to have a trigger or to explicitly execute the query
>(maybe in a transaction) any time I need?


There should be some extra overhead against maintaining coherency
yourself, as the trigger actions will be compiled into the VM for the main
table delete statement, which will involve some extra glue. Also, if
deleting more than one row, the trigger will be fired for each row, which
may involve a table scan of the other table for each main row table
deleted, rather than a single table scan you may be able to get away with
for seperate delete statements.

The benefit of using triggers are:
- The coherency is always maintained if the triggers are
  implemented correctly.
- The action of removing a row from the main table is guaranteed to be
  atomic, even if not executed within an explicit transaction.

I say go with the trigger solution and take any performance hit, which as
I said, is likely to be minimal, especially if updates are small.


>
>Thanks
>
>Paolo
>

Christian


-- 
    /"\
    \ /    ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
     X                           - AGAINST MS ATTACHMENTS
    / \

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to