Moving things into a ram disk will not help database queries take less
time.  The way Linux works is to copy any disk data into ram for use,
and then keep it there until the system is out of memory for new data. 
This is called "page cache"

Here is an example of the "free" command output on my machine (in
megabytes)

Code:
--------------------
    $ free -m
  total       used       free     shared    buffers     cached
  Mem:          5984       5932         52          0        775       3524
  -/+ buffers/cache:       1633       4351
  Swap:         4141         32       4108
  
--------------------


As you can see, I have about 6GB of ram, and most of that is "in use"
since my machine has been up for a reasonable amount of time.  But if
you look at the second row, you see that only 1.6GB of ram is used by
applications (mostly firefox, bleh)  4.3GB of my ram is in use for page
cache.

The entire mysql database is only 74MB.

Code:
--------------------
    
  # ls -lh /var/lib/squeezeboxserver/cache/MySQL/ibdata1 
  -rw-rw---- 1 squeezeboxserver nogroup 74M 2010-04-10 17:20 
/var/lib/squeezeboxserver/cache/MySQL/ibdata1
  
--------------------


It takes no time at all for my system to read the entire contents of
this file into memory:


Code:
--------------------
    
  # time cat /var/lib/squeezeboxserver/cache/MySQL/ibdata1 > /dev/null
  real  0m1.270s
  user  0m0.000s
  sys   0m0.000s
  
--------------------


And then if I do the same thing again, the data is already in ram, and
reads in a tiny fraction of the time.


Code:
--------------------
    
  # time cat /var/lib/squeezeboxserver/cache/MySQL/ibdata1 > /dev/null
  real  0m0.085s
  user  0m0.000s
  sys   0m0.060s
  
--------------------


That's less than 1/10th of a second to scan all 75MB of mysql data. 
The only way for queries to take a very long time is to be doing
something very wrong.  Either poorly indexed queries, or very very
complex queries that are eating CPU time to re-scan all the data
hundreds of times over for any request.


-- 
SuperQ
------------------------------------------------------------------------
SuperQ's Profile: http://forums.slimdevices.com/member.php?userid=2139
View this thread: http://forums.slimdevices.com/showthread.php?t=77140

_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to