Best strategy question

Ruslan Zasukhin sunshine at public.kherson.ua
Thu Sep 11 13:36:43 CDT 2008


On 9/11/08 9:08 PM, "Bart Pietercil" <bart.pietercil at cognosis.be> wrote:

Hi Bart,

> bit of a strategy question here:
> 
> what is the best way (inside a stored procedure) to verify if a record
> exists. If it does not exist I want to insert it, if it exists not.
> The table I will insert the record has a unique_check method in place
> 
> So what do I do:
> 
> 1) immediately insert the record and count on the exception to tell me
> it already exist

This method is good if you expect that for your data say from 10 inserts
only one will refuse.

Agree? Then in 9 inserts you will have ZERO overhead.


> 2) do a select on the record to verify if it exists on only do the
> insert if the cursor returned empty

And this way can be better if you may get very often refuses.

> I am inclined to think 1) is optimal for speed but is it the best way
> altogether....
> 
> Looking forward to your thoughts

-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list