Triggers or primary key constraints
Posted in 1999
Topics: SQL Development & Query Writing, Triggers, Constraints & Referential Integrity
Hi all, Here is the issue ;; Table (col1,col2) i have 3 indexes in this table 1. unique index on (col1,col2) 2. duplicate on col1 3. duplicate on col2 I have lock contention because of index 1 mainly on updates. So i was thinking avoiding the unique index and write a trigger for the uniqueness of the values. I do know the trigger takes more time as i need to inculde a SELECT statement to check the uniqueness. what do you guys think about the overhead of this? I know that this is a foolish question ...Still, i have to get rid of the unique index but also have to make sure the uniqueness of data. So which one you feel is a better option? or Is there any other way to accomplish the same Thanks in advance. Dhanesh
Hi... >Table (col1,col2) >i have 3 indexes in this table > 1. unique index on (col1,col2) > 2. duplicate on col1 > 3. duplicate on col2 I think you can drop Index 2, because "col1" is the first column in the composite index. The optimizer will use index 1 in queries of col1. > So i was thinking avoiding the unique index and write a trigger for the >uniqueness of the values. I do know the trigger takes more time A trigger will be slower than the primary key constraint, but you can use it. []ao LEO Cardoso ---