Re: mysql performance >I develop an application in java in that several objects are querying
>a database, occasionally simultaneous.
>I think when this happens, the mysql server returns with an error
>message to one of this objects.
The normal MySQL response to two requests that conflict is to make
one wait, so they happen as though one came after the other. If,
for example, you are trying with two different requests to insert
a record with the same primary key, and that is causing an error,
you are computing a new primary key wrong (try an auto-increment
column).
If you THINK there is an error message, try actually logging it, along
with the query that caused it and perhaps a time stamp.
>My question is: what is the best practice when competeing objects are
>using the same resource?
What resource? A table?
>I was thinking on using table locks, but I am not sure whether it is
>the most elegant way to solve it.
If you have a series of changes that need to be made all-or-nothing
without interference from something else, use transactions (and
InnoDB tables). |