Re: How to keep a table in memory? - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: How to keep a table in memory?
Date
Msg-id 473818F0.5010501@enterprisedb.com
Whole thread Raw
In response to How to keep a table in memory?  (adrobj <adrobj@yahoo.com>)
Responses Re: How to keep a table in memory?  (Alex Drobychev <adrobj@yahoo.com>)
Re: How to keep a table in memory?  (Devrim GÜNDÜZ <devrim@CommandPrompt.com>)
List pgsql-hackers
adrobj wrote:
> I have a pretty small table (~20MB) that is accessed very frequently and
> randomly, so I want to make sure it's 100% in memory all the time. There is
> a lot of other staff that's also gets accessed frequently, so I don't want
> to just hope that Linux file cache would do the right thing for me.
> 
> Is there any way to do that?
> 
> One idea I have in my head is to start a process that does mmap() and
> mlock() with the table file. Will it work? If so, are there any potential
> problems?

Just leave it to the cache management algorithms in Postgres and Linux. 
If it really is frequently accessed, it should stay in Postgres shared 
buffers.

You can use the pg_buffercache contrib module to see what's in cache.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: [hibernate-team] PostgreSQLDialect
Next
From: "Pavel Stehule"
Date:
Subject: Re: proposal casting from XML[] to int[], numeric[], text[]