Academic Question using HINTs

Hi all
I have a stored procedure with the code below (this is an excerpt)
create or replace procedure queryone
as
abench integer;
bbench integer;
begin
select count(*) into abench from bench where kseq=2;
select count(*) into bbench from bench where k100k=2;
dbms_output.put_line (abench || ' KSEQ');
dbms_output.put_line (bbench || ' K100k');
end;
Now I have to use HINT as part of the assignment.
I know I have to use SELECT /*+ all_rows*/ from ....and this is where I get lost..
Am I on the right track? Do I put abench or bench after the from? I can't get either to work.
Thanks so much

If you really have to use a hint:
select /*+ all_rows */ count(*) into abench from bench where kseq = 2;

Similar Messages

  • Question bout using HINTS

    Folks,
    Say I have a sql which is using 20 tables and have 40 indexes (latest stat, newly rebuilt index).
    What is the bottleneck/issue if I use 70% hints for this query? What is the best way to reduce use of Hints (perhaps not use at all) and gain performance?
    regards,
    Lily

    The general concerns with using hints in production queries
    - You may be covering up deficiencies in optimizer statistics. If the CBO isn't picking the best path for this query, it probably won't be picking the best path for other queries, so it's often more efficient to get to the root cause than to have to end up hinting lots of queries and/or suffering with poorly performing queries
    - You may be preventing a future version of Oracle from using a more efficient path. The CBO is evolving all the time, if your hints are forcing a particular path, you're eliminating future changes that might help.
    - Hints with syntax errors don't generate errors, they are silently ignored. This means that if someone modifies the query in the future and accidentally screws up one of your hints, it'll still run but may not run well.
    - You may end up under-hinting a query, giving the CBO just enough room to do something screwy.
    - Stored outlines (optimizer plan stability) tends to be a cleaner way to force the optimizer to use a particular query plan.
    Justin

  • What is the disadvantage of using hints in query

    hi all,
    i am report developer, in my project we were using hits in the query ... so that the query performance has improved ..
    my question is if we use hints in the query will it give any effects.. means to say instead of using hints we can make use of execution plan..
    what is the use of execution plan i don't know.. but i have an ideal about it .. if we change the execution plan then that will be use full i think
    please reply me,, if am wrong please correct me.. am not that much good at execution plan and hints in oracle..
    please tel me the difference between hints and execution plan and which one is better ?
    Thanks
    Raja

    Hint are used to bias the execution plan of a query. So there is no 'which is bettter'. Hints may be used to generate a different execution plan, but you can't predict how an execution plan looks like in the end. This decision is done by the db engine.
    It best to start without any hints and let the query optimizer do the work. For queries you feel run to slow you can try to give hints and see if your assumption is correct (when the execution time is faster with hints).
    On the other side your question is not related to jdev. You may ask the question in the {forum:id=75} forum
    Timo

  • Can we use hints in oracle 11g version ?

    can we use hints in oracle 11g version ? is it working ??

    Why do you ask these questions? Have you looked at the SQL Reference Guide and Performance Tuning Guide for your Oracle version - both which covers using hints?
    Have you see a statement that is not supported? Or does not work?
    Or are you simply doing idle speculation and expecting forum members to spend their free time in answering a basic question where the answer is ridiculously simply to find?

  • Using hints to improve performance

    Hi I am trying to create table using the below stmt. I am giving the counts on the tables also.
    It is taking 5-6 minutes to create the table. I am trying to improve its performance.
    Are my hints correct? What is nested look?
    Any suggestions.
    Thanks.
    create table dt_25_temp as
    select /*+ index(dt,DT_25_IDX) index(cl, T_CL_CLIENT_ID_CL_ID_IDX1 ) index(ml,T_MAILING_IDX2) index (ms ,t_ms_pk) use_nl(dupe,master)*/
    dt.id ,dt.l_id , dt.cl_id
    , ml.ml_id
    , ml.ml_u3
    , ms.t_cd
    , ml.ml_u1
    , ml.ml_u2
    , ml.ml_u4
    , ml.ml_u5
    from Dt_25 dt
    , t_ml ml
    , t_cl cl
    , t_ms ms
    where dt.cl_id = cl.id
    and cl.ml_id = ml.id
    and dt.ms_id = ms.id
    and cl.client_id = 12345
    and ml.client_id = 12345
    select count(1) from t_cl--1576262 records
    select count(1) from t_ml--280682
    select count(1) from t_ms--10341585
    select count(1) from dt_25--1092469 ( this is temporary table I create daily , it mave have 1000 to 1M records )
    DT_25_IDX is on column ID
    T_CL_CLIENT_ID_CL_ID_IDX1 is on client_id and id
    T_ML_IDX2 on id,cl_id
    t_ms_pk is on column id

    user10405034 wrote:
    Hi I am trying to create table using the below stmt. I am giving the counts on the tables also.
    It is taking 5-6 minutes to create the table. I am trying to improve its performance.
    Are my hints correct? What is nested look?
    Any suggestions.First of all, why are you using hints? If you have representative statistics in place and you're using the cost based optimizer it should be able to come up with a reasonable plan by itself. If not, you need to find out why. You should use hints only as a last resort, if you know something about your data that the optimizer simply doesn't know and therefore can't recognize.
    I wonder why you use the USE_NL hint if you're asking what a "nested look" (I assume you meant NESTED LOOP) is, suggesting that you don't know what this particular hint is about?
    - Can you show us the output of EXPLAIN PLAN using DBMS_XPLAN.DISPLAY? Use the \ tag before and after to use proper formatting in fixed font- What 4-digit version (e.g. 10.2.0.4) of Oracle are you using?
    - Given the fact that your DT_25 table might have significantly different sizes, the question is if the data from the other tables joined to will be restricted by the join or not. It would be possible that if your DT_25 table is small, a index access into the other tables might be faster, whereas if your DT_25 table is large and covers a lot of data from the other tables, a full table scan of those tables might be more appropriate.
    - How restrictive are these filter predicates specified:
    and cl.client_id = 12345
    and ml.client_id = 12345
    i.e. how many rows from the totals provided correspond to those predicates?
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to use hint on with clause query

    Hi all,
    I have a query and it consits full of tabs with WITH clause. Top level I am just selecting all the tabs (queries with WITH clause) by saying select * from tab1,tab2,.....so on .
    Now my question is If I want to use hint on my SQL can I use the same by using tab1,tab2...
    tab1, tab2 are not actually tables ....each tab represents one SQL with WITH clause.
    Please let me know if there is any confusion on my post.

    What's stopping you from trying it yourself?
    Post your results here to help others.

  • About Using Hints in OWB

    Hi ALL
    I am facing one diffculty about using hints in OWB. Through the mapping configuration, i am trying to use INDEX hint for my table. The generated code is correct, but is a very redundant code. Hint is repeating multiple times in the sub query. Below is the sample:
    SELECT
    /*+ INDEX ("My_Table1") INDEX ("My_Table2") */
    Column1,
    Column2,
    Column3,
    Column4,
    Column5,
    Column6,
    Column7,
    Column8
    FROM
    ( SELECT
    /*+ INDEX ("My_Table1") INDEX ("My_Table2") INDEX ("My_Table1") INDEX ("My_Table2") INDEX ("My_Table1") INDEX ("My_Table2") INDEX ("My_Table1") INDEX ("My_Table2") INDEX ("My_Table1") INDEX ("My_Table2") INDEX ("My_Table1") INDEX ("My_Table2") INDEX ("My_Table1") INDEX ("My_Table2") INDEX ("My_Table1") INDEX ("My_Table2") INDEX ("My_Table1") INDEX ("My_Table2") INDEX ("My_Table1") INDEX ("My_Table2") INDEX ("My_Table1") INDEX ("My_Table2")
    Column9,
    Column10,
    Column11,
    Column12
    FROM
    ( SELECT .....
    The text under the hint ("My_Table1") INDEX ("My_Table2") is repeating again and again. Any way of controlling the code being generated..?

    From a performance standpoint, using hints in that manner may cause poorer performance than without. The INDEX (table_name) hint directs the optimizer to evaluate all relevant indexes. It is very easy to build an example where your column of interest is the last column in a multicolumn index and have a query perform worse than what a full table scan would produce. Oracle's recommendation is to "use hints sparingly" and that is for good reason.

  • Tuning query without using hint

    Hi,
    i want to change the plan of a query without using hint.
    Also i want to use the plan that hint generate in my original query.
    My db is a 11g.
    How can i do this?
    tnx

    You can use SQL Plan Manager. You might find this interesting:
    http://blogs.oracle.com/optimizer/entry/what_should_i_do_with_old_hints_in_my_workload
    The link above basically suggests these steps:
    1. Run the query with the hints, then
    2. Take the plan from #1 and associate its SQL plan baseline with the query with no hints
    3. Remove the hints for that query in the code and start capturing and evolving plans for the un-hinted query

  • How to use hints in PL/SQL

    Hi,
    If I want to use hints in PL/SQL procedure, it is valid to write it this way:
    begin
    update /*+  INDEX(opp DIM_OPP_REFDB_IDX) */
            scott.rec_dim_opportunity opp
            set opp.mp_opportunity_re ....
    endI doubt when I tried it that the optimizer didn't actually use the index.
    Thanks in advance.
    Oracle 10g R1
    Windows 2003 32-bit

    the table is of 90MB and when the UPDATE statement is used in SQL, the explain plan output shows that the index is used.
    When I execute it from a procedure, the Current Statement show in TOAD doesn't show that the index is used and the update takes forever. Explain plan of the statement (as show in TOAD) shows that full table scan is being used.

  • Interactive questions using IP/TV

    I am interested in how users can post questions using IP/TV while the presentation is ongoing. What is the process behind this as I don't really see how it works, any kind of insight would be useful.
    Many thanks Alex

    When you set up the program, you can (or not) enable interactive "from the field" questions.
    The client provide a button that can be pressed to flag the presenter that a field question is pending.
    The presenter can then address the questions as possible.
    Depending on the scope and location of the audience, you may also consider bringing up a conference bridge for voice-based questions.
    Good Luck
    Scott

  • How to use hints in Obiee to increase performance

    Anybody please tell me how can we use hints to increase performance of ad hoc and dashboard reports in obiee

    Hi,
    Check this,
    http://www.howtoexam.com/index.php?option=com_content&view=article&id=75%3Ausing-hints-in-obiee-rpd-and-answers&catid=790%3Acomputers-and-software&Itemid=166
    Rgds,
    Dpka

  • Is this now where to ask DVD Studio Pro questions?  If not, please let me know where.  Here's my question:  Using DVD Studio Pro 3, when trying to burn a disc which is 4.5GB, I get error message "Not eough disk space in target folder".  What to do?

    Is this now where to ask DVD Studio Pro questions?  If not, please let me know where.  Here's my question:  Using DVD Studio Pro 3, when trying to burn a disc which is 4.5GB, I get error message "Not eough disk space in target folder".  What to do?

    Thanks.  Unfortunately, I need to make a master DVD that can then be duplicated in bulk as a single layer disc.  This surprises me because I tried burning a different DVD project that has worked in the past which is also 4.5 GB and now I could not burn that either.  I also reencoded some material to get the new project down to 4.4 GB but it still would not burn.  Any ideas are appreciated.

  • Using hint in hyperion query

    hi
    i m using hyperion verion 9.3.1.2 ..
    and i have problem where given query in request tab is taking lot of time to execute.
    i took the query log also saw the explain plan of query..
    when i chnged the index on which the query is executing (using hint) on sql promt the response time was improved drastically.
    please can any one let me know if i can make ue of that hint in hyperion ????
    thanks
    tushar

    If you are talking about Hyperion Interactive Reporting (IR) you can add hints. One quick way is to add a computed column to your request line and make it your first item requested. Put the hint in the computed item and process the query. If you want to do it another way, let me know if you are using IR.

  • Need to use Hint for Select Query  11g

    Hi,
    I have a select query which is fetching data from multiple table.
    I just need 10 or less rows, already I m using rownum <=10
    Could you tell which is the better choice for using HINT.
    /*+ FIRST_ROWS(10) */      (or)    /*+ all_rows */
    Thanks.

    On Oracle 11.2.0.3 and 11.1.0.7 on my test table with an ORDER BY in the query, I found FIRST_ROWS using the index to get sorted rows and ALL_ROWS retrieving 10 rows from a full scan and then sorting them.
    On Oracle  I didn't find any difference in plan on a different, physically smaller, table.
    For the ALL_ROWS version the optimiser already knows that there will only be 10 rows returned.
    The performance difference: As usual, only use FIRST_ROWS if you actually intend to fetch less than the full data set. If you intend to fetch all 10 rows, use ALL_ROWS, which should be the default (taken from the optimizer_mode system parameter).

  • Using Hints Oracle

    Hi All,
    I have a statement which selects from WB2_V_MKPF_MSEG2
    SELECT
    MBLNR MJAHR ZEILE_I BWART_I MATNR_I WERKS_I LGORT_I CHARG_I SHKZG_I MENGE_I MEINS_I UMMAT_I UMWRK_I  UMLGO_I UMCHA_I
    FROM WB2_V_MKPF_MSEG2 INTO TABLE ITAB_MSEG
    FOR ALL ENTRIES IN ITAB_BATCH WHERE
          MATNR_I = ITAB_BATCH-MATNR AND WERKS_I = STRC_T001L-WERKS AND LGORT_I IN S_LGORT1 AND
          BWART_I IN ('311', '312') AND CHARG_I = ITAB_BATCH-CHARG AND BUDAT IN R_BUDAT  %_HINTS ORACLE
          '&SUBSTITUTE VALUES&' ORACLE '&max_blocking_factor 20&'.
    When I observed the trace, I found 2 different execution plans (I had executed the report multiple times)
    First -
    1. Index Range Scan MKPF~BUD
    2. Table Access by Index Rowid MKPF
    3. Index Range Scan MSEG~0
    4. Table Access by Index Rowid MSEG
    Second -
    1. Index Range Scan MSEG~M 
    Index M contains the following fields - MATNR, WERKS, LGORT, BWART, SOBKZ, CHARG
    2.Table Access by Index Rowid MSEG
    3. Index Range Scan MKPF~BUD
    4. Table Access by Index Rowid MKPF
    The report running with second execution plan takes less time when compared to first. Though Optimizer is selecting a execution plan which goes through Index in both cases it is unable to select the Best Optimal Plan in all the cases ie Second.
    I tried to use Hints,
    ORACLE 'INDEX("MSEG" "MSEG~M" "MSEG^M")'
    but the optimizer is not considering, still I get the First Execution Plan.
    I could observe that Hints are working when I use a single table ie either MKPF or MSEG. But when I use View it is not working.
    Is it possible to influence Optimizer to consider first MSEGM and then MKPFBUD using Hints
    Can any one help me on this.
    Regards,
    Vipin.

    Hi,
    > Can you tell the Syntax for LEADING Hint and USE_NL Hint to influence the order of Selection ie first MSEGM and then MKPFBUD.
    sure, this hint:
    %_HINTS ORACLE 'LEADING(T2)'
             ORACLE 'USE_NL(T1)'.
    will start with MSEG - T2 (alias from view) and use nested loop to access MKPF - T1 (alias from view)
    > And I have one more doubt, when I am going through Oracle Performance Tuning Guide 10g for hints, I found this
    >
    >
    > Oracle does not encourage the use of hints inside or on views (or subqueries). This
    > is because you can define views in one context and use them in another. Also, such
    > hints can result in unexpected execution plans. In particular, hints inside views or
    > on views are handled differently, depending on whether the view is mergeable into
    > the top-level query.
    >
    >
    >  Can you please give me your advice on this.
    hm i think this means that you should not hint IN the view itself because it may be used
    from many different call positions.
    you didn't hint in the view, you hinted your query that access the view.
    Another query without hint may use a different execution plan.
    Kind regards,
    Hermann

Maybe you are looking for