Tuning an SQL query on a view
Hi
I have an SQL that has poor performance when querying a 3 table view.
I have tried to tune the view by adding an additional index but the EXPLAIN plan does not change. In fact, the plan is ONLY using fields specified in the the views join conditions and not the WHERE clause.
I have created an index EKET~Z1 with the column for table (T003)
EINDT
and I have also tried another index EKKO~Z2 with the columns for table T001
BSART
BSTYP
EKORG
The query is as follows:
SQL Statement
SELECT
"MANDT" , "EBELN" , "EBELP" , "ETENR" , "EKKO_LOEKZ" , "BSTYP" ,
"BSART" , "BUKRS" , "EKORG" , "EKGRP" , "STATU" , "AEDAT" , "ERNAM" ,
"BEDAT" , "LIFNR" , "ADRNR" , "WAERS" , "EKPO_LOEKZ" , "EKPO_BSTYP" ,
"TXZ01" , "MATNR" , "EMATN" , "WERKS" , "MATKL" , "IDNLF" , "MENGE" ,
"MEINS" , "NETPR" , "NETWR" , "PSTYP" , "KNTTP" , "WEPOS" , "ANFNR" ,
"PRDAT" , "KONNR" , "KTPNR" , "ELIKZ" , "EREKZ" , "EINDT" , "SLFDT" ,
"LPEIN" , "EKET_MENGE" , "EKET_WEMNG" , "BANFN" , "BNFPO" , "MBDAT" ,
"WADAT" , "WEBRE" , "FRGRL" , "ZZKONNR" , "ZZKTPNR" , "MAHNZ" ,
"MAHN1" , "MAHN2" , "MAHN3" , "INFNR"
FROM
"ZPO_DETAIL"
WHERE
"MANDT" = ? AND "EKORG" = ? AND "BSTYP" = ? AND "BSART" = ? AND
"WERKS" = ? AND "EINDT" < ? AND "EKPO_LOEKZ" <> ? AND "ELIKZ" <> ?
ORDER BY
"EBELN" , "EBELP" , "ETENR"
VIEW DETAILS
CREATE VIEW ZPO_DETAIL
(MANDT,
EBELN,
EBELP,
ETENR,
EKKO_LOEKZ,
BSTYP,
BSART,
BUKRS,
EKORG,
EKGRP,
STATU,
AEDAT,
ERNAM,
BEDAT,
LIFNR,
ADRNR,
WAERS,
EKPO_LOEKZ,
EKPO_BSTYP,
TXZ01,
MATNR,
EMATN,
WERKS,
MATKL,
IDNLF,
MENGE,
MEINS,
NETPR,
NETWR,
PSTYP,
KNTTP,
WEPOS,
ANFNR,
PRDAT,
KONNR,
KTPNR,
ELIKZ,
EREKZ,
EINDT,
SLFDT,
LPEIN,
EKET_MENGE,
EKET_WEMNG,
BANFN,
BNFPO,
MBDAT,
WADAT,
WEBRE,
FRGRL,
ZZKONNR,
ZZKTPNR,
MAHNZ,
MAHN1,
MAHN2,
MAHN3 )
AS SELECT
T0003."MANDT",
T0003."EBELN",
T0003."EBELP",
T0001."ETENR",
T0002."LOEKZ",
T0002."BSTYP",
T0002."BSART",
T0002."BUKRS",
T0002."EKORG",
T0002."EKGRP",
T0002."STATU",
T0002."AEDAT",
T0002."ERNAM",
T0002."BEDAT",
T0002."LIFNR",
T0002."ADRNR",
T0002."WAERS",
T0003."LOEKZ",
T0003."BSTYP",
T0003."TXZ01",
T0003."MATNR",
T0003."EMATN",
T0003."WERKS",
T0003."MATKL",
T0003."IDNLF",
T0003."MENGE",
T0003."MEINS",
T0003."NETPR",
T0003."NETWR",
T0003."PSTYP",
T0003."KNTTP",
T0003."WEPOS",
T0003."ANFNR",
T0003."PRDAT",
T0003."KONNR",
T0003."KTPNR",
T0003."ELIKZ",
T0003."EREKZ",
T0001."EINDT",
T0001."SLFDT",
T0001."LPEIN",
T0001."MENGE",
T0001."WEMNG",
T0001."BANFN",
T0001."BNFPO",
T0001."MBDAT",
T0001."WADAT",
T0003."WEBRE",
T0002."FRGRL",
T0003."ZZKONNR",
T0003."ZZKTPNR",
T0003."MAHNZ",
T0003."MAHN1",
T0003."MAHN2",
T0003."MAHN3"
FROM
SAPCEP."EKET" T0001,
SAPCEP."EKKO" T0002,
SAPCEP."EKPO" T0003
WHERE
T0002."MANDT" = T0003."MANDT" AND
T0002."EBELN" = T0003."EBELN" AND
T0003."MANDT" = T0001."MANDT" AND
T0003."EBELN" = T0001."EBELN" AND
T0003."EBELP" = T0001."EBELP"
EXPLAIN PLAN
Execution Plan for SQL Optimizer
TABLENAME COLUMN OR INDEX STRATEGY PAGECOUNT
T0003 RANGE CONDITION FOR KEY 15758
MANDT (USED KEY COLUMN)
T0001 JOIN VIA MULTIPLE KEY COLUMNS 8632
MANDT (USED KEY COLUMN)
EBELN (USED KEY COLUMN)
T0002 JOIN VIA MULTIPLE KEY COLUMNS 40109
MANDT (USED KEY COLUMN)
EBELN (USED KEY COLUMN)
EBELP (USED KEY COLUMN)
NO TEMPORARY RESULTS CREATED
SHOW RESULT IS COPIED , COSTVALUE IS 31186
SHOW QUERYREWRITE - APPLIED RULES:
SHOW MergeFromSelectOrView 1
The statistics are up-to-date.
Any tips would be welcome.
Thanks
Doug
> I have created an index EKET~Z1 with the column for table (T003)
> EINDT
>
> and I have also tried another index EKKO~Z2 with the columns for table T001
> BSART
> BSTYP
> EKORG
>
SQL Statement
>
> SELECT
> "MANDT" , "EBELN" , "EBELP" , "ETENR" , "EKKO_LOEKZ" , "BSTYP" ,
> FROM
> "ZPO_DETAIL"
> WHERE
> "MANDT" = ? AND "EKORG" = ? AND "BSTYP" = ? AND "BSART" = ? AND
> "WERKS" = ? AND "EINDT" < ? AND "EKPO_LOEKZ" <> ? AND "ELIKZ" <> ?
> ORDER BY
> "EBELN" , "EBELP" , "ETENR"
>
> EXPLAIN PLAN
> -
>
> Execution Plan for SQL Optimizer
>
> TABLENAME COLUMN OR INDEX STRATEGY PAGECOUNT
>
> T0003 RANGE CONDITION FOR KEY 15758
> MANDT (USED KEY COLUMN)
>
> T0001 JOIN VIA MULTIPLE KEY COLUMNS 8632
> MANDT (USED KEY COLUMN)
> EBELN (USED KEY COLUMN)
>
> T0002 JOIN VIA MULTIPLE KEY COLUMNS 40109
> MANDT (USED KEY COLUMN)
> EBELN (USED KEY COLUMN)
> EBELP (USED KEY COLUMN)
>
> NO TEMPORARY RESULTS CREATED
> SHOW RESULT IS COPIED , COSTVALUE IS 31186
> SHOW QUERYREWRITE - APPLIED RULES:
> SHOW MergeFromSelectOrView 1
>
>
> The statistics are up-to-date.
> Any tips would be welcome.
Hi Doug,
here we go...
What MaxDB version are you using? Did you check whether the DB parameters all comply to the recommendations?
If so, what are the cardinalities of the columns you indexed (a.k.a. how many different values do each of them contain?)
If the specification of BSART, BSTYP and EKORG does not reduce the number of rows to be retrieved to a large extent, then the indexaccess is likely to produce additional work.
Anyhow, the join order looks a bit odd here - this might be the problem caused by having set OPTIMIZE_OPERATOR_JOIN_COSTFUNC = YES in a MaxDB version between 7.6.04 and 7.6.06.
So make sure it's set to NO (see note 814704 MaxDB Version 7.6 parameter settings for OLTP/BW).
regards,
Lars
Similar Messages
-
Need help with SQL Query with Inline View + Group by
Hello Gurus,
I would really appreciate your time and effort regarding this query. I have the following data set.
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
Please Ignore '----', added it for clarity
I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
The query should return the following data set
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
The following is my query. I am kind of lost.
select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
from (
select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
from INVOICE
group by sequence_id,check_date, check_number, invoice_number, vendor_number
) A, INVOICE B
where A.sequence_id = B.sequence_id
Thanks,
NickIt looks like it is a duplicate thread - correct me if i'm wrong in this case ->
Need help with SQL Query with Inline View + Group by
Regards.
Satyaki De. -
Passing an argument in the SQL Query of a View Object
Hi,
It is possible that this question has been asked before, however I have searched for a half an hour in the forums and couldn't find a solution.
I am also new to using JDeveloper and ADF. Here's the situation:
I am developing an application that doesn't have to do anything else then displaying data from a database. Pretty straightforward actually.
Now I have made a vew pages with several collapsible panels (af:showDetailHeader) and have setup the datasources (or so I thought).
All that remains is:
- drag & drop a view object, from the application module that I created, onto the collabsible panels, so a child element gets created which displays data from the database.
- hack the layout so it looks like I want it to.
The problem that I have is the following:
I am using a 'User'-class that contains values I need when quering the database.
That User-object is part of a user-session.
What I want, for example, is to use the 'getPersonId()' function of that User-object and pass the argument to a SQL-query of a certain view-object.
The query would become something like:
'SELECT * FROM people WHERE people.personId = :someNumber'.
Now I've read some stuff about variable binding, which is complemented by something like (backing bean code):
getDBTransaction().getRootApplicationModule().getACertainViewObject().setWhereClauseParameter(1, user.getPersonId());
The examples I have found that might match my wishes are not using business components, but EJB's. I am having difficulty with understanding the 'how'-part of variable binding.
Also, I do not know enough of ADF to be able to create a situation like:
'User loads page, collapsible panel 1 is fully shown, the others are undisclosed.'
(meaning, that for panel1 a query has been executed.)
'User clicks on collapsible panel 2 which triggers a backingbean that somehow retrieves data from a view object'.
I would appreciate any help that somebody can give.
If it is not too much of a problem, please provide code snippets in case you have a solution. I am new to ADF :(.
-edit
I am using JDeveloper 10.1.3.3.0 in case that is of any importance.
Message was edited by:
Hugo BoogHello Stijn,
I didn't think about a referenced bean rule in the faces-config.
I added it right away and I am now able to set parameters of a View-object, not using a page button and before the page loads. You made my day!
In case anyone ever reads this post again, the summary of how to generate a table based on a View-object using dynamic parameters.:
1a: Go to faces-config.xml -> Overview tab'
1b: Go to the menuitem "Referenced Beans"
1c: Click on 'new' and select the existing bean you want to access data from and input a name. In this example I use name="user"
2: Create a View-object using the wizard.
2a: Specify the query you want in the menuitem 'SQL Statement'.
Add the 'parameters' you want to. You will have something like:
"SELECT * FROM someTable WHERE table.columnname LIKE :someArgument".
- hint: if you want the result to become something like:
"SELECT * FROM someTable WHERE table.columnname LIKE '%someArgument%'" then you have to add the '%'-characters in your code itself (read: someClass.setParameter("%" + someArgument);).
2b: In the menuitem 'Bind Variables' you have to add the variables you are referring to in the query. If you look at the query in 2a, then you have to add a variable with name "someArgument".
2c: Add the View-object to a Application Module (create one if nessecairy).
3a: Open a .jsp(x) file. Drag the View-object created in step 2 from the 'Data Controls'-pane to the page.
3b: Click on the '+' of the View-object in the 'Data Controls'-pane and open 'Operations' and drag 'ExecuteWithParams' to your page as a button.
3c: We do not want to use a button, the action has to be executed immediatly. So In the page source remove the lines that were created after dropping 'ExecuteWithParams'.
3d: Right-click on the page and select "Go to Page Definition".
3e: Go to the action id that is called 'ExecuteWithParams#', where # is a number.
Change the id to something useful.
3f: Change the NDValue so it corresponds with the value you want.
Example:
<action id="getAddressData" IterBinding="AddressesView1Iterator"
InstanceName="MyHRServiceModuleDataControl.AddressView1"
DataControl="MyHRServiceModuleDataControl" RequiresUpdateModel="true" Action="95">
<NamedData NDName="someArgument" NDType="java.lang.String"
NDValue="#{user.personId}"/>
</action>
Note: It is possible to use the value of a Backing Bean in NDValue.
Note 2: user is the bean I referred to in the faces-config.xml!
3g: Under the executables item, add an 'invokeAction' to pass the parameter to the View-object before your JSP-file loads:
<executables>
<invokeAction Binds="getAddressData"
id="loadAddressDataOfPersonIdInSession"
Refresh="prepareModel"/>
Thank Stijn Haus for this :) -
Using IN keyword in an sql query in a view criteria
Hi,
I am using jdev 11.1.1.1.0 and defined an lov query/viewobject as
select a, b, c from myTable
I now need to predefine filtering for lov search functionality and need something like the following
select a, B, c from myTable where B in ('X','Y')
I could not find a way to do it (i.e. specify the use of IN Keyword) in the Create View Criteria dialog box. I tried to define OR, but is that the best way to redefine IN as i have a long list (the above is just an example)
(( ( (UPPER(B_FLAG) = UPPER('X') ) ) OR ( (UPPER(DISPLAY_FLAG) = UPPER('Y') ) ) ))If you know how many variables are in your "in" You can just write this in the sql query of your VO:
http://www.oracle.com/technology/obe/obe11jdev/ps1/ria_application/images/t136.gif
From this tutorial:
http://www.oracle.com/technology/obe/obe11jdev/ps1/ria_application/developriaapplication_long.htm#ah1 -
Dear Guru,
We are facing a issue in performance part, we have a view as below and taking 9 minutes to throw output when try to query the below view.
let us know your valuable suggestion ASAP
CREATE OR REPLACE VIEW VW_WUF_HISTORY
(SPR, JOB_REFERENCE, JOB_CROSS_REFERENCE, JOB_TYPE_CODE, JOB_STATUS,
JOB_STATUS_REASON_CODE, FLOW_CREATED_DATE, FILE_CREATED_DATE, PROCESS_ID, WUF_FLOW_TYPE,
ADDITIONAL_INFORMATION, DATE_OF_ACTION, APPOINTMENT_DATE, APPOINTMENT_TIME_CODE, EARLIEST_APPOINTMENT_TIME,
LATEST_APPOINTMENT_TIME)
AS
SELECT SPR ,
JOB_REFERENCE ,
JOB_CROSS_REFERENCE ,
JOB_TYPE_CODE ,
JOB_STATUS ,
JOB_STATUS_REASON_CODE ,
FLOW_CREATED_DATE ,
FILE_CREATED_DATE ,
NVL(PROCESS_ID, USER_ID) PROCESS_ID,
WUF_FLOW_TYPE ,
ADDITIONAL_INFORMATION ,
DECODE(DATE_OF_ACTION, NULL,DATE_OF_ACTION, TO_DATE((TO_CHAR(DATE_OF_ACTION,'DD/MM/YYYY') ||' '|| RPAD(TIME_OF_ACTION,6,0)), 'DD/MM/YYYY HH24:MI:SS')) DATE_OF_ACTION,
APPOINTMENT_DATE ,
APPOINTMENT_TIME_CODE ,
EARLIEST_APPOINTMENT_TIME ,
LATEST_APPOINTMENT_TIME
FROM AR_FILE_COMPARE
WHERE FLOW_REF IN ('D2033001')
AND WUF_FLOW_TYPE IN ('N', 'R')
UNION ALL
SELECT SPR ,
JOB_REFERENCE ,
JOB_CROSS_REFERENCE ,
JOB_TYPE_CODE ,
JOB_STATUS ,
JOB_STATUS_REASON_CODE ,
FLOW_CREATED_DATE ,
FILE_CREATED_DATE ,
NVL(PROCESS_ID, USER_ID) PROCESS_ID ,
WUF_FLOW_TYPE ,
ADDITIONAL_INFORMATION ,
DECODE(DATE_OF_ACTION, NULL,DATE_OF_ACTION, TO_DATE((TO_CHAR(DATE_OF_ACTION,'DD/MM/YYYY') ||' '|| RPAD(TIME_OF_ACTION,6,0)), 'DD/MM/YYYY HH24:MI:SS')) DATE_OF_ACTION,
APPOINTMENT_DATE ,
APPOINTMENT_TIME_CODE ,
EARLIEST_APPOINTMENT_TIME ,
LATEST_APPOINTMENT_TIME
FROM TR_OFILE_COMPARE
WHERE FLOW_REF IN ('D2033001')
AND WUF_FLOW_TYPE IN ('N', 'R')
UNION ALL
SELECT
A.SPR ,
A.JOB_REFERENCE ,
A.JOB_CROSS_REFERENCE ,
A.JOB_TYPE_CODE ,
A.JOB_STATUS ,
A.JOB_STATUS_REASON_CODE ,
A.CREATED_DATE FLOW_CREATED_DATE,
NULL FILE_CREATED_DATE,
NVL(PROCESS_ID, USER_ID) PROCESS_ID ,
A.WUF_FLOW_TYPE ,
A.ADDITIONAL_INFORMATION ,
DECODE(B.DATE_OF_ACTION, NULL,B.DATE_OF_ACTION, TO_DATE((TO_CHAR(B.DATE_OF_ACTION,'DD/MM/YYYY') ||' '|| RPAD(B.TIME_OF_ACTION,6,0)), 'DD/MM/YYYY HH24:MI:SS')) DATE_OF_ACTION,
C.APPOINTMENT_DATE ,
C.APPOINTMENT_TIME_CODE ,
C.EARLIEST_APPOINTMENT_TIME ,
C. LATEST_APPOINTMENT_TIME
FROM TR_WUF_JOB_DETAIL A ,
TR_WUF_JOB_VISIT B ,
TR_WUF_NEW_APPT C
WHERE A.SPR = B.SPR (+)
AND A.SPR = C.SPR (+)
AND A.JOB_REFERENCE = B.JOB_REFERENCE (+)
AND A.JOB_REFERENCE = C.JOB_REFERENCE (+)
AND A.CREATED_DATE = B.CREATED_DATE (+)
AND A.CREATED_DATE = C.CREATED_DATE (+)
AND A.EXCEP_CODE IS NULL
AND WUF_FLOW_TYPE IN ('N', 'R')
/What were you expecting the response time to be?
Maybe 9 minutes is excellent.Yes 9 minutes is excellent!
With 9 minuts I wouldn't been able to read half of it. -
Tuning SQL Query calling multiple views
Dear All,
I have a complex scenario in which I have created views in 3 levels for sales and Service separately so total no of views are 6.
Level 2 calls view in Level 1 and Level 3 calls level 2 in sales as well as services.
Finally Level 4 has the union of sales and Service Level 3 view.
There are 5 tables used in total and all have been indexed for better performance.
The cube processing for the above scenario has processing time of 6 mins.
The goal is to bring it down to 2-3 mins.
The amount of data currently we are looking at is not more than 2-3 GB.
Can anybody help me fine tune this scenario?
Thanks, Franco.Run the queries the cube is using in SSMS and turn on the Include Actual Execution Plan option.
https://msdn.microsoft.com/en-us/library/ms189562.aspx?f=255&MSPPError=-2147217396
Straight up it may suggest missing indexes which you can test to see if they improve the query performance. You can't take these suggestions as gospel - sometimes SQL Server gets it wrong - so you need to test them.
After that look in the query plan for any table scan operators. Unless you are actually retrieving every row in a table you shouldn't have any of these and they can probably be removed by placing a properly considered index on the table.
After that look for any RID Lookups or Key Lookups. These can generally be resolved fairly easily by adding the columns being looked up as "include" columns in the indexes.
Here are some links that might get you started.
Reading Execution Plans: http://www.mssqltips.com/sqlservertip/1873/how-to-read-sql-server-graphical-query-execution-plans/
Resolving Table Scans http://blog.sqlauthority.com/2007/03/30/sql-server-index-seek-vs-index-scan-table-scan/
Resolving Lookups: http://blog.sqlauthority.com/2009/11/09/sql-server-removing-key-lookup-seek-predicate-predicate-an-interesting-observation-related-to-datatypes/
Those are the obvious things - and generally the easiest to achieve. Performance tuning is a big area. It may be that the database queries are already performing perfectly well and the time being spent is processing the cube itself so you need
to establish where the time is going. There is no point trying to tune the database queries if they are already working well.
LucasF -
Performance tuning in SQL query using join of views
Hi,
Am trying to tune a query of the format
select ........ from view1,view2
where view1.keyfield = view2.keyfield
The base tables of the views view1 and view2 have indexes specified on 'keyfield'.
However, when I do an explain plan of the query, Full table scan of those base tables are performed.
Even tried using Hints in this query to force Oracle to use those indexes, but still not successful.
Any pointers on how to tune this kind of query would be highly welcome.
Regards,
BaishIf your query is really of the same form as you posted, then full table scans then a hash or merge join may be the most efficient plan.
You are asking for all of the rows from view1 and the matching rows from view2, because of this, Oracle dedcided that the cost of full table scans using multi-block reads is cheaper than using single block reads to get the rowids from the index, then single block reads to get the rows from the table.
FULL SCAN <> BAD
John -
MS SQL query slow using view column as criteria
HI,
I am experiencing a very frustrate problem. I have 2 tables, and create a view
to union these 2 tables, when do a select on this view using the column of the
view as criteria is took more 1 minutes, but the query runs fine in Qurey Analyzer.
Anybody has the same experience? is this the problem with jdbc?I searched http://e-docs.bea.com/wls/docs70/index.html, also searched the documentation
for wls6.1, wls5.1. As you pointed I searched support site, they are all the customer
case, it's not formal documentation.
Joe Weinstein <[email protected]> wrote:
>
>
jen wrote:
Thanks. but I search on the table is fine (the same column). is thereany db setting
could be tuned? so the view is the problem? No, it's a client decision/issue. If you defined your tables to have
nvarchar columns
the jdbc driver's parameter values would be fine as-is.
I searched "useVarChars" on whole
site and can't find anything.Which site? This is a property of the weblogic.jdbc.mssqlserver4.Driver.
I just went to www.bea.com/support and entered useVarChars in the Ask
BEA
question panel and got hits...
Joe
Joe Weinstein <[email protected]> wrote:
Jen wrote:
Sorry it's my bad. I am testing on wls81, but the problems is on wls70,so they
are using different drivers.
You are the magic man. It worked on wls81 now. I am sure it will curethe problem
on wls70. Is there any documentation on this? Why it is not a problemon some
databse server? ThanksSure. The issue has to do with the MS client-DBMS protocol having evolved
from
an 8-bit (7-bit really) character representation. Now it has a newer
16-bit
way, to transfer NVARCHAR data. Java characters are all 16-bit, so
by default
a JDBC driver will send Java parameters over as NVARCHAR data. This
is
crucial
for Japanese data etc. However, once simple ASCII data is transformed
to an
NVARCHAR format, the DBMS can't directly compare it to varchar data,
or use it
in index searches. The DBMS has to convert the VARCHAR data to NVARCHAR,
but it
can't guarantee that the converted data will retain the same ordering
as the index,
so the DBMS has to do a table scan!
The properties I suggested are each driver's way of allowing you
to say "I'm
a simple American ;) I am using simple varchar data so please sendmy
java
strings that way.". This allows the DBMS to use your varchar indexes
in queries.
Joe Weinstein at BEA
Joe Weinstein <[email protected]> wrote:
Jen wrote:
It doesn't cure the problem. Here is my pool
<JDBCConnectionPool DriverName="weblogic.jdbc.sqlserver.SQLServerDriver"Name="test_pool"
Password="{3DES}fKSovViFe5kHzl/vTs0LVQ==" Properties="user=user;PortNumber=1543;useVarChars=true;ServerName=194.20.2.10;DatabaseName=devDB"
Targets="admin" TestTableName="SQL SELECT COUNT(*) FROM sysobjects"URL="jdbc:bea:sqlserver://194.20.2.10:1543"/>
Strange is some database is fine.Oh, sorry. I thought it was the older weblogic driver. Change the
useVarChars=true to sendStringParametersAsUnicode=false
Let me know... Also, I suggest changing the TestTableName to "SQL
select
1".
For MS, that will be much more efficient than involving a full count
of sysobjects!
Joe
Joe Weinstein <[email protected]> wrote:
Jen wrote:
You are right. Tadaa! Am I Kreskin, or what? ;) Here's what I recommend:
In your pool definition, for this driver add a driver property:
useVarChars=true
and let me know if it's all better.
Joe
I am using weblogic jdbc driver weblogic.jdbc.mssqlserver4.Driver.
here is the code:
getData(Connection connection, String stmt, ArrayList arguments)
PreparedStatement pStatement=null;>>>>>>>> ResultSet resultSet=null;>>>>>>>> try {>>>>>>>> pStatement = connection.prepareStatement(stmt);>>>>>>>> for (int i = 1; i <= arguments.size(); i++) {>>>>>>>> pStatement.setString(i, (String) arguments.get(i-1));>>>>>>>> resultSet = pStatement.executeQuery(); //this statement takesmore than 1
min.
Joe Weinstein <[email protected]> wrote:
Jen wrote:
HI,
I am experiencing a very frustrate problem. I have 2 tables,
and
create
a view
to union these 2 tables, when do a select on this view using
the
column
of the
view as criteria is took more 1 minutes, but the query runs
fine
in
Qurey Analyzer.
Anybody has the same experience? is this the problem with jdbc?
I have suspicions... Show me the jdbc code. I'm guessing it's
a
PreparedStatement,
and you send the search criterion column value as a parameter
you
set
with a
setString().... Let me know... (also let me know which jdbc driveryou're
using).
Joe -
Tuning the sql query when we have 30 Million records
Hi Friends,
I have query which takes around 25 to 30 Minutes to retrieve 9 Million records.
Oracle version=11.2.0.2
OS=Solaris 10 64bit
query details
CREATE OR REPLACE VIEW TIBEX_ORDERSBYQSIDVIEW
AS
SELECT A."ORDERID", A."USERORDERID", A."ORDERSIDE", A."ORDERTYPE",
A.ORDERSTATUS, A.BOARDID, A.TIMEINFORCE, A.INSTRUMENTID,
A.REFERENCEID, A.PRICETYPE, A.PRICE, A.AVERAGEPRICE,
A.QUANTITY, A.MINIMUMFILL, A.DISCLOSEDQTY, A.REMAINQTY,
A.AON, A.PARTICIPANTID, A.ACCOUNTTYPE, A.ACCOUNTNO,
A.CLEARINGAGENCY, A.LASTINSTRESULT, A.LASTINSTMESSAGESEQUENCE,
A.LASTEXECUTIONID, A.NOTE, A.TIMESTAMP, A.QTYFILLED, A.MEID,
A.LASTINSTREJECTCODE, A.LASTEXECPRICE, A.LASTEXECQTY,
A.LASTINSTTYPE, A.LASTEXECUTIONCOUNTERPARTY, A.VISIBLEQTY,
A.STOPPRICE, A.LASTEXECCLEARINGAGENCY, A.LASTEXECACCOUNTNO,
A.LASTEXECCPCLEARINGAGENCY, A.MESSAGESEQUENCE,
A.LASTINSTUSERALIAS, A.BOOKTIMESTAMP, A.PARTICIPANTIDMM,
A.MARKETSTATE, A.PARTNEREXID, A.LastExecSETTLEMENTCYCLE,
A.LASTEXECPOSTTRADEVENUETYPE, A.PRICELEVELPOSITION,
A.PREVREFERENCEID, A.EXPIRYTIMESTAMP, matchType,
a.lastExecutionRole, a.MDEntryID, a.PegOffset,
a.haltReason, A.COMPARISONPRICE, A.ENTEREDPRICETYPE,
A.ISPEX, A.CLEARINGHANDLING, B.qsid
FROM tibex_Order A,
tibex_Participant b
WHERE a.participantID = b.participantID
AND (A.MessageSequence, A.OrderID) IN (
SELECT max(C.MessageSequence), C.OrderID
FROM tibex_Order C
WHERE LastInstRejectCode = 'OK'
GROUP By C.OrderID
AND a.OrderStatus IN (
SELECT OrderStatus
FROM tibex_orderStatusEnum
WHERE ShortDesc IN (
'ORD_OPEN', 'ORD_EXPIRE', 'ORD_CANCEL', 'ORD_FILLED','ORD_CREATE','ORD_PENDAMD','ORD_PENDCAN'
UNION ALL
SELECT A.ORDERID, A.USERORDERID, A.ORDERSIDE, A.ORDERTYPE,
A.ORDERSTATUS, A.BOARDID, A.TIMEINFORCE, A.INSTRUMENTID,
A.REFERENCEID, A.PRICETYPE, A.PRICE, A.AVERAGEPRICE,
A.QUANTITY, A.MINIMUMFILL, A.DISCLOSEDQTY, A.REMAINQTY,
A.AON, A.PARTICIPANTID, A.ACCOUNTTYPE, A.ACCOUNTNO,
A.CLEARINGAGENCY, A.LASTINSTRESULT, A.LASTINSTMESSAGESEQUENCE,
A.LASTEXECUTIONID, A.NOTE, A.TIMESTAMP, A.QTYFILLED, A.MEID,
A.LASTINSTREJECTCODE, A.LASTEXECPRICE, A.LASTEXECQTY,
A.LASTINSTTYPE, A.LASTEXECUTIONCOUNTERPARTY, A.VISIBLEQTY,
A.STOPPRICE, A.LASTEXECCLEARINGAGENCY, A.LASTEXECACCOUNTNO,
A.LASTEXECCPCLEARINGAGENCY, A.MESSAGESEQUENCE,
A.LASTINSTUSERALIAS, A.BOOKTIMESTAMP, A.PARTICIPANTIDMM,
A.MARKETSTATE, A.PARTNEREXID, A.LastExecSETTLEMENTCYCLE,
A.LASTEXECPOSTTRADEVENUETYPE, A.PRICELEVELPOSITION,
A.PREVREFERENCEID, A.EXPIRYTIMESTAMP, matchType,
a.lastExecutionRole, A.MDEntryID, a.PegOffset,
a.haltReason, A.COMPARISONPRICE, A.ENTEREDPRICETYPE,
A.ISPEX, A.CLEARINGHANDLING, B.qsid
FROM tibex_Order A,
tibex_Participant b
WHERE a.participantID = b.participantID
AND orderstatus in (
SELECT orderstatus
FROM tibex_orderStatusEnum
WHERE ShortDesc in ('ORD_REJECT')
AND 1 IN (
SELECT count(*)
FROM tibex_order c
WHERE c.orderid=a.orderid
AND c.instrumentID=a.instrumentID
/Tried by modifying the query but same result was not retrieved but it was Quicker 6 min.Can Somebody check where i am going wrong.
CREATE OR REPLACE VIEW TIBEX_ORDERSBYQSIDVIEW
AS
WITH REJ AS
SELECT ROWID RID
FROM TIBEX_ORDER
WHERE ORDERSTATUS = (SELECT ORDERSTATUS
FROM TIBEX_ORDERSTATUSENUM
WHERE SHORTDESC = 'ORD_REJECT')
REJ1 AS
SELECT ROWID RID
FROM TIBEX_ORDER
WHERE ORDERSTATUS NOT IN (SELECT ORDERSTATUS
FROM TIBEX_ORDERSTATUSENUM
WHERE SHORTDESC = 'ORD_NOTFND'
OR SHORTDESC = 'ORD_REJECT')
SELECT O.*,
P.QSID
FROM TIBEX_ORDER O,
TIBEX_PARTICIPANT P
WHERE O.PARTICIPANTID = P.PARTICIPANTID
AND O.ROWID IN (
SELECT RID
FROM (
SELECT ROWID RID,
ORDERSTATUS,
RANK () OVER (PARTITION BY ORDERID ORDER BY MESSAGESEQUENCE ASC) R
FROM TIBEX_ORDER
WHERE R = 1
AND RID IN (SELECT RID FROM REJ)
UNION ALL
SELECT O.*,
P.QSID
FROM TIBEX_ORDER O,
TIBEX_PARTICIPANT P
WHERE O.PARTICIPANTID = P.PARTICIPANTID
AND O.ROWID IN (
SELECT RID
FROM (
SELECT ROWID RID,
ORDERSTATUS,
RANK () OVER (PARTITION BY ORDERID ORDER BY MESSAGESEQUENCE DESC) R
FROM TIBEX_ORDER
WHERE R = 1
AND RID IN (SELECT RID FROM REJ1)
);Regards
NMHi Satish,
CREATE OR REPLACE VIEW TIBEX_ORDERSBYQSIDVIEW
(ORDERID, USERORDERID, ORDERSIDE, ORDERTYPE, ORDERSTATUS,
BOARDID, TIMEINFORCE, INSTRUMENTID, REFERENCEID, PRICETYPE,
PRICE, AVERAGEPRICE, QUANTITY, MINIMUMFILL, DISCLOSEDQTY,
REMAINQTY, AON, PARTICIPANTID, ACCOUNTTYPE, ACCOUNTNO,
CLEARINGAGENCY, LASTINSTRESULT, LASTINSTMESSAGESEQUENCE, LASTEXECUTIONID, NOTE,
TIMESTAMP, QTYFILLED, MEID, LASTINSTREJECTCODE, LASTEXECPRICE,
LASTEXECQTY, LASTINSTTYPE, LASTEXECUTIONCOUNTERPARTY, VISIBLEQTY, STOPPRICE,
LASTEXECCLEARINGAGENCY, LASTEXECACCOUNTNO, LASTEXECCPCLEARINGAGENCY, MESSAGESEQUENCE, LASTINSTUSERALIAS,
BOOKTIMESTAMP, PARTICIPANTIDMM, MARKETSTATE, PARTNEREXID, LASTEXECSETTLEMENTCYCLE,
LASTEXECPOSTTRADEVENUETYPE, PRICELEVELPOSITION, PREVREFERENCEID, EXPIRYTIMESTAMP, MATCHTYPE,
LASTEXECUTIONROLE, MDENTRYID, PEGOFFSET, HALTREASON, COMPARISONPRICE,
ENTEREDPRICETYPE, ISPEX, CLEARINGHANDLING, QSID)
AS
SELECT A."ORDERID", A."USERORDERID", A."ORDERSIDE", A."ORDERTYPE",
A.ORDERSTATUS, A.BOARDID, A.TIMEINFORCE, A.INSTRUMENTID,
A.REFERENCEID, A.PRICETYPE, A.PRICE, A.AVERAGEPRICE,
A.QUANTITY, A.MINIMUMFILL, A.DISCLOSEDQTY, A.REMAINQTY,
A.AON, A.PARTICIPANTID, A.ACCOUNTTYPE, A.ACCOUNTNO,
A.CLEARINGAGENCY, A.LASTINSTRESULT, A.LASTINSTMESSAGESEQUENCE,
A.LASTEXECUTIONID, A.NOTE, A.TIMESTAMP, A.QTYFILLED, A.MEID,
A.LASTINSTREJECTCODE, A.LASTEXECPRICE, A.LASTEXECQTY,
A.LASTINSTTYPE, A.LASTEXECUTIONCOUNTERPARTY, A.VISIBLEQTY,
A.STOPPRICE, A.LASTEXECCLEARINGAGENCY, A.LASTEXECACCOUNTNO,
A.LASTEXECCPCLEARINGAGENCY, A.MESSAGESEQUENCE,
A.LASTINSTUSERALIAS, A.BOOKTIMESTAMP, A.PARTICIPANTIDMM,
A.MARKETSTATE, A.PARTNEREXID, A.LastExecSETTLEMENTCYCLE,
A.LASTEXECPOSTTRADEVENUETYPE, A.PRICELEVELPOSITION,
A.PREVREFERENCEID, A.EXPIRYTIMESTAMP, matchType,
a.lastExecutionRole, a.MDEntryID, a.PegOffset,
a.haltReason, A.COMPARISONPRICE, A.ENTEREDPRICETYPE,
A.ISPEX, A.CLEARINGHANDLING, B.qsid
FROM tibex_Order A,
tibex_Participant b
WHERE a.participantID = b.participantID
AND (A.MessageSequence, A.OrderID) IN ( SELECT MAX (C.MessageSequence), C.OrderID
FROM tibex_Order C
WHERE c.LastInstRejectCode = 'OK'
and a.OrderID=c.OrderID
GROUP BY C.OrderID)
AND a.OrderStatus IN (2,4,5,6,1,9,10)
UNION ALL
SELECT A.ORDERID, A.USERORDERID, A.ORDERSIDE, A.ORDERTYPE,
A.ORDERSTATUS, A.BOARDID, A.TIMEINFORCE, A.INSTRUMENTID,
A.REFERENCEID, A.PRICETYPE, A.PRICE, A.AVERAGEPRICE,
A.QUANTITY, A.MINIMUMFILL, A.DISCLOSEDQTY, A.REMAINQTY,
A.AON, A.PARTICIPANTID, A.ACCOUNTTYPE, A.ACCOUNTNO,
A.CLEARINGAGENCY, A.LASTINSTRESULT, A.LASTINSTMESSAGESEQUENCE,
A.LASTEXECUTIONID, A.NOTE, A.TIMESTAMP, A.QTYFILLED, A.MEID,
A.LASTINSTREJECTCODE, A.LASTEXECPRICE, A.LASTEXECQTY,
A.LASTINSTTYPE, A.LASTEXECUTIONCOUNTERPARTY, A.VISIBLEQTY,
A.STOPPRICE, A.LASTEXECCLEARINGAGENCY, A.LASTEXECACCOUNTNO,
A.LASTEXECCPCLEARINGAGENCY, A.MESSAGESEQUENCE,
A.LASTINSTUSERALIAS, A.BOOKTIMESTAMP, A.PARTICIPANTIDMM,
A.MARKETSTATE, A.PARTNEREXID, A.LastExecSETTLEMENTCYCLE,
A.LASTEXECPOSTTRADEVENUETYPE, A.PRICELEVELPOSITION,
A.PREVREFERENCEID, A.EXPIRYTIMESTAMP, matchType,
a.lastExecutionRole, A.MDEntryID, a.PegOffset,
a.haltReason, A.COMPARISONPRICE, A.ENTEREDPRICETYPE,
A.ISPEX, A.CLEARINGHANDLING, B.qsid
FROM tibex_Order A,
tibex_Participant b
WHERE a.participantID = b.participantID
AND orderstatus=3
AND 1 IN (
SELECT count(*)
FROM tibex_order c
WHERE c.orderid=a.orderid
AND c.instrumentID=a.instrumentID
select * from TIBEX_ORDERSBYQSIDVIEW where participantid='NITE';
Current SQL using Temp Segment and Look for Column TEMPSEG_SIZE_MB
SID TIME OPERATION ESIZE MEM MAX MEM PASS TEMPSEG_SIZE_MB
183 11/10/2011:13:38:44 HASH-JOIN 43 43 1556 1 1024
183 11/10/2011:13:38:44 GROUP BY (HASH) 2043 2072 2072 0 4541Edited by: NM on 11-Oct-2011 04:38 -
Sql Query to MVC View via LINQ
I have a Query that is returning the proper results in Sql Server View that runs the query below:
SELECT CertificateNumber, COUNT(*) AS LoginCount, InsertDate
FROM dbo.LogIns
GROUP BY CertificateNumber, InsertDate
Results:
40050004289468 1
2015-03-22
40050004417374 1
2015-03-22
40160015050974 1
2015-03-22
40250024398851 1
2015-03-22
711511 9
2015-03-22
90021255342381 6
2015-03-22
40060005110838 2
2015-03-23
40070006178842 1
2015-03-23
40070006216238 1
2015-03-23
40070006282800 1
2015-03-23
40110010957264 1
2015-03-23
40250024090870 1
2015-03-23
4045004499703 9 1
2015-03-23
711511 13
2015-03-23
I am trying to return the same results to an MVC 5 View:
I imported the view from the db:
Model:
public partial class LogInView
public string CertificateNumber { get; set; }
public Nullable<int> LoginCount { get; set; }
public Nullable<System.DateTime> InsertDate { get; set; }
Controller:
public ActionResult LoginActivity()
return View(db.LogInViews.OrderByDescending(i => i.InsertDate).ToList());
View:
@model IEnumerable<GCadmin.Models.LogInView>
ViewBag.Title = "LoginActivity";
<h2>LoginActivity</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.InsertDate)
</th>
<th>
Card Number
</th>
<th>
@Html.DisplayNameFor(model => model.LoginCount)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@item.InsertDate.Value.ToShortDateString()
</td>
<td>
@Html.DisplayFor(modelItem => item.CertificateNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.LoginCount)
</td>
</tr>
</table>
Result:
3/23/2015 40060005110838
2
3/23/2015 40070006178842
1
3/23/2015 40070006216238
1
3/23/2015 40070006282800
1
3/23/2015 40110010957264
1
3/23/2015 40250024090870
1
3/23/2015 4045004499703 9
1
3/23/2015 711511
13
3/22/2015 40050004289468
1
3/22/2015 40050004417374
1
3/22/2015 40160015050974
1
3/22/2015 40250024398851
1
3/23/2015 711511
13
3/22/2015 90021255342381
6
The 711511 on 3/23 is repeated.
I cant figure this one out.
Thanks, DougIn the listing of the original query output, might the extra space be part of the issue? (2nd from the last entry).
4045004499703 9
1 2015-03-23 -
Help with sql query on materialized view logs
I am in need of a query to find out what tablespace and snap shot site a long list of materialized view logs are associated with.
something like below except tablespace and snap_shot_site are not an option for this table.
select log_owner, master, log_table, tablespace, snap_shot_site from dba_mview_logs;What is the refresh method set as?
Could you paste the full MV log creation script and the corresponding MV creation script. -
Hi All,
I have query in using oracle report , its taking long time to run the report when we run for 1 month period , even its taking time trying with 1 or 2 days also .
below is the query , here we are using most of the VIew also , please help me how to improve the perfomance of this.what needs to concentrate mainly here . please help me out. Thanks in advance.
SELECT
pd.segment20 discipline,
ppx.employee_number,
SUBSTR (ppx.full_name, 1, 50) fullname,
pj.NAME designation,
horg.NAME department,
SUM (a.measure) hours,
d.segment1 projectnumber,
d.NAME projectname,
pat.task_name
FROM per_analysis_criteria pd,
per_people_x ppx,
per_jobs_v pj,
hr_all_organization_units horg,
hxc_time_building_blocks a,
pa_projects_all d,
pa_tasks pat,
hxc_time_attribute_usages b,
hxc_time_attributes c,
hxc_time_building_blocks DAY,
hxc_time_building_blocks TIME,
per_assignments_x pax,
hxc_timecard_summary summary,
per_person_analyses pe,
per_special_info_types_v pf
WHERE pax.organization_id = horg.organization_id
AND pd.id_flex_num = pf.id_flex_num
AND pd.analysis_criteria_id = pe.analysis_criteria_id
AND pax.job_id = pj.job_id
AND c.attribute1 = pat.project_id
AND c.attribute2 = pat.task_id
AND a.time_building_block_id = b.time_building_block_id
AND d.project_id = c.attribute1
AND pat.task_id = c.attribute2
AND b.time_attribute_id = c.time_attribute_id
AND a.parent_building_block_id = DAY.time_building_block_id
AND a.parent_building_block_ovn = DAY.object_version_number
AND DAY.parent_building_block_id = TIME.time_building_block_id
AND DAY.parent_building_block_ovn= TIME.object_version_number
AND TIME.time_building_block_id = summary.timecard_id
AND TIME.object_version_number = summary.timecard_ovn
AND a.resource_id = ppx.person_id
AND ppx.person_id = pax.person_id
AND pf.id_flex_num = pe.id_flex_num
AND pe.person_id = ppx.person_id
AND pf.business_group_id = pe.business_group_id
AND a.object_version_number = b.time_building_block_ovn
AND pax.primary_flag = 'Y'
AND summary.approval_status = 'APPROVED'
AND a.SCOPE = 'DETAIL'
AND pf.NAME = 'SEC Staff Movement'
AND c.attribute_category = 'PROJECTS'
AND d.segment1 LIKE '905%'
AND DAY.start_time >= :p_start_date
AND TRUNC (DAY.stop_time, 'DD') <= :p_end_date
AND SYSDATE BETWEEN a.date_from AND a.date_to
AND SYSDATE BETWEEN DAY.date_from AND DAY.date_to
AND SYSDATE BETWEEN TIME.date_from AND TIME.date_to
AND a.object_version_number =
(SELECT MAX (b.object_version_number)
FROM hxc_time_building_blocks b
WHERE b.time_building_block_id = a.time_building_block_id)
AND pe.date_from = (SELECT MAX (xsm.date_from)
FROM xsec_staff_movement xsm
WHERE xsm.emp_person_id = ppx.person_id)
GROUP BY pd.segment20,
ppx.employee_number,
SUBSTR (ppx.full_name, 1, 50),
pj.NAME,
horg.NAME,
d.segment1,
d.NAME,
pat.task_name
[\pre]
Thanks
RG
Message was edited by:
user549459Hi Rob , I managed to recreate the plan table and below is the out put. please help me out
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 1 | 573 | 383 |
| 1 | SORT GROUP BY | | 1 | 573 | 380 |
|* 2 | FILTER | | | | |
| 3 | NESTED LOOPS | | 1 | 573 | 355 |
| 4 | NESTED LOOPS | | 1 | 554 | 353 |
| 5 | NESTED LOOPS | | 1 | 529 | 351 |
| 6 | NESTED LOOPS | | 1 | 484 | 349 |
| 7 | NESTED LOOPS | | 1 | 461 | 348 |
| 8 | NESTED LOOPS | | 1 | 417 | 347 |
| 9 | NESTED LOOPS | | 1 | 394 | 345 |
| 10 | NESTED LOOPS | | 1 | 379 | 342 |
| 11 | NESTED LOOPS | | 1 | 328 | 181 |
| 12 | NESTED LOOPS | | 1 | 305 | 180 |
| 13 | NESTED LOOPS | | 1 | 297 | 179 |
| 14 | NESTED LOOPS | | 1 | 287 | 178 |
| 15 | NESTED LOOPS | | 1 | 256 | 177 |
| 16 | NESTED LOOPS | | 1 | 215 | 173 |
PLAN_TABLE_OUTPUT
| 17 | NESTED LOOPS | | 1 | 97 | 171 |
| 18 | NESTED LOOPS | | 1 | 71 | 169 |
|* 19 | HASH JOIN | | 1 | 59 | 5 |
| 20 | NESTED LOOPS | | 1 | 51 | 2 |
|* 21 | TABLE ACCESS BY INDEX ROWID | FND_ID_FLEX_STRUCTURES_TL | 1 | 37 | 2 |
|* 22 | INDEX RANGE SCAN | FND_ID_FLEX_STRUCTURES_TL_N1 | 1 | | 1 |
|* 23 | INDEX UNIQUE SCAN | FND_ID_FLEX_STRUCTURES_U1 | 1 | 14 | |
| 24 | TABLE ACCESS FULL | PER_SPECIAL_INFO_TYPES | 45 | 360 | 2 |
| 25 | TABLE ACCESS BY INDEX ROWID | PER_ANALYSIS_CRITERIA | 1527 | 18324 | 164 |
|* 26 | INDEX RANGE SCAN | PER_ANALYSIS_CRITERIA_N1 | 1768 | | 6 |
|* 27 | TABLE ACCESS BY INDEX ROWID | PER_PERSON_ANALYSES | 1 | 26 | 2 |
|* 28 | INDEX RANGE SCAN | PER_PERSON_ANALYSES_FK2 | 3 | | 1 |
|* 29 | TABLE ACCESS BY INDEX ROWID | PER_ALL_PEOPLE_F | 1 | 118 | 2 |
|* 30 | INDEX RANGE SCAN | PER_PEOPLE_F_PK | 1 | | 1 |
| 31 | SORT AGGREGATE | | 1 | 417 | |
| 32 | NESTED LOOPS OUTER | | 1 | 417 | 25 |
| 33 | NESTED LOOPS OUTER | | 1 | 319 | 23 |
| 34 | NESTED LOOPS OUTER | | 1 | 221 | 21 |
| 35 | NESTED LOOPS OUTER | | 1 | 217 | 21 |
| 36 | NESTED LOOPS OUTER | | 1 | 213 | 21 |
| 37 | NESTED LOOPS OUTER | | 1 | 209 | 21 |
PLAN_TABLE_OUTPUT
| 38 | NESTED LOOPS OUTER | | 1 | 205 | 21 |
|* 39 | HASH JOIN | | 1 | 201 | 21 |
| 40 | NESTED LOOPS | | 1 | 177 | 18 |
| 41 | NESTED LOOPS | | 1 | 51 | 17 |
|* 42 | TABLE ACCESS BY INDEX ROWID| PER_ALL_ASSIGNMENTS_F | 1 | 33 | 5 |
|* 43 | INDEX RANGE SCAN | PER_ASSIGNMENTS_F_N12 | 3 | | 2 |
| 44 | TABLE ACCESS BY INDEX ROWID| PER_PERSON_ANALYSES | 1 | 18 | 12 |
|* 45 | INDEX RANGE SCAN | PER_PERSON_ANALYSES_N3 | 1 | | 1 |
| 46 | TABLE ACCESS BY INDEX ROWID | PER_ANALYSIS_CRITERIA | 1 | 126 | 1 |
|* 47 | INDEX UNIQUE SCAN | PER_ANALYSIS_CRITERIA_PK | 1 | | |
|* 48 | TABLE ACCESS FULL | FND_ID_FLEX_STRUCTURES | 1 | 24 | 2 |
|* 49 | INDEX UNIQUE SCAN | PA_TASKS_U1 | 1 | 4 | |
|* 50 | INDEX UNIQUE SCAN | PA_TASKS_U1 | 1 | 4 | |
|* 51 | INDEX UNIQUE SCAN | PA_TASKS_U1 | 1 | 4 | |
|* 52 | INDEX UNIQUE SCAN | PA_PROJECTS_U1 | 1 | 4 | |
|* 53 | INDEX UNIQUE SCAN | PA_PROJECTS_U1 | 1 | 4 | |
|* 54 | TABLE ACCESS BY INDEX ROWID | PER_ALL_PEOPLE_F | 1 | 98 | 2 |
|* 55 | INDEX RANGE SCAN | PER_PEOPLE_F_PK | 1 | | 1 |
|* 56 | TABLE ACCESS BY INDEX ROWID | PER_ALL_PEOPLE_F | 1 | 98 | 2 |
|* 57 | INDEX RANGE SCAN | PER_PEOPLE_F_PK | 1 | | 1 |
|* 58 | TABLE ACCESS BY INDEX ROWID | PER_ALL_ASSIGNMENTS_F | 1 | 41 | 4 |
PLAN_TABLE_OUTPUT
|* 59 | INDEX RANGE SCAN | PER_ASSIGNMENTS_F_N12 | 3 | | 1 |
| 60 | TABLE ACCESS BY INDEX ROWID | HR_ALL_ORGANIZATION_UNITS | 1 | 31 | 1 |
|* 61 | INDEX UNIQUE SCAN | HR_ORGANIZATION_UNITS_PK | 1 | | |
| 62 | TABLE ACCESS BY INDEX ROWID | PER_JOBS | 1 | 10 | 1 |
|* 63 | INDEX UNIQUE SCAN | PER_JOBS_PK | 1 | | |
|* 64 | TABLE ACCESS BY INDEX ROWID | PER_JOB_GROUPS | 1 | 8 | 1 |
|* 65 | INDEX UNIQUE SCAN | PER_JOB_GROUPS_PK | 1 | | |
| 66 | TABLE ACCESS BY INDEX ROWID | PER_JOBS_TL | 1 | 23 | 1 |
|* 67 | INDEX UNIQUE SCAN | PER_JOBS_TL_PK | 1 | | |
|* 68 | TABLE ACCESS BY INDEX ROWID | HXC_TIME_BUILDING_BLOCKS | 8 | 408 | 161 |
|* 69 | INDEX RANGE SCAN | HXC_TIME_BUILDING_BLOCKS_FK2 | 543 | | 5 |
| 70 | TABLE ACCESS BY INDEX ROWID | HXC_TIME_ATTRIBUTE_USAGES | 1 | 15 | 3 |
|* 71 | INDEX RANGE SCAN | HXC_TIME_ATTRIBUTE_USAGES_FK2 | 1 | | 2 |
|* 72 | TABLE ACCESS BY INDEX ROWID | HXC_TIME_ATTRIBUTES | 1 | 23 | 2 |
|* 73 | INDEX UNIQUE SCAN | HXC_TIME_ATTRIBUTES_PK | 1 | | 1 |
|* 74 | TABLE ACCESS BY INDEX ROWID | PA_PROJECTS_ALL | 1 | 44 | 1 |
|* 75 | INDEX UNIQUE SCAN | PA_PROJECTS_U1 | 1 | | |
|* 76 | TABLE ACCESS BY INDEX ROWID | PA_TASKS | 1 | 23 | 1 |
|* 77 | INDEX UNIQUE SCAN | PA_TASKS_U1 | 1 | | |
|* 78 | TABLE ACCESS BY INDEX ROWID | HXC_TIME_BUILDING_BLOCKS | 1 | 45 | 2 |
|* 79 | INDEX UNIQUE SCAN | HXC_TIME_BUILDING_BLOCKS_PK | 1 | | 1 |
PLAN_TABLE_OUTPUT
|* 80 | TABLE ACCESS BY INDEX ROWID | HXC_TIME_BUILDING_BLOCKS | 1 | 25 | 2 |
|* 81 | INDEX UNIQUE SCAN | HXC_TIME_BUILDING_BLOCKS_PK | 1 | | 1 |
|* 82 | TABLE ACCESS BY INDEX ROWID | HXC_TIMECARD_SUMMARY | 1 | 19 | 2 |
|* 83 | INDEX UNIQUE SCAN | HXC_TIMECARD_SUMMARY_PK | 1 | | 1 |
| 84 | SORT AGGREGATE | | 1 | 9 | |
| 85 | FIRST ROW | | 1 | 9 | 3 |
|* 86 | INDEX RANGE SCAN (MIN/MAX) | HXC_TIME_BUILDING_BLOCKS_PK | 10M| | 3 |
Predicate Information (identified by operation id):
2 - filter("SYS_ALIAS_1"."OBJECT_VERSION_NUMBER"= (SELECT /*+ */ MAX("B"."OBJECT_VERSION_NUMBER")
"HXC"."HXC_TIME_BUILDING_BLOCKS" "B" WHERE "B"."TIME_BUILDING_BLOCK_ID"=:B1))
19 - access("X"."ID_FLEX_NUM"="B"."ID_FLEX_NUM")
21 - filter("T"."ID_FLEX_CODE"='PEA')
22 - access("T"."ID_FLEX_STRUCTURE_NAME"='SEC Staff Movement' AND "T"."LANGUAGE"=:B1)
23 - access("B"."APPLICATION_ID"="T"."APPLICATION_ID" AND "B"."ID_FLEX_CODE"="T"."ID_FLEX_CODE" AN
"B"."ID_FLEX_NUM"="T"."ID_FLEX_NUM")
filter("B"."ID_FLEX_CODE"='PEA')
26 - access("PD"."ID_FLEX_NUM"="X"."ID_FLEX_NUM")
PLAN_TABLE_OUTPUT
27 - filter("X"."ID_FLEX_NUM"="PE"."ID_FLEX_NUM" AND "X"."BUSINESS_GROUP_ID"="PE"."BUSINESS_GROUP_
28 - access("PD"."ANALYSIS_CRITERIA_ID"="PE"."ANALYSIS_CRITERIA_ID")
29 - filter(DECODE("APPS"."HR_SECURITY"."VIEW_ALL"(),'Y','TRUE',"APPS"."HR_SECURITY"."SHOW_PERSON"
ID","SYS_ALIAS_2"."CURRENT_APPLICANT_FLAG","SYS_ALIAS_2"."CURRENT_EMPLOYEE_FLAG","SYS_ALIAS_2
S_2"."EMPLOYEE_NUMBER","SYS_ALIAS_2"."APPLICANT_NUMBER","SYS_ALIAS_2"."NPW_NUMBER"))='TRUE' A
"SYS_ALIAS_2"."BUSINESS_GROUP_ID"=DECODE("APPS"."HR_GENERAL"."GET_XBG_PROFILE"(),'Y',"SYS_ALI
S"."HR_GENERAL"."GET_BUSINESS_GROUP_ID"()))
30 - access("PE"."PERSON_ID"="SYS_ALIAS_2"."PERSON_ID" AND "SYS_ALIAS_2"."EFFECTIVE_END_DATE">=TRU
"SYS_ALIAS_2"."EFFECTIVE_START_DATE"<=TRUNC(SYSDATE@!))
filter("SYS_ALIAS_2"."EFFECTIVE_START_DATE"<=TRUNC(SYSDATE@!) AND
"SYS_ALIAS_2"."EFFECTIVE_END_DATE">=TRUNC(SYSDATE@!) AND "PE"."DATE_FROM"= (SELECT /*+ */ MAX
"PA"."PA_TASKS" "PAT3","PA"."PA_TASKS" "PAT2","PA"."PA_TASKS" "PAT1","HR"."PER_ALL_PEOPLE_F"
"PAP","PA"."PA_PROJECTS_ALL" "PAP2","PA"."PA_PROJECTS_ALL" "PAP1","APPLSYS"."FND_ID_FLEX_STRU
"D","HR"."PER_ALL_ASSIGNMENTS_F" "PAA","HR"."PER_PERSON_ANALYSES" "B","HR"."PER_ANALYSIS_CRIT
"A"."ANALYSIS_CRITERIA_ID"="B"."ANALYSIS_CRITERIA_ID" AND "B"."PERSON_ID"="PAA"."PERSON_ID" A
"PAA"."PERSON_ID"=:B2 AND "PAA"."PRIMARY_FLAG"='Y' AND DECODE("APPS"."HR_SECURITY"."VIEW_ALL"
ITY"."SHOW_RECORD"('PER_ALL_ASSIGNMENTS_F',"PAA"."ASSIGNMENT_ID",TO_CHAR("PAA"."PERSON_ID"),"
' AND "PAA"."BUSINESS_GROUP_ID"=DECODE("APPS"."HR_GENERAL"."GET_XBG_PROFILE"(),'Y',"PAA"."BUS
ERAL"."GET_BUSINESS_GROUP_ID"()) AND "PAA"."EFFECTIVE_START_DATE"<=TRUNC(SYSDATE@!) AND
"PAA"."EFFECTIVE_END_DATE">=TRUNC(SYSDATE@!) AND "A"."ID_FLEX_NUM"="D"."ID_FLEX_NUM" AND
"D"."ID_FLEX_STRUCTURE_CODE"='SEC_STAFF_MOVEMENT' AND "PAP1"."PROJECT_ID"(+)=TO_NUMBER("A"."S
PLAN_TABLE_OUTPUT
"PAP2"."PROJECT_ID"(+)=TO_NUMBER("A"."SEGMENT3") AND "PAP"."PERSON_ID"(+)=TO_NUMBER("A"."SEGM
DECODE("APPS"."HR_SECURITY"."VIEW_ALL"(),'Y','TRUE',"APPS"."HR_SECURITY"."SHOW_PERSON"("PAP".
APPLICANT_FLAG"(+),"PAP"."CURRENT_EMPLOYEE_FLAG"(+),"PAP"."CURRENT_NPW_FLAG"(+),"PAP"."EMPLOY
NUMBER"(+),"PAP"."NPWNUMBER"(+)))='TRUE' AND "PAP"."BUSINESS_GROUP_ID"(+)=DECODE("APPS"."HR
'Y',"PAP"."BUSINESS_GROUP_ID"(+),"APPS"."HR_GENERAL"."GET_BUSINESS_GROUP_ID"()) AND
"PAP"."EFFECTIVE_START_DATE"(+)<=TRUNC(SYSDATE@!) AND "PAP"."EFFECTIVE_END_DATE"(+)>=TRUNC(SY
"PAP"."PERSON_ID"(+)=TO_NUMBER("A"."SEGMENT11") AND DECODE("APPS"."HR_SECURITY"."VIEW_ALL"(),
"."SHOW_PERSON"("PAP"."PERSON_ID"(+),"PAP"."CURRENT_APPLICANT_FLAG"(+),"PAP"."CURRENT_EMPLOYE
FLAG"(+),"PAP"."EMPLOYEE_NUMBER"(+),"PAP"."APPLICANT_NUMBER"(+),"PAP"."NPW_NUMBER"(+)))='TRUE
"PAP"."BUSINESS_GROUP_ID"(+)=DECODE("APPS"."HR_GENERAL"."GET_XBG_PROFILE"(),'Y',"PAP"."BUSINE
ERAL"."GET_BUSINESS_GROUP_ID"()) AND "PAP"."EFFECTIVE_START_DATE"(+)<=TRUNC(SYSDATE@!) AND
"PAP"."EFFECTIVE_END_DATE"(+)>=TRUNC(SYSDATE@!) AND "PAT1"."TASK_ID"(+)=TO_NUMBER("A"."SEGMEN
"PAT2"."TASK_ID"(+)=TO_NUMBER("A"."SEGMENT18") AND "PAT3"."TASK_ID"(+)=TO_NUMBER("A"."SEGMENT
39 - access("A"."ID_FLEX_NUM"="D"."ID_FLEX_NUM")
42 - filter("PAA"."PRIMARY_FLAG"='Y' AND DECODE("APPS"."HR_SECURITY"."VIEW_ALL"(),'Y','TRUE',"APPS
ECORD"('PER_ALL_ASSIGNMENTS_F',"PAA"."ASSIGNMENT_ID",TO_CHAR("PAA"."PERSON_ID"),"PAA"."ASSIGN
"PAA"."BUSINESS_GROUP_ID"=DECODE("APPS"."HR_GENERAL"."GET_XBG_PROFILE"(),'Y',"PAA"."BUSINESS_
"GET_BUSINESS_GROUP_ID"()))
43 - access("PAA"."PERSON_ID"=:B1 AND "PAA"."EFFECTIVE_END_DATE">=TRUNC(SYSDATE@!) AND
"PAA"."EFFECTIVE_START_DATE"<=TRUNC(SYSDATE@!))
filter("PAA"."EFFECTIVE_START_DATE"<=TRUNC(SYSDATE@!) AND "PAA"."EFFECTIVE_END_DATE">=TRUNC(S
PLAN_TABLE_OUTPUT
45 - access("B"."PERSON_ID"="PAA"."PERSON_ID")
filter("B"."PERSON_ID"=:B1)
47 - access("A"."ANALYSIS_CRITERIA_ID"="B"."ANALYSIS_CRITERIA_ID")
48 - filter("D"."ID_FLEX_STRUCTURE_CODE"='SEC_STAFF_MOVEMENT')
49 - access("PAT3"."TASK_ID"(+)=TO_NUMBER("A"."SEGMENT21"))
50 - access("PAT2"."TASK_ID"(+)=TO_NUMBER("A"."SEGMENT18"))
51 - access("PAT1"."TASK_ID"(+)=TO_NUMBER("A"."SEGMENT2"))
52 - access("PAP2"."PROJECT_ID"(+)=TO_NUMBER("A"."SEGMENT3"))
53 - access("PAP1"."PROJECT_ID"(+)=TO_NUMBER("A"."SEGMENT1"))
54 - filter(DECODE("APPS"."HR_SECURITY"."VIEW_ALL"(),'Y','TRUE',"APPS"."HR_SECURITY"."SHOW_PERSON"
PAP"."CURRENT_APPLICANT_FLAG"(+),"PAP"."CURRENT_EMPLOYEE_FLAG"(+),"PAP"."CURRENT_NPW_FLAG"(+)
AP"."APPLICANT_NUMBER"(+),"PAP"."NPW_NUMBER"(+)))='TRUE' AND "PAP"."BUSINESS_GROUP_ID"(+)=DEC
BG_PROFILE"(),'Y',"PAP"."BUSINESS_GROUP_ID"(+),"APPS"."HR_GENERAL"."GET_BUSINESS_GROUP_ID"())
55 - access("PAP"."PERSON_ID"(+)=TO_NUMBER("A"."SEGMENT11") AND "PAP"."EFFECTIVE_END_DATE"(+)>=TRU
"PAP"."EFFECTIVE_START_DATE"(+)<=TRUNC(SYSDATE@!))
filter("PAP"."EFFECTIVE_START_DATE"(+)<=TRUNC(SYSDATE@!) AND "PAP"."EFFECTIVE_END_DATE"(+)>=T
56 - filter(DECODE("APPS"."HR_SECURITY"."VIEW_ALL"(),'Y','TRUE',"APPS"."HR_SECURITY"."SHOW_PERSON"
PAP"."CURRENT_APPLICANT_FLAG"(+),"PAP"."CURRENT_EMPLOYEE_FLAG"(+),"PAP"."CURRENT_NPW_FLAG"(+)
AP"."APPLICANT_NUMBER"(+),"PAP"."NPW_NUMBER"(+)))='TRUE' AND "PAP"."BUSINESS_GROUP_ID"(+)=DEC
BG_PROFILE"(),'Y',"PAP"."BUSINESS_GROUP_ID"(+),"APPS"."HR_GENERAL"."GET_BUSINESS_GROUP_ID"())
57 - access("PAP"."PERSON_ID"(+)=TO_NUMBER("A"."SEGMENT4") AND "PAP"."EFFECTIVE_END_DATE"(+)>=TRUN
PLAN_TABLE_OUTPUT
"PAP"."EFFECTIVE_START_DATE"(+)<=TRUNC(SYSDATE@!))
filter("PAP"."EFFECTIVE_START_DATE"(+)<=TRUNC(SYSDATE@!) AND "PAP"."EFFECTIVE_END_DATE"(+)>=T
58 - filter("PAA"."PRIMARY_FLAG"='Y' AND DECODE("APPS"."HR_SECURITY"."VIEW_ALL"(),'Y','TRUE',"APPS
ECORD"('PER_ALL_ASSIGNMENTS_F',"PAA"."ASSIGNMENT_ID",TO_CHAR("PAA"."PERSON_ID"),"PAA"."ASSIGN
"PAA"."BUSINESS_GROUP_ID"=DECODE("APPS"."HR_GENERAL"."GET_XBG_PROFILE"(),'Y',"PAA"."BUSINESS_
"GET_BUSINESS_GROUP_ID"()))
59 - access("SYS_ALIAS_2"."PERSON_ID"="PAA"."PERSON_ID" AND "PAA"."EFFECTIVE_END_DATE">=TRUNC(SYSD
"PAA"."EFFECTIVE_START_DATE"<=TRUNC(SYSDATE@!))
filter("PAA"."EFFECTIVE_START_DATE"<=TRUNC(SYSDATE@!) AND "PAA"."EFFECTIVE_END_DATE">=TRUNC(S
61 - access("PAA"."ORGANIZATION_ID"="HORG"."ORGANIZATION_ID")
63 - access("PAA"."JOB_ID"="JOB"."JOB_ID")
64 - filter("JGR"."INTERNAL_NAME"='HR_'||TO_CHAR("JOB"."BUSINESS_GROUP_ID"))
65 - access("JOB"."JOB_GROUP_ID"="JGR"."JOB_GROUP_ID")
67 - access("JBT"."JOB_ID"="JOB"."JOB_ID" AND "JBT"."LANGUAGE"=:B1)
68 - filter("SYS_ALIAS_1"."PARENT_BUILDING_BLOCK_ID" IS NOT NULL AND "SYS_ALIAS_1"."PARENT_BUILDIN
NULL AND "SYS_ALIAS_1"."DATE_FROM"<=SYSDATE@! AND "SYS_ALIAS_1"."DATE_TO">=SYSDATE@!)
69 - access("SYS_ALIAS_1"."RESOURCE_ID"="SYS_ALIAS_2"."PERSON_ID" AND "SYS_ALIAS_1"."SCOPE"='DETAI
71 - access("SYS_ALIAS_1"."TIME_BUILDING_BLOCK_ID"="B"."TIME_BUILDING_BLOCK_ID" AND
"SYS_ALIAS_1"."OBJECT_VERSION_NUMBER"="B"."TIME_BUILDING_BLOCK_OVN")
72 - filter("C"."ATTRIBUTE_CATEGORY"='PROJECTS')
73 - access("B"."TIME_ATTRIBUTE_ID"="C"."TIME_ATTRIBUTE_ID")
PLAN_TABLE_OUTPUT
74 - filter("D"."SEGMENT1" LIKE '905%')
75 - access("D"."PROJECT_ID"=TO_NUMBER("C"."ATTRIBUTE1"))
76 - filter("PAT"."PROJECT_ID"=TO_NUMBER("C"."ATTRIBUTE1"))
77 - access("PAT"."TASK_ID"=TO_NUMBER("C"."ATTRIBUTE2"))
78 - filter("DAY"."PARENT_BUILDING_BLOCK_ID" IS NOT NULL AND "DAY"."PARENT_BUILDING_BLOCK_OVN" IS
"DAY"."START_TIME">=:Z AND TRUNC("DAY"."STOP_TIME",'fmdd')<=:Z AND "DAY"."DATE_FROM"<=SYSDATE
"DAY"."DATE_TO">=SYSDATE@!)
79 - access("SYS_ALIAS_1"."PARENT_BUILDING_BLOCK_ID"="DAY"."TIME_BUILDING_BLOCK_ID" AND
"SYS_ALIAS_1"."PARENT_BUILDING_BLOCK_OVN"="DAY"."OBJECT_VERSION_NUMBER")
80 - filter("TIME"."DATE_FROM"<=SYSDATE@! AND "TIME"."DATE_TO">=SYSDATE@!)
81 - access("DAY"."PARENT_BUILDING_BLOCK_ID"="TIME"."TIME_BUILDING_BLOCK_ID" AND
"DAY"."PARENT_BUILDING_BLOCK_OVN"="TIME"."OBJECT_VERSION_NUMBER")
82 - filter("TIME"."OBJECT_VERSION_NUMBER"="SUMMARY"."TIMECARD_OVN" AND "SUMMARY"."APPROVAL_STATUS
83 - access("TIME"."TIME_BUILDING_BLOCK_ID"="SUMMARY"."TIMECARD_ID")
86 - access("B"."TIME_BUILDING_BLOCK_ID"=:B1)
[\pre]
Note: cpu costing is off
Message was edited by:
user549459 -
Hi I need to create a simple view like this
No Count
10 15
to get the No i am using a function which would normally return 1 value like 10 above but could sometimes return 2 numbers in the following format 10:5
When I get a number like this i need to split it into 2 rows in the view with the same count.
No Count
10 15
5 15
at the moment i get this
No Count
10:5 15
5 15
I can use plsql or sql thanks in advance
kirkNot sure i was clear enough so heres my view as it stands
CREATE OR REPLACE FORCE VIEW "Q_ABSENCE" ("OWNERID", "OWNERTYPE", "TYPE", "ITEMCOUNT") AS
select distinct 'No',
count(*) as itemcount
from sick_absence
where ab_proccessed =2
and AB_COORDPROCESSED = 'No'
group by ab_owner
Which would return the following data
NO Count
10 2
5 4
4:3 2
2 1
234:23 4
I need it to return
No Count
10 2
5 4
4 2
3 2
2 1
234 4
23 4
thanks for your time
Kirk -
Tuning of SQL query in PO base tables
Hi all,
Is there any way to optimize the below query as its taking too many hours to exectute when I pass the dates parameters for long period like eg. 6months to 1 year. Am I missing something...?
SELECT poh.org_id,
rcvt.organization_id,
mcat.segment1,
pov.vendor_name,
poh.vendor_id,
rcvt.transaction_type,
rcvt.primary_quantity,
poh.rate,
pol.unit_price,
NULL,
pvs.attribute8,
pvs.address_line1,
pvs.address_line2,
pvs.city,
pvs.state,
pvs.zip,
pvs.country
FROM rcv_transactions rcvt,
mtl_item_categories icat,
po_line_locations_all poll,
po_lines_all pol,
mtl_system_items_b msi,
po_headers_all poh,
po_vendors pov,
mtl_categories_b mcat,
po_vendor_sites_all pvs,
mtl_categories_b mcatedi
WHERE pov.vendor_id = poh.vendor_id
AND poh.po_header_id = pol.po_header_id
AND msi.inventory_item_id = pol.item_id
AND pov.vendor_id = pvs.vendor_id
AND pvs.vendor_site_id = poh.vendor_site_id
AND msi.organization_id = 117
AND mcatedi.category_id = pol.category_id
AND poll.po_line_id = pol.po_line_id
AND icat.organization_id = msi.organization_id +0
AND icat.inventory_item_id = msi.inventory_item_id +0
AND icat.category_set_id = 1
AND icat.category_id = mcat.category_id
AND rcvt.po_line_location_id = poll.line_location_id
AND rcvt.transaction_date BETWEEN p_Start_Date AND p_End_Date
AND ((rcvt.transaction_type = 'RETURN TO VENDOR') OR (rcvt.transaction_type = 'RECEIVE' ))
AND ((rcvt.transaction_type = 'RECEIVE') OR (rcvt.transaction_type = 'RETURN TO VENDOR')
AND nvl(rcvt.reason_id, 110) IN
SELECT reason_id
FROM mtl_transaction_reasons
WHERE disable_date IS NULL AND reason_id NOT IN(20 , 21 , 22 , 23, 24 , 25 , 26 ,27 , 28 , 29 , 50 , 51 , 52 , 53 , 54 , 55 ,100 ,102, 103, 122 ,123 , 124)
Thank you all in advance....This is the explain I have in my instance. Looks like there is a different in indexes.
I have no full table scan on any table in the SQL I sent you. There are the changes I have made:
Removing the table --, mtl_categories_b mcatedi. It is not necessary to link the categories to PO lines unless you are entering POs without items. That I think you are not (looks like) as you are looking at the transactions line Receive and Retrun to vendor so I assumed these inventory purchases where you are using item. Hence removed that.
One more possibility is that you are reciving the expense POs also (accruing on receipt for expese purchases). If you want to add that table and condition (AND mcatedi.category_id = pol.category_id) add that and test.
Mistakenly commented out AND pvs.vendor_site_id = poh.vendor_site_id. You can add that back.
Added this where condition:
AND rcvt.organization_id = msi.organization_id
Reason: You are receiving into organization where the item is assigned to. If you remove this where condition it will do full table scan on the tables you mentioned along with the po_vendors_all. This is what making all the difference.
Remaining all is your SQL only.
SQL
====================================
SELECT poh.org_id, rcvt.organization_id, mcat.segment1, pov.vendor_name, poh.vendor_id
, rcvt.transaction_type, rcvt.primary_quantity, poh.rate, pol.unit_price, NULL, pvs.attribute8
, pvs.address_line1, pvs.address_line2, pvs.city, pvs.state, pvs.zip, pvs.country
FROM po_headers_all poh
, po_lines_all pol
, po_line_locations_all poll
, po_vendors pov
, po_vendor_sites_all pvs
, rcv_transactions rcvt
, mtl_system_items_b msi
, mtl_item_categories icat
, mtl_categories_b mcat
, mtl_categories_b mcatedi
WHERE poh.po_header_id = pol.po_header_id
AND pol.po_line_id = poll.po_line_id
AND poh.vendor_id = pov.vendor_id
AND pov.vendor_id = pvs.vendor_id
AND pol.item_id = msi.inventory_item_id
AND rcvt.organization_id = msi.organization_id
AND pvs.vendor_site_id = poh.vendor_site_id
AND msi.organization_id = 117
AND mcatedi.category_id = pol.category_id
AND msi.organization_id = icat.organization_id
AND msi.inventory_item_id = icat.inventory_item_id
AND icat.category_set_id = 1
AND icat.category_id = mcat.category_id
AND rcvt.po_line_location_id = poll.line_location_id
AND trunc(rcvt.transaction_date) BETWEEN ('01-JAN-2008') AND ('31-MAR-2008')
AND ((rcvt.transaction_type = 'RETURN TO VENDOR') OR (rcvt.transaction_type = 'RECEIVE'))
AND ( (rcvt.transaction_type = 'RECEIVE')
OR (rcvt.transaction_type = 'RETURN TO VENDOR')
AND NVL (rcvt.reason_id, 110) IN (
SELECT reason_id
FROM mtl_transaction_reasons
WHERE disable_date IS NULL
AND reason_id NOT IN
(20
, 21
, 22
, 23
, 24
, 25
, 26
, 27
, 28
, 29
, 50
, 51
, 52
, 53
, 54
, 55
, 100
, 102
, 103
, 122
, 123
, 124
==================
Plan
======================
SELECT STATEMENT CHOOSECost: 388 Bytes: 306 Cardinality: 1
30 FILTER
26 NESTED LOOPS Cost: 388 Bytes: 306 Cardinality: 1
24 NESTED LOOPS Cost: 388 Bytes: 302 Cardinality: 1
21 NESTED LOOPS Cost: 387 Bytes: 290 Cardinality: 1
18 NESTED LOOPS Cost: 385 Bytes: 150 Cardinality: 1
15 NESTED LOOPS Cost: 384 Bytes: 122 Cardinality: 1
12 NESTED LOOPS Cost: 383 Bytes: 91 Cardinality: 1
10 NESTED LOOPS Cost: 381 Bytes: 73 Cardinality: 1
8 NESTED LOOPS Cost: 380 Bytes: 64 Cardinality: 1
5 NESTED LOOPS Cost: 379 Bytes: 41 Cardinality: 1
2 TABLE ACCESS BY INDEX ROWID PO.RCV_TRANSACTIONS Cost: 378 Bytes: 31 Cardinality: 1
1 INDEX RANGE SCAN NON-UNIQUE PO.RCV_TRANSACTIONS_N22 Cost: 11 Cardinality: 3,490
4 TABLE ACCESS BY INDEX ROWID PO.PO_LINE_LOCATIONS_ALL Cost: 1 Bytes: 10 Cardinality: 1
3 INDEX UNIQUE SCAN UNIQUE PO.PO_LINE_LOCATIONS_U1 Cardinality: 1
7 TABLE ACCESS BY INDEX ROWID PO.PO_LINES_ALL Cost: 1 Bytes: 23 Cardinality: 1
6 INDEX UNIQUE SCAN UNIQUE PO.PO_LINES_U1 Cardinality: 1
9 INDEX UNIQUE SCAN UNIQUE INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Bytes: 9 Cardinality: 1
11 INDEX RANGE SCAN UNIQUE INV.MTL_ITEM_CATEGORIES_U1 Cost: 2 Bytes: 18 Cardinality: 1
14 TABLE ACCESS BY INDEX ROWID PO.PO_HEADERS_ALL Cost: 1 Bytes: 31 Cardinality: 1
13 INDEX UNIQUE SCAN UNIQUE PO.PO_HEADERS_U1 Cardinality: 1
17 TABLE ACCESS BY INDEX ROWID PO.PO_VENDORS Cost: 1 Bytes: 28 Cardinality: 1
16 INDEX UNIQUE SCAN UNIQUE PO.PO_VENDORS_U1 Cardinality: 1
20 TABLE ACCESS BY INDEX ROWID PO.PO_VENDOR_SITES_ALL Cost: 2 Bytes: 140 Cardinality: 1
19 INDEX RANGE SCAN UNIQUE PO.PO_VENDOR_SITES_U1 Cost: 1 Cardinality: 1
23 TABLE ACCESS BY INDEX ROWID INV.MTL_CATEGORIES_B Cost: 1 Bytes: 12 Cardinality: 1
22 INDEX UNIQUE SCAN UNIQUE INV.MTL_CATEGORIES_B_U1 Cardinality: 1
25 INDEX UNIQUE SCAN UNIQUE INV.MTL_CATEGORIES_B_U1 Bytes: 4 Cardinality: 1
29 FILTER
28 TABLE ACCESS BY INDEX ROWID INV.MTL_TRANSACTION_REASONS Cost: 1 Bytes: 4 Cardinality: 1
27 INDEX UNIQUE SCAN UNIQUE INV.MTL_TRANSACTION_REASONS_U1 Cardinality: 1
Thanks
Nagamohan -
Performance tuning of sql query with multiple joins
My query takes at least half an hour to execute and the number of records returned are approx 1 lakh records.
Structure of tables are:
tblSession : ID,option1,option2,option3,option4,option5,option6,option7,option8,option9.
tblOption : ID, labelID
tblLabelDetail : ID, LABELID, text
optionID 1 to optionID9 are Foreign keys to table tblOption.ID
My query is as below :
select
session.ID
,session.tstamp
,session.score
,session.hid1
,session.hID2
,session.hID3
,session.collectionID
,session.consumerID
,session.langID
,cons_cust.text1 as customCons_text1,
cons_cust.text2 as customCons_text2,
cons_cust.text3 as customCons_text3,
cons_cust.text4 as customCons_text4,
cons_cust.text5 as customCons_text5,
cons_cust.text6 as customCons_text6,
cons_cust.text7 as customCons_text7,
cons_cust.text8 as customCons_text8,
cons_cust.text9 as customCons_text9,
ld_cons1.text as customCons_option1GUID,
ld_cons2.text as customCons_option2GUID,
ld_cons3.text as customCons_option3GUID,
ld_cons4.text as customCons_option4GUID ,
ld_cons5.text as customCons_option5GUID,
ld_cons6.text as customCons_option6GUID,
ld_cons7.text as customCons_option7GUID,
ld_cons8.text as customCons_option8GUID,
ld_cons9.text as customCons_option9GUID,
--session
session_cust.text1 as session_cust_text1,
session_cust.text2 as session_cust_text2,
session_cust.text3 as session_cust_text3,
session_cust.text4 as session_cust_text4,
session_cust.text5 as session_cust_text5,
session_cust.text6 as session_cust_text6,
session_cust.text7 as session_cust_text7,
session_cust.text8 as session_cust_text8,
session_cust.text9 as session_cust_text9,
ld_sess1.text as session_cust_option1GUID,
ld_sess2.text as session_cust_option2GUID,
ld_sess3.text as session_cust_option3GUID,
ld_sess4.text as session_cust_option4GUID,
ld_sess5.text as session_cust_option5GUID,
ld_sess6.text as session_cust_option6GUID,
ld_sess7.text as session_cust_option7GUID,
ld_sess8.text as session_cust_option8GUID,
ld_sess9.text as session_cust_option9GUID,
session_cust.tStamp1,
session_cust.tStamp2
from mvSession session with (noexpand)
inner join tblCollection c on c.ID=session.collectionID AND c.templateID = 405
left join tblConsumer cons on cons.ID=session.consumerID and cons.sessionYM between 601 and 1412 and cons.sID=105
left join vCustomConsumer cons_cust on cons_cust.sessionYM between 601 and 1412 and cons_cust.sID=105 and cons_cust.ID=cons.ID
left join tbloption o_cons1 on o_cons1.id = cons_cust.option1 and o_cons1.sid = 105
left join tblLabelDetail ld_cons1 on ld_cons1.labelID = o_cons1.labelID and ld_cons1.langId = 1 and ld_cons1.eid = 107
left join tbloption o_cons2 on o_cons2.id = cons_cust.option2 and o_cons2.sid = 105
left join tblLabelDetail ld_cons2 on ld_cons2.labelID = o_cons2.labelID and ld_cons2.langId = 1 and ld_cons2.eid = 107
left join tbloption o_cons3 on o_cons3.id = cons_cust.option3 and o_cons3.sid = 105
left join tblLabelDetail ld_cons3 on ld_cons3.labelID = o_cons1.labelID and ld_cons3.langId = 1 and ld_cons3.eid = 107
left join tbloption o_cons4 on o_cons4.id = cons_cust.option4 and o_cons4.sid = 105
left join tblLabelDetail ld_cons4 on ld_cons4.labelID = o_cons4.labelID and ld_cons4.langId = 1 and ld_cons4.eid = 107
left join tbloption o_cons5 on o_cons5.id = cons_cust.option5 and o_cons5.sid = 105
left join tblLabelDetail ld_cons5 on ld_cons5.labelID = o_cons5.labelID and ld_cons5.langId = 1 and ld_cons5.eid = 107
left join tbloption o_cons6 on o_cons6.id = cons_cust.option6 and o_cons6.sid = 105
left join tblLabelDetail ld_cons6 on ld_cons6.labelID = o_cons6.labelID and ld_cons6.langId = 1 and ld_cons6.eid = 107
left join tbloption o_cons7 on o_cons7.id = cons_cust.option7 and o_cons7.sid = 105
left join tblLabelDetail ld_cons7 on ld_cons7.labelID = o_cons7.labelID and ld_cons7.langId = 1 and ld_cons7.eid = 107
left join tbloption o_cons8 on o_cons8.id = cons_cust.option8 and o_cons8.sid = 105
left join tblLabelDetail ld_cons8 on ld_cons8.labelID = o_cons8.labelID and ld_cons8.langId = 1 and ld_cons8.eid = 107
left join tbloption o_cons9 on o_cons9.id = cons_cust.option9 and o_cons9.sid = 105
left join tblLabelDetail ld_cons9 on ld_cons9.labelID = o_cons9.labelID and ld_cons9.langId = 1 and ld_cons9.eid = 107
left join vCustomSession session_cust on session_cust.sessionYM between 601 and 1412 and session_cust.sID=105 and session_cust.ID=session.ID
left join tbloption o_sess1 on o_sess1.id = session_cust.option1 and o_sess1.sid = 105
left join tblLabelDetail ld_sess1 on ld_sess1.labelID = o_sess1.labelID and ld_sess1.langId = 1 and ld_sess1.eid = 107
left join tbloption o_sess2 on o_sess2.id = session_cust.option2 and o_sess2.sid = 105
left join tblLabelDetail ld_sess2 on ld_sess2.labelID = o_sess2.labelID and ld_sess2.langId = 1 and ld_sess2.eid = 107
left join tbloption o_sess3 on o_sess2.id = session_cust.option3 and o_sess3.sid = 105
left join tblLabelDetail ld_sess3 on ld_sess3.labelID = o_sess2.labelID and ld_sess3.langId = 1 and ld_sess3.eid = 107
left join tbloption o_sess4 on o_sess4.id = session_cust.option4 and o_sess4.sid = 105
left join tblLabelDetail ld_sess4 on ld_sess4.labelID = o_sess4.labelID and ld_sess4.langId = 1 and ld_sess4.eid = 107
left join tbloption o_sess5 on o_sess5.id = session_cust.option5 and o_sess5.sid = 105
left join tblLabelDetail ld_sess5 on ld_sess5.labelID = o_sess5.labelID and ld_sess5.langId = 1 and ld_sess5.eid = 107
left join tbloption o_sess6 on o_sess6.id = session_cust.option6 and o_sess6.sid = 105
left join tblLabelDetail ld_sess6 on ld_sess6.labelID = o_sess6.labelID and ld_sess6.langId = 1 and ld_sess6.eid = 107
left join tbloption o_sess7 on o_sess7.id = session_cust.option7 and o_sess7.sid = 105
left join tblLabelDetail ld_sess7 on ld_sess7.labelID = o_sess7.labelID and ld_sess7.langId = 1 and ld_sess7.eid = 107
left join tbloption o_sess8 on o_sess8.id = session_cust.option8 and o_sess8.sid = 105
left join tblLabelDetail ld_sess8 on ld_sess8.labelID = o_sess8.labelID and ld_sess8.langId = 1 and ld_sess8.eid = 107
left join tbloption o_sess9 on o_sess9.id = session_cust.option9 and o_sess9.sid = 105
left join tblLabelDetail ld_sess9 on ld_sess9.labelID = o_sess9.labelID and ld_sess9.langId = 1 and ld_sess9.eid = 107
where session.sID=105 and session.tStamp >= 'Sep 1 2014 12:00AM' and session.tStamp < 'Dec 12 2014 12:00AM'
order by session.tStamp, session.ID
Is there a way , where i can simplify the joins with tbloption and tblLabelDetail and get my o/p in optimal time.
RegardsI have headed towards another approach ie. using unpivot and then pivot.
First i am converting option1-option9 into column , then doing PIVOT to get back the same record . But issue is that when i am doing pivoting i am getting NULL values.
My query is :
select * into #t1 from
select ID
, option1
, option2
, option3
, option4
, option5
, option6
, option7
, option8
, option9
from vCustomConsumer
where sid=105
and sessionYM = 1412
) SourceTable
UNPIVOT
optionID FOR Col IN
(option1
,option2
,option3
,option4
,option5
,option6
,option7
,option8
,option9 )
) AS unpvt
select t.ID,t.optionID,t.col,cast(ld.text as varchar(max)) as text into #t2
from #t1 t
left outer join tbloption o on o.ID = t.optionID
left outer join tblLabelDetail ld on ld.labelID = o.labelID and ld.langID=1
order by ID,col
select ID,option1
,option2
,[option3]
,option4
,option5
,option6
,option7
,option8
,option9
from
select ID,optionID,col,text
from #t2
)up
pivot
min(text)for col in
(option1
,option2
,[option3]
,option4
,option5
,option6
,option7
,option8
,option9
)as pvt
In my last query where i am using pivot, i am getting NULL values. When i check the data in temp table #t2 , it exists perfectly . But when pivoting i dont understand why it is returning most of the NULL values. I am getting data for only one column in single
row.
Below are some rows from result set finally obtained after pivoting :
ID
option1
option2
option3
option4
option5
option6
option7
option8
option9
62949026
NULL
0 to 200 seconds
NULL
NULL
NULL
NULL
NULL
NULL
NULL
62966000
NULL
NULL
4
NULL
NULL
NULL
NULL
NULL
NULL
62966032
NULL
NULL
4
NULL
NULL
NULL
NULL
NULL
NULL
63090372
NULL
NULL
NULL
NULL
EN
NULL
NULL
NULL
NULL
63090375
NULL
NULL
NULL
NULL
EN
NULL
NULL
NULL
NULL
Thanks,
Maybe you are looking for
-
Backing up songs to External Hard Drive
When i first bought my external hard drive, I slid my entire itunes folder into the external hard drive to save all my songs. My question is, what is the best way to save ONLY the new songs onto your external hard drive? I don't think it would be nec
-
Post foreign currency valuation for special G/L accounts
Dear experts, Our client wants to evaluate the balance of down payment account after each partial clearing with invoice.As down payments are being posted by special G/L indicators, they are not able to post to the down payment account directly. and t
-
How can I deactivate indesign3 from an old desktop that no longer works?
I bought a new laptop and need to deactivate indesign3 from my old desktop and install it on my new laptop. Please Help! Thanks
-
Oracle Cluster Health Monitor on Windows
Hi experts I looked in the forum but found no answers, so I'm begging for help... I'm trying to install OCHM on a 2-nodes RAC. Windows 2003 Enterprise Edition SP2, 32 bits Oracle 10.2.0.5 Standard Edition, 32 bits. The two servers are named S92 and S
-
Table entries missing in table TJ05
Hi Experts, I have search in SCN regarding below issue...but i havn't get any solution. Recently we upgrade to ECC EHP5 from 4.7, The values "ZIN1" in table "TJ05" is missing in ECC 6.0. This value was available in 4.7 . How can Z1N1 value insert in