Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Balakrishna.

Asked: July 17, 2016 - 6:43 am UTC

Last updated: March 11, 2017 - 1:49 am UTC

Version: 12c

Viewed 1000+ times

You Asked

Hi Tom,

1)first up all great thanks to you for spending time for me
explain about following hints
Parallel
append
index
no_index
first_rows
and all_rows with an example in which situation we may use what hint in select the data from table?


and Connor said...

Some simple definitions below:

parallel
- I want to use more server resources to complete a task. So the database will invoke more than 1 session (ie, "slaves") to divide a large task into several smaller ones that will run concurrently.

append
- I want to insert lots of rows. Rather than go hunting in existing blocks for free space, I will add them all at the "end" of the table in fresh blocks thus making it more efficiently load them in bulk. (The whole table will be locked whilst I do it)

index
- Tell the the optimizer that I want to use an index, or a particular index, when running this query.

no_index
- The opposite of above. Tell the optimizer not to use an index, or a particular index.

(Both index/no_index hints normally mean some underlying issue you might want to tackle, ie, *why* did the optimizer make a bad choice...it might be out of date or missing statistics etc. Ideally you shouldnt need to use index/no_index hints)

first_rows/all_rows
- When you run a query that will return (say) 1000 rows, you are letting the optimizer know what is more important to you:
a) getting the first batch of rows back as quickly as possible,
b) getting all of the rows back as quickly as possible

Think about (say) a Google search on "Oracle" - there's millions of hits, but I really want the first page of results to come back quick. That's "first_rows".

But if I wanted to (say) add up all of last years sales by day, then seeing the first week quickly doesnt matter to me - I want *all* of the days. Thats "all_rows"


Rating

  (2 ratings)

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

Comments

When to use No Index

Mansi Raval, March 10, 2017 - 7:16 am UTC

I have one table X with column A,B,C.
Data inserted into X on the bases of column A(We used seq to generate value of A).
A is PK and index too.
Index is also there on C.

Is it wise to use index in below select query.

Select A,B where C in(value,value,value...);

This query is taking so much IO,Is it because of Index on C.


Connor McDonald
March 11, 2017 - 1:49 am UTC

Maybe....maybe not :-)

There's a simple way to work it out

a) try it with the index
b) try it without the index


A reader, March 15, 2017 - 10:31 am UTC

Great Thanks tom ot is very much useful

More to Explore

Performance

Get all the information about database performance in the Database Performance guide.