Quote:
|
Originally Posted by Cougar8000
Or it is NULL during the initial INSERT only?
|
NULL during insert. I'll explain:
I am trying to tackle the "well known paradox" of relational vs object-oriented. The database I'm currently managing is "not really" according to the relation rules. I see many different tables sharing the same primary-key. The J2EE application just utilizes DB2 as an persistance-instrument. Well, you do not have to like it, you'll have to deal with it.
My attempt:
Let's create one big table to hold all the data and create a userview for each "table/object" the application sees.
This means:
- give each column name a code-suffix in the table and use the "as" clause in the view to give it back it's original name
- write "instead of" triggers to capture the INSERT/DELETE fired from the J2EE app.
- appoint 1 column per view to act as an boolean (true = this row is also a row in this view) . I was lucky to find a technicall field "creation_date" in all tables so I could use that. This same field is used in my CREATE VIEW in the WHERE clause. I test it for NOT NULL.
Now we're back on topic. Shall I make that column an index or not? Some figures:
it is one physical table with 27,000,000 rows
there are 16 views defined as described above varying from 10,000,000 rows to only 12,000 rows. So I am left with 16 CREATION_DATE_
code columns.
The paradox I am facing:
1) no index. a simple "select count(*) from view" is never executed. whenever it is executed, I left with a table-scan over 27 miljon rows and nobody likes me any more
2) index. I was hoping that an INSERT in the main-table with 16 NULL columns forming 16 indexes would not generate too much delay because they are NULL... Thank you umayer for shaking me out of that dream.
3) middle of the road. I'll just INCLUDE those 16 columns in my primary-key-index. Whenever a "select count(*)" is fired, it is not a table scan but
only an index-scan.....
I have not figured it out yet. help will be appriciated.