Views into tables

From: Joanne Woytek <joanne_at_daac.gsfc.nasa.gov>
Date: 1996/06/10
Message-ID: <31BC5106.1788_at_daac.gsfc.nasa.gov>#1/1


We have a very large table (called large_table) which has a column named status which has a small number of valid values, making it a poor candidate for indexing. Unfortunately a large number of queries and updates are done with status in the where statement. Most of the rest of the queries are on well-indexed columns. So one possibility I'm considering is breaking the table up into smaller tables based on the status values; e.g. table_A would have those rows which were in the original table with a status='A' and table_B would have those rows which were in the original table with a status='B'. We could then choose which table to use in our PL_SQL or PRO*C programs rather than constantly doing full-table scans of the very large table. (Another assumption is that most queries are on only one possible status at a time.)

The problem is that we have a number of queries and updates which expect the original table structure to always be there. What I was hoping to do was to create a view which was named large_table which selected columns from either table_A or table_B depending on the status query and had the same structure as the table originally had; e.g.

table_a
id
data

table_b
id
data

large_table (now a view)
id
data
status

A pseudo-create view statement is:
create view large_table (id, data, status) as select id, data, 'A' from table_A when status in where is 'A' or

   select id, data, 'B' from table_B when status in where is 'B'

Any ideas, suggestions, pointers on how to do this in a real create view statement, or simply letting me know that I am asking the impossible, would be appreciated.

-- 
Joanne Woytek
joanne_at_daac.gsfc.nasa.gov
Code 902
NASA/GSFC
Received on Mon Jun 10 1996 - 00:00:00 CEST

Original text of this message