Ora-01039 - Insuffficient priviliges - Tuning using Explain Plan

In a TEST instance, i am trying (as the APPS user) on a 9.2.0.5 DB (11.5.10.2) trying to run an explain plan on a query but keep getting the 'ora-01039 - Insuffficient privileges on underlying objects of view' error message.
I have granted 'select any dictionary' to both the APPS and APPLSYS users - but this does not seem to enable the explain plan to work.
Could someone please shed some light on this?
Tks

You seem to be doin an Explain Plan on a query against a custom view against non-Apps objects.
Explain Plan needs to be able to "see" the underlying tables (in that other schema).
See :
SQL> create view his_cntry_vw as select * from my_cntry;
View created.
SQL> grant select on his_cntry_vw to abc;
Grant succeeded.
SQL> connect abc/abc
Connected.
SQL> create synonym his_cntry_vw for otheruser.his_cntry_vw;
Synonym created.
SQL> select * from his_cntry_vw;
GRP_I CNTRY
ABC   Z9
XYZ   UK
SQL> explain plan for select * from his_cntry_vw;
explain plan for select * from his_cntry_vw
ERROR at line 1:
ORA-01039: insufficient privileges on underlying objects of the view
SQL> REM  THIS IS THE FIX :
SQL> connect otheruser/otheruser
Connected.
SQL> grant select on my_cntry to abc;
Grant succeeded.
SQL> connect abc/abc
Connected.
SQL> explain plan for select * from his_cntry_vw;
Explained.
SQL>Hemant K Chitale
http://hemantoracledba.blogspot.com

