malai.kuangren
malai.kuangren

Reputation: 359

Multiple thread access(read/write) same table

If there are multiple thread which access (read/write) to a same table into a DB, what considerations of thread-safety should I take?

Upvotes: 2

Views: 2756

Answers (2)

cevaris
cevaris

Reputation: 5794

Here are some good tips, for example if using MySQL

  • Use row-level locking.
  • Use the TRANSACTION_READ_COMMITTED isolation level.
  • Avoid queries that cannot use indexes; they require locking of all the rows in the table (if only very briefly) and might block an update.
  • Avoid sharing Statements among threads

Here is some more information and reference

Upvotes: 3

crhistoncho
crhistoncho

Reputation: 56

check for mechanisms which implement transactions in different isolation levels. These mechanism are present in database system or your API.

Upvotes: 1

Related Questions