473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Tables spanning db's in cluster

Is it possible to define a table that spans all db's in a cluster similar to pg_database, pg_users?
Perhaps by altering relfilenode in pg_class of all db's to point to the same shared table...

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #1
2 1498
William Harazim wrote:
Is it possible to define a table that spans all db's in a cluster
similar to pg_database, pg_users? Perhaps by altering relfilenode
in pg_class of all db's to point to the same shared table...


Uh, no, I don't think that is possible. You could try setting
pg_class.relisshared, but you would have to move the file over into the
/global directory --- not sure if that would work either, though.

--
Bruce Momjian | http://candle.pha.pa.us
pg***@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #2
Bruce Momjian <pg***@candle.pha.pa.us> writes:
William Harazim wrote:
Is it possible to define a table that spans all db's in a cluster
similar to pg_database, pg_users? Perhaps by altering relfilenode
in pg_class of all db's to point to the same shared table...
Uh, no, I don't think that is possible. You could try setting
pg_class.relisshared, but you would have to move the file over into the
/global directory --- not sure if that would work either, though.


Just for fun, I spent some time experimenting with this. It seems to be
possible but it's definitely in the "not ready for prime time" category.

What seems to work:

Create table in template1. Do a checkpoint (essential if you created
any indexes for the table, because dirty buffers must get flushed before
you move the table). Update pg_class to set relisshared=true for the
table, all of its indexes, and its toast table and toast index if any.
Quit and shut down postmaster. Move the physical files from template1
($PGDATA/base/1) into $PGDATA/global (you'll need to have made note of
their relfilenode numbers so you can do this). Restart postmaster.

The table will now be visible in template1 and all databases
subsequently created from template1. Beware however that you cannot
alter the table schema (eg add/remove columns or indexes or foreign
keys) because there isn't any good way to propagate such changes into
other databases. Only updates to the table contents are sharable by
this mechanism. I suppose you could make schema changes in template1
and then propagate them by deleting/recreating other DBs, but that
doesn't sound real practical. Another problem is that pg_dump won't
understand what you've done and will dump the table as a separate
entity in each database.

I was really expecting to find that this couldn't work at all; I had a
vague recollection that there was some showstopper reason why shared
tables had to be created at initdb time. I didn't run into any such
problem once I'd worked out the above recipe for creation procedure,
though.

If you need to share data, consider whether you shouldn't be using
multiple schemas in one database rather than multiple separate
databases...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mario T. Lanza | last post by:
Greetings, I've been working on a 3-column layout where the center column is of a fixed width (230px wide). The center column must always be 230px and the columns on the right/left (always the...
2
by: Gabriele Bartolini | last post by:
Hi guys, just a quick and probably stupid question. When I make a cluster based on an index on a table, how can I remove it later? Should I 'create' a new one by using the primary key index? ...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
17
by: Peter Ericsson | last post by:
Does anyone know if Microsoft plans to implement an C# (.net) API for MS Cluster like the one in C++? Or has someone else written a C# wrapper for the C++ API?
26
by: Ed L. | last post by:
Here's some of my current notions on pgsql performance tuning strictly as it relates to pgsql tuning parameters in the context of a dedicated linux or hpux server. I'm particularly focusing on...
0
by: matt | last post by:
(first -- does anyone know of a good CR group?) hello, i am new to CR. i have created one report that queries the db and presents the data to the user in a tabular-like format. however, i...
3
by: Simon | last post by:
Hi All, I'm hoping someone will have some words of wisdom for me regarding MS Clustering on Windows 2003. I have a service that runs on a cluster. During invocation it's supposed to...
1
by: jenny22 | last post by:
i have a problem i am very new to c++ and want to construct a minimum spanning tree for 8 stocks i have calculated in excel the relevant formulas and know the weights of each of gthe vertices but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.