LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-16-2010, 01:31 AM   #1
yoachan
Member
 
Registered: Nov 2009
Posts: 109

Rep: Reputation: 16
mysql optimization -- Copying to tmp table on disk


Dear all,

we had a CENTOS 5.5 x86_64 machine with 8GB RAM, powered with MySQL 5.0.91-community.

Currently we had a very high number of Created_tmp_disk_tables (31k in 4,5 hours!!!).
I've read suggestion that we need to increase tmp_table_size, and we've set tmp_table_size to 64M, but this drupal modul's query still cause mysql create tmp table on disk
Code:
SELECT DISTINCT node.nid AS nid,
        comments.subject AS comments_subject,
            comments.cid AS comment"
Finally, I desperately increase tmp_table_size to 512M, but mysql still create disk tmp tables instead of memory temporary table. (But currently we switched it back to 64M because 512M was insane).

This thing become a problem because several times when high request occurs, tmp usage increased to several Gigs, and caused mysql crashed.

does anyone has any suggestion(s)?

any help appreciated.

regards,

yoachan
 
Old 11-16-2010, 02:14 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
My first suggestion is to make a filesystem of type tmp_fs and mount it. Then point mysql at it, to make its tmp tables there.

tmp_fs is a ramdrive, and so is made of ram. Therefore, mysql will still be writing tmp-tables out to ram, even though it thinks it is writing to disk.

http://www.thegeekstuff.com/2008/11/...tmpfs-on-linux

Last edited by szboardstretcher; 11-16-2010 at 02:17 PM.
 
Old 11-17-2010, 01:51 AM   #3
yoachan
Member
 
Registered: Nov 2009
Posts: 109

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by szboardstretcher View Post
My first suggestion is to make a filesystem of type tmp_fs and mount it. Then point mysql at it, to make its tmp tables there.

tmp_fs is a ramdrive, and so is made of ram. Therefore, mysql will still be writing tmp-tables out to ram, even though it thinks it is writing to disk.

http://www.thegeekstuff.com/2008/11/...tmpfs-on-linux
It doesn't answer the real question,
but it sure is a good alternate solution to speedup the swap process.
thanks for sharing
 
Old 11-18-2010, 12:36 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Quote:
Originally Posted by yoachan View Post
It doesn't answer the real question,
but it sure is a good alternate solution to speedup the swap process.
thanks for sharing
You are creating many TMP tables, that are eventually swapping to physical disk. Therefore, if you create a ramdisk, and lower the max size of tmp tables, they will be written to memory/ramdisk - thus staying in ram. This is one solution directly related to your problem.

Also, to figure out what your configuration values should be, take a look at this:

http://www.sitebuddy.com/Mysql/tmp_t...ad_buffer_size
 
Old 11-23-2010, 08:24 AM   #5
yoachan
Member
 
Registered: Nov 2009
Posts: 109

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by szboardstretcher View Post
You are creating many TMP tables, that are eventually swapping to physical disk. Therefore, if you create a ramdisk, and lower the max size of tmp tables, they will be written to memory/ramdisk - thus staying in ram. This is one solution directly related to your problem.

Also, to figure out what your configuration values should be, take a look at this:

http://www.sitebuddy.com/Mysql/tmp_t...ad_buffer_size
Yes, it's in deed related
But my main question is why it dump the table to disk, instead of memory.
The link that you gave was so helpful.
Instead of only increasing tmp_table_size, I need to increase MAX_HEAP_TABLE_SIZE too. And currently everything is working as I expected.

Thanks.

-- case closed --
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql Copying to tmp table constantly, crashing server abefroman Linux - Server 1 10-28-2009 02:54 PM
Can't login, says tmp directory full but tmp file is empty! Could be linked to MySQL? bethanlowder Fedora 7 09-25-2009 07:17 AM
Mysql optimization fullgore Linux - Server 2 11-09-2006 11:24 AM
Table copying in MySQL prabhatsoni General 4 10-26-2004 05:43 PM
How to import MS ACCESS Table including OLE filed into the MySQL Table ? myunicom Linux - General 1 11-28-2003 11:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration