Skip site navigation (1) Skip section navigation (2)

Re: Shared memory and memory context question

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: richard(dot)hills(at)balliol(dot)oxford(dot)ac(dot)uk
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Shared memory and memory context question
Date: 2006-02-05 14:43:56
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On Sun, Feb 05, 2006 at 02:31:23PM +0000, Richard Hills wrote:
> I have a number of functions which modify tables based on complex rules stored 
> in script-files. I wrote a parser for these files as a separate program first 
> before incorporating it as a shared object, subsequentially it loads and 
> executes rules from memory. As anything can be read from the files, and rules 
> can be unloaded later, I was hoping for flexibility in allocing memory to 
> store it all.

So what you load are the already processed rules? In that case you
could probably use the buffer management system. Ask it to load the
blocks and they'll be in the buffer cache. As long as you have the
buffer pinned they'll stay there. That's pretty much a read-only

If you're talking about things that don't come from disk, well, hmm...
If you want you could use a file on disk as backing and mmap() it into
each processes address space...

> Another option is to load the files but store the rules within the database, 
> which should be possible, but appears to be a slightly messy way of doing it. 
> Then again, messing about with shared memory allocation may be messier. 
> Asking as an fairly inexperienced postgres person, what would you suggest?

The real question is, does it need to be shared-writable.
Shared-readonly is much easier (ie one writer, multiple readers). Using
a file as backing store for mmap() may be the easiest....

Have a nice day,
Martijn van Oosterhout   <kleptog(at)svana(dot)org>
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to


pgsql-hackers by date

Next:From: Andrew DunstanDate: 2006-02-05 14:44:09
Subject: drop if exists remainder
Previous:From: Richard HillsDate: 2006-02-05 14:31:23
Subject: Re: Shared memory and memory context question

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group