Similar Messages

  • ORA-01039 on attempt to perform EXPLAIN PLAN

    Folks,
    I'm running a query below on Ora10G and getting "ORA-01039: insufficient privileges on underlying objects of the view":
    EXPLAIN PLAN INTO DBO.plan_table FOR SELECT last_analyzed FROM all_tables WHERE table_name='MyTable'
    I'm running under a user TST account and I did "grant all privileges to TST" to make sure I did not forget any privileges. This did not help. I also tried to explicitly "grant insert on plan_table to TST" and "grant select on all_users to TST" but that did not help either. What am I doing wrong?
    Thanks,
    Vladimir.

    To perform such execution plans on data dictionnary, you need to have the DBA role or have the "SELECT ANY DICTIONARY" privilege (if your O7_DICTIONARY_ACCESSIBILITY parameter is at the default value of FALSE. Otherwise, "SELECT ANY TABLE" should be enough). I don't haver 10G installed, but that should hold true, according to what I found on http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9013.htm#i2155015.
    Daniel

  • Using explain plan

    Hi,
    I am quite new to use explain plan in oracle.
    I want to know what are the important factors that we should emphasize to optimize a SQL query.
    Thanks in Advance,
    Dilip

    If I had to identify key SQL tuning factors to look for in relation to an explain plan I would say that number one is to verify that the plan is driving on the right tables in the proper order.
    Second looking at the SQL make sure it is not written in such a manner as to disable the use of available indexes such as when a trunc is done on an indexed date column so it can be compared equal to another date when a >= date value of midnight and < midnight of first day not desired could be used instead enabling use of the index on the date column by the optimizer. Implicit conversions of join column data types can also disable use of an index.
    Third, if the CBO is doing something other than what you expected do not just assume it is wrong. Try to figure out why it is doing what it is doing and then try to determine if it is right or wrong. I have caught people trying to tune SQL because they knew the plan was wrong, but did not actually test it before spending a lot of time to develop a different path that ran slower than the optimzer plan.
    HTH -- Mark D Powell --

  • ERROR: insufficient privileges while using EXPLAIN PLAN command

    Hi,
    I have a table named TEST and i ran following command on this table.
    SQL> EXPLAIN PLAN FOR
    2 SELECT NAME FROM TEST;
    SELECT NAME FROM TEST
    ERROR at line 2:
    ORA-01031: insufficient privileges
    So which privilege do i need to give for using EXPLAIN PLAN command.
    Thank.

    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/ex_plan.htm#i19260
    SQL> @C:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\utlxplan.sql
    Table created.
    SQL> select table_name from user_tables where table_name='PLAN_TABLE';
    TABLE_NAME
    PLAN_TABLE
    You might consider checking dba_tables to check the owner in your case and may be you don't privilege on that table.

  • Query tunning in Oracle using Explain Plan

    Adding to my below question: I have now modified the query and the path shownby 'Explain plan' has reduced. The 'Time' column of plan_table is also showing much lesser value. However, some people are suggesting me to consider the time required by the query to execute on Toad. Will it be practical? Please help!!
    Hi, I am using Oracle 11g. I need to optimize a Select query(Need to minimize the execution time). I need to know how 'Explain Plan' would help me. I know how to use Explain Plan command. I refer Plan_table table to see the details of the plan. Please guide me regarding which columns of the Plan_table should be considered while modifying the query for optimization. Some people say, 'Time' column should be considered, some say 'Bytes' etc. Some suggest on minimizing the full table scans, while some people say that I should minimize the total no. operations (less no. of rows should be displayed in Plan_table). As per an experienced friend of mine, full table scans should be reduced (for e.g. if there are 5 full table scans in the plan, then try to reduce them to less than 5. ). However, if I consider any full table scan operation in the plan_table, its shows value of 'time' column as only 1 which is very very less. Does this mean the full scan is actually taking very less time?? If yes, then this means full table scans are very fast in my case and no need to work on them. Some articles suggest that plan shown by 'Explain Plan' command is not necessarily followed while executing the query. So what should I look for then? How should I optimize the query and how will I come to know that it's optimized?? Please help!!...
    Edited by: 885901 on Sep 20, 2011 2:10 AM

    885901 wrote:
    Hi, I am using Oracle 11g. I need to optimize a Select query(Need to minimize the execution time). I need to know how 'Explain Plan' would help me. I know how to use Explain Plan command. I refer Plan_table table to see the details of the plan. Please guide me regarding which columns of the Plan_table should be considered while modifying the query for optimization. Some people say, 'Time' column should be considered, some say 'Bytes' etc. Some suggest on minimizing the full table scans, while some people say that I should minimize the total no. operations (less no. of rows should be displayed in Plan_table). As per an experienced friend of mine, full table scans should be reduced (for e.g. if there are 5 full table scans in the plan, then try to reduce them to less than 5. ). However, if I consider any full table scan operation in the plan_table, its shows value of 'time' column as only 1 which is very very less. Does this mean the full scan is actually taking very less time?? If yes, then this means full table scans are very fast in my case and no need to work on them. Some articles suggest that plan shown by 'Explain Plan' command is not necessarily followed while executing the query. So what should I look for then? How should I optimize the query and how will I come to know that it's optimized?? Please help!!...how fast is fast enough?

  • Tunning using EXPLAIN PLAN

    HI,
    I am trying to do EXPLAIN PLAN. But SP HAS SO MANY PARAMETER declaration, its very difficult to run explain for each select statement.
    Can any one help me how to run explain paln.

    885901 wrote:
    Hi, I am using Oracle 11g. I need to optimize a Select query(Need to minimize the execution time). I need to know how 'Explain Plan' would help me. I know how to use Explain Plan command. I refer Plan_table table to see the details of the plan. Please guide me regarding which columns of the Plan_table should be considered while modifying the query for optimization. Some people say, 'Time' column should be considered, some say 'Bytes' etc. Some suggest on minimizing the full table scans, while some people say that I should minimize the total no. operations (less no. of rows should be displayed in Plan_table). As per an experienced friend of mine, full table scans should be reduced (for e.g. if there are 5 full table scans in the plan, then try to reduce them to less than 5. ). However, if I consider any full table scan operation in the plan_table, its shows value of 'time' column as only 1 which is very very less. Does this mean the full scan is actually taking very less time?? If yes, then this means full table scans are very fast in my case and no need to work on them. Some articles suggest that plan shown by 'Explain Plan' command is not necessarily followed while executing the query. So what should I look for then? How should I optimize the query and how will I come to know that it's optimized?? Please help!!...how fast is fast enough?

  • Not able to use EXPLAIN PLAN in Toad

    hi,
    I am not able to use Explain Plan in Toad. The error it gives is the table PLAN_TABLE doesn't exit.
    But after seeing this error I did run the script "UTLXPLAN.sql" in order to create the plan_table table.
    After installing the above table I am not able to use EXPLAIN_PLAN from toad, Its giving same error Table PLAN_TABLE doesn't exit though i created it successfully in the proper schema.
    Thanks in advance
    Ram

    check and post.
    SQL> select owner from dba_tables where table_name='PLAN_TABLE';
    before using toad ,first u should connect to sqlplus by that user and issue
    SET AUTOTRACE ON.
    Kuljeet

  • Used Explain Plan

    Hi,
    on 11.2.0.3 , I use the following to verify the Explain Plan used for an executed query.
    SELECT * FROM
    TABLE(DBMS_XPLAN.DISPLAY_AWR('<sql_id>','<plan_hash>'));
    For example
    SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_AWR('cx8m90z5n57g1','3867296312'));
    The problem is that it does not bring always back a result to display . Every now and then it does not find any Explain Plan. Why ?
    Any other way that let to find Used Explain Plan for sure ?
    Thanks and regards.

    The problem is that it does not bring always back a result to display . Every now and then it does not find any Explain Plan. Why ?
    Because the statemen didn't qualify according to the thresholds of thw AWR or was already removed from the AWR.
    Any other way that let to find Used Explain Plan for sure ?
    Definitely. And anyone providing DBMS_XPLAN examples as search string in Google would have been able to find them.
    Sybrand Bakker
    Senior Oracle DBA

  • [8i] Can someone help me on using explain plan, tkprof, etc.?

    I am trying to follow the instructions at When your query takes too long ...
    I am trying to figure out why a simple query takes so long.
    The query is:
    SELECT COUNT(*) AS tot_rows FROM my_table;It takes a good 5 minutes or so to run (best case), and the result is around 22 million (total rows).
    My generic username does not (evidently) allow access to PLAN_TABLE, so I had to log on as SYSTEM to run explain plan. In SQL*Plus, I typed in:
    explain plan for (SELECT COUNT(*) AS tot_rows FROM my_table);and the response was "Explained."
    Isn't this supposed to give me some sort of output, or am I missing something?
    Then, the next step in the post I linked is to use tkprof. I see that it says it will output a file to a path specified in a parameter. The only problem is, I don't have access to the db's server. I am working remotely, and do not have any way to remotely (or directly) access the db server. Is there any way to have the file output to my local machine, or am I just S.O.L.?

    SomeoneElse used "create table as" (CTAS), wich automatically gathers the stats. You can see the differende before and after stats clearly in this example.
    This is the script:
    drop table ttemp;
    create table ttemp (object_id number not null, owner varchar2(30), object_name varchar2(200));
    alter table ttemp add constraint ttemp_pk primary key (object_id);
    insert into ttemp
    select object_id, owner, object_name
    from dba_objects
    where object_id is not null;
    set autotrace on
    select count(*) from ttemp;
    exec dbms_stats.gather_table_stats('PROD','TTEMP');
    select count(*) from ttemp;And the result:
    Table dropped.
    Table created.
    Table altered.
    46888 rows created.
      COUNT(*)
         46888
    1 row selected.
    Execution Plan
               SELECT STATEMENT Optimizer Mode=CHOOSE
       1         SORT AGGREGATE
       2    1      TABLE ACCESS FULL PROD.TTEMP
    Statistics
              1  recursive calls
              1  db block gets
            252  consistent gets
              0  physical reads
            120  redo size
              0  PX remote messages sent
              0  PX remote messages recv'd
              0  buffer is pinned count
              0  workarea memory allocated
              4  workarea executions - optimal
              1  rows processed
    PL/SQL procedure successfully completed.
      COUNT(*)
         46888
    1 row selected.
    Execution Plan
               SELECT STATEMENT Optimizer Mode=CHOOSE (Cost=4 Card=1)
       1         SORT AGGREGATE (Card=1)
       2    1      INDEX FAST FULL SCAN PROD.TTEMP_PK (Cost=4 Card=46 K)
    Statistics
              1  recursive calls
              2  db block gets
            328  consistent gets
              0  physical reads
           8856  redo size
              0  PX remote messages sent
              0  PX remote messages recv'd
              0  buffer is pinned count
              0  workarea memory allocated
              4  workarea executions - optimal
              1  rows processed

  • Why bother to use explain plan?

    All my colleagues used the third party applications, Crystal Report or TAOD, to query data from the 10g R2 database for some kind of reporting. The problem is they always created the query with multiple outer join (> 10 tables) and they WRITE the codes without using the explain plan. They simply used the query for result of the moment and the query they wrote only were used for few time (< 3), because the manager requested the report kept changing the requirement. They did it on both Dev and Prod
    I think it is bad practice, how can I convience them to change their practice?

    The concept that something is ad hoc and therefore doesn't matter can break down pretty quickly when a bright light is shined upon it. But what you are fighting here is more a question of politics than technology.
    If the system is still chugging along at an acceptable speed, no end-user complaints, and practices in your organization range from sloppy to lazy you should probably just polish up your resume and move to a job where people care about professional standards and doing a good job.
    To change a practice such as this usually one must get to the level of childish schoolyard play and create a competitive atmosphere. Take one of those slow queries and tune it. Challenge someone to do better than you did. Offer a beer to anyone that can write it more efficiently than you did, etc. Make it a game.
    But don't be surprised if the reason they aren't running explain plan is that:
    1. They don't know how
    2. They know how but don't know how to read the output
    3. They know how to read the output but haven't a clue what to do about it.
    As an example ... I know a lot of people that think they know how to output an explain plan. In truth not 10% of them understand this:
    SELECT * FROM TABLE(dbms_xplan.display_cursor('cpm9ss48qd32f', 0));
    http://www.psoug.org/reference/dbms_xplan.html
    Which is really rather sad.

  • Error  SP2-0027 while using explain plan

    I'm using explain paln command in order to get the tables
    acceeded by a SQL query.
    When I use the command with some of them, that's OK.
    But when I use it with a query of 4999 characters, it gives me
    this error message:
    SP2-0027: Input is too long (> 2499 characters) - line ignored
    Has anybody an idea to solve this problem or to change this
    limit of 2499?

    user12043927 wrote:
    Open the file (or copy the sql) in a text editor and then resave the file as a different file type.
    In Microsoft Word, you click on File, Save As, then select file type 'text only with line breaks' and save the file. Once this is done, you can successfully run the script from SQL*Plus or Server Manager.You never get a second chance for your first impression.
    As your first post you resurrect a ten year dead zombie post.
    SWEET!
    Can you find a post that is older & dormant to boost your post count?

  • Sql tuning set explain plan

    A hypothetical question came up between dbas in the office.   We regularly take tuning sets before making significant changes on the DB.  Populate from cache.  Great little way of checking to see if anything changed.  Someone asked if a table T1 was accessed during a given day where we had a tuning set being populated from the cache (no reason for auditing to be on at the time).  Well first thing to do is search the sql_statements
    select * from DBA_SQLSET_STATEMENTS
    where sqlset_name = 'my_sts'
    and sql_text like '%select * from t1%'
    but no rows returned, so next idea is to query the plan in case a synonym was used
    select * from DBA_SQLSET_PLANS
    where sqlset_name = 'my_sts'
    and object_name = 'T1'
    And yes, its there we had a select against the table, the main sql_text in the dba_sqlset_statments view was using a synonym.  great, so now we might be able to use this as a alternative audit method (mmv depending on whether you have the diag pack). 
    Heres the question, can we always be guaranteed an object will be in a plan?

    Dom Brooks wrote:
    Also, the presence of a SQL statement in the shared pool does not indicate it was run today - you'd need to check the relevant column, something like last_active_time.
    More importantly, the absence of a SQL statement from the shared pool does not indicate that it was not run today.
    Just that it's no longer in the shared pool.
    I'm concious of that when running the populate,  even in a busy period our pools last over an hour,  with that in mind when Im populating my tuning set, I set the frequency to 10 minutes to poll the cache where distinct IDs and HASHes are overloaded in the tuning set if theyre already there. 
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_sqltun.htm#CACJHDDC
    Note that in production systems the time limit and repeat interval would be set much higher. You should tune the time_limit and repeat_interval parameters based on the workload time and cursor cache turnover properties of your system.

  • COLUMN WIDTH USING EXPLAIN PLAN

    I set autotrace on and when it displays the Execution Plan it wrap and is quite annoying. Is there a command so it will not wrap, but still display all the output?

    You misunderstood, this it what it look like
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=62)
       1    0   FILTER
       2    1     TABLE ACCESS (FULL) OF 'NEW_TRAINING_REQUIREMENT' (Cost=
              1 Card=1 Bytes=62)
       3    1     NESTED LOOPS (Cost=12 Card=6 Bytes=210)
       4    3       MERGE JOIN (CARTESIAN) (Cost=6 Card=6 Bytes=168)
       5    4         NESTED LOOPS (Cost=2 Card=1 Bytes=18)
       6    5           TABLE ACCESS (BY INDEX ROWID) OF 'CORP_TESTERS' (C
              ost=1 Card=1 Bytes=10)
       7    6             INDEX (UNIQUE SCAN) OF 'IDX_PK_CORP_TESTERS_1' (
              UNIQUE)
       8    5           TABLE ACCESS (FULL) OF 'FULLTIME_WORKER' (Cost=1 C
              ard=1 Bytes=8)
       9    4         SORT (JOIN) (Cost=5 Card=6 Bytes=60)
      10    9           TABLE ACCESS (FULL) OF 'NEW_PERSONAL' (Cost=4 Card
              =6 Bytes=60)
      11    3       TABLE ACCESS (BY INDEX ROWID) OF 'NEW_ORGANIZATION' (C
              ost=1 Card=348 Bytes=2436)
      12   11         INDEX (UNIQUE SCAN) OF 'IDX_PK_NEWORGANIZATION_1' (U
              NIQUE)But I would like for it to look like
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=62)
       1    0   FILTER
       2    1     TABLE ACCESS (FULL) OF 'NEW_TRAINING_REQUIREMENT' (Cost=1 Card=1 Bytes=62)
       3    1     NESTED LOOPS (Cost=12 Card=6 Bytes=210)
       4    3       MERGE JOIN (CARTESIAN) (Cost=6 Card=6 Bytes=168)
       5    4         NESTED LOOPS (Cost=2 Card=1 Bytes=18)
       6    5           TABLE ACCESS (BY INDEX ROWID) OF 'CORP_TESTERS' (Cost=1 Card=1 Bytes=10)
       7    6             INDEX (UNIQUE SCAN) OF 'IDX_PK_CORP_TESTERS_1' (UNIQUE)
       8    5           TABLE ACCESS (FULL) OF 'FULLTIME_WORKER' (Cost=1 Card=1 Bytes=8)
       9    4         SORT (JOIN) (Cost=5 Card=6 Bytes=60)
      10    9           TABLE ACCESS (FULL) OF 'NEW_PERSONAL' (Cost=4 Card=6 Bytes=60)
      11    3       TABLE ACCESS (BY INDEX ROWID) OF 'NEW_ORGANIZATION' (Cost=1 Card=348 Bytes=2436)
      12   11         INDEX (UNIQUE SCAN) OF 'IDX_PK_NEWORGANIZATION_1' (UNIQUE)If I set wrap off it cuts off what normally would appear in the second line

  • ORA-01039: insufficient privileges... on EXPLAIN PLAN but OK when run

    I get
    ORA-01039: insufficient privileges on underlying objects of the viewwhen I use EXPLAIN PLAN but if I actually run the SQL it is fine!
    SQL> explain plan for select * from ifsinfo.gscdb_xref;
    explain plan for select * from ifsinfo.gscdb_xref
    ERROR at line 1:
    ORA-01039: insufficient privileges on underlying objects of the view
    SQL>select * from ifsinfo.gscdb_xref;
    GSCDB_COMPANY                  COMPANY                        VARCHAR2
    GSCDB_COMPANY                  NAME                           VARCHAR2
    GSCDB_COMPANY                  ADDRESS1                       VARCHAR2
    GSCDB_COMPANY                  ADDRESS2                       VARCHAR2
    GSCDB_COMPANY                  ZIP_CODE                       VARCHAR2
    GSCDB_COMPANY                  CITY                           VARCHAR2
    GSCDB_COMPANY                  COUNTY                         VARCHAR2
    GSCDB_COMPANY                  STATE                          VARCHAR2
    GSCDB_COMPANY                  COUNTRY_DB                     VARCHAR2
    GSCDB_COMPANY                  GSCDB_LAST_UPDATE              VARCHAR2
    GSCDB_CUSTOMER                 CUSTOMER_ID                    VARCHAR2
    GSCDB_CUSTOMER                 NAME                           VARCHAR2
    GSCDB_CUSTOMER                 ADDRESS_ID                     VARCHAR2
    :

    ...in which case (providing the SQLs in question are SELECT statements) you may be better off with DBMS_SQL.PARSE rather than explain plan.

  • Use of explain Plan

    Hi
    I am using explain plan for query.How can i optimize query to see result of explain plan.
    Thanx

    Collect statistics, use hints, create indexes... many ways. You try using of outlines, but it is not common practice. Usually you haven't to influence the plan directly

Maybe you are looking for

  • I need a list of all folders created in Profile folder by Excel 2013

    I am having issues with Excel 2013, I have noticed some folders are missing .e.g xlstart.  So I need a complete list of folders created by Excel 2013 to compare

  • Process Sheduler for Linux

    Hello, We have to create a monitoring application which shall take some corrective action if required on Linux servers. This shall monitor if the service is running or not after a fixed time interval. If the target service is not running, it shall ta

  • ADS Interactive Forms and NW2004s Sneak Preview - Credentials

    Hi everybody, I have recently installed the Sneak Preview of NW 2004s SPS07 which comes with Adobe Interactive Forms. Trying to use an Interactive Form in an Web Dynpro App I keep getting an Exception saying Could not retrieve a password for credenti

  • Elements 11 organizer stopped working, solution in action center of FFMPEG doesn't go their either

    , solution in action center of FFMPEG doesn't through on line either. but I can open info for a solution. Then Elements 11 wants to shut down. The Action Center on my hp windows 7 desk top gives me this info: Source Elements 11 Organizer  Summary Sto

  • Removal of Photoshop CS6 Beta

    I installed Photoshop CS6 Beta and I just removed it using the uninstaller under Applications/Utility/Adobe Installers/Adobe Photoshop uninstaller alias. I had to find it myself as the information on the Web is wrong. Obviously I am on a Mac (Lion 10