Tune slow query in Oracle 11gr2

Have a query like this:
select count(*) from T1 where c1 = 'str1' and c2='str2' and c3='str3';

It complains "waits a long time for 'direct path read'. Are there any possible ways to tune the query?   What kind of indexes can I create? Can any gurus shed some lights on it?
Thanks in advance.
jl66Asked:
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.

jl66Author Commented:
Can any gurus give me a quick tips for it? Appreciate it.
0
slightwv (䄆 Netminder) Commented:
The easiest answer is an index on all 3 columns:  c1,c2 and c3.

That might not be the 'best' for your system.  Depending on the cardinality, number of rows, etc... you might just need an index on 1 or two of the columns.

I really cannot say which ones because I don't know your data and systems.
0
gheistCommented:
EXPLAIN PLAN FOR
  select count(*) from T1 where c1 = 'str1' and c2='str2' and c3='str3';

??? can you post the output???
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.

Tomas Helgi JohannssonCommented:
Hi!

Take a look at the column cardinality of those columns ( c1,c2 and c3) on table T1.
Then make sure you have an index on those columns where c1, c2 and c3 are the first 3 columns of the index.
Also make sure that the order of those 3 columns are in the order where you have the column with the  smallest column cardinality first and then in increasing cardinality order.
That should speed up your query.

Regards,
     Tomas Helgi
0
slightwv (䄆 Netminder) Commented:
>>Also make sure that the order of those 3 columns are in the order where you have the column with the  smallest column cardinality first and then in increasing cardinality order.

This isn't that important in Oracle.  What column is more commonly used in other queries should be more important.

From:
https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5671539468597


2 -- no, the order of columns in an index is based on how you use them, not on their cardinality.
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
jl66Author Commented:
Thanks a lot for the tips. The query takes a long time to complete. Will run the query again to collect the info for you.
0
slightwv (䄆 Netminder) Commented:
>>The query takes a long time to complete. Will run the query again to collect the info for you.

explain plan doesn't actually execute the query.  It should take a second to run.

After running the explain plan, provide the output from:
select * from table(dbms_xplan.display);
0
gheistCommented:
Should be pretty straightforward once 'explain plan' output is visible.
Just address most expensive operation, repeat explain, repeat until it is fast.

Sometimes system tuning plays huge role, but it is worthless unless query is resonably optimal.
0
jl66Author Commented:
Thanks a lot for everyone's inputs. Really appreciate it. Now it seems OK.
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.