X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 95BA252A17 for ; Fri, 8 Jul 2005 17:33:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47776-08 for ; Fri, 8 Jul 2005 20:33:02 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.204]) by svr1.postgresql.org (Postfix) with ESMTP id 9E81352820 for ; Fri, 8 Jul 2005 17:33:01 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id i12so544470wra for ; Fri, 08 Jul 2005 13:33:03 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=A7S+8Z+if4df+KEypYh0gNM6HlrF8rku4zfecVb6OEizx5Nx3JZOMpgK7y0lJWkETwcx/E3ogeHG1GSiQwqxzWm69Uy4WVsd9sRvBCgMjGAhLd5wz7fg0Y3c7OGjJ4DYF9Yjjsm77WBbfmLziHCftrOnopAETLp6r377SiiE4H0= Received: by 10.54.29.10 with SMTP id c10mr1942772wrc; Fri, 08 Jul 2005 13:32:31 -0700 (PDT) Received: by 10.54.94.16 with HTTP; Fri, 8 Jul 2005 13:32:31 -0700 (PDT) Message-ID: <28b4448e05070813326d98e574@mail.gmail.com> Date: Fri, 8 Jul 2005 22:32:31 +0200 From: Frank Hagstrom Reply-To: Frank Hagstrom To: pgsql-sql@postgresql.org Subject: Possible to use a table to tell what table to select from? Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.122 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200507/119 X-Sequence-Number: 22097 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 (SELECT tablename FROM table1 WHERE item_id=3D"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