How to run a SQL statement to use a specific implementation plan
Hi all
I have a SQL that has recently been run badly. I tried the Advisor tuning SQL for the given SQL query and it gives the following information:
GENERAL INFORMATION SECTION
-------------------------------------------------------------------------------
Name of the task of tuning: 2q94zb7djr2xn
The owner task of tuning: LMDBPROD
Type of work: single SQL statement
County of execution: 2
The current run: EXEC_8869
Type of execution: TUNE SQL
Scope: COMPLETE
Time Limit (seconds): 60
Status: COMPLETED
Started on the: 03/02/2014-20:43:39
To the: 03/02/2014 20:44:25
-------------------------------------------------------------------------------
Name of the schema: LMDBPROD
SQL ID: 2q94zb7djr2xn
SQL text: SELECT NPCOMMON. FGET_ACTION_CODE (ORDNUM) ACTIONCODE, STATUS,
SUMA COUNT (*) FROM SORDER, WHERE HEADORDNUM IS NOT NULL AND
NPCOMMON. FGET_PRODUCTOFFER4ORDER (ORDNUM) IN (SELECT ID FROM)
PRODUCTOFFER WHERE PPSPECIFICATION_ID IN (SELECT ID FROM)
PPSPECIFICATION WHERE PCLASS_CODE IN (SELECT PCLASS_CODE FROM)
ARUSERGROUP WHERE CODE IN (SELECT ARUSERGROUP_CODE FROM)
ARUSER_ARUSERGROUP WHERE ARUSER_USERNAME =: B1 AND STATUS = '1')
AND STATUS = '1'))) GROUP BY NPCOMMON. FGET_ACTION_CODE (ORDNUM),
STATUS
-------------------------------------------------------------------------------
RESULTS SECTION (1 result)
-------------------------------------------------------------------------------
1-alternative Plan conclusion
---------------------------
Some implementation plans alternative for this statement was found by searching
performance data in real-time and historical of the system.
The following table lists these plans sorted by their average time.
See "SECTION of ALTERNATIVE PLANS" section for detailed information on each
plan.
plan ID hash last visit elapsed note of origin (s)
-- ---------- -------------------- ------------ --------------- ----------------
1 617797893 2013-07-11/07: 45:20 9.555 no reproducible STS
2 1311086720 2014-01-31/04: 00:44 19.569 AWR
3 1226863820 2014-01-31/18: 00:24 AWR 21.158
4 1359606848 2014-02-03/16: 00:34 21.492 AWR original plan
The plan with hash 617797893 seems the most efficient one and is based on some specific SQL Tuning Set I ran on this time. But the note says that the plan is not reproducible. Is there anyway how can I force the SQL statement to execute the plan? The database version is Standard Edition 11.2.0.1.0
Best regards
Rodriguez
Hello
I think you can use this
before 11 g, we used to create an outline stored for this.
concerning
Tags: Database
Similar Questions
-
How to run multiple sql statements
Hi all
I wonder if I can run multiple sql statements in one shot with > >, immediate run
for example:
I set the variable as X: = sql statement
Y: = sql statement
z: = sql statement
can I execute immediate (X, Y, Z);
If yes how? and if not what other possible
Thank youBeginning with the codes of Ganesh
DECLARE l_statement VARCHAR2 (2000); v_passwd VARCHAR2 (200); v_username VARCHAR2 (200) := 'test'; v_pwd_key VARCHAR2 (200) := 'lwty23'; v_dblink_name VARCHAR2 (2000); v_dblink_drop VARCHAR2 (2000); v_dblink_create VARCHAR2 (2000); v_dblink_check_connection VARCHAR2 (2000); l_number NUMBER; BEGIN --<
> FOR c_instance IN (SELECT * FROM v_oracle_instances WHERE environment = 'Developement') LOOP SELECT encpwd_owner.display_db_encpwd (v_username, c_instance.host_name, c_instance.instance_name, v_pwd_key) INTO v_passwd FROM DUAL; v_dblink_name := c_instance.host_name || '_' || c_instance.instance_name; v_dblink_create := ' CREATE DATABASE LINK ' || v_dblink_name || ' CONNECT TO ' || v_username || ' ' || 'IDENTIFIED BY ' || v_passwd || ' USING' || ' ''(DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST= ' || c_instance.host_name || ')(PORT=' || c_instance.LISTENER_PORT || '))(CONNECT_DATA=(SID=' || c_instance.instance_name || ')))'''; v_dblink_check_connection := 'select 1 from global_name@' || v_dblink_name || '.QCM'; --- Notice this change. I am simply selecting 1. That should be enough to test the database link. v_dblink_drop := 'drop database link ' || v_dblink_name || '.QCMTLAF'; -- l_statement := 'BEGIN ' || v_dblink_create ';' || v_dblink_check_connection ';' || v_dblink_drop '; END ;' BEGIN EXECUTE IMMEDIATE (v_dblink_create); DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Created'); EXCEPTION WHEN others THEN dbms_output.put_line( 'Failed to create the database link ' || v_dblink_name ); dbms_output.put_line( dbms_utility.format_error_backtrace() ); INSERT INTO error_table( column_list ) VALUES( < - > );
END;
EXECUTE IMMEDIATE (v_dblink_check_connection) INTO l_number; --- Notice this.
DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Tested');
BEGIN
EXECUTE IMMEDIATE (v_dblink_drop);
DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Dropped');
EXCEPTION
WHEN others THEN
dbms_output.put_line( 'Failed to drop the database link ' || v_dblink_name );
dbms_output.put_line( dbms_utility.format_error_backtrace() );
INSERT INTO error_table( column_list )
VALUES( <
- > );
END;
END LOOP;
END;
But I agree with the comment that others have grown up is not really wise to create and drop a database like that link.
Justin
-
How to run grid sql statements
Hello
I would like to run some of the grid control sql statements as tablespace freespace check.
Grid options could there be to execute the sql statement?
If so, how to set up the output of the sql for E-mail
Please I need your suggestion to proceed.
Version of the grid: 10.2.0.5.0
Platform: Sun
Thank you.Hello
no need to run the sql statement of the grid, instead of that you can configure the threshold values.
for example, if your tablespace capacity 85% complete and then he will send you the email alert that you configured in notifications.
you will find on the home page - bottom of the page - > manage settings...
check http://download.oracle.com/docs/cd/B19306_01/server.102/b14196/montune001.htm#CACCIHAB
http://download.Oracle.com/docs/CD/B19306_01/EM.102/b40002/notification.htm#sthref995
Thank you
-
Dear friends,
As I recently started working with SQL more, I realized that my opinion on this has changed.
andselect first_name, last_name from personal_details
andselect first_name, last_name from personal_details, education_details
andselect first_name, last_name from personal_details a , education_details b where a.id =b.id
is it different? or make the same result?select first_name, last_name from personal_details a , education_details b where b.id =a.id
Won't return the same result.
Just started to wonder, how it actually works of in.
Can anyone shine some light on this issue?
Thank you.
Benard>
...By default, I think that oracle starts executing the last where condition and so queries can take different time, depending on which is the primary key, or if any column index created on this subject.
This statement is almost always wrong. Oracle evaluates what query condition is the best to run first. This is done by the optimizer cost based using statistical information about the tables, columns and the indexec on these columns. There had been questions back in the day Oracle 7 and the RBO (rule based optimizer) where the order in the clause from and where clause was important. But in general, do not care anymore to this topic.
-
How to run a SQL string to a procedure of forms?
Hello
first the background. I have a Varchar2 column in a Table with a SQL string.
Now I want to read this chain in forms and run the SQL statement - but I don't know how.
This is the SQL string:
Select the country from p_1 from countries where country_nr = p_2
P_1 and p_2 are Variables in the procedure of forms.Most people forget that groups Records are excellent tools for dynamic queries like this. Search for Populate_group_with_query.
Only you need to change your sql, it is not in the sentence, like this:
Select the country as P_1
country
where country_nr = p_2
and p_3 = p_3
and p_4 = p_4Select name as P_1
of the customer
where customer_nr = p_2
and country_nr = p_3
and p_4 = p_4Your rec group would have a single column, P_1, where the data would be accessible after the query. Get_group_char_cell allows you to retrieve the value of P_1. I don't know, but you should not "AS P_1" expression in the select, as long as you have created the record group initially with a specific column name.
The only thing that is not clear, however, is your use of variables in the where clause. You can either hardcode the literal values in the SQL string, like this:
'where country_nr = ''123'' and...'
Note as you build your text string SQL, you use two apostrophes instead of one, given that pl/sql uses the apostrophe of beginning and end of the string.
Or alternatively, you can use bind variables for your where the variables paragraph as follows:
where customer_nr = :Parameter.var_2
and country_nr = :Parameter.var_3Then, you can move a value in the: parameter values before completing the Group rec. You can use elements in a block of control rather than the settings, too.
Here is an example of using dynamic query in a record group: Re: dynamic query
-
How to run wfstatus.sql for i-expenses
How to run wfstatus.sql i-expenses in EBS 11i.Select this check box, hope it helps.
How to find and solve the reports on Internet expenditures within workflow [ID 185004.1]
How wfstatus.sql to run on a statement of expenses Internet [134895.1 ID]
-
How to execute a SQL statement that is stored within a SQL Table
Hello
If someone please help me with the following problem I would be eternally grateful
I have a SQL statement that is stored inside a certain SQL table, I want to use this SQL statement inside my PL/SQL procedure.
Thought a simple solution was to get the SQL statement in a table, and then run it, but how could I do so exactly with PL/SQL? I only started to play with PL/SQL in the last days.
Thanks in advance!
This is what it looks like more or less:
Display result for:
---------------------
SELECT TRIM (OBJ_VALU_TXT)
OF OBJ_VALU_DOC
WHERE TYPE_OBJET = 'FLD '.
AND OBJECT_CODE = 15443
AND OBJ_VALU_CD = 'CAB '.
ORDER BYDOC_SEQ_NO
00001
------------------------------------------------------------------
SELECT
VALUE (MAX (RECEIPT_NO) + 1,: OUT-COMP-FACTOR)
THE FRONT DESK
WHERE (RECEIPT_NO BETWEEN
(: OUT-COMP-FACTOR AND: OUT TO A NUMBER) OR
(RECEIPT_NO >: OUT-COMP-FACTOR AND)
(: OUT-TO-NUMBER = 0)
Here's a demo of your condition.
create table t (col1 varchar2 (200));
table created
insert into values t ('select * from double ');
1 row inserted
declare
v_col varchar2 (200);
v_val varchar2 (200);
StartSelect col1 in t v_col;
run immediately v_col in v_val;
dbms_output.put_line (v_val);
end;-----
XUse in the clause, you can use as many variables as needed. But the basic approach remains the same.
But storage in DB SQL is not an efficient design.
Ishan
-
How to execute the sql statement in the file beats?
I want to execute after the statement
C:\ > sqlplus/nolog
SQL > conn scott/tiger
SQL > select * from tab;
I know I can achieve it following test.bat and testdb.sql file
test.bat is:
sqlplus/nolog @testdb.sql
TestDB.SQL is:
Conn scott/tiger
Select * from tab;
Now I don't want to use the sql file, I want only use bat file, as follows:
test.bat is:
sqlplus/nolog
Conn scott/tiger
Select * from tab;
When I run test.bat, I find only one sqlplus /nolog execute statement, do not execute other statements.
(1) I want to know if there is a method to run the SQL file by fighting without a sql file? How to make it happen?
(2) if I call the sql file, how to hide the password of user? Because I don't want other people to know scott password, if I use conn scott/tiger in testdb.sql, other person can see testdb.sql and the password. Is there a good way to avoid?
Thank you!It works a bit different in Windows. Create a file is like this:
( echo conn scott/tiger@orcl echo spool c:\temp\list.txt echo select sysdate from dual; echo spool off echo exit ) | sqlplus -s -l /nolog
-
Try to run a SQL statement through the window of OEM 12 c run SQL. Statement fails
All,
I have a 11g database. When it is initially installed, I installed it in $ORACLE_BASE = / orabin/app/oracle/product and $ORACLE_HOME = $ORACLE_BASE/11gDB_R2. This is the version 11.2.0.1 to give birth to 11.2.0.3.
Recently, I installed 11.2.0.4 in $ORACLE_BASE/11.2.0.4. Then, I upgraded my database at 11.2.0.4. Everything works fine.
All my scripts on the linux host logon changed to point my environment at $ORACLE_BASE/11.2.0.4 House and my $PATH when I connect to the linux host is: /orabin/app/oracle/product/11.2.0.4/bin:/orabin/app/oracle/product/11.2.0.4/OPatch:/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin
On my OEM Console, the database appears as 11.2.0.4 and me can manage very well.
However, when I try to use the window of the OEM Console to execute SQL to execute any type of SQL statement, it fails.
The failure error is:
Could not launch/orabin/app/oracle/product/11gDB_R2/bin/sqlplus-s/nolog: no such file or directory
It would be a mistake since the 11gDB_R2 directory tree (the 11.2.0.3 software) has been removed from the host, now that the database is set to level and working as 11.2.0.4.
I wonder if somewhere in the OEM software, there is always a pointer to the old ORACLE_HOME? I can't find anything in the .bashrc or other shell scripts that are executed when a Shell session on the host computer which were still the reference to the old directory of 11gDB_R2 so I'm a bit puzzled.
I have 8 guests, and all have been improved in the same way at 11.2.0.4. For some databases, the OEM window run SQL is executing the SQL code.
Someone has some ideas on this?
Go to the Configuration of the analysis of the database (when you set the password) and update of the Oracle home. Also do this for all targets listener on this host as well.
-
How to execute the SQL statement in the Application Module
Hi people
I´d would like to know how I can execute a SQL statement like "remove user" in the Module to request... prepareSession method...
I m using Jdev 10 with ADF Faces
Thank youThis is possible, but you should think twice about it.
If this can be done with an EO/VO do in this way.
If you can't do it with an EO/VO you can yourself the DB operation (ApplicationModule.getDBTransaction ()) and use a call of createStatement (...) do what you want.Timo
-
How to run script on the web using HTTP web page?
Hi guys
Please let me know how to execute script on the web using HTTP web page?
Concerning
FrankHi Jos,
ODI provides web-based UI to run scenarios using metadata (read only your components ODI) Navigator and designer Lighweight (you can change the mapping here).
If please review how to install the metadata browser in ODI and take a look at the document ODI Setup for more information.
Thank you
Guru -
How to concatenate two sql statements?
Hello
How can I combine the following two sql statements so that the result of a line of the first statement appears before the lines of my second sql statement. The reason I need it is to order the lines correctly.
Select the username, id
some abusers
where id = 0
Select the username, id
some abusers
where id! = 0
order by username
Thank you
jYou should ask in the forum of the Apex:
Oracle Application Express (APEX)Nicolas.
-
How to run PL/SQL code, as soon as a page opens
Hello
We have a business scenario where we have Apps initialize to obtain data of the ebs. We want this commissioning to arrive as soon as the page opens. Is there a way to do this? Simple, we want to be able to run pl/sql code, as soon as the page opens. Is there a way to do this?
PL Note: We use APEX with ebs.
Kind regards
Joseph"You can have the pl/sql code in an Application process that has a ' process ' of ' On Load: before header".
CITY
-
How to remove the sql statement in the output of the coil?
Hi gurus,
If my spool request is like that
I get my file csv as like this:set feedback off set verify off set trimspool on set heading off spool c:\test\test.csv select * FROM test; spool off
What should I change in my SQL query such that I won't include these lines:SELECT * FROM test1 SSO -------------------- shsrgh dehrerdh wtw55hd dhdfhdfh hdhdh SET SPOOL OFF;
Thank youSELECT * FROM test1 SSO -------------------- SET SPOOL OFF;
user10679113 wrote:
What should I change in my SQL query such that I won't include these lines:
SELECT * FROM test1 SSO -------------------- SET SPOOL OFF;
You cannot change anything in your SQL query to exclude these lines.
These lines refer to the client you are using i.e. SQL * more and have nothing to do with the SQL language as such.You could put all of these SQL * more commands in a script file and run this SQL script file *, as shown below:
test@ORA10G> test@ORA10G> -- show contents of the script: c:\test.sql test@ORA10G> host type c:\test.sql set feedback off set trimspool on set heading off set echo off spool c:\test.log select ename from emp; spool off set echo on set heading on set feedback on test@ORA10G> test@ORA10G> -- run the script test@ORA10G> @c:\test.sql SMITH ALLEN WARD JONES MARTIN BLAKE CLARK SCOTT KING TURNER ADAMS JAMES FORD MILLER test@ORA10G> set heading on test@ORA10G> set feedback on test@ORA10G> test@ORA10G> -- show contents of the spooled file: c:\test.log test@ORA10G> host type c:\test.log SMITH ALLEN WARD JONES MARTIN BLAKE CLARK SCOTT KING TURNER ADAMS JAMES FORD MILLER test@ORA10G>
HTH,
isotope -
How to combine towing sql statements.
Hi all
I try to combine the two sql statements. but it is giving error 907, I can't stand no less. Please correct me if am wrong.
Here's my query
Select a.A1, b.C1, a.B1 in)
(select C1, sum (s.amount_sold) cust_first_name
customers c, s sales where c.cust_id = s.cust_id
C.cust_first_name group),
(select t.calendar_year A1, sum (c.unit_cost) B1
the time period t, cost c where
t.TIME_ID = c.TIME_ID and t.calendar_year
((1998,1999) group by t.calendar_year) b) order of 1, 2
Thank you
SreeI found two [a start and closing] and additional fasteners - from parentheses after FROM and closing introductory "order by".
Try this:
SELECT a.A1, b.C1, a.B1 FROM ( SELECT cust_first_name C1, SUM (s.amount_sold) FROM customers c, sales s WHERE c.cust_id = s.cust_id GROUP BY c.cust_first_name) a, (select t.calendar_year A1,sum(c.unit_cost) B1 from times t,costs c where t.time_id=c.time_id and t.calendar_year in (1998,1999) group by t.calendar_year) b order by 1,2
Published by: user130038 on Sep 1, 2011 08:19
Maybe you are looking for
-
Occasional kernel panic crash.
I have occasional kernel panic events that trigger a crash and restart the computer. I'm running OS X 10.10.5 Yosemite. I did a recent permissions repair and got the message, "the SUID file ' System/Library/Core...as been modified and will not be rep
-
HP Officejet 4630: Enter search term the PROBLEMS of PRINTER
I'm trying to print a document on my printer. I get: " error printing on HP Officejet 4630.» Printer has a problem that requires your intervention"on computer. Then on the printer I get: " unable to print. Press OK to connect the printer to update s
-
Satellite P870 - operational noises
Various regular intervals, my model emits strange noises, when I first heard them I thought that the unit was defective. Of course, they are difficult to describe, but they are like a rattle, type click noise. Sometimes, they are rather pronounced cl
-
OR sell stepper motors or continuous or not?
Sorry if this is a silly question but I have conflicting information on this topic... Clearly, I see engine illustrated with prices but a rep OR was told that they don't sell the engines so they'd put me in contact with the 3rd party sellers? What
-
My documents and attachments in my email are open in Notepad form vs pdf
If I try to open an e-mail that I sent to someone who was in the form of pdf and it says pdf. It opens in Notepad and Icannot display it. I don't know why it does this