Can the format of a SQL Statement modify the execution time of an SQL ....
Can the format of a SQL Statement modify the execution time of an SQL statement?
Thanks in advance
It depends on:
1) What oracle version are you using
2) What do you mean for "format"
For example: if you're on Oracle9i and changing format means changing the order of the tables in the FROM clause and you're using Rule Based Optimizer then the execution plan and the execution time can be very different...
Max
[My Italian Oracle blog|http://oracleitalia.wordpress.com/2009/12/29/estrarre-i-dati-in-formato-xml-da-sql/]
Similar Messages
-
Expensive SQL Statements of the day?
Hi...
How can i find out Expensive SQL Statements of the day please.?
Our SAP Version is ECC 6.0 on Oracle 10.2.0.4.0
RgdsHi Srinivas,
On ECC 6.0, go to ST04 t-code --> performance --> SQL Cache --> You see SQL Statements where you need to sort by SQL Statements by Total Execution Time(ms).
I have tried on one of my R/3 4.7EE system, ST04n --> Resource COnsumption --> Top SQL Statements --> you will see 50 Top most expensive SQL Statements interms of wait time.
also Read: [Re: Diagnosis of the expensive ABAP programs having database time > 90%;
[Please Read before Posting in the Performance and Tuning Forum;
Regards,
Kanthi Kiran -
XML Publisher - can we specify multiple SQL statements in the report?
Hi there,
can we specify multiple SQL statements in the report with XML Publisher?
Regards,
LiviuCould we eventually generate with the Wizards available in XML Publisher desktop 5.6.2 an xml file with a structure like the one given below? The reason is to facilitate creation of the two rowsets. Thanks, Liviu.
<?xml version="1.0" encoding="UTF-8"?>
<DATA>
<ROWSET2>
<ROW2>
<FIELD1>Query1</FIELD1>
<FIELD2>field2</FIELD2>
<FIELD3>field3</FIELD3>
</ROW2>
</ROWSET2>
<ROWSET>
<ROW>
<FIELD1>Query2</FIELD1>
<FIELD2>field2</FIELD2>
<FIELD3>field3</FIELD3>
</ROW>
</ROWSET>
</DATA> -
How to pass the bind variable value to the sql statement of the LOV
Hi,
I am using Forms 10g builder.
I have a text item which will be populated by a LOV when i press a button, but i have a bind variable in the SQL statement of the LOV. That bind variable should be replaced by a value which is derived from a radio group in the same data block.
For Ex: ( )radio1 ( )radio2
before i click on the push button, I'll select one of the radio button above,so my question is how to assign this radio group value to the bind variable in the sql statement in the LOV?
Pl any hint is appreciated!
Thanks
ReddyThe variable can be taken into account in the SELECT order contained in the Record Group used by the LOV.
e.g. Select ... From ... Where column = :block.radio_group ...Francois -
Custom SQL statement on the fly
Is it possible to construct dynamic SQL statement in DB adapter on the fly?
One Solution is pass your sql statement to the procedure and fire it from the procedure.
stmt_str := 'INSERT INTO ' || tablename || ' VALUES
(:deptno, :dname, :loc)';
EXECUTE IMMEDIATE stmt_str
USING deptnumber, deptname, location;
refer this thread Dynamic database adapter
--Prasanna -
How can I format my intell based imac without the original Tiger discs? I have a user account on it that I dont want. I have upgraded to Snow Leopard but I want to to start affresh. Thank you. I have tried loading the Snow Leopard disc whilst holding down th C key but it goes straight into install mode. I am new to Macs and I have inherited this machine.
Hello, many options...
1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu. (In Mac OS X 10.4 or later, you must select your language first.)
*Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.*
3. Click the Erase tab.
4. Click the disclosure triangle to the left of the hard drive icon to display the names of your hard disk volumes and partitions.
5. Select your Mac OS X volume.
6. Highlight the drive, select Partition Tab, then Format type... MacOS Extended Journalled, select the Security Options button, choose Zero Out Data, Erase... after completion do a new install.
Or...
Open System Preferences>Accounts, unlock the lock, click on the little plus icon, make a new admin account, log out & into the new account.
In the same pref pane highlight your old account, click the little minus icon, then use Disk Utility to Secure Erase Free Space. -
How to find out the execution time of a sql inside a function
Hi All,
I am writing one function. There is only one IN parameter. In that parameter, i will pass one SQL select statement. And I want the function to return the exact execution time of that SQL statement.
CREATE OR REPLACE FUNCTION function_name (p_sql IN VARCHAR2)
RETURN NUMBER
IS
exec_time NUMBER;
BEGIN
--Calculate the execution time for the incoming sql statement.
RETURN exec_time;
END function_name;
/Please note that wrapping query in a "SELECT COUNT(*) FROM (<query>)" doesn't necessarily reflect the execution time of the stand-alone query because the optimizer is smart and might choose a completely different execution plan for that query.
A simple test case shows the potential difference of work performed by the database:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
Session altered.
SQL>
SQL> drop table count_test purge;
Table dropped.
Elapsed: 00:00:00.17
SQL>
SQL> create table count_test as select * from all_objects;
Table created.
Elapsed: 00:00:02.56
SQL>
SQL> alter table count_test add constraint pk_count_test primary key (object_id)
Table altered.
Elapsed: 00:00:00.04
SQL>
SQL> exec dbms_stats.gather_table_stats(ownname=>null, tabname=>'COUNT_TEST')
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.29
SQL>
SQL> set autotrace traceonly
SQL>
SQL> select * from count_test;
5326 rows selected.
Elapsed: 00:00:00.10
Execution Plan
Plan hash value: 3690877688
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5326 | 431K| 23 (5)| 00:00:01 |
| 1 | TABLE ACCESS FULL| COUNT_TEST | 5326 | 431K| 23 (5)| 00:00:01 |
Statistics
1 recursive calls
0 db block gets
419 consistent gets
0 physical reads
0 redo size
242637 bytes sent via SQL*Net to client
4285 bytes received via SQL*Net from client
357 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
5326 rows processed
SQL>
SQL> select count(*) from (select * from count_test);
Elapsed: 00:00:00.00
Execution Plan
Plan hash value: 572193338
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 5 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | INDEX FAST FULL SCAN| PK_COUNT_TEST | 5326 | 5 (0)| 00:00:01 |
Statistics
1 recursive calls
0 db block gets
16 consistent gets
0 physical reads
0 redo size
412 bytes sent via SQL*Net to client
380 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>As you can see the number of blocks processed (consistent gets) is quite different. You need to actually fetch all records, e.g. using a PL/SQL block on the server to find out how long it takes to process the query, but that's not that easy if you want to have an arbitrary query string as input.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle:
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Sql statement consuming significant database time
This sql statement consuming significant elapsed time(2,446 seconds). also also cause significant user i/0 , is this because of using temp TABLE IN THIS QUERY ,
or is there any alternative for this query ?
"WITH TEMP AS ( SELECT ROOT, CHILD, LEVEL LEV FROM catagory V START WITH CHILD=:B1 CONNECT BY PRIOR ROOT=CHILD ) SELECT CHILD FROM TEMP WHERE LEV=(SELECT MAX(LEV) FROM TEMP) "
Thanks
RenjithClick on the FAQ stick posting (at the top of this forum). Find the "+when my query is slow+" question and read the FAQ response to it.
-
If the program has a write statement at the top & the TOP-OF-PAGE
Q] We know that START-OF-SELECTION is triggered by the 1st writr statement. Now if the program has a write statement at the top & the TOP-OF-PAGE too is written explicitly which also contains write statements-----what will be the effect?
Hi,
i will order of events
see first of all initialization event gets triggred and then at selection screen triggres and then it goes to start of selection and if it found any list processing statement then it goes to top-of -page event and after executing all the statements it returns back to the start of selection event
just i will give one test case to u execute it u will know one thing
give one write statement in the initialization event and in the start of selection of give one write statement see what happns u can find different different things just try i will expalin u the concept..
plzz reward if it is useful...
plzz dont forget to reward..
if u want any concepts u can contact me on [email protected]
plzz reward -
I am trying to update and am getting this error message. Error 1321. The Installer has insufficient privileges to modify the file c:\Program Files(x86)\Adobe\Acrobat 11.0\Resource\Font\MinionPro-It.otf. I am the systems administrator so I am at a bit of a loss.
You need to log in as the administrator (seems like you are) and may need to disable anti-virus. You might want to copy the otf file and then uninstall that font, trying again.
-
I am trying to download the free Adobe Reader and I get the message Error1321:The Installer has insufficient privileges to modify the file C:\Program Files (x86)\Adobe\Reader11.0\Readerwow_helper.exe. I do not know how to fix this.
Hi Koncar,
Kindly try the steps mentioned below.
1) Download the Adobe Reader.msi from ftp://ftp.adobe.com/pub/adobe/reader/win/11.x/11.0.00/en_US/
2) Run the .MSI for Reader and when you get the error click on Retry and installation would go trough.
Thanks,
Vikrantt Singh -
I have Adobe Acrobat 10.0. I keep getting an error. Error 1321. The installer has insufficient privileges to modify the file C:\Programs Files\Adobe\Acrobat10.0\Acrobat\rt3d.dll
How do I fix this issue?This happened after a forced update. This copy of Adobe has been running fine on the laptop for about a year and a half now all the sudden I am getting this error. Is the only fix to uninstall and reinstall?
-
How to reduce execution time of this SQL?
This SQL will output only 2 rows. I tried using hints (an index) but to no avail.
http://www.freeimagehosting.net/uploads/cf214afcf1.jpg
Or, is it NOT possible, limit of query optimization has reached?Rakesh jayappa wrote:
Hi,
Run the sql tuning advisory.
Let me know recommendation.
Kind Regards,
Rakesh************************** Here is my tuning request **************************
1.) The following SQL statement has been identified to perform poorly. It currently takes up to 12 seconds to execute, but it's supposed to take a second at most.
This is the statement:
select DISTINCT trunc(c.sst_post_date) as post_date
from ac_t_sessn b , ac_t_ssntr c
where
b.ses_status = 0
and b.ses_profit_center = c.sst_profit_center
and b.ses_acct_year = c.sst_acct_year
and b.ses_acct_period = c.sst_acct_period
and b.ses_sessn_no = c.sst_sessn_no
AND
C.sst_post_mtd||C.sst_post_TYPE IN
(SELECT Y.pst_post_mtd||Y.pst_post_type
FROM ac_r_post_functions Y
WHERE Y.pst_post_status IN (0,'2'))
order by trunc(c.sst_post_date);It should return data from a table in a specific order.
2.) The version of the database is Oracle9i Enterprise Edition Release *9.2.0.6.0*
3.) These are the parameters relevant to the optimizer:
UAT_UML@umltest>show parameter optimizer
NAME TYPE VALUE
optimizer_dynamic_sampling integer 1
optimizer_features_enable string 9.2.0
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_max_permutations integer 2000
optimizer_mode string CHOOSE
UAT_UML@umltest>show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 16
UAT_UML@umltest>show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
UAT_UML@umltest>show parameter cursor_sharing
NAME TYPE VALUE
cursor_sharing string EXACT
UAT_UML@umltest>column sname format a20
UAT_UML@umltest>column pname format a20
UAT_UML@umltest>column pval2 format a20
UAT_UML@umltest>select
2 sname
3 , pname
4 , pval1
5 , pval2
6 from
7 sys.aux_stats$;
no rows selected4.) Here is the output of EXPLAIN PLAN:
UAT_UML@umltest>select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost |
| 0 | SELECT STATEMENT | | 454 | 22700 | | 5391 |
| 1 | SORT UNIQUE | | 454 | 22700 | | 5072 |
| 2 | HASH JOIN | | 69384 | 3387K| 2592K| 4478 |
| 3 | INDEX FAST FULL SCAN| INDX_AC_T_SESSN | 110K| 1294K| | 244 |
| 4 | HASH JOIN | | 416K| 15M| | 3877 |
| 5 | TABLE ACCESS FULL | AC_R_POST_FUNCTIONS | 23 | 253 | | 2 |
| 6 | TABLE ACCESS FULL | AC_T_SSNTR | 1790K| 46M| | 3866 |
Note: cpu costing is off, PLAN_TABLE' is old version5.) Here is the output of SQL*Plus AUTOTRACE including the TIMING information:
UAT_UML@umltest>set autotrace traceonly arraysize 100
UAT_UML@umltest>
UAT_UML@umltest>select DISTINCT trunc(c.sst_post_date) as post_date
2 from ac_t_sessn b , ac_t_ssntr c
3 where
4 b.ses_status = 0
5 and b.ses_profit_center = c.sst_profit_center
6 and b.ses_acct_year = c.sst_acct_year
7 and b.ses_acct_period = c.sst_acct_period
8 and b.ses_sessn_no = c.sst_sessn_no
9 AND
10 C.sst_post_mtd||C.sst_post_TYPE IN (SELECT Y.pst_post_mtd||Y.pst_post_type FROM ac_r_po
st_functions Y
11 WHERE Y.pst_post_status IN (0,'2'))
12 order by trunc(c.sst_post_date);
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=5391 Card=454 Bytes=
22700)
1 0 SORT (UNIQUE) (Cost=5072 Card=454 Bytes=22700)
2 1 HASH JOIN (Cost=4478 Card=69384 Bytes=3469200)
3 2 INDEX (FAST FULL SCAN) OF 'INDX_AC_T_SESSN' (NON-UNIQU
E) (Cost=244 Card=110433 Bytes=1325196)
4 2 HASH JOIN (Cost=3877 Card=416304 Bytes=15819552)
5 4 TABLE ACCESS (FULL) OF 'AC_R_POST_FUNCTIONS' (Cost=2
Card=23 Bytes=253)
6 4 TABLE ACCESS (FULL) OF 'AC_T_SSNTR' (Cost=3866 Card=
1790555 Bytes=48344985)
Statistics
0 recursive calls
0 db block gets
42741 consistent gets
171 physical reads
0 redo size
425 bytes sent via SQL*Net to client
507 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
2 rows processed
UAT_UML@umltest>DISCONNECT
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production6.) The TKPROF output snippet
TKPROF: Release 11.2.0.1.0 - Development on Wed Oct 27 12:47:35 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Trace file: umltest_ora_1604.trc
Sort options: prsela exeela fchela
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
select DISTINCT trunc(c.sst_post_date) as post_date
from ac_t_sessn b , ac_t_ssntr c
where
b.ses_status = 0
and b.ses_profit_center = c.sst_profit_center
and b.ses_acct_year = c.sst_acct_year
and b.ses_acct_period = c.sst_acct_period
and b.ses_sessn_no = c.sst_sessn_no
AND
C.sst_post_mtd||C.sst_post_TYPE IN (SELECT Y.pst_post_mtd||Y.pst_post_type FROM ac_r_post_functions Y
WHERE Y.pst_post_status IN (0,'2'))
order by trunc(c.sst_post_date)
call count cpu elapsed disk query current rows
Parse 1 0.01 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 3.20 4.38 171 42741 0 2
total 4 3.21 4.39 171 42741 0 2
Misses in library cache during parse: 1
Optimizer mode: CHOOSE
Parsing user id: 445
Rows Row Source Operation
2 SORT UNIQUE
24 HASH JOIN
11 INDEX FAST FULL SCAN OBJ#(62817) (object id 62817)
2293715 HASH JOIN
31 TABLE ACCESS FULL OBJ#(67305)
1790555 TABLE ACCESS FULL OBJ#(62828)
alter session set sql_trace true
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 1 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Misses in library cache during execute: 1
Optimizer mode: CHOOSE
Parsing user id: 445
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 1 0.01 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 3.20 4.38 171 42741 0 2
total 5 3.21 4.39 171 42741 0 2
Misses in library cache during parse: 1
Misses in library cache during execute: 1
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
2 user SQL statements in session.
0 internal SQL statements in session.
2 SQL statements in session.
Trace file: umltest_ora_1604.trc
Trace file compatibility: 9.02.00
Sort options: prsela exeela fchela
1 session in tracefile.
2 user SQL statements in trace file.
0 internal SQL statements in trace file.
2 SQL statements in trace file.
2 unique SQL statements in trace file.
51 lines in trace file.
10 elapsed seconds in trace file. Any help would be greatly appreciated? -
How Can I Retrieve SQL Statement From The User ?
Hi
I want to know, how can I make the user can enter the SQL statement from himself ?? in this code he can't enter it. Only he can display the SQL that i wrote it...
this is my Code:
import java.sql.*;
public class db_testing {
static final String DRIVER = "com.mysql.jdbc.Driver";
static final String DATABASE_URL = "jdbc:mysql://localhost/S204111933";
public static void main(String[] args) {
Connection cn=null;
Statement st= null;
ResultSet rset=null;
try{
Class.forName(DRIVER);
cn=DriverManager.getConnection(DATABASE_URL, "root", "admin");
st=cn.createStatement();
rset=st.executeQuery("select * from employee");
ResultSetMetaData metadata=rset.getMetaData();
System.out.println("The begining: ");
for(int i=1;i<=metadata.getColumnCount();i++)
System.out.print(metadata.getColumnName(i)+"\t");
System.out.println();
System.out.println();
while(rset.next()){
for(int i=1;i<=metadata.getColumnCount();i++)
System.out.print(rset.getObject(i)+"\t\t");
System.out.println();}
catch(Exception e){
e.printStackTrace();
finally{
try{
cn.close();
st.close();
rset.close();
catch(Exception e1){
e1.printStackTrace();
}The following changes in the code will make the user to give the input
import java.sql.*;
public class db_testing {
static final String DRIVER = "com.mysql.jdbc.Driver";
static final String DATABASE_URL = "jdbc:mysql://localhost/S204111933";
public static void main(String[] args) {
Connection cn=null;
Statement st= null;
ResultSet rset=null;
try{
Class.forName(DRIVER);
cn=DriverManager.getConnection(DATABASE_URL, "root", "admin");
// st=cn.createStatement();
// rset=st.executeQuery("select * from employee");
PreparedStatement pstmt=null;
pstmt=cn.prepareStatement("select * from employee where id=?");
pstmt.setInt(1,Integer.parseInt(args[0]));
rset=pstmt.executeQuery();
ResultSetMetaData metadata=rset.getMetaData();
System.out.println("The begining: ");
for(int i=1;i<=metadata.getColumnCount();i++)
System.out.print(metadata.getColumnName(i)+"\t");
System.out.println();
System.out.println();
while(rset.next()){
for(int i=1;i<=metadata.getColumnCount();i++)
System.out.print(rset.getObject(i)+"\t\t");
System.out.println();}
catch(Exception e){
e.printStackTrace();
finally{
try{
cn.close();
st.close();
rset.close();
catch(Exception e1){
e1.printStackTrace();
} -
Passing plsql parm to a sql statement in the procedure database link name
Would like to pass a parm that is the database link name to a stored procedure. I defined this as below. var1 is the name of the db link that I would like to pass
create or replace procedure proc1 (var1 in varchar2) as
cursor c1 is
select num,name,city from emp@var1;
However, this is getting a plsql error in the above code as bad bind variable, db link name expected.
Is there a method to pass a variable within a stored proc into a SQL statement that has a cursor ..
thanksHi,
Database links have to be hard-coded. If you really need to specify the database link at run-time, then you need Dyanmic SQL.
Why do you need to do this? How many databases are involved? Do you have new database links all the time? The more you can say about your business requirements, the more helpful we can be.
Are there only a couple of possible database links? If so, you might consider hard-coding each of them, and branching to the appropriate one in your code.
is the real variable here the environment (Development, Test, Production) that you're in? For example, do you need to use one database link in Development, a different one in Test, and a third in Production, but you don't want to change the code when you move from one environment to another? If so, you can try conditional comilation.
Maybe you are looking for
-
What is the best way to reformat a mini and reinstall Mavericks
What is the best way to reformat a mini and reinstall Mavericks?
-
hi , i created a view and i wanted to change some criteria when i tried to recompile or even to drop it just "hang" there or it's taking a real long time to execute the command what could go wrong here ? tks & rdgs
-
I upload a number of new pages to our website every week, and I am accustomed to changing each page's title (the text that shows up on the top of the window when the page is being browsed). In the previous versions of Dreamweaver, there was a box are
-
Hi , I need to support a Bex report and need to understand the existing custome exit they have for a variable. Eg : in the BEx Query, i see they have created a custom variable and used that to automatically get the current month and populate the quer
-
How do I enter a url? The window for this has disappeared.
The new Firefox home screen lacks a place to enter a url. All I seem to be able to do is go to Ask.com, which I do not want to do. I want to be able to enter a url, press enter, and go to a webpage. With the new design of the screen I cannot see how