> If you are on V9, you can make use of the table partitioning feature, i.e.
> range partitioning. Then you don't have to worry about views etc.
> > If you are on V9, you can make use of the table partitioning feature, i.e.
> > range partitioning. Then you don't have to worry about views etc.To the best of my knowledge the table partitioning feature is only
> available in the enterprise edition of db2 v9. So, this is only a
> viable solution if you are targetting the enterprise edition.
i did not test it yet but i am assumming that if i create view like
view abc as select * from table1_2005 union all select * from
table1_2006 and
then query like select * from abc where c2 = '05062005' , it will not
use existing index on both table if all underlying tables have index on
column c2 which is a date column
i will also test this today but please share with me if someone already
know the answer
Mark A - 29 Nov 2006 14:50 GMT
>> > If you are on V9, you can make use of the table partitioning feature,
>> > i.e.
[quoted text clipped - 13 lines]
> i will also test this today but please share with me if someone already
> know the answer
It will use the index.
You should probably read this article to understand UNION ALL views:
http://www-128.ibm.com/developerworks/db2/library/techarticle/0202zuzarte/0202zu
zarte.pdf
Mark A - 29 Nov 2006 14:57 GMT
> It will use the index.
>
> You should probably read this article to understand UNION ALL views:
>
> http://www-128.ibm.com/developerworks/db2/library/techarticle/0202zuzarte/0202zu
zarte.pdf
Just to clarify, if the C2 column is defined as a DATE in DB2, then Where
clause should look like this:
WHERE C2 = '2005-06-05'
If the column is defined as CHAR(8), then you could use
WHERE C2 = '05062005'
A DATE column only takes up 4 bytes of storage in DB2.
db2admin - 29 Nov 2006 15:04 GMT
> > It will use the index.
>
[quoted text clipped - 8 lines]
>
> A DATE column only takes up 4 bytes of storage in DB2.
unfortunately, it is a character column and i will convert this to date
soon
thanks for the article on partitioning using union all view
everyone in this group is awesome
i will try implement all this and will get back to you
gwise@pressganey.com - 29 Nov 2006 16:27 GMT
Once you've converted that field to a date, you'll want to make sure
you include the date range within the view definition for each of the
sub-tables.
For example:
create view .....
select c1, c2, date_col
from table1
where date_col between '01/01/2004' and '12/31/2004'
union all
select c1, c2, date_col
from table2
where date_col between '01/01/2005' and '12/31/2005'
union all
select c1, c2, date_col
from table3
where date_col between '01/01/2006' and '12/31/2006'
If you do this, then any queries off the view that are for a specific
date range should hit only the qualifying tables.
Good Luck,
Greig Wise
> > > It will use the index.
> >
[quoted text clipped - 14 lines]
> everyone in this group is awesome
> i will try implement all this and will get back to you
Tonkuma - 30 Nov 2006 09:23 GMT
> unfortunately, it is a character column and i will convert this to date
> soon
If the column C2 is CHAR(8) and value is 'mmddyyyy', you can change it
to DATE by the following expression.
DATE(TRANSLATE('EFGH-AB-CD', C2, 'ABCDEFGH'))
Brian Tkatch - 29 Nov 2006 14:51 GMT
> > > If you are on V9, you can make use of the table partitioning feature, i.e.
> > > range partitioning. Then you don't have to worry about views etc.To the best of my knowledge the table partitioning feature is only
[quoted text clipped - 11 lines]
> i will also test this today but please share with me if someone already
> know the answer
Rule number one, never use SELECT *.
Rule number two, see rule number one.
Does a query on each of the underlying TABLEs use that INDEX for the
same query?
B.
Raj - 29 Nov 2006 15:13 GMT
We use the union all view and indexes are used without any issues...