PostgreSQL locking mode -


from doc http://www.postgresql.org/docs/current/static/explicit-locking.html

i knew postgresql provides various lock modes control concurrent access data in tables.

my problem have many sessions accessing db , i'm confuse should made 1 big table 40 column or many tables fewer column (one 1 relationship).

  1. because when select data select of ---> takes more time when select many tables using inner join, takes less time select 1 big table. php respond slower if i'm using many tables.

  2. but when use 1 table meanwhile many session update data in table, i'm afraid of deadlocks or delay because commands update, delete, , insert acquire row exclusive lock mode on target table. in general, lock mode acquired command modifies data in table.

could suggested best approach should made? 1 big table or many tables?

it true insert, update or delete must acquire row exclusive lock on table updated.

however, lock not prevent select working normally. select requires access share lock. lock compatible row exclusive - in other words, can execute select while other data updated insert, update or delete, long don't acquire explicit locks.

in other words, should never see deadlocks using second approach (just don't use select update , you'll fine).

read more in postgresql documentation.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -