Re: newbie question about memory



Sergei Shelukhin wrote:
Hi. I am a database prorgammer and I work on windows/MSSQL or with
small MySql databases 90% of the time, however on a project that is on
the way now, I have to use PostgreSQL on Linux; moreover, I need to
configure the server.

So, as I was figuring out the amount of memory on the server that I
can grab for db server operations, I stumbled upon an interesting
thing.
According to cat /proc/meminfo, I have 2 Gb of memory and 500Mb are
free.

My box has 8 GBytes RAM, and right now about 21 Megabytes are free. The
machine is not doing much; in particular, no database operations are being
done (although some of the daemons are running).

Now the database is very big, but it's not operating it, so I was
surprised to see such a high memory use.

In Linux, the philosophy is that there is no point in having a lot of free
memory, so the system uses the "excess" for caching recently read pages in
case they are needed again. I have so much memory that it could cache entire
programs so they would load faster if I run them again soon enough.

I checked ps -eo user,comm,%mem, and memory percents total to about
1.2% 0_o I see a lot of fancy labels in meminfo output, cached, etc,
but I cannot figure out what they mean and google seems
uncooperative :)

I have two questions
1) Where did the memory go?

On my system, about 660 Megabytes are used for (output) buffers and about 6
GBytes are used for (input) cache.

2) Can it be freed e.g. can I safely assume that I have 1-1.5Gb for
PostgreSQL to roam free?

I do not think you can explicitly free it, but the kernel will grab as much
cache as it needs. It may also get buffer space although that may cost more
(as it may need to be written out first).

I do not know how postgreSQL is designed. I run IBM's DB2. It does its own
IO in raw mode (i.e., it uses the kernel drivers, but not the file system),
making the stuff contiguous on disk, and using much larger page sizes that
are typical in Linux. I have set up my kernel to allow each process to use 4
GBytes of RAM (instead of the usual 3 GBytes) (which does not make sense
unless you have more than 4 GBytes of RAM, IMAO). And I have set DB2 to have
a buffer pool for the index of around 4 GBytes. My hope is to get the entire
index of my database (well, only the hot parts, actually) to speed things
up. It is now tuned so that the bottleneck is the speed of writing the
logfiles (I am going to replace the 7200rpm IDE hard drive with a 10,000 rpm
SCSI drive on a different SCSI controller from the other database drives to
speed this up, although I do not know how much I will get from that.)

Anyway, you can know how much memory you will really need for this. I would
worry that 2 GBytes may not be enough. While you could allocate a large
enough swap partition to run, if you actually use it much, the paging rate
may make the system insufficiently responsive. So try to find out how much
memory you will actually need and then try to have at least that much.

My machine permits 16 GBytes, but my wallet did not.

--
.~. Jean-David Beyer Registered Linux User 85642.
/V\ PGP-Key: 9A2FC99A Registered Machine 241939.
/( )\ Shrewsbury, New Jersey http://counter.li.org
^^-^^ 09:55:01 up 70 days, 21:23, 3 users, load average: 4.49, 4.18, 4.12
.



Relevant Pages

  • Re: newbie question about memory
    ... as I was figuring out the amount of memory on the server that I ... Now the database is very big, but it's not operating it, so I was ... Linux uses memory to cache everything for speedy response, ... database really uses up all your RAM. ...
    (comp.os.linux.misc)
  • Databases and memory management on Linux 2.6+
    ... I've been trying to figure out how much memory to give a database ... are created on top of a Linux filesystem. ... Ie. there is only paging. ...
    (comp.os.linux.setup)
  • Re: Quad AMD opteron system and Linux
    ... I want to find out if you had any experiences with linux on ... > you run memory hungry applications on a 32 bit system. ... I'm hoping to see Debian support it ... > memory spaces for database and scientific applications. ...
    (comp.os.linux.hardware)
  • Re: Caching in memory for Apache
    ... I've never used Linux before this project so it's a really big learning ... One of the questions I have is: How do you cache stuff in memory? ... I've got a bunch of stuff I need to create from a set of database rows. ... You are facing a huge learning curve. ...
    (comp.lang.python)
  • Re: How to set up a Linux machine that occupies the minimum memory footprint ?
    ... >>need to find a way to MINIMIZE the Linux memory footprint. ... > space won't allow a single process to have more than 4 GB. ... each process can get up to 4 GBytes per process. ...
    (comp.os.linux.misc)