Possible to use a table to tell what table to select from?

From: Frank Hagstrom <frank(dot)hagstrom(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Possible to use a table to tell what table to select from?
Date: 2005-07-08 20:32:31
Message-ID: 28b4448e05070813326d98e574@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello

I've been thinking on a potential problem I might get in a distant
future, but once I started thinking on it I just as well had to
check...

Is it possible to have say ~ 6 tables, where the first one is a
'reference' to all the others (they all are with the same structure).
The other 5 or so have information stored in importance/access/age,
where one table will be only recent/important things, the other with a
bit lower priority and so on until the last table that can be really
huge and slow and used more like a storage ... Is it possible to write
an SQL query to let the first table figure out what table one will do
the actual select from?

like the pseudo code:
SELECT name,content FROM <some command> (SELECT tablename FROM table1
WHERE item_id="123456")

Or is this a totally pointless thing, as the first table would need to
be so large either way? (or only good for storing large blobs and
such?)

/Frank H

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message CG 2005-07-08 20:55:03 Clustering problem
Previous Message Alvaro Herrera 2005-07-08 19:51:25 Re: Make COUNT(*) Faster?