SQL statement processed by the optimizer
Hello Experts ;
Any SQL statement processed by Oracle, the optimizer performs the following operations:
Evaluation of expressions and conditions
Inspection of integrity constraints to learn more about the data and optimize based on this metadata
Statement transformation
Choice of optimizer goals
Choice of access paths
Choice of join orders
The Query Optimizer - i got some information from here .
Can i get some more explanations or links for above points ?
Hi,
did you have a look at the 11g version?
http://docs.oracle.com/cd/E11882_01/server.112/e41573/optimops.htm#i82005
Andre
Similar Messages
-
Cancel sql statement processing
Are there any possibilities to cancel sql statement processing after:
"Resultset theResultSet = preparedStatement.executeQuery();"
like: datasource.close() or connection.close() etc.
Because process-time is too long.
With best regards hape.deFrom the API for PreparedStatement...
setQueryTimeout cancels the query after specified number of seconds throwing a SQLException.
ResultSet theResultSet = null;
try {
preparedStatement.setQueryTimeout(5); // 5 seconds
theResultSet = preparedStatement.executeQuery();
} catch( SQLException e ) {
System.out.println( "executeQuery SQLException: " + e.getMessage() );
if( theResultSet != null ) {
// Process your results -
Sql statement for retrieving the last update time of a table
Hello all,
Can somebody give me an example of sql statement for retrieving the last update time of an oracle table.
Thank you
IlThanks for the fast replies. It works great when I test it as a sql statement but when trying to populate a datalist with it it raises the following exception:
Exception Details: System.ArgumentException: SCN_TO_TIMESTAMP(MAX(ORA_ROWSCN is neither a DataColumn nor a DataRelation for table DefaultView
Part of the Datalist Code:
ItemTemplate>
Line 12: SCN_TO_TIMESTAMP(MAX(ORA_ROWSCN)):
Line 13: <asp:Label ID="SCN_TO_TIMESTAMP_MAX_ORA_ROWSCN__Label" runat="server" Text='<%# Eval("[SCN_TO_TIMESTAMP(MAX(ORA_ROWSCN))]") %>'>
Line 14: </asp:Label><br/>
Line 15: <br/>
{code}
Why is this happening? Any ideas?
Il -
Error when generating the SQL statement while running the Query
Hello SDN Mates,
Am using three cubes in one infoset and build a query on that. Intially it was running fine, but now am getting error generating the SQL statement. Can you please throw some light on this. Your idea would be highly appreciated.
Thanks and Regards
Arun SHi Arun
is there any change in the objects (Check also the consistency of infoobject ) included in infoset, just make sure those are active, open the query in designer and check if no error/warning message are present
Thanks
Tripple k -
Enter Sql Statement is causing the Oracle SQL editor to freeze
I find Oracle SQL Developer's editor keep on freezing as I am writing sql statement on the editor. Is there an option to turn off the freeze.
If there is an option to turn off. Does it affect the sql editor not to automatically show objects on select object from database windown. Meaning it will not shows all table names in the dropdown box.
Lookforward for your assitance.
ricard
Edited by: user531731 on 29/04/2009 17:30
Edited by: user531731 on 29/04/2009 20:39Yes, completion insight can have pretty bad performance and worst is the UI doesn't become responsive again until it completes.
I have both turned of, but you can lower the popup speed too, in Preferences - Code Editor - Code Insight. Even when turned off, you can still access it through CTRL-space.
Hope that helps,
K. -
How to see all sql statements passed to the db?
Is it possible to configure Jdevloper (11.1.1.4) in way so that it shows all sql statements in the console?
thx in advanceHi,
under your ViewController-Project Properties you'll find the Run Configurations. Under Java Options enter the following statement:
-Djbo.debugoutput=console
Marc -
Logging/viewing SQL statements generated by the SQL Developer IDE?
I know it is possible to view the SQL statements that the SQL Developer IDE generates to fetch result-sets from the database whenever one performs any action - say expanding the "Tables" node for a database, for example. I would appreciate if someone could point out how this functionality could be enabled.
Thanks,
RGIn 1.0, you could use the AddVMOption -Daudit.trace=db_api option inside the sqldeveloper.conf file.
In 1.1 however, I don't get output inside the console anymore (for expanding trees, etc.).
Kris, has this option been replaced by another one? Please let us in on all the fun ;-)
K. -
Dynamic SQL statement to select the tables which are updated today...
Hi Guys,
I need to find the names of all the tables which contain rows that are inserted/updated in a given time stamp...
Below statement gives me the list of all the tables in the database...
select t.table_name from all_tables t;All these tables in the database have a column called rowversion which gives the updated/inserted date of a record. I need to write a select statement (probably dynamic) which will give me the table names which contain the rowversion value 24-01-2013....
Any help is very much appreciated...Napster wrote:
Hi Karthick,
Thanks for your reply...
But when I execute your select statement I am getting an error saying table SYS.DBMS_XMLGEN does not exist.
Probably something wrong in my environment?Yes you can, here is a quick untested code
declare
my_filter date := to_date('24-01-2013', 'dd-mm-yyyy');
my_count integer;
begin
for i in (select table_name from user_tables)
loop
execute immediate q'[select count(*) from ]' || i.table_name || q'[ where rowversion = :1]'
using my_filter
into my_count;
if my_count > 0 then
dbms_output.put_line(i.table_name);
end if;
end loop;
end;
/ -
Sql statement to get the count of items in a group.
i have a table as follows
group id items
1 item1
1 item2
1 item3
2 item4
2 item5
i need to get the count of items for each group
the out put should be like
group = 1 count = 3
group = 2 count = 2
i wrote the following query
select group count( * )
into (group , lv_count)
from table1
group by group.
endselect.
is it possible to write this query without using end select.
when i am using the same query with into table addition the count is not coming.Hi,
It will work, I tested just now, ofcourse with some other table.
Like this:
select group count( * )
INTO TABLE ITAB
from table1
group by group.
Regards,
Amit Mittal. -
Is there any way to print out a sql statement to a window when using on session?
I have a sql select statement which looks like the following:
SQL SELECT * FROM table_name
WHERE column_a = :Value1
ON SESSION lDBSession;
I would like to be able to pring out the statement that was actually executed.
Does anyone have any ideas how this can be done without rewriting the sql?
Thanks,
KRCTry trace flags
trc:db:2:1 prints all the sql statements processed by the database session
trc:db:2:50 shows input values for the sql statement
On the DB Sessiob. -
DBIF_RSQL_INVALID_RSQL The maximum size of an SQL statement was exceeded
Dear,
I would appreciate a helping hand
I have a problem with a dump I could not find any note that I can help solve the problem.
A dump is appearing at various consultants which indicates the following.
>>> SELECT * FROM KNA1 "client specified
559 APPENDING TABLE IKNA1
560 UP TO RSEUMOD-TBMAXSEL ROWS BYPASSING BUFFER
ST22
What happened?
Error in the ABAP Application Program
The current ABAP program "/1BCDWB/DBKNA1" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
and
therefore caused a runtime error.
The reason for the exception is:
The SQL statement generated from the SAP Open SQL statement violates a
restriction imposed by the underlying database system of the ABAP
system.
Possible error causes:
o The maximum size of an SQL statement was exceeded.
o The statement contains too many input variables.
o The input data requires more space than is available.
o ...
You can generally find details in the system log (SM21) and in the
developer trace of the relevant work process (ST11).
In the case of an error, current restrictions are frequently displayed
in the developer trace.
SQL sentence
550 if not %_l_lines is initial.
551 %_TAB2[] = %_tab2_field[].
552 endif.
553 endif.
554 ENDIF.
555 CASE ACTION.
556 WHEN 'ANZE'.
557 try.
>>> SELECT * FROM KNA1 "client specified
559 APPENDING TABLE IKNA1
560 UP TO RSEUMOD-TBMAXSEL ROWS BYPASSING BUFFER
561 WHERE KUNNR IN I1
562 AND NAME1 IN I2
563 AND ANRED IN I3
564 AND ERDAT IN I4
565 AND ERNAM IN I5
566 AND KTOKD IN I6
567 AND STCD1 IN I7
568 AND VBUND IN I8
569 AND J_3GETYP IN I9
570 AND J_3GAGDUMI IN I10
571 AND KOKRS IN I11.
572
573 CATCH CX_SY_DYNAMIC_OSQL_SEMANTICS INTO xref.
574 IF xref->kernel_errid = 'SAPSQL_ESCAPE_WITH_POOLTABLE'.
575 message i412(mo).
576 exit.
577 ELSE.
wp trace:
D *** ERROR => dySaveDataBindingValue: Abap-Field= >TEXT-SYS< not found [dypbdatab.c 510]
D *** ERROR => dySaveDataBindingEntry: dySaveDataBindingValue() Rc=-1 Reference= >TEXT-SYS< [dypbdatab.c 430]
D *** ERROR => dySaveDataBinding: dySaveDataBindingEntry() Rc= -1 Reference=>TEXT-SYS< [dypbdatab.c 137]
Y *** ERROR => dyPbSaveDataBindingForField: dySaveDataBinding() Rc= 1 [dypropbag.c 641]
Y *** ERROR => ... Dynpro-Field= >DISPLAY_SY_SUBRC_TEXT< [dypropbag.c 642]
Y *** ERROR => ... Dynpro= >SAPLSTPDA_CARRIER< >0700< [dypropbag.c 643]
D *** ERROR => dySaveDataBindingValue: Abap-Field= >TEXT-SYS< not found [dypbdatab.c 510]
D *** ERROR => dySaveDataBindingEntry: dySaveDataBindingValue() Rc=-1 Reference= >TEXT-SYS< [dypbdatab.c 430]
D *** ERROR => dySaveDataBinding: dySaveDataBindingEntry() Rc= -1 Reference=>TEXT-SYS< [dypbdatab.c 137]
Y *** ERROR => dyPbSaveDataBindingForField: dySaveDataBinding() Rc= 1 [dypropbag.c 641]
Y *** ERROR => ... Dynpro-Field= >DISPLAY_FREE_VAR_TEXT< [dypropbag.c 642]
Y *** ERROR => ... Dynpro= >SAPLSTPDA_CARRIER< >0700< [dypropbag.c 643]
I thank you in advance
If you require other information please requestHi,
Under certain conditions, an Open SQL statement with range tables can be reformulated into a FOR ALL ENTRIES statement:
DESCRIBE TABLE range_tab LINES lines.
IF lines EQ 0.
[SELECT for blank range_tab]
ELSE.
SELECT .. FOR ALL ENTRIES IN range_tab ..
WHERE .. f EQ range_tab-LOW ...
ENDSELECT.
ENDF.
Since FOR ALL ENTRIES statements are automatically converted in accordance with the database restrictions, this solution is always met by means of a choice if the following requirements are fulfilled:
1. The statement operates on transparent tables, on database views or on a projection view on a transparent table.
2. The requirement on the range table is not negated. Moreover, the range table only contains entries with range_tab-SIGN = 'I'
and only one value ever occurs in the field range_tab OPTION.
This value is then used as an operator with operand range_tab-LOW or range_tab-HIGH.In the above example, case 'EQ range_tab-LOW' was the typical case.
3. Duplicates are removed from the result by FOR ALL ENTRIES.This must not falsify the desired result, that is, the previous Open SQL statement can be written as SELECT DISTINCT.
For the reformulation, if the range table is empty it must be handled in a different way:with FOR ALL ENTRIES, all the records would be selected here while this applies for the original query only if the WHERE clause consisted of the 'f IN range_tab' condition.
FOR ALL ENTRIES should also be used if the Open SQL statement contains several range tables.Then (probably) the most extensive of the range tables which fill the second condition is chosen as a FOR ALL ENTRIES table.
OR
What you could do in your code is,
prior to querying;
since your select options parameter is ultimately an internal range table,
1. split the select-option values into a group of say 3000 based on your limit,
2. run your query against each chunck of 3000 parameters,
3. then put together the results of each chunk.
For further reading, you might want to have a look at the Note# 13607 as the first suggestion is what I read from the note. -
The number of reloads for the SQL statements
Hi,
in 10g R2, how to see the number of reloads for the SQL statements ? Any query ? Which value is high ? Which valu is low ?
Thanks.thanks all.
It was a test question for 1Z0-042 exam as follows :
The users on your SALESDB are complaining of slow response to their queries. Using the SQL Tuning Advisor, you determine
that the SQL statements are using the best optimization plan. Querying the dynamic views, you see that the number of reloads
for the SQL statements is high, which can cause performance degradation.
Which component of the SGA should you resize to reduce the number of reloads of the SQL statements?
Answer :
shared poolThen I wonder how to see the number of reloads for the SQL ? -
Hi All
I have writen a SQL statement.
However, the result has duplicate value, may I know how should i optimize the code below to avoild duplicate? Or maybe a better way to do the query?
SELECT KKUNNR KVKORG KVTWEG BBZIRK
INTO CORRESPONDING FIELDS OF TABLE IT_REP
FROM VBPA AS V
INNER JOIN VBKD AS B ON ( BVBELN = VVBELN
AND BPOSNR = VPOSNR )
INNER JOIN VBAK AS K ON KVBELN = BVBELN
WHERE K~KUNNR IN S_REP
AND V~PARVW IN ('ZD','ZS','ZX').
Result I get :
300027 100 10 NBA
300027 100 10 NBA (DUPLICATE)
300027 100 10 NBA (DUPLICATE)
300005 187 10 NAE
Thanks a lot.You could do a SELECT DISTINCT.
What you need to do is run an SE16 on the tables and see which table has the multiple entries. Then adjust your code accordingly to use the correct join conditions.
Extract the partner funtion into your table, this is probably causing the duplicate entries.
Message was edited by:
Martin Shinks -
I'm getting an error on a line in the middle of a larger sql script, only in SQL Azure.
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'foouser')
CREATE USER [foouser] FOR LOGIN [foouser] WITH DEFAULT_SCHEMA=[dbo]
GO
Error: "The CREATE USER statement must be the only statement in the batch."
I don't actually understand what 'the only statement in the batch' means.
What is a batch? Is it a SQL file? Is it related to a 'GO' statement or an 'IF' statement? What is the reason for the error? And how do I avoid it?
Thanks,
Tim>IF...ELSE imposes conditions on the execution of a Transact-SQL statement
I understand the general purpose of an If statement. I could let go of our definition of statement counting disagreeing too except that because of the error I'm stuck.
It's less important for Create User but what I am really puzzled over now is a very similar issue how am I supposed to do a safe version of CREATE LOGIN, when I don't know whether a login has been previously created on the server or whether I
am setting up the database on a clean server?
IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE name = N'foouser')
CREATE LOGIN [foouser] WITH PASSWORD = 'asdfasdf'
GO
If I try and execute this script, it throws the same error as above.
The first unworkable workaround idea is to omit the if statement
CREATE LOGIN [foouser] WITH PASSWORD = 'asdfasdf'
GO
But if the login already exists on the server (because a similar script was already run), then the script throws an error.
The second unworkable workaround idea is to do
DROP LOGIN [foouser]
GO
CREATE LOGIN [foouser] WITH PASSWORD = 'asdfasdf'
GO
Obviously this throws an error in the second block if the login doesn't already exist on the server.
The third workaround idea I have is to go conditional by putting an IF condition around DROP instead of CREATE:
Unfortunately that doesn't work for me either!
"The DROP LOGIN statement must be the only statement in the batch"
(This is despite the fact that 'drop login' is listed on the
supported commands page, not the partially supported page..?! Which disagrees with the notes on
this page.)
Anyway the real question I am interesting in addressing is: is there actually a way to have a 'Create/Delete login
if exists' operation which is SQL-Azure compatible and doesn't throw me error messages (which messes with the sql execution tool I am using)?
If there is no way, I would like to believe it's because it would be a bad idea to do this. But in that case why is it a bad idea?
Tim -
Multiple Executions Plans for the same SQL statement
Dear experts,
awrsqrpt.sql is showing multiple executions plans for a single SQL statement. How is it possible that one SQL statement will have multiple Executions Plans within the same AWR report.
Below is the awrsqrpt's output for your reference.
WORKLOAD REPOSITORY SQL Report
Snapshot Period Summary
DB Name DB Id Instance Inst Num Release RAC Host
TESTDB 2157605839 TESTDB1 1 10.2.0.3.0 YES testhost1
Snap Id Snap Time Sessions Curs/Sess
Begin Snap: 32541 11-Oct-08 21:00:13 248 141.1
End Snap: 32542 11-Oct-08 21:15:06 245 143.4
Elapsed: 14.88 (mins)
DB Time: 12.18 (mins)
SQL Summary DB/Inst: TESTDB/TESTDB1 Snaps: 32541-32542
Elapsed
SQL Id Time (ms)
51szt7b736bmg 25,131
Module: SQL*Plus
UPDATE TEST SET TEST_TRN_DAY_CL = (SELECT (NVL(ACCT_CR_BAL,0) + NVL(ACCT_DR_BAL,
0)) FROM ACCT WHERE ACCT_TRN_DT = (:B1 ) AND TEST_ACC_NB = ACCT_ACC_NB(+)) WHERE
TEST_BATCH_DT = (:B1 )
SQL ID: 51szt7b736bmg DB/Inst: TESTDB/TESTDB1 Snaps: 32541-32542
-> 1st Capture and Last Capture Snap IDs
refer to Snapshot IDs witin the snapshot range
-> UPDATE TEST SET TEST_TRN_DAY_CL = (SELECT (NVL(ACCT_CR_BAL,0) + NVL(AC...
Plan Hash Total Elapsed 1st Capture Last Capture
# Value Time(ms) Executions Snap ID Snap ID
1 2960830398 25,131 1 32542 32542
2 3834848140 0 0 32542 32542
Plan 1(PHV: 2960830398)
Plan Statistics DB/Inst: TESTDB/TESTDB1 Snaps: 32541-32542
-> % Total DB Time is the Elapsed Time of the SQL statement divided
into the Total Database Time multiplied by 100
Stat Name Statement Per Execution % Snap
Elapsed Time (ms) 25,131 25,130.7 3.4
CPU Time (ms) 23,270 23,270.2 3.9
Executions 1 N/A N/A
Buffer Gets 2,626,166 2,626,166.0 14.6
Disk Reads 305 305.0 0.3
Parse Calls 1 1.0 0.0
Rows 371,735 371,735.0 N/A
User I/O Wait Time (ms) 564 N/A N/A
Cluster Wait Time (ms) 0 N/A N/A
Application Wait Time (ms) 0 N/A N/A
Concurrency Wait Time (ms) 0 N/A N/A
Invalidations 0 N/A N/A
Version Count 2 N/A N/A
Sharable Mem(KB) 26 N/A N/A
Execution Plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | UPDATE STATEMENT | | | | 1110 (100)| |
| 1 | UPDATE | TEST | | | | |
| 2 | TABLE ACCESS FULL | TEST | 116K| 2740K| 1110 (2)| 00:00:14 |
| 3 | TABLE ACCESS BY INDEX ROWID| ACCT | 1 | 26 | 5 (0)| 00:00:01 |
| 4 | INDEX RANGE SCAN | ACCT_DT_ACC_IDX | 1 | | 4 (0)| 00:00:01 |
Plan 2(PHV: 3834848140)
Plan Statistics DB/Inst: TESTDB/TESTDB1 Snaps: 32541-32542
-> % Total DB Time is the Elapsed Time of the SQL statement divided
into the Total Database Time multiplied by 100
Stat Name Statement Per Execution % Snap
Elapsed Time (ms) 0 N/A 0.0
CPU Time (ms) 0 N/A 0.0
Executions 0 N/A N/A
Buffer Gets 0 N/A 0.0
Disk Reads 0 N/A 0.0
Parse Calls 0 N/A 0.0
Rows 0 N/A N/A
User I/O Wait Time (ms) 0 N/A N/A
Cluster Wait Time (ms) 0 N/A N/A
Application Wait Time (ms) 0 N/A N/A
Concurrency Wait Time (ms) 0 N/A N/A
Invalidations 0 N/A N/A
Version Count 2 N/A N/A
Sharable Mem(KB) 26 N/A N/A
Execution Plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | UPDATE STATEMENT | | | | 2 (100)| |
| 1 | UPDATE | TEST | | | | |
| 2 | TABLE ACCESS BY INDEX ROWID| TEST | 1 | 28 | 2 (0)| 00:00:01 |
| 3 | INDEX RANGE SCAN | TEST_DT_IND | 1 | | 1 (0)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID| ACCT | 1 | 26 | 4 (0)| 00:00:01 |
| 5 | INDEX RANGE SCAN | INDX_ACCT_DT | 1 | | 3 (0)| 00:00:01 |
Full SQL Text
SQL ID SQL Text
51szt7b736bm UPDATE TEST SET TEST_TRN_DAY_CL = (SELECT (NVL(ACCT_CR_BAL, 0) +
NVL(ACCT_DR_BAL, 0)) FROM ACCT WHERE ACCT_TRN_DT = (:B1 ) AND PB
RN_ACC_NB = ACCT_ACC_NB(+)) WHERE TEST_BATCH_DT = (:B1 )Your input is highly appreciated.
Thanks for taking your time in answering my question.
RegardsOracle Lover3 wrote:
Dear experts,
awrsqrpt.sql is showing multiple executions plans for a single SQL statement. How is it possible that one SQL statement will have multiple Executions Plans within the same AWR report.If you're using bind variables and you've histograms on your columns which can be created by default in 10g due to the "SIZE AUTO" default "method_opt" parameter of DBMS_STATS.GATHER__STATS it is quite normal that you get different execution plans for the same SQL statement. Depending on the values passed when the statement is hard parsed (this feature is called "bind variable peeking" and enabled by default since 9i) an execution plan is determined and re-used for all further executions of the same "shared" SQL statement.
If now your statement ages out of the shared pool or is invalidated due to some DDL or statistics gathering activity it will be re-parsed and again the values passed in that particular moment will determine the execution plan. If you have skewed data distribution and a histogram in place that reflects that skewness you might get different execution plans depending on the actual values used.
Since this "flip-flop" behaviour can sometimes be counter-productive if you're unlucky and the values used to hard parse the statement leading to a plan that is unsuitable for the majority of values used afterwards, 11g introduced the "adaptive" cursor sharing that attempts to detect such a situation and can automatically re-evaluate the execution plan of the statement.
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/
Maybe you are looking for
-
When I try to Hot synch my Treo 700 I get a message that the operation failured because of a conflict in the installed conduits has been detected. The example that was cited was between my contacts and my address book which is what is not being back
-
Convert Illustrator script from cs3 to CS5
Hi Everyone, I'm new to illustrator scripting I did some simple InDesign script before but this the first time I am ask to create script for Illustrator. We have an old script that will create a report for the properties (e.i.: fonts, linkedImages, s
-
Login page user name and password for Oracle Database
Hi, I created a login.jsp page with username,password and a submit button. How can I validate this username and password from my Oracle database username and password? I am using NetBeans5.5 with Tomcat5.5.17. Right now I have hardcoded username and
-
Add time field in database table
Hi Gurus, I am trying to add a time field in database table. I know i can add it by using append structure. but my problem is when records r creating in database table, the time field also populate with respective system time automatically. i think i
-
Scripting: Bounding Box Paragraph Style
I just got off of a chat with Om of Adobe Tech Support. He informs me what I am trying to do is possible with scripting, but I am not skilled at this at all, so I was hoping the community here might be able to help me. What I am trying to do is thi