Database locking

This is a discussion on Database locking within the MySQL Database forums, part of the Database Forums category; some questions abt table locking (assume using myisam) 1. If a slow query is running on a table, is update/...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-11-2007
howa
 
Posts: n/a
Default Database locking

some questions abt table locking (assume using myisam)

1. If a slow query is running on a table, is update/insert operations
blocked?

2. If a slow query is running on a table (slave), is replication
operations blocked?

thanks.

Reply With Quote
  #2 (permalink)  
Old 01-11-2007
Axel Schwenke
 
Posts: n/a
Default Re: Database locking

"howa" <howachen@gmail.com> wrote:
> some questions abt table locking (assume using myisam)
>
> 1. If a slow query is running on a table, is update/insert operations
> blocked?
>
> 2. If a slow query is running on a table (slave), is replication
> operations blocked?


Regarding MyISAM there are three groups of statements:

1. SELECT
2. INSERT at end of table (append)
3. DELETE, UPDATE, INSERT not at end of table

At a given point in time and for a given table there can be multiple
statements from group 1 and up to one statement from group 2
*or* one statement from group 3.

In other words:

- reads are done concurrently
- all writes (also append) are serialized
- reads mix with append

The replication SQL thread is not different from any other client
thread in that respect.


XL
--
Axel Schwenke, Senior Software Developer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Reply With Quote
  #3 (permalink)  
Old 01-11-2007
howa
 
Posts: n/a
Default Re: Database locking


Axel Schwenke ¼g¹D¡G

> In other words:
>
> - reads are done concurrently
> - all writes (also append) are serialized
> - reads mix with append
>
> The replication SQL thread is not different from any other client
> thread in that respect.
>
>


ok, are there any method to reduce the priority of SELECT threads?

since in our system, some slow query under heavy system load will
affect the write performance, we want to give write a higher priority,
is it possible?

Reply With Quote
  #4 (permalink)  
Old 01-11-2007
Axel Schwenke
 
Posts: n/a
Default Re: Database locking

"howa" <howachen@gmail.com> wrote:
> Axel Schwenke =BCg=B9D=A1G
>
>> - reads are done concurrently
>> - all writes (also append) are serialized
>> - reads mix with append
>>
>> The replication SQL thread is not different from any other client
>> thread in that respect.

>
> ok, are there any method to reduce the priority of SELECT threads?
>
> since in our system, some slow query under heavy system load will
> affect the write performance, we want to give write a higher priority,
> is it possible?


This is the default already. As soon as there is a write pending for
a table, all new read requests are enqeued to be executed after the
write. See here for details:

http://dev.mysql.com/doc/refman/5.0/...e-locking.html


If MyISAMs coarse locking kills the performance of your database,
consider using InnoDB tables.


XL
--
Axel Schwenke, Support Engineer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Reply With Quote
  #5 (permalink)  
Old 01-12-2007
howa
 
Posts: n/a
Default Re: Database locking


Axel Schwenke ¼g¹D¡G

> "howa" <howachen@gmail.com> wrote:
> > Axel Schwenke =BCg=B9D=A1G
> >

>
> If MyISAMs coarse locking kills the performance of your database,
> consider using InnoDB tables.
>
>



okay, it is a good practice to use InnoDB as Master, MyISAM as slave in
this case?
(assume using replication)

Reply With Quote
  #6 (permalink)  
Old 01-12-2007
Axel Schwenke
 
Posts: n/a
Default Re: Database locking

"howa" <howachen@gmail.com> wrote:
> Axel Schwenke =BCg=B9D=A1G
>>
>> If MyISAMs coarse locking kills the performance of your database,
>> consider using InnoDB tables.

>
> okay, it is a good practice to use InnoDB as Master, MyISAM as slave in
> this case?


There is nothing wrong with that. In fact this is an often seen
solution if one needs both transactional behaviour of a table
(InnoDB) and MyISAM-only features like FULLTEXT indexes.


XL
--
Axel Schwenke, Support Engineer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Reply With Quote
  #7 (permalink)  
Old 01-12-2007
howa
 
Posts: n/a
Default Re: Database locking


Axel Schwenke ¼g¹D¡G

1. SELECT
2. INSERT at end of table (append)
3. DELETE, UPDATE, INSERT not at end of table



one more thing:

1. why i can't update/delete at the end of the table while running a
slow query
2. what will happen if a slow query is running, and update/delete not
at the end of the table?


thanks.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:08 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0