Go Back   Forum Care Forums > Development Reference Area > MySQL Discussion

Reply
 
LinkBack Thread Tools Display Modes
Database locking
Old
  (#1)
howa
Guest
 
Posts: n/a
Default Database locking - 06-04-2007, 07:46 AM

some questions abt table locking (***ume 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.

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Database locking
Old
  (#2)
Axel Schwenke
Guest
 
Posts: n/a
Default Re: Database locking - 06-04-2007, 07:46 AM

"howa" <EMAIL REMOVED> wrote:
> some questions abt table locking (***ume 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/
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Database locking
Old
  (#3)
howa
Guest
 
Posts: n/a
Default Re: Database locking - 06-04-2007, 07:46 AM


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?

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Database locking
Old
  (#4)
Axel Schwenke
Guest
 
Posts: n/a
Default Re: Database locking - 06-04-2007, 07:46 AM

"howa" <EMAIL REMOVED> 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/
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Database locking
Old
  (#5)
howa
Guest
 
Posts: n/a
Default Re: Database locking - 06-04-2007, 07:46 AM


Axel Schwenke ¼g¹D¡G

> "howa" <EMAIL REMOVED> 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?
(***ume using replication)

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Database locking
Old
  (#6)
Axel Schwenke
Guest
 
Posts: n/a
Default Re: Database locking - 06-04-2007, 07:46 AM

"howa" <EMAIL REMOVED> 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/
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Database locking
Old
  (#7)
howa
Guest
 
Posts: n/a
Default Re: Database locking - 06-04-2007, 07:46 AM


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.

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top