delete takes a long time on table hash partitioned

emp table is  PARTITION BY HASH (emp_no)  PARTITIONS 100 and the table has 100 million rows.

The following delete takes a long time.  I think it is accessing all the 100 partitions.  So how to make the delete faster in this case?  That may be the problem with HASH partition itself.  Thanks.
Delete from emp table where year =2008 and month =1
ewang1205Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ewang1205Author Commented:
Will create an index on year/month make this delete faster?  Thanks.
0
johnsoneSenior Oracle DBACommented:
You are deleting based on criteria that are not part of the partition key.  It would have to go through all the partitions to do the delete.

Creating a local index on the year/month should speed up the process.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ewang1205Author Commented:
johnsone: thanks for the help.  Try the index and working great so far.  Much faster now.  Will test more.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

SujithData ArchitectCommented:
I would suggest you to partition the table based on your most frequent operations.

If you are interested to access/manage the data based on the date, you may better range partition by date. That will hit the selected partitions directly.
0
ewang1205Author Commented:
I view data by emp_no, load data by year/month.  So I partition by emp_no to speed up the view data, but I am running into the slow loading problem.  I may think to partition by year/month and subpartition by emp_no!!  What do you think?  Thanks.
0
SujithData ArchitectCommented:
>> I may think to partition by year/month and subpartition by emp_no
May not help. As you are viewing the data bases on emp_no, you may hit many partitions just to query one single emp_no, provided you are maintaining the historical data in the table.

How much is the retention in the table? Can records with the same emp_no be present in the table for different dates?
0
ewang1205Author Commented:
100 million totaly for 3 years.  Year view same emp_no for different months and that is the problem.  Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.