Question

I am going to use unique keys for my messages table which will be conbination of three columns fromid, localid and timestamp

I want to ask a question that is the message insertion will get slow or it will perform well?

Was it helpful?

Solution

Compared to what?

Having a primary key or unique index is always going to affect message insertion time, because column values need to be compared to the values in the index. In most environments, the unique index can fit in memory, so this is just a few comparison operations and an insert -- nothing to worry about and much less than either network overhead or disk i/o.

If you have a really large table compared to available memory, then the operations could start to take more time.

If your application needs to enforce this unique index, then you should use it. You probably won't notice the additional overhead for enforcing uniqueness, unless you do very intense performance tests.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top