| Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML | ||||
|
||||
| Tutorial Categories: Ajax
| Articles
| JSP
| Bioinformatics
| Database
| Free
Books |
Hibernate
| J2EE
| J2ME
| Java
| JavaScript
| JDBC
| JMS
| Linux
| MS
Technology |
PHP
| RMI
| Web-Services
| Servlets
| Struts
| UML
|
Locking IssuesMySQL can manage the contention for table contents by using Locking :
Internal Locking MethodsIn this section we are describing you about internal locking, Internal Locking is performed in the MySQL server itself for managing the contention for table content by multiple threads. This locking is known as internal because this locking is performed entirely by the server and it does not involve any other programs. Table – level locking is used by MySQL to MyISAM and MEMORY, row – level locking for InnoDB tables and page – level locking for BDB tables. In some cases you can guess which locking is best for an application but generally is not easy to say that a given lock is better than another lock type. Actually everything is depend on the application because different parts of application can required different lock types. For deciding this, if you are using storage engine with row – level locking then you must look at what application does and what is the combination of update and select statements it uses. MySQL uses table level locking for storage engines. In MySQL table locking is deadlock free. Deadlock prevention can be managed by requesting all required lock at once at the beginning of query and the lock the tables in the same order. MySQL grants the table WRITE locks are given below:
MySQL grants the table READ locks are given below:
After releasing the lock, lock is available for the threads in the write lock queue and then for the threads in read lock queue. For analyzing the contention of table lock we check the Table_locks_immediate and Table_locks_waited status variables :
InnoDB and BDB type tables uses row locks and page locks respectively. All locking are deadlock free except of these two because they acquire the lock between the processing of SQL statements rather than the beginning of transaction. Row level locking advantages are given below:
Row level locking disadvantages are given below:
Table locks are more useful rather than page or row level locks in the following cases:
In large tables table locks is much useful than row locks but there are some pitfalls:
Disadvantages of Table locking is given below:
In the following section we are describing you some ways for avoiding the contention caused by table locking:
External LockingExternal locking is the used of filesystem locking for managing the contention to databases tables by
multiple processes. External locking is performed when server and other programs lock the table files for coordinating among themselves which program may access the tables at which time. For mysqld, the system variable skip_external_locking value is used to control the external locking. If this system variable is enabled then external locking is disabled and vice versa. We can also control the use of external locking by –external-locking or –skip-external-locking option at server startup. |
| Facing Programming Problem? | |||||||
| Add This Tutorial To: | |||||||
| |
|
|
|
|
|
|
|
![]() |
|
JDO Tutorials EAI Articles Struts Tutorials Java Tutorials Java Certification |
|
|
|
||||||||||||||||||||||||||||||
|
Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs |
||||||||||||||||||||||||||||||
Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.
Copyright © 2007. All rights reserved.
Current Comments
0 comments so far (post your own) View All Comments Latest 10 Comments: