views:

158

answers:

3

Hi,

I am using PostgreSQL 8.4. I really like the new unnest() and array_agg() features; it is about time they realize the dynamic processing potential of their Arrays!

Anyway, I am working on web server back ends that uses long Arrays a lot. Their will be two successive processes which will each occur on a different physical machine. Each such process is a light python application which ''manage'' SQL queries to the database on each of their machines as well as requests from the front ends.

The first process will generate an Array which will be buffered into an SQL Table. Each such generated Array is accessible via a Primary Key. When its done the first python app sends the key to the second python app. Then the second python app, which is running on a different machine, uses it to go get the referenced Array found in the first machine. It then sends it to it's own db for generating a final result.

The reason why I send a key is because I am hopping that this will make the two processes go faster. But really what I would like is for a way to have the second database send a query to the first database in the hope of minimizing serialization delay and such.

Any help/advice would be appreciated.

Thanks

A: 

not sure I totally understand, but you've looked at notify/listen? http://www.postgresql.org/docs/8.1/static/sql-listen.html

Craig
I am not sure. Would this help me have one postmaster process running on machine A send or receive data from a postmaster process running on machine B, without having to pass the data to a middle man app like python?
Nicholas Leonard
Hi Nicholas, well that's not entirely true no. Something like pgpool or something else that does replication of PG data might be more to your liking.Notify/listen would let your (say python) code listen for changes from the database async, and then you can act on those notifications, by getting data, etc.You also might look into triggers, so on insert/update/delete to table X, a trigger would fire, exporting the data to /data (or wherever). Then you'd have a process that would grab files from /dataThese are just a few ways to do what you want.
Craig
A: 

I am thinking either listen/notify or something with a cache such as memcache. You would send the key to memcache and have the second python app retrieve it from there. You could even do it with listen/notify... e.g; send the key and notify your second app that the key is in memcache waiting to be retrieved.

Joshua D. Drake
Its not the key that I am worried about. The key is used by machine B to Select out its associated Array from machine A. What I would like is to have the postmaster in machine B query a postmaster in machine B to minimize interprocess communication. Basically, I am scared that by passing through python, the Array will waste time and resources. I would like to be able to say: SELECT FROM machineA.db.table WHERE key = $1 etc. etc. Thanks for your concern, and sorry for being so unclear ;)
Nicholas Leonard
+1  A: 

Sounds like you want dblink from contrib. This allows some inter-db postgres communication. The pg docs are great and should provide the needed examples.

rfusca
This seems to be it. Thanks.
Nicholas Leonard