First_rows hint not working

Dear Experts,

I heard first_rows hint will retrieve the query fast for n rows.
But there is no difference with or without the hint.

Are there any conditions for this.?
sakthikumarAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

PortletPaulEE Topic AdvisorCommented:
what version of Oracle is it? (the full version string please)

how are you using that hint?
can we see the query?

have you looked at the explain plan?
0
sakthikumarAuthor Commented:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE      11.2.0.4.0      Production
TNS for HPUX: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

Same 12 seconds with or with out hint

select  /*+ FIRST_ROWS(20) */ *
  from gcb_dba.bol b
 where exists (select 1
          from gcb_dba.gcb_cargo_cat_mapping d
         where b.bol_no = d.bol_no)
   and not exists (select 1
          from gcb_dba.gcb_charge_collection c
         where b.dpc_boe_no = c.doc_no)

                                                                                                                          Cost   Cardinality     Bytes            
SELECT STATEMENT, GOAL = HINT: FIRST_ROWS                                           20      1      484
 NESTED LOOPS ANTI                                                      20      1      484
  HASH JOIN SEMI                                                                       15      1      471
   VIEW      GC_STAGING      BOL                                                            11      21      9786
    UNION-ALL                              
     TABLE ACCESS FULL      OPCSJAD_DBA.BOL                                           4      10      2850
     TABLE ACCESS FULL      OPCSPRD_DBA.BOL                          2      11      3168
   TABLE ACCESS FULL      GCB_DBA      GCB_CARGO_CAT_MAPPING       2      612      3060
  INDEX SKIP SCAN      GCB_DBA      GCB_CHARGE_COLLECTION_IDX_03       5      1      13
0
johnsoneSenior Oracle DBACommented:
Assuming that your statistics are correct, it doesn't look like the hint would help because the tables are so small.  My guess is that it would be slower if it used indexes (assuming they are there).

Essentially, the FIRST_ROWS hint will tend to use nested loops rather than hash or merge joins.  There really is no guarantee about getting rows faster.  It is a join hint.
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
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Geert GOracle dbaCommented:
usually a skip scan is very slow

have you tried adding an index on gcb_dba.gcb_charge_collection with only dpc_boe_no ?
0
sakthikumarAuthor Commented:
So, Can i use this for hint for online queries,(I mean queries to display results in front end)
0
Geert GOracle dbaCommented:
a front-end usually has this same parameter, it's best to use the same value

if your front-end grid wants to display data in grid-mode per 25 lines then it's best to also use first_rows(25)
otherwise ... grid-mode: 25 lines, first_rows(5)
will give the first 5 rows to the grid, but the grid will wait until it gets at least 25 lines to display anything
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.