This is a discussion on Index or procedure within the MySQL Database forums, part of the Database Forums category; Hello, I need to check out if a description is already present in a table while inserting or updating. I ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Wed, 17 Oct 2007 09:38:42 +0200, Marco Cotroneo <m.cot@italia.it> wrote:
> Hello, > I need to check out if a description is already present in a table > while inserting or updating. I am wondering whether use an index on that > description or check it in the trigger after/begin insert/update. It depends on the cicumstances. Having a reasonably 'small' description which should be enforced unique in a table would be best served with keys. Longer blobs with text I wouldn't make a key of, and just check wether it exists before a transaction. A UNIQUE Key, and using an 'INSERT .... ON DUPLICATE KEY UPDATE ..' syntax often does wonders. -- Rik Wasmus |
|
|||
|
Rik Wasmus ha scritto:
> On Wed, 17 Oct 2007 09:38:42 +0200, Marco Cotroneo <m.cot@italia.it> wrote: > >> Hello, >> I need to check out if a description is already present in a table >> while inserting or updating. I am wondering whether use an index on >> that description or check it in the trigger after/begin insert/update. > > It depends on the cicumstances. Having a reasonably 'small' description > which should be enforced unique in a table would be best served with > keys. Longer blobs with text I wouldn't make a key of, and just check > wether it exists before a transaction. > > A UNIQUE Key, and using an 'INSERT .... ON DUPLICATE KEY UPDATE ..' > syntax often does wonders. Thanks for your replay. :-) |