Home » RDBMS Server » Performance Tuning » Table Partitioned with Primary key (oracle 10.0.2)
Table Partitioned with Primary key [message #469417] Wed, 04 August 2010 10:12 Go to next message
rawat_me
Messages: 45
Registered: September 2005
Member
Hi All,
I have normal tables with hugh Data and would like to increase the performace by following means:

1) Add a new column in each table. Say this column Name is IS_LIVE. This new column have only two value 1 ( LIVE ) OR 0 ( NOT LIVE ).
2) Change the normal tables to Partitioned table. There would be only two partitioned in all the table. The partitioned key column would be IS_LIVE and both partitioend recrods would be in two different tablespace.
3) Added a POLICY function to these partitioned table to Always add a Query Predicate of '1' to all queuries.

I am interested to know that what kind of Indexes ( Global Or local ) would be suitable for these kind of Design.
2) Is there any use of having Local index on IS_LIVE.


Please note that Primary Key doesnot have this new column in it.

Thanks
Rawat
Re: Table Partitioned with Primary key [message #469419 is a reply to message #469417] Wed, 04 August 2010 10:26 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Index and partitioning are dependent on the SQL statements you execute.
Without them, no one is able to give any advice on what could be done.

Regards
Michel
Re: Table Partitioned with Primary key [message #469421 is a reply to message #469417] Wed, 04 August 2010 10:27 Go to previous messageGo to next message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
I feel local would be better.
As the index also get partitioned on is_live, the selectivity would be less and perform better.

By the way, what do you mean by "Table Partitioned with Primary key"?
It is quite confusing.

By
Vamsi
Re: Table Partitioned with Primary key [message #469422 is a reply to message #469421] Wed, 04 August 2010 10:29 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>I have normal tables with hugh Data and would like to increase the performace by following means:
>
>1) Add a new column in each table. Say this column Name is IS_LIVE. This new column have only two value 1 ( LIVE ) OR 0 ( NOT LIVE ).

SELECT COUNT(*) FROM HUGH_DATA;
SELECT COUNT(*) FROM HUGH_DATA WHERE IS_LIVE = 0;
SELECT COUNT(*) FROM HUGH_DATA WHERE IS_LIVE = 1;


>2) Change the normal tables to Partitioned table. There would be only two partitioned in all the table. The partitioned key column would be IS_LIVE and both partitioend recrods would be in two different tablespace.

What controls content of IS_LIVE?
How often does IS_LIVE change value?
Re: Table Partitioned with Primary key [message #469427 is a reply to message #469422] Wed, 04 August 2010 10:55 Go to previous messageGo to next message
rawat_me
Messages: 45
Registered: September 2005
Member
The Values of IS_LIVE would be changed only once in a month from the Batch Job.

All the records which would matured would updated to 0 .

The SELECT Claues would never have exclusive Where condition with IS_LIVE.

The Statement would always:

Select * from tbl_a.

It would never be filter by IS_LIVE column.:
Select * from tbl_a where is_live = '0' would never execute.

Rather this would be applied by Oracle by using a POLICY function ( virtual Private Database ) Like.

Select * from ( Seelct * from tbl_a ) where IS_LIVE = '1'.


Re: Table Partitioned with Primary key [message #469429 is a reply to message #469427] Wed, 04 August 2010 10:58 Go to previous messageGo to next message
cookiemonster
Messages: 13958
Registered: September 2008
Location: Rainy Manchester
Senior Member
And what's the logic for applying that policy?
When do you get live data?
When do you get none live data?
Re: Table Partitioned with Primary key [message #469434 is a reply to message #469429] Wed, 04 August 2010 11:15 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Select * from ( Seelct * from tbl_a ) where IS_LIVE = '1'.
How much faster do your benchmark test show this approach to be faster than regular indexing?
Re: Table Partitioned with Primary key [message #469483 is a reply to message #469434] Wed, 04 August 2010 22:21 Go to previous messageGo to next message
rawat_me
Messages: 45
Registered: September 2005
Member
@cookiemonster:
There are around 40M records in the table at present.
I am expecting 20M would move to non_LIVE in first run and subsequent run of every month would move around 45K records to Non_LIVE data every month.

Logic is : All transation which are expired in the last month would move to Non_LIVE.
All new and old transaction which are still not expired would still remain as LIVE.

So around one point of time i am expecting 20M LIVE transaction
and 20M non-Live transaction.

@BlackSwan:
I am expecting around 30-40% of improvement as 50% of Data would be non-Live and applying sql:
Select * from ( Select * from tbl_a ) where IS_LIVE = '1'
should filter non_live data. I hope Oracle internally would do that.



[Updated on: Wed, 04 August 2010 22:52]

Report message to a moderator

Re: Table Partitioned with Primary key [message #469491 is a reply to message #469483] Thu, 05 August 2010 00:13 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>I am expecting around 30-40% of improvement as 50% of Data would be non-Live and applying sql:

I did not ask what you EXPECT!
I asked -. How much faster do your benchmark test SHOW this approach to be faster than regular indexing?


Please post reproducible proof!
Re: Table Partitioned with Primary key [message #469587 is a reply to message #469491] Thu, 05 August 2010 04:20 Go to previous messageGo to next message
cookiemonster
Messages: 13958
Registered: September 2008
Location: Rainy Manchester
Senior Member
@rawat_me - that doesn't actually answer my question at all.
Re: Table Partitioned with Primary key [message #470073 is a reply to message #469587] Sat, 07 August 2010 23:12 Go to previous message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
You don't need to index the partition key. There is no point indexing it on its own because Oracle already knows where all the LIVE and NON-LIVE rows are, and there is not point adding it to Local Non-Unique indexes for the same reason.

If you want your Primary key enforced WITHIN EACH PARTITION (rather than across the whole table), you can add the column to your Primary Key index and keep the index LOCAL. If - as you say - all queries are via the VPD, then all queries will implicitly include a predicate on the LIVE/NON-LIVE column. That being the case, I would make the new partition key column the FIRST column of the Primary Key index, and make the Primary Key index PREFIXED and LOCALLY PARTITIONED. Search the doco for why Prefixed is important.

However, if you want to retain uniqueness across the entire table, you will need a Global index on your PK, which should not include the table partition key.

Ross Leishman
Previous Topic: create table statement with union
Next Topic: index creation
Goto Forum:
  


Current Time: Fri Nov 22 07:54:40 CST 2024