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?
 
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
 
PortletPaulfreelancerCommented:
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
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.

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

All Courses

From novice to tech pro — start learning today.