Skip to Main Content

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Anand.

Asked: June 27, 2016 - 5:57 pm UTC

Last updated: July 04, 2016 - 9:34 am UTC

Version: 11.0.2.3

Viewed 1000+ times

You Asked

Hello

I would like to post a question related to which partitioning I can go for based on the below scenario.

I have 2 tables named table1 and table2. Both the tables are having customer I'd and user id column. The hierarchy is multiple users will come under a customer.

Currently in those tables I have got 55k unique users and all these users are tagged under 17k customers. Volume of data in these tables are 100million respectively.

Now I will be having below queries from the application to access data from these tables.

Q1: select * from table1 where report_date =<input date> and user_I'd in <list of user id > and customer_I'd=<input customer id >

Q2: select * from table1 where user_id in <list of user id> and report _date <input date>

Q3: select * from table2 where customer_id =<input customer id > and user_id in <list of user id >

Q4: select * from table2 where user_id in <list of user id>

Considering this scenario, what would be thr best approach.

For Q 1 and 2. Can I go like table1 range partitioned by report date and locally partitioned index on user Id?

For Q3 and 4, hash partition on customer id and global.index or globally partitioned index on user Id?

Please suggest the best way. Environment is oltp.

and Chris said...

For Oracle Database to use partition pruning when executing a query, you need to include the partition columns in your where clause.

1 & 2: Yes, partitioning by report_date will enable you to have partition elimination for these queries. A local index on user_id, or maybe (user_id, customer_id) is worth considering.

3 & 4: customer_id isn't in the where clause of Q4. So it's likely you'll be hitting multiple partitions by doing this. User_id is a better candidate for partitioning.

As always, make sure you test and verify in your environment before diving in and making these changes. The performance benefits may be small. Or partitioning may even make the queries slower!

Also, before doing any of this answer the question:

Why are you partitioning these tables?

Query performance is just one aspect of partitioning. Enhancing availability and manageability are other drivers for doing this.

Read up on the concepts behind these at:

http://docs.oracle.com/database/121/CNCPT/schemaob.htm#CNCPT88858
http://docs.oracle.com/database/121/VLDBG/GUID-EA7EF5CB-DD49-43AF-889A-F83AAC0D7D51.htm#VLDBG002

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

VLDB

If you are new to partitioning, check out Connor McDonald's introduction series here.

VLDB

Documentation set on VLDB and Partitioning.