Where Clause - Modification via SDK
Good morning,
We are currently experiencing quite a large performance impact as our record selection formulas, and parameters are not hitting our database (in where clause) and therefore a large amount of data is being pulled back and then filtered out at the report level. Was hoping someone might be able to provide some information on how we could either dynamically append to the where clause via sdk, or devise optional workaround to make sure our selected parameters are passed to the db.
Environment
Solaris, with custom User Interface that passes information to crystal reports via SDK. Crystal Reports (2008) with Universe as datasource.
Thanks,
Ian S
Good morning,
We are currently experiencing quite a large performance impact as our record selection formulas, and parameters are not hitting our database (in where clause) and therefore a large amount of data is being pulled back and then filtered out at the report level. Was hoping someone might be able to provide some information on how we could either dynamically append to the where clause via sdk, or devise optional workaround to make sure our selected parameters are passed to the db.
Environment
Solaris, with custom User Interface that passes information to crystal reports via SDK. Crystal Reports (2008) with Universe as datasource.
Thanks,
Ian S
Similar Messages
-
WHERE Clause sorting via String
Hi, I am joining 2 tables together while using DISTINCT in the Select statement but i need to sort all the rows that only match by Date '1996'. Problem is the conversion of the Date/Time value is not a String i need to return only the rows where companies
only placed orders in 1996.
I have also tried WHERE o.OrderDate LIKE '[1996]%'
Select DISTINCT CompanyName
From Customers c
JOIN Orders o ON o.OrderDate = c.CompanyName
WHERE o.OrderDate = '1996'
Order By CompanyName ASC;I have to use DISTINCT & JOIN both tables it is apart of my assignment i have no choice in the matter.
I don't care what your professor tells you. I care that you learn SQL properly. And, hey, chances are good that I know T-SQL better than your professor.
DISTINCT is a highly abused keyword. To the extent that I would say that anytime you feel compelled to put in DISTINCT, you should start thinking if you might have gone wrong somewhere in the query. In a properly written join, there is rarely a need for
DISTINCT. If it happens, it may be one of the following:
1) Incomplete join-conditions. You joined two tables on a single column, when there is a two-column key linking them. That is, an error in the query.
2) The table that introduces duplicates in the query is not included in the SELECT list, because the table only appears in the query to check existence. This is your case, and you should use EXISTS instead (no matter what your professor asks you for).
3) You only include a subset of the columns from the tables in the query, and in those columns alone there is a duplicate. This may be a legit case, because you may only be looking for the distinct values. But you should review the requirements first.
I don't list these points because I am bored on a Saturday night. I list these points, because I see these errors over and over again by inexperienced programmers on the forums. And for that matter not-so-inexperienced programmers who once learnt bad
habits, and still are sticking to them.
So, OK, show your professor the query with JOIN and DISTINCT. But also show him the query with EXISTS. Also make sure that you understand how that query works. Your professor may or may not be impressed, but that does not matter. You learn for life, and
not to impress your professor.
And, oh, one more thing. The condition on OrderDate should really be:
AND O.OrderDate >= '19960101'
AND O.OrderDate < '19970101'
This is guaranteed to do an IndexSeek on OrderDate if the optimizer finds that this is the best solution. (Which it will not in this case, because you are looking at one third of all orders.) On the other hand, the condition that Ronen is trying to lure
you to use:
WHERE datepart(year,o.OrderDate) = 1996
may or may not seek the index, depending on how the optimizer is implemented this year.
I realise that the talk about indexes and optimizer may go above your head at this point, but again, I am eager that you learn best practices early, and that you don't learn things you will need to unlearn later. You can remember this lesson in this
way: never entangle a column into an expression, if you can resolve the condition with simple comparison operations.
Erland Sommarskog, SQL Server MVP, [email protected] -
Row Level Security using BO SDK - Dynamic Group and Criteria (where clauses)
To the Universe Gurus out there:
I have a rather daunting task of implementing a Row Level Security on a number of tables within our project using BO XI R2 SP2 with SQLServer 2005. Given the nature of the requirements around this (listed below), I am going to go with BO SDK to accomplish the creation of Restrictions. That said, I need some insight into some of the problem areas I have listed below. Any help is much appreciated.
Background:
We have 11 tables that are to be restricted.
Each table is accessible to potentially 1..* group of users only.
For eg SALES is accessible to ALL_SALES members only.
Each row within each table is accessible to 1..* groups of users only. The restriction will occur on 2 columns Jurisdiction and LineID on SALES table.
For eg
1)Rows with NY Jurisdiction and LineID=123 are accessible to NY_SALES_ADMIN group only initially.
2)NY_ADMIN will then approve that the above rows be open to NY_SALES_INTERNAL group only. This approval in turn will call upon the BO SDK to add a new restriction for the group with appropriate where clause.
3)At a later point, the above rows will be opened to NY_SALES_EXTERNAL group also.
This same concept holds good a number of jurisdiction (more or less static) and a dynamic number of LineIDs. So, if 10000 rows of data corresponding to new LineID 999 and Jurisdiction AK are in the table now, they are initially accessible only to AK_SALES_ADMIN group only. No one else should be able to access it.
Results:
1) With the way I laid out the business rules above, I am ending up with 528 groups.
2) There is a restriction created for a unique combination of Jurisdiction and LineID for each table.
Problems/Questions:
How can I restrict access to the new rows to one group only. I know that I can let a certain group only look at certain data but how can I restrict that all others cannot look at the same.
AK_SALES_ADMIN can look at LineID=999 and Jurisdiction='AK'.
Do I use an Everyone group based restriction? If so, my Everyone group will end up with tons of restrictions. How will they be resolved in terms of priority.
Am I even thinking of this the right way or is there a more noble way to do this?
Regardsthe connectinit setting should look something like this:
declare a date; begin vpd_setup('@VARIABLE('BOUSER')'); Commit; end;
The vpd_setup procedure (in Oracle) should look like this:
CREATE OR REPLACE procedure vpd_setup (p_user varchar)IS
BEGIN
DBMS_SESSION.set_vpd( 'SESSION_VALUES', 'USERID', p_user );
END vpd_setup;
Then you can retrieve the value of the context variable in your vpd functions
and set the vpd. -
Index usage in depending on where clause changes.
Hello Friends,
I need your help for one issue.
I have one query , which is using two table Say T1 and T2, where C1 is common column using which both are joined.
C1 is primary key in T1, but no index available in T2 for C1. T1C2 is the column which we want to select.
(Note that Either of table can be a Master table)
Now see the query:
Select T1C2
From T1, T2
where T2.C1 = T1.C1
Here where clause may have other conditions and From clause may have others tables as per requirements.
I want to know that, if, I change the query like following to let my query use the available index of T1.C1.
Select T1C2
from T1, T2
where T1.C1 = T2.C1
Then, Will the query use the available index of T1. and Will i get better performance. Even a little improvement in performance may help me a lot as this kind of query is being used within a where loop (so it is going to be executed multiple times).
Please advise on this..
Regards,
Dipali..Hi,
18:43:17 rel15_real_p>create table t1(c1 number primary key, c2 number);
Table created.
18:43:26 rel15_real_p>create table t2(c1 number, c2 number);
18:45:08 rel15_real_p>
18:45:09 rel15_real_p>begin
18:45:09 2 for i in 1..100
18:45:09 3 loop
18:45:09 4 insert into t1(c1,c2) values (i,i+100);
18:45:09 5 end loop;
18:45:09 6 commit;
18:45:09 7 end;
18:45:09 8 /
PL/SQL procedure successfully completed.
18:45:09 rel15_real_p>
18:45:09 rel15_real_p>
18:45:09 rel15_real_p>begin
18:45:09 2 for i in 1..100
18:45:09 3 loop
18:45:09 4 insert into t2(c1,c2) values (i,i+200);
18:45:09 5 end loop;
18:45:09 6 commit;
18:45:09 7 end;
18:45:09 8 /
18:45:23 rel15_real_p>select count(*) from t1;
COUNT(*)
100
18:45:30 rel15_real_p>select count(*) from t2;
COUNT(*)
100
18:45:49 rel15_real_p>select index_name,index_type from user_indexes where table
_name='T1';
INDEX_NAME INDEX_TYPE
SYS_C0013059 NORMAL
18:48:21 rel15_real_p>set autotrace on
18:52:25 rel15_real_p>Select T1.C2
18:52:29 2 From T1, T2
18:52:29 3 where T2.C1 = T1.C1
18:52:29 4 /
C2
101
102
103
104
105
C2
200
100 rows selected.
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=7 Card=100 Bytes=
900)
1 0 HASH JOIN (Cost=7 Card=100 Bytes=3900)
2 1 TABLE ACCESS (FULL) OF 'T1' (TABLE) (Cost=3 Card=100 By
es=2600)
3 1 TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 By
es=1300)
Statistics
0 recursive calls
0 db block gets
21 consistent gets
0 physical reads
0 redo size
1393 bytes sent via SQL*Net to client
562 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
100 rows processed
18:52:31 rel15_real_p>analyze table t1 compute statistics;
Table analyzed.
18:55:35 rel15_real_p>analyze table t2 compute statistics;
18:55:38 rel15_real_p>set autotrace on
18:55:42 rel15_real_p>Select T1.C2
18:55:43 2 From T1, T2
18:55:45 3 where T2.C1 = T1.C1
18:55:46 4 /
C2
101
102
103
104
105
C2
200
100 rows selected.
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=100 Bytes=7
00)
1 0 MERGE JOIN (Cost=6 Card=100 Bytes=700)
2 1 TABLE ACCESS (BY INDEX ROWID) OF 'T1' (TABLE) (Cost=2 Ca
rd=100 Bytes=500)
3 2 INDEX (FULL SCAN) OF 'SYS_C0013059' (INDEX (UNIQUE)) (
Cost=1 Card=100)
4 1 SORT (JOIN) (Cost=4 Card=100 Bytes=200)
5 4 TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 B
ytes=200)
Statistics
1 recursive calls
0 db block gets
23 consistent gets
0 physical reads
0 redo size
1393 bytes sent via SQL*Net to client
562 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
100 rows processed
18:56:56 rel15_real_p>Select T1.C2
18:56:56 2 From T1, T2
18:56:56 3 where T1.C1 = T2.C1
18:56:58 4 /
C2
101
102
103
104
105
C2
200
100 rows selected.
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=100 Bytes=7
00)
1 0 MERGE JOIN (Cost=6 Card=100 Bytes=700)
2 1 TABLE ACCESS (BY INDEX ROWID) OF 'T1' (TABLE) (Cost=2 Ca
rd=100 Bytes=500)
3 2 INDEX (FULL SCAN) OF 'SYS_C0013059' (INDEX (UNIQUE)) (
Cost=1 Card=100)
4 1 SORT (JOIN) (Cost=4 Card=100 Bytes=200)
5 4 TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 B
ytes=200)
Statistics
1 recursive calls
0 db block gets
23 consistent gets
0 physical reads
0 redo size
1393 bytes sent via SQL*Net to client
562 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
100 rows processed- Pavan Kumar N -
Performance with dates in the where clause
Performance with dates in the where clause
CREATE TABLE TEST_DATA
FNUMBER NUMBER,
FSTRING VARCHAR2(4000 BYTE),
FDATE DATE
create index t_indx on test_data(fdata);
query 1: select count(*) from TEST_DATA where trunc(fdate) = trunc(sysdate);
query 2: select count(*) from TEST_DATA where fdate between trunc(sysdate) and trunc(SYSDATE) + .99999;
query 3: select count(*) from TEST_DATA where fdate between to_date('21-APR-10', 'dd-MON-yy') and to_date('21-APR-10 23:59:59', 'DD-MON-YY hh24:mi:ss');
My questions:
1) Why isn't the index t_indx used in Execution plan 1?
2) From the execution plan, I see that query 2 & 3 is better than query 1. I do not see any difference between execution plan 2 & 3. Which one is better?
3) I read somewhere - "Always check the Access Predicates and Filter Predicates of Explain Plan carefully to determine which columns are contributing to a Range Scan and which columns are merely filtering the returned rows. Be sceptical if the same clause is shown in both."
Is that true for Execution plan 2 & 3?
3) Could some one explain what the filter & access predicate mean here?
Thanks in advance.
Execution Plan 1:
SQL> select count(*) from TEST_DATA where trunc(fdate) = trunc(sysdate);
COUNT(*)
283
Execution Plan
Plan hash value: 1486387033
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 9 | 517 (20)| 00:00:07 |
| 1 | SORT AGGREGATE | | 1 | 9 | | |
|* 2 | TABLE ACCESS FULL| TEST_DATA | 341 | 3069 | 517 (20)| 00:00:07 |
Predicate Information (identified by operation id):
2 - filter(TRUNC(INTERNAL_FUNCTION("FDATE"))=TRUNC(SYSDATE@!))
Note
- dynamic sampling used for this statement
Statistics
4 recursive calls
0 db block gets
1610 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
Execution Plan 2:
SQL> select count(*) from TEST_DATA where fdate between trunc(sysdate) and trunc(SYSDATE) + .99999;
COUNT(*)
283
Execution Plan
Plan hash value: 1687886199
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 9 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 9 | | |
|* 2 | FILTER | | | | | |
|* 3 | INDEX RANGE SCAN| T_INDX | 283 | 2547 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter(TRUNC(SYSDATE@!)<=TRUNC(SYSDATE@!)+.9999884259259259259259
259259259259259259)
3 - access("FDATE">=TRUNC(SYSDATE@!) AND
"FDATE"<=TRUNC(SYSDATE@!)+.999988425925925925925925925925925925925
9)
Note
- dynamic sampling used for this statement
Statistics
7 recursive calls
0 db block gets
76 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
Execution Plan 3:
SQL> select count(*) from TEST_DATA where fdate between to_date('21-APR-10', 'dd-MON-yy') and to_dat
e('21-APR-10 23:59:59', 'DD-MON-YY hh24:mi:ss');
COUNT(*)
283
Execution Plan
Plan hash value: 1687886199
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 9 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 9 | | |
|* 2 | FILTER | | | | | |
|* 3 | INDEX RANGE SCAN| T_INDX | 283 | 2547 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter(TO_DATE('21-APR-10','dd-MON-yy')<=TO_DATE('21-APR-10
23:59:59','DD-MON-YY hh24:mi:ss'))
3 - access("FDATE">=TO_DATE('21-APR-10','dd-MON-yy') AND
"FDATE"<=TO_DATE('21-APR-10 23:59:59','DD-MON-YY hh24:mi:ss'))
Note
- dynamic sampling used for this statement
Statistics
7 recursive calls
0 db block gets
76 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 processedHi,
user10541890 wrote:
Performance with dates in the where clause
CREATE TABLE TEST_DATA
FNUMBER NUMBER,
FSTRING VARCHAR2(4000 BYTE),
FDATE DATE
create index t_indx on test_data(fdata);Did you mean fdat<b>e</b> (ending in e)?
Be careful; post the code you're actually running.
query 1: select count(*) from TEST_DATA where trunc(fdate) = trunc(sysdate);
query 2: select count(*) from TEST_DATA where fdate between trunc(sysdate) and trunc(SYSDATE) + .99999;
query 3: select count(*) from TEST_DATA where fdate between to_date('21-APR-10', 'dd-MON-yy') and to_date('21-APR-10 23:59:59', 'DD-MON-YY hh24:mi:ss');
My questions:
1) Why isn't the index t_indx used in Execution plan 1?To use an index, the indexed column must stand alone as one of the operands. If you had a function-based index on TRUNC (fdate), then it might be used in Query 1, because the left operand of = is TRUNC (fdate).
2) From the execution plan, I see that query 2 & 3 is better than query 1. I do not see any difference between execution plan 2 & 3. Which one is better?That depends on what you mean by "better".
If "better" means faster, you've already shown that one is about as good as the other.
Queries 2 and 3 are doing different things. Assuming the table stays the same, Query 2 may give different results every day, but the results of Query 3 will never change.
For clarity, I prefer:
WHERE fdate >= TRUNC (SYSDATE)
AND fdate < TRUNC (SYSDATE) + 1(or replace SYSDATE with a TO_DATE expression, depending on the requirements).
3) I read somewhere - "Always check the Access Predicates and Filter Predicates of Explain Plan carefully to determine which columns are contributing to a Range Scan and which columns are merely filtering the returned rows. Be sceptical if the same clause is shown in both."
Is that true for Execution plan 2 & 3?
3) Could some one explain what the filter & access predicate mean here?Sorry, I can't. -
My function in where clause? help me please.
hello friends, I need to call my function in where clause as dummy example below:
declare
name_ table1.name%type;
function return_id(id number) return number is
begin
return 1;
end return_id;
begin
select name into name_
from table1
where id = return_id(table1.id);
end;
raise exception: 'the function doesn't used in where clause'. why????-- CREATING A FUNCTION AVAILABLE THROUGH A PACKAGE SPEC.
SQL> ed
Wrote file afiedt.buf
1 create package mypackage is
2 function myfunc(p_val NUMBER) RETURN NUMBER;
3* end;
SQL> /
Package created.
SQL> ed
Wrote file afiedt.buf
1 create or replace package body mypackage is
2 function myfunc(p_val NUMBER) RETURN NUMBER IS
3 begin
4 RETURN (p_val*p_val)-1;
5 end;
6* end;
SQL> /
Package body created.
SQL> declare
2 v_myval NUMBER := 2;
3 begin
4 select mypackage.myfunc(v_myval)
5 into v_myval
6 from dual;
7 dbms_output.put_line(v_myval);
8 select mypackage.myfunc(v_myval)
9 into v_myval
10 from dual;
11 dbms_output.put_line(v_myval);
12 end;
13 /
3
8
PL/SQL procedure successfully completed.
-- CREATING A STANDALONE DATABASE FUNCTION.
SQL> create or replace function myfunc2(p_val number) return number is
2 begin
3 return (p_val*2)+1;
4 end;
5 /
Function created.
SQL> ed
Wrote file afiedt.buf
1 declare
2 v_myval NUMBER := 2;
3 begin
4 select myfunc2(v_myval)
5 into v_myval
6 from dual;
7 dbms_output.put_line(v_myval);
8 select myfunc2(v_myval)
9 into v_myval
10 from dual;
11 dbms_output.put_line(v_myval);
12* end;
SQL> /
5
11
PL/SQL procedure successfully completed.
-- CREATING A LOCAL FUNCTION IN THE ANONYMOUS PL/SQL BLOCK
SQL> ed
Wrote file afiedt.buf
1 declare
2 v_myval NUMBER := 2;
3 function myfunc3(p_val number) return number is
4 begin
5 return (p_val*p_val*p_val);
6 end;
7 begin
8 select myfunc3(v_myval)
9 into v_myval
10 from dual;
11 dbms_output.put_line(v_myval);
12 select myfunc3(v_myval)
13 into v_myval
14 from dual;
15 dbms_output.put_line(v_myval);
16* end;
SQL> /
select myfunc3(v_myval)
ERROR at line 8:
ORA-06550: line 8, column 10:
PLS-00231: function 'MYFUNC3' may not be used in SQL
ORA-06550: line 8, column 10:
PL/SQL: ORA-00904: : invalid identifier
ORA-06550: line 8, column 3:
PL/SQL: SQL Statement ignored
ORA-06550: line 12, column 10:
PLS-00231: function 'MYFUNC3' may not be used in SQL
ORA-06550: line 12, column 10:
PL/SQL: ORA-00904: : invalid identifier
ORA-06550: line 12, column 3:
PL/SQL: SQL Statement ignored
SQL>As you can see (and as previously mentioned by someone else) the function has to be available to the SQL engine either via a datavbase package or as a database function. If you declare the function locally within the anonymous PL/SQL block then the function only exists in the scope of that PL/SQL block and thus when your SQL statement is sent to the SQL engine for execution, the SQL engine can't see it.
;) -
Where to download Acrobat SDK?
Hello, friends,
Where to download Acrobat SDK? I was brought to the download page,
http://www.adobe.com/cfusion/entitlement/index.cfm?e=acrobat%5Fsdk
Acrobat Developer CenterAcrobat 8.1 SDK
Acrobat 8.1 SDK is now available free of charge to all users. Developers can use the SDK to create software and plug-ins to interact and customize Acrobat and Adobe Reader.
All Acrobat 8.1 SDK Samples
Download - Windows (ZIP,21.8MB)
Download - Mac (ZIP, 18.8MB)
Acrobat 8.1 SDK documentation
Download (ZIP, 52.9MB)
Acrobat 8.1 SDK JavaScript support samples
Download - Windows (ZIP, 15.4MB)
Download - Mac (ZIP,14.4MB)
Thank you for your interest in the Acrobat 8 SDK.
however, all it has are sample source code. I was expecting the real SDK: Installation files to install necessary components.
Any ideas? Thanks a lot.Hi, Aandi,
"And after all, the description you cut and pasted did exactly describe it. "
I don't think so.
The exact description should be:
Acrobat 8.1 SDK is now available FREE of charge to all users. Although developers can use the SDK to create software and plug-ins to interact and customize FREE Adobe Reader, developers can NOT use the SDK to create software and plug-ins to interact and customize Acrobat without buying (NOT FREE) Acrobat.
But, Aandi, please do not misunderstand me: I was NOT intenting to argue with you. Simply I felt very frustarted and upset by Adobe's policy.
Our customers just need to read .pdf files. They wish our c#.net application can open the file they select from our app, and automatically jump to the page they preselect, and save the paper numbers they select this time so that they can use next time. They do not need edit/save/delete/... functions at all.
However, based on what you said, our customers will have to buy hundreds of Acrobat for the functions they will never allowed to use. (Those .pdf files are read only legal papers, no modification is allowed). -
Performance hit using "where" clause in the query
Hi All,
I am facing a huge performance hit in the java code when using "where" clause in queries. Following are the details:
1. SELECT * FROM Employee
2. SELECT * FROM Employee where employeeid in (26,200,330,571,618,945)
There is no difference in Query Execution Time for both queries.
Business Logic Time is huge in second case as compared to first one (ratio - 1:20).
Rows returned are more in first case as compared to second case.(ratio - 1:4)
Business Logic is same for both the cases where I iterate through the ResultSet, get the objects and set them in a data structure.
Does anybody know the reason of unexpected time difference for the business logic in the second case?Since you're mentioning clustering your index, I'll assume you are using Oracle. Knowing what database you are using makes it a lot easier to suggest things.
Since you are using Oracle, you can get the database to tell you what execution plan it is using for each of the 2 SQL statements, and figure out why they have similar times (if they do).
First, you need to be able to run SQL*Plus; that comes as part of a standard database installation and as part of the Oracle client installation - getting it set up and running is outside the scope of this forum.
Second, you may need your DBA to enable autotracing, if it's not already:
http://asktom.oracle.com/~tkyte/article1/autotrace.html
http://www.samoratech.com/tips/swenableautotrace.htm
Once it's all set up, you can log in to your database using sql*plus, issue "SET AUTOTRACE ON", issue queries and get execution plan information back.
For example:
SQL> set autotrace on
SQL> select count(*) from it.ticket where ticket_number between 10 and 20;
COUNT(*)
11
Execution Plan
Plan hash value: 2983758974
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 4 | 1 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 4 | | |
|* 2 | INDEX RANGE SCAN| TICKET_N10 | 12 | 48 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("TICKET_NUMBER">=10 AND "TICKET_NUMBER"<=20)
Statistics
0 recursive calls
0 db block gets
1 consistent gets
0 physical reads
0 redo size
515 bytes sent via SQL*Net to client
469 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> This tells me that this query used an INDEX RANGE SCAN on index TICKET_N1; the query can't do much better than that logically... In fact, the statistic "1 consistent gets" tells me that Oracle had to examine only one data block to get the answer, also can't do better than that. the statistic, "0 physical reads" tells me that the 1 data block used was already cached in Oracle's memory.
the above is from Oracle 10g; autotrace is available back to at least 8i, but they've been adding information to the output with each release.
If you have questions about sql_plus, check the forums at asktom.oracle.com or http://forums.oracle.com/forums/category.jspa?categoryID=18
since sql*plus is not a JDBC thing...
Oh, and sql*plus can also give you easier access to timing information, with "set timing on". -
I have 3 tables with 3 different name for month field.
table month
A bill_mon
B bill_month
C month
now on the basis of month field in where clause I want to take Export of above tables.
How I can do it?No you dont need a select.
D:\ORANT\BIN>exp usr/pwd@db file=b:\demo.dmp tables=(abc) query='where 1=1'
Export: Release 8.1.6.0.0 - Production on Thu Feb 8 17:02:43 2007
(c) Copyright 1999 Oracle Corporation. All rights reserved.
Connected to: Oracle8i Enterprise Edition Release 8.1.7.4.1 - Production
With the Partitioning option
JServer Release 8.1.7.4.1 - Production
Export done in WE8ISO8859P1 character set and WE8ISO8859P1 NCHAR character set
About to export specified tables via Conventional Path ...
. . exporting table ABC 1 rows exported
Export terminated successfully without warnings. -
I have a selection screen like:
Table Field
EKKO EKORG
EKKO EKGRP
EKKO LIFNR
ESSR EBELN
ESSR EBELP
ESSR LBLNE
ESSR FRGZU
ESSR ERDAT
ESSR LOEKZ
Due to further complexities in the program i am joining 3 tables EKKO, EKPO and ESSR together. I can write the select stmt in 2 ways. I want to understand which one is better in terms of performance and is there exactly a rule here that i should follow before i write the where clause in this join.
SELECT aebeln bebelp alifnr aekorg aekgrp bpackno c~lblni
clblne cerdat cpackno cloekz cfrgsx cfrgkl c~frgzu
INTO TABLE gt_test
FROM ekko AS a INNER JOIN ekpo AS b
ON aebeln = bebeln
INNER JOIN essr AS c
ON aebeln = cebeln
AND bebeln = cebeln
AND bebelp = cebelp
WHERE a~lifnr IN so_lifnr
AND a~ekorg IN so_ekorg
AND a~ekgrp IN so_ekgrp
AND c~lblne IN so_lblne
AND c~ebeln IN so_ebeln
AND c~ebelp IN so_ebelp
AND c~erdat IN so_erdat.
SELECT aebeln bebelp alifnr aekorg aekgrp bpackno c~lblni
clblne cerdat cpackno cloekz cfrgsx cfrgkl c~frgzu
INTO TABLE gt_test
FROM ekko AS a INNER JOIN ekpo AS b
ON aebeln = bebeln
INNER JOIN essr AS c
ON aebeln = cebeln
AND bebeln = cebeln
AND bebelp = cebelp
WHERE a~ebeln IN so_ebeln
AND a~lifnr IN so_lifnr
AND a~ekorg IN so_ekorg
AND a~ekgrp IN so_ekgrp
AND b~ebelp IN so_ebelp
AND c~lblne IN so_lblne
AND c~erdat IN so_erdat.
AND c~erdat IN so_erdat.Hi,
This part is not necessary:
... a~ebeln = c~ebeln ...
Modify:
AND c~ebeln IN so_ebeln
AND c~ebelp IN so_ebelp
by
AND a~ebeln IN so_ebeln
AND b~ebelp IN so_ebelp
The best option will be:
if not so_ebeln[] is initial.
select ... where a~ebeln IN so_ebeln ... (2nd select)
else.
select ... where a~lifnr IN so_lifnr ... (1st select)
endif.
Also, you can try only the 2nd select, because it has WHERE clause to ebeln and lifnr. Depending on your database, you can check (via ST04) if the right index is selected (eg. if you inform so_ebeln the database must do the selection using ebeln index. if you inform so_lifnr the database must do the selection using lifnr index, etc..)
Best regards,
Leandro Mengue -
Problems with WHERE CLAUSE in selects executed by BAPIs
Dear Experts,
I'm trying to make a SAP Java Connector. My problem is that, when they are called by Java, BAPI functions don't run in the same manner as in SAP testing mode .
I tested two BAPI functions called through my connector and I saw with the debbuger that BAPI functions don't execute the select and loop at with a WHERE clause when they are called by Java, therefore they throw errors. But in the SAP testing mode functions work just fine.
I'm new to SAP and I don't know why this happens. Would you like to explain to me how to fix this problem?
Thank you very much.
Kind regards,
Maricica979380 wrote:
Yeah,i m sorry.I m a forum newbie.All right,we ve been given an oracle account for the purpose of this project,an we have connect to the oracle database either via linux terminal with sqlplus,or via oracle client and plsql.So i have to create some tables,then fill these tables with tuples(we ve been given fixed .sql files to do that),and we re suggested to do that from the linux terminal.I did that successfully.Then we have to run some queries either in terminal or plsql.I chose plsql.I connect,i can see the tables that i have created but when i run(in both sql and terminal window) for example the query "select * from table_1",i take 0 rows as a result.I tested to run the query from terminal(with sqlplus) to see if the tables are really empty,but i recieve the results as i should.
I am sorry for my chaotic writing but i cant even explain the problem to myself better and i m not a native.
(im using oracle version 11.2.0.1, this is the first time i m using oracle databases and i m a rookie in databases in general)
Edited by: 979380 on 1 Ιαν 2013 10:33 πμ
[oracle@localhost ~]$ sqlplus user1/user1
SQL*Plus: Release 11.2.0.2.0 Production on Tue Jan 1 11:19:29 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table table_1 (id number);
Table created.
SQL> select * from table_1;
no rows selected
SQL> insert into table_1 values(1);
1 row created.
SQL> select * from table_1;
ID
1
SQL> in order to SELECT any rows from any table, first you must INSERT data into the table!
is COPY & PASTE broken for you? -
DYNAMIC WHERE CLAUSE in PROCEDURE
I am trying to pass in the IN portion of the where clause to an update statement within a procedure and it is not updating any rows. I want to update 2 columns where the ID's are in the string of ID's I am passing in.
PROCEDURE upd_corebio
(p_dup_string IN VARCHAR2,
p_source IN VARCHAR2,
p_title IN VARCHAR2)
IS
BEGIN
UPDATE corebio
SET corettlbar = p_title, coresource = p_source
WHERE coreid IN (p_dup_string);
END upd_corebio;
upd_corebio('1001,2002,3003','SOURCE','TITLE')
FYI...COREID IS CHAR(10)
CORETTLBAR IS CHAR(30)
CORESOURCE IS CHAR(6)The rownum hint seems to work on my system (Windows, 9.2.0.1)
First, we'll set up the objects
create table collection_test (
col1 NUMBER,
col2 VARCHAR2(100)
create sequence coll_seq
start with 1
increment by 1
cache 100;
begin
for x in (select * from all_objects)
loop
insert into collection_test
values( coll_seq.nextval, x.object_name );
end loop;
end;
create unique index coll_test_idx
on collection_test( col1 );
analyze index coll_test_idx compute statistics
analyze table collection_test compute statistics;Now, try with the "generic" approach, with the CARDINALITY hint, which won't work, and the rownum trick, which appears to work
SQL> ed
Wrote file afiedt.buf
1 SELECT *
2 FROM collection_test
3* WHERE col1 IN (SELECT * FROM TABLE(CAST(f_number_table('1,2,3') as numberTable)))
SQL> /
COL1
COL2
1
/1005bd30_LnkdConstant
2
/10076b23_OraCustomDatumClosur
3
/10297c91_SAXAttrList
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=297327 Card=1 Bytes=
28)
1 0 NESTED LOOPS (SEMI) (Cost=297327 Card=1 Bytes=28)
2 1 TABLE ACCESS (FULL) OF 'COLLECTION_TEST' (Cost=19 Card=2
7028 Bytes=756784)
3 1 COLLECTION ITERATOR (PICKLER FETCH) OF 'F_NUMBER_TABLE'
Statistics
687 recursive calls
0 db block gets
331 consistent gets
6 physical reads
68 redo size
546 bytes sent via SQL*Net to client
503 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
19 sorts (memory)
0 sorts (disk)
3 rows processed
SQL> ed
Wrote file afiedt.buf
1 SELECT *
2 FROM collection_test
3* WHERE col1 IN (SELECT /*+ CARDINALITY(t 10) */ * FROM TABLE(CAST(f_number_table('1,2,3') as nu
SQL> /
COL1
COL2
1
/1005bd30_LnkdConstant
2
/10076b23_OraCustomDatumClosur
3
/10297c91_SAXAttrList
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=297327 Card=1 Bytes=
28)
1 0 NESTED LOOPS (SEMI) (Cost=297327 Card=1 Bytes=28)
2 1 TABLE ACCESS (FULL) OF 'COLLECTION_TEST' (Cost=19 Card=2
7028 Bytes=756784)
3 1 COLLECTION ITERATOR (PICKLER FETCH) OF 'F_NUMBER_TABLE'
Statistics
0 recursive calls
0 db block gets
177 consistent gets
0 physical reads
0 redo size
546 bytes sent via SQL*Net to client
503 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
3 rows processed
SQL> ed
Wrote file afiedt.buf
1 SELECT *
2 FROM collection_test
3* WHERE col1 IN (SELECT /*+ CARDINALITY(t 10) */ * FROM TABLE(CAST(f_number_table('1,2,3') as nu
SQL> /
COL1
COL2
1
/1005bd30_LnkdConstant
2
/10076b23_OraCustomDatumClosur
3
/10297c91_SAXAttrList
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=23 Card=10 Bytes=410
1 0 NESTED LOOPS (Cost=23 Card=10 Bytes=410)
2 1 VIEW OF 'VW_NSO_1' (Cost=11 Card=10 Bytes=130)
3 2 SORT (UNIQUE)
4 3 COUNT
5 4 FILTER
6 5 COLLECTION ITERATOR (PICKLER FETCH) OF 'F_NUMBER
_TABLE'
7 1 TABLE ACCESS (BY INDEX ROWID) OF 'COLLECTION_TEST' (Cost
=1 Card=1 Bytes=28)
8 7 INDEX (UNIQUE SCAN) OF 'COLL_TEST_IDX' (UNIQUE)
Statistics
0 recursive calls
0 db block gets
14 consistent gets
0 physical reads
0 redo size
546 bytes sent via SQL*Net to client
503 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
3 rows processedUnless I'm missing the boat, it seems like the last approach is using the more appropriate index access path.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Howto use jsp with where-clause restriction for viewObject
hello there,
i am currently trying to figure out how to pass parameters via url to the jsp,
so that the corresponding viewobjects where clause can be extended and i only get the select-results that i want. i am familiar with doing this in a stright java-environment but don't know how to implement it in a jsp-client.
does anyone know something about this or can name me a ressource i can read about that.
Thanx
Selim Keserthank you, but i have only 19 days left for
my diploma and nobody in this company can help me with this issue.
what i need is an example or something like a reciept about what to do
to achieve the following:
I want to type in an url like:
localhost:8080/myapp/browse.jsp?customerid=123
so that i can extend the where-clause in my ViewObject
and only see the rows of customer 123 in my jsp.
it is a bit hard for a newbie to figure out how to pass down the parameters way down to the ViewObject. I am shure that this is easy to do once one understands the how it works. This is my first "Web-Experience" and I am running out of time.
Thanx
Selim Keser -
Order of Execution in WHERE clause
DB Version 10gR2
In a query like
SELECT sal from emp where empid=7891 and empname='JOHN';
What does Oracle evaluate first in the WHERE clause, is it empid=7891 or empname='JOHN'? I couldn't find this in 10G R2 documentation, hence this thread.Hi,
You need to read the execution plan of a query to see which filtering condition is applied first or last.
For the sample "EMP" table from SCOTT schema, following is clear:
SQL> set autotrace on
SQL> SELECT sal from emp where empno=7891 and ename='JOHN';
no rows selected
Execution Plan
Plan hash value: 2949544139
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 14 | 1 (0)| 00:00:01 |
|* 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 14 | 1 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | PK_EMP | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("ENAME"='JOHN')
2 - access("EMPNO"=7891)
Statistics
0 recursive calls
0 db block gets
1 consistent gets
0 physical reads
0 redo size
272 bytes sent via SQL*Net to client
384 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processed
SQL>Message was edited by:
Citrus
added complete autotrace output -
Why a table full scan when I've got the PK in the WHERE clause?
There is a very complex query that I need to optimize in an Oracle 10gR2 environment. I am deconstructing it into layers to see what is causing the first bottleneck. The innermost portion is fine, with an explain plan cost of 54. With a typical value for the bind variable, it returns 125 zero_id values. There are over 100,000 rows in table T_ONE in my test database, but my customer has over one million rows in their production instance.
WITH t_merged_id AS (SELECT DISTINCT zero_id FROM t_zero WHERE NVL(column2, zero_id) = :i_id)
SELECT t_one.one_id
FROM t_one
INNER JOIN t_two
ON t_one.column1 = t_two.two_id
INNER JOIN t_merged_id
ON t_two.column10 = t_merged_id.zero_id
UNION ALL
SELECT t_one.one_id
FROM t_one
INNER JOIN t_two
ON t_one.column2 = t_two.two_id
INNER JOIN t_merged_id
ON t_two.column10 = t_merged_id.zero_id
UNION ALL
SELECT t_one.one_id
FROM t_one
INNER JOIN t_three
ON t_one.column3 = t_three.three_id
INNER JOIN t_merged_id
ON t_three.column10 = t_merged_id.zero_id
UNION ALL
SELECT t_one.one_id
FROM t_one
INNER JOIN t_four
ON t_one.column4 = t_four.four_id
INNER JOIN t_two
ON t_four.column1 = t_two.two_id
INNER JOIN t_merged_id
ON t_two.two_id = t_merged_id.zero_id
UNION ALL
SELECT t_one.one_id
FROM t_one INNER JOIN t_merged_id ON t_one.column5 = t_merged_id.zero_id
UNION
SELECT t_one.one_id
FROM t_one INNER JOIN t_merged_id ON t_one.column6 = t_merged_id.zero_idHowever, the next step is to obtain a bunch of columns from T_ONE for each of those ONE_ID values. Adding that looks like the following, which causes a table full scan on T_ONE (and an explain plan cost over 1,500 for this query in my test system) and it takes far too long to return the results.
SELECT t_one.*
FROM t_one
INNER JOIN
(--This is the start of the query shown above
WITH t_merged_id AS (SELECT DISTINCT zero_id FROM t_zero WHERE NVL(column2, zero_id) = :i_id)
SELECT t_one.one_id
FROM t_one
INNER JOIN t_two
ON t_one.column1 = t_two.two_id
INNER JOIN t_merged_id
ON t_two.column10 = t_merged_id.zero_id
UNION ALL
SELECT t_one.one_id
FROM t_one
INNER JOIN t_two
ON t_one.column2 = t_two.two_id
INNER JOIN t_merged_id
ON t_two.column10 = t_merged_id.zero_id
UNION ALL
SELECT t_one.one_id
FROM t_one
INNER JOIN t_three
ON t_one.column3 = t_three.three_id
INNER JOIN t_merged_id
ON t_three.column10 = t_merged_id.zero_id
UNION ALL
SELECT t_one.one_id
FROM t_one
INNER JOIN t_four
ON t_one.column4 = t_four.four_id
INNER JOIN t_two
ON t_four.column1 = t_two.two_id
INNER JOIN t_merged_id
ON t_two.two_id = t_merged_id.zero_id
UNION ALL
SELECT t_one.one_id
FROM t_one INNER JOIN t_merged_id ON t_one.column5 = t_merged_id.zero_id
UNION
SELECT t_one.one_id
FROM t_one INNER JOIN t_merged_id ON t_one.column6 = t_merged_id.zero_id
--This is the end of the query shown above
) t_list
ON t_one.one_id = t_list.one_idMy question is, why wouldn’t Oracle use the existing index PK_T_ONE, which is keyed on T_ONE.ONE_ID? I tried refactoring the query using a “WHERE t_one.one_id IN” construct instead of the INNER JOIN but it didn’t make any difference. Neither did adding an index hint, which I hoped would force the use of the PK index.
Any ideas?I was able to completely resolve my problem, but I still want to understand why the original query wouldn't use an index.
(My solution was to move all the joins and where clauses from the query that wrapped the one we've been discussing and put them into each SELECT in the UNION, so there is no longer any inner subquery. So instead of trying to first get a list of ID values from the subquery, get the full records for the IDs from an outer query, and then joining to the outer query, I made SELECT in the UNION contain the full logic. This makes the query a lot more verbose, because all the joins and wheres are repeated six times, but it does use the index and returns in 0.04 seconds instead of over nine minutes in my test database.)
hoek wrote:
Values for optimizer_index_caching and optimizer_index_cost_adj are not the defaults. Any reasons for that?I am not a DBA and have no idea. However, I did a Google search and found this: http://decipherinfosys.wordpress.com/2007/02/13/optimizer_index_cost_adj-and-optimizer_index_caching/. Apparently Tom Kyte would approve more of our settings than the defaults.
hoek wrote:
Any chance to get a realistic dataset on your test server?Unfortunately, not for quite some time. The customer won't provide any real data, and generating data for testing is complex because of all the interrelationships. I have someone working on that. However, I was able to get back on the primary test server that has 136k records in the main table instead of only 2k. So far as I know, the Oracle configuration between the test server and the customer's server is the same. However, they have much more serious hardware that I do (more processors, more RAM, more platters). On the other hand, they have 10 times as much data.
hoek wrote:
Your second execution plan contains differents stats, they're not the 'common ones'. (E-rows etc.)The predicates are the same as the first. The 2nd plan was generated by the 10g-specific portion of Randolph's script using the command "select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));".
This is the result from running the script on the main test server:
NAME TYPE VALUE
_optimizer_cost_based_transformation string OFF
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.4
optimizer_index_caching integer 95
optimizer_index_cost_adj integer 10
optimizer_mode string CHOOSE
optimizer_secure_view_merging boolean TRUE
db_file_multiblock_read_count integer 32
db_block_size integer 8192
cursor_sharing string FORCE
SNAME PNAME PVAL1 PVAL2
SYSSTATS_INFO STATUS COMPLETED
SYSSTATS_INFO DSTART 04-04-2008 07:02
SYSSTATS_INFO DSTOP 04-04-2008 07:02
SYSSTATS_INFO FLAGS 1
SYSSTATS_MAIN CPUSPEEDNW 646.57331
SYSSTATS_MAIN IOSEEKTIM 10
SYSSTATS_MAIN IOTFRSPEED 4096
SYSSTATS_MAIN SREADTIM
SYSSTATS_MAIN MREADTIM
SYSSTATS_MAIN CPUSPEED
SYSSTATS_MAIN MBRC
SYSSTATS_MAIN MAXTHR
SYSSTATS_MAIN SLAVETHR
SQL> SELECT st.*
2 FROM t_senttsk st INNER JOIN (WITH t_mrgdusr AS (SELECT DISTINCT usr_id
3 FROM t_usr
4 WHERE NVL(usr_mrgemstr, usr_id) = 10000002 /* i_payer_id */
5 )
6 SELECT t_senttsk.setk_id
7 FROM t_senttsk INNER JOIN t_mrgdusr
8 ON t_senttsk.setk_affn_memb = t_mrgdusr.usr_id
9 UNION
10 SELECT t_senttsk.setk_id
11 FROM t_senttsk INNER JOIN t_mrgdusr
12 ON t_senttsk.setk_ownr = t_mrgdusr.usr_id) t_affil
13 ON st.setk_id = t_affil.setk_id;
no rows selected
Elapsed: 00:13:14.54
Execution Plan
Plan hash value: 1241660758
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 169K| 64M| 1403 (3)| 00:00:17 |
| 1 | NESTED LOOPS | | 169K| 64M| 1403 (3)| 00:00:17 |
| 2 | TABLE ACCESS FULL | T_SENTTSK | 136K| 51M| 1400 (3)| 00:00:17 |
| 3 | VIEW | | 1 | 6 | 1 (0)| 00:00:01 |
| 4 | TEMP TABLE TRANSFORMATION | | | | | |
| 5 | LOAD AS SELECT | | | | | |
| 6 | TABLE ACCESS BY INDEX ROWID | T_USR | 1 | 8 | 1 (0)| 00:00:01 |
|* 7 | INDEX RANGE SCAN | IX_NVL_USR_MRGEMSTR_USR_ID | 1 | | 1 (0)| 00:00:01 |
| 8 | SORT UNIQUE | | | | | |
| 9 | UNION-ALL PARTITION | | | | | |
| 10 | NESTED LOOPS | | 1 | 25 | 3 (0)| 00:00:01 |
| 11 | TABLE ACCESS BY INDEX ROWID| T_SENTTSK | 1 | 12 | 1 (0)| 00:00:01 |
|* 12 | INDEX UNIQUE SCAN | PK_T_SENTTSK | 1 | | 1 (0)| 00:00:01 |
|* 13 | VIEW | | 1 | 13 | 2 (0)| 00:00:01 |
| 14 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6608_399116CE | 1 | 6 | 2 (0)| 00:00:01 |
| 15 | NESTED LOOPS | | 1 | 22 | 3 (0)| 00:00:01 |
|* 16 | TABLE ACCESS BY INDEX ROWID| T_SENTTSK | 1 | 9 | 1 (0)| 00:00:01 |
|* 17 | INDEX UNIQUE SCAN | PK_T_SENTTSK | 1 | | 1 (0)| 00:00:01 |
|* 18 | VIEW | | 1 | 13 | 2 (0)| 00:00:01 |
| 19 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6608_399116CE | 1 | 6 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
7 - access(NVL("USR_MRGEMSTR","USR_ID")=10000002)
12 - access("T_SENTTSK"."SETK_ID"="ST"."SETK_ID")
13 - filter("T_SENTTSK"."SETK_AFFN_MEMB"="T_MRGDUSR"."USR_ID")
16 - filter("T_SENTTSK"."SETK_OWNR" IS NOT NULL)
17 - access("T_SENTTSK"."SETK_ID"="ST"."SETK_ID")
18 - filter("T_SENTTSK"."SETK_OWNR"="T_MRGDUSR"."USR_ID")
Statistics
349 recursive calls
275041 db block gets
1239881 consistent gets
26 physical reads
52730252 redo size
3312 bytes sent via SQL*Net to client
240 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
136835 sorts (memory)
0 sorts (disk)
0 rows processed
SQL> SELECT /*+ gather_plan_statistics */ st.*
2 FROM t_senttsk st INNER JOIN (WITH t_mrgdusr AS (SELECT DISTINCT usr_id
3 FROM t_usr
4 WHERE NVL(usr_mrgemstr, usr_id) = 10000002 /* i_payer_id */
5 )
6 SELECT t_senttsk.setk_id
7 FROM t_senttsk INNER JOIN t_mrgdusr
8 ON t_senttsk.setk_affn_memb = t_mrgdusr.usr_id
9 UNION
10 SELECT t_senttsk.setk_id
11 FROM t_senttsk INNER JOIN t_mrgdusr
12 ON t_senttsk.setk_ownr = t_mrgdusr.usr_id) t_affil
13 ON st.setk_id = t_affil.setk_id;
no rows selected
Elapsed: 00:09:15.90
SQL>
SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
SQL_ID 2rc9d2c83a7ak, child number 0
SELECT /*+ gather_plan_statistics */ st.* FROM t_senttsk st INNER JOIN (WITH t_mrgdusr AS (SELECT DISTINCT usr_id
FROM t_usr WHERE NVL(usr_mrgemstr, usr_id) = :"SYS_B_0"
/* i_payer_id */ )
SELECT t_senttsk.setk_id FROM t_senttsk INNER JOIN t_mrgdusr
ON t_senttsk.setk_affn_memb = t_mrgdusr.usr_id UNION SELECT
t_senttsk.setk_id FROM t_senttsk INNER JOIN t_mrgdusr ON
t_senttsk.setk_ownr = t_mrgdusr.usr_id) t_affil ON st.setk_id = t_affil.setk_id
Plan hash value: 1065206678
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
| 1 | NESTED LOOPS | | 1 | 169K| 0 |00:09:02.47 | 1514K| | | |
| 2 | TABLE ACCESS FULL | T_SENTTSK | 1 | 136K| 136K|00:00:01.64 | 7062 | | | |
| 3 | VIEW | | 136K| 1 | 0 |00:09:00.54 | 1507K| | | |
| 4 | TEMP TABLE TRANSFORMATION | | 136K| | 0 |00:09:00.12 | 1507K| | | |
| 5 | LOAD AS SELECT | | 136K| | 0 |00:08:24.31 | 548K| 1024 | 1024 | |
| 6 | TABLE ACCESS BY INDEX ROWID | T_USR | 136K| 1 | 0 |00:00:06.12 | 410K| | | |
|* 7 | INDEX RANGE SCAN | IX_NVL_USR_MRGEMSTR_USR_ID | 136K| 1 | 0 |00:00:05.41 | 410K| | | |
| 8 | SORT UNIQUE | | 136K| | 0 |00:00:19.10 | 822K| 1024 | 1024 | |
| 9 | UNION-ALL PARTITION | | 136K| | 0 |00:00:17.40 | 822K| | | |
| 10 | NESTED LOOPS | | 136K| 1 | 0 |00:00:08.02 | 411K| | | |
| 11 | TABLE ACCESS BY INDEX ROWID| T_SENTTSK | 136K| 1 | 136K|00:00:06.36 | 411K| | | |
|* 12 | INDEX UNIQUE SCAN | PK_T_SENTTSK | 136K| 1 | 136K|00:00:03.68 | 273K| | | |
|* 13 | VIEW | | 136K| 1 | 0 |00:00:01.03 | 0 | | | |
| 14 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6609_399116CE | 136K| 1 | 0 |00:00:00.67 | 0 | | | |
| 15 | NESTED LOOPS | | 136K| 1 | 0 |00:00:06.54 | 411K| | | |
|* 16 | TABLE ACCESS BY INDEX ROWID| T_SENTTSK | 136K| 1 | 34256 |00:00:05.87 | 411K| | | |
|* 17 | INDEX UNIQUE SCAN | PK_T_SENTTSK | 136K| 1 | 136K|00:00:03.46 | 273K| | | |
|* 18 | VIEW | | 34256 | 1 | 0 |00:00:00.25 | 0 | | | |
| 19 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6609_399116CE | 34256 | 1 | 0 |00:00:00.16 | 0 | | | |
Predicate Information (identified by operation id):
7 - access("T_USR"."SYS_NC00127$"=:SYS_B_0)
12 - access("T_SENTTSK"."SETK_ID"="ST"."SETK_ID")
13 - filter("T_SENTTSK"."SETK_AFFN_MEMB"="T_MRGDUSR"."USR_ID")
16 - filter("T_SENTTSK"."SETK_OWNR" IS NOT NULL)
17 - access("T_SENTTSK"."SETK_ID"="ST"."SETK_ID")
18 - filter("T_SENTTSK"."SETK_OWNR"="T_MRGDUSR"."USR_ID")
hoek wrote:Does rewriting 'the heart of the issue' into like below make any difference?
select a.*
from foo a
where exists ( select null
from bar b
where a.foo_pk_id = b.foo_pk_id
and b.some_col = :bind_var
The UNION in the subquery seems to make that difficult.
Maybe you are looking for
-
Cannot select a Date in the 2nd week of any month from "Month View"
Looking for some help with a strange problem that has started within the last day or 2. In Calendar, under the Month view, it will not allow me to select a date in the current week (or the second Week dates in ANY Month for that matter i.e. 6-8-08 th
-
User exit or BADI for purchase order
Hi, I want send outbound IDOC for purchase order to 3rd party integration system. It is too hard to map between standard purchase order IDOC and business object of 3rd party system because the structure of standard purchase order IDOC is so complicat
-
How to handle OnInputProcessing in a page from an another page
Hi All, can someone help me? I have a bsp page with 2 frames. Frame1 contains a button. On pushing this button, i want to handle page2 OnInputProcessing event (without passing by OnInitialization) How can i do that ? Edited by: geek nadine on May 3,
-
IPhoto '09 won't recognize .jpg images for importing.
The resulting pop-up window displays the otherwise normal images as Unix Executable Files. If I convert the .jpg to .jpg 2000, then it imports with no problems. Result is a MUCH larger file. Any fixes?
-
What app would I use to create an online report like this?
What Adobe CC app would I use to create a web based report like this? http://sowc2015.unicef.org Could it be done with Muse or does it need something like Dreamweaver and bespoke coding?