Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How to enable /dev/shm RAM disk for MySQL? (temp dir in /dev/shm)

$ vi /etc/fstab
tmpfs /dev/shm tmpfs defaults,size=512m 0 0

$ mount -o remount /dev/shm

Is this correct? Now what?

......

......

......

Server info:

VPS (Xen)
1.5GB RAM
share|improve this question

migrated from stackoverflow.com Jul 26 '11 at 1:59

This question came from our site for professional and enthusiast programmers.

    
I think I should have posted this at ServerFault.com.... –  Randomprogrammer Jul 20 '11 at 11:02
    
Creating ramdisks will only starve the server of memory - every byte you allocate to a ramdisk is one byte less for cacheing/buffering and executing code. How about boosting mysql's cache/buffer sizes instead? –  Marc B Jul 20 '11 at 15:09
    
What do you want to do when your VPS is rebooted, and you've lost all your tables ? Maybe you can rather add suitable indexes to speed things up. –  nos Jul 20 '11 at 18:39
    
themattreid.com/wordpress/2011/04/04/… --- Question closed. –  Randomprogrammer Jul 25 '11 at 16:51

3 Answers 3

The first rule of optimisation is: Don't assume.

Don't assume that you will automatically get better performance by putting (any) files on a ramdisc. Also consider how you are hoping to persist data following the (inevitable) power failure.

In general, SQL is slow because you are using it wrong, so it is an application design fault. The fix is to (re-)design your application correctly.

share|improve this answer
    
I didn't wrote that app. –  Randomprogrammer Jul 25 '11 at 16:28

Just use MEMORY storage engine.

share|improve this answer

Edit your my.cnf file and add/change this

tmpdir = /dev/shm

under the [mysqld] section

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.