Performance of query for getting item revisions
Hi All,
The following query took several minutes in an environment with about 7,500,000 item revisions :
SELECT
MIR.INVENTORY_ITEM_ID
, MSI.CONCATENATED_SEGMENTS ITEM_NUMBER
, MIR.ORGANIZATION_ID
, MP.ORGANIZATION_CODE
FROM
MTL_ITEM_REVISIONS_VL MIR
, MTL_PARAMETERS MP
, MTL_SYSTEM_ITEMS_VL MSI
WHERE
(MIR.INVENTORY_ITEM_ID = p_Item_ID OR MSI.CONCATENATED_SEGMENTS = p_Item_Number)
AND (MIR.ORGANIZATION_ID = p_Org_ID OR MP.ORGANIZATION_CODE = p_Org_Code)
AND MP.ORGANIZATION_ID = MIR.ORGANIZATION_ID
AND MIR.INVENTORY_ITEM_ID = MSI.INVENTORY_ITEM_ID
AND MIR.ORGANIZATION_ID = MSI.ORGANIZATION_ID ORDER BY EFFECTIVITY_DATE, REVISION DESC;
If changing this query to the following, it takes less than a second:
SELECT
MIR.INVENTORY_ITEM_ID
, MSI.CONCATENATED_SEGMENTS ITEM_NUMBER
, MIR.ORGANIZATION_ID
, MP.ORGANIZATION_CODE
FROM
MTL_ITEM_REVISIONS_VL MIR
, MTL_PARAMETERS MP
, MTL_SYSTEM_ITEMS_VL MSI
WHERE
MSI.CONCATENATED_SEGMENTS = p_Item_Number
AND MP.ORGANIZATION_CODE = p_Org_Code
AND MP.ORGANIZATION_ID = MIR.ORGANIZATION_ID
AND MIR.INVENTORY_ITEM_ID = MSI.INVENTORY_ITEM_ID
AND MIR.ORGANIZATION_ID = MSI.ORGANIZATION_ID ORDER BY EFFECTIVITY_DATE, REVISION DESC;
Can anyone explain the extreme difference in performance between these two queries?
Thanks & Regards
Carolin
They don't look logically equivalent to me.
Here are the differences:
WHERE (MIR.INVENTORY_ITEM_ID = p_Item_ID
OR MSI.CONCATENATED_SEGMENTS = p_Item_Number)
AND (MIR.ORGANIZATION_ID = p_Org_ID
OR MP.ORGANIZATION_CODE = p_Org_Code)
vs
WHERE MSI.CONCATENATED_SEGMENTS = p_Item_Number
AND MP.ORGANIZATION_CODE = p_Org_CodeIf they aren't logically equivalent there's no point in comparing the performance.
Similar Messages
-
Query to get Item revision Mismatch
Dear Guru's,
Need your help. I am looking for a queryo get those below details.
1) Need a query which should give item revisions which are not match with 2 orgs. Ex:: We have two orgs p001 & P002 and we are seeing few item revision is same for p001 & p002 and few items are not matching with p001 item revisions. Please help me to prepare a query which will give the mismatch item details along with item revisions.
--> in P001 the item revision is 0, 001, 002 & 003
--> In P002 the item revision is only 0.
i need those mismatc records where the item revision does not match with p001 to p002 item revisions.
Thanks in advance for the help.
Regards,
SSPHi ,
This?? This is the Sample one or other wise give me sample data scripts create & insert commands or post in SQL and PLSQL Forum
SELECT A.* FROM sampl_table A
WHERE EXISTS (
SELECT 1 FROM sampl_table B
WHERE A.item_id = B.item_id
AND ....
AND NOT EXISTS (
SELECT 2 FROM sampl_table B
WHERE A.item_id = B.item_id
AND A.SDAY = B.SDAY
AND .....
or you use Joins -
Query for getting records max reported timestamp and 2nd max report
query for getting records in between
max reported timestamp and 2nd max reported timestamp
HERE IS ALL RESULT SET
TIME DOMAIN
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:08:05 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:08:05 TOMCAT
PD_REPORTED_TIMESTAM PD_USER
30:jun:2006:20:08:25 TOMCAT
30:jun:2006:20:08:25 TOMCAT
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:08:05 TOMCAT
30:jun:2006:20:08:05 TOMCAT
PD_REPORTED_TIMESTAM PD_USER
30:jun:2006:20:08:25 TOMCAT
30:jun:2006:20:08:25 TOMCAT
QUERY RESULT TO COME
TIME DOMAIN
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
Message was edited by:
user517983Hi,
can we write query like this.
1 select pd_user,PD_REPORTED_TIMESTAMP
2 from sp_process_detail_current spdc
3 where host_id='DSCP02469'and pd_user='TOMCAT'
4 and exists(
5 select PD_REPORTED_TIMESTAMP from sp_process_detail_current
6* having max(PD_REPORTED_TIMESTAMP)-spdc.PD_REPORTED_TIMESTAMP=0)
SQL> /
PD_USER PD_REPORTED_TIMESTAM
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45 -
Query for getting all function and procedure inside the packages
hi All
Please provide me Query for getting all function and procedure inside the packages
thanksAs Todd said, you can use user_arguments data dictionary or you can join user_objects and user_procedures like below to get the name of the packaged function and procedure names.
If you are looking for the packaged procedures and functions source then use user_source data dictionary
select a.object_name,a.procedure_name from user_procedures a,
user_objects b
where a.object_name is not null
and a.procedure_name is not null
and b.object_type='PACKAGE'
and a.object_name=b.object_name -
Some one please provide query for getting REMIT TO ADDRESS details by using the column RA_CUSTOMER_TRX_ALL.REMIT_TO_ADDRESS_ID
try
select ct.remit_to_address_id,
raa_remit_ps.party_site_number,
raa_remit_loc.state,
ft_remit.territory_short_name,
ct.*
from ra_customer_trx_all ct,
hz_cust_acct_sites_all raa_remit,
hz_party_sites raa_remit_ps,
hz_locations raa_remit_loc,
fnd_territories_vl ft_remit
where 1 = 1
and ct.remit_to_address_id = raa_remit.cust_acct_site_id(+)
and raa_remit.party_site_id = raa_remit_ps.party_site_id(+)
and raa_remit_loc.location_id(+) = raa_remit_ps.location_id
and raa_remit_loc.country = ft_remit.territory_code(+) -
Query for getting Responsibility, Menu and submenus
Hi,
I need one query for getting Responsibilites, menus, submenus agian submenus like that..
Pls share the query any body have.
Thanks in advance,
Hanimi.See user487104's post in Re: How to check a function is accessible under responsibility? .
He has given a script to build the output. -
Query for Getting previous date in oracle in specifc scenario
I have the below data in a table A which i need to insert into table B along with one compute column.
TABLE A:
Account_No | Balance | As_on_date
1001 |-100 | 1-Jan-2013
1001 |-150 | 2-Jan-2013
1001 | 200 | 3-Jan-2013
1001 |-250 | 4-Jan-2013
1001 |-300 | 5-Jan-2013
1001 |-310 | 6-Jan-2013
Table B:
In table B,there should be no of days to be shown when balance is negative and the date one which it has gone into negative.
So,for 6-Jan-2013,this table should show below data:
Account_No | Balance | As_on_date | Days_passed | Start_date
1001 | -310 | 6-Jan-2013 | 3 | 4-Jan-2013
Here,no of days should be the days when the balance has gone negative in recent time and not from the old entry.
I need to write a sql query to get the no of days passed and the start date from when the balance has gone negative.
I tried to formulate a query using Lag analytical function,but i am not getting how should i check the first instance of negative balance by traversing back using LAG function. Even the first_value function was given a try but not getting how to partition in it based on negative value.
Any help or direction on this will be really helpful.
ThanksI think you can apply the Tabibitoshan method here. The query is more complex but performs better than other methods. For an explanation, see Tabibitosan method tutorial by Aketi Jyuuzou
The idea behind the method is to identify "continuous" records without gaps. Here I identify records that are "continuous" because they contain an uninterrupted series of negative balances.
drop table t;
CREATE TABLE t (Account_No , Balance , As_on_date) AS SELECT
1001 ,-100 , to_date('1-Jan-13', 'DD-MON-YY') FROM dual UNION ALL SELECT
1001 ,-150 , to_date('2-Jan-13', 'DD-MON-YY') FROM dual UNION ALL SELECT
1001 , 200 , to_date('3-Jan-13', 'DD-MON-YY') FROM dual UNION ALL SELECT
1001 ,-250 , to_date('4-Jan-13', 'DD-MON-YY') FROM dual UNION ALL SELECT
1001 ,-300 , to_date('5-Jan-13', 'DD-MON-YY') FROM dual UNION ALL SELECT
1001 ,-310 , to_date('6-Jan-13', 'DD-MON-YY') FROM dual;
SELECT Account_No, Balance, to_char(As_on_date, 'DD-MON-YYYY') as_on_date,
CASE
WHEN balance < 0
THEN row_number() OVER(PARTITION BY account_no, grp ORDER BY as_on_date)
END days_passed,
CASE
WHEN balance < 0
THEN to_char(
first_value(as_on_date) OVER(PARTITION BY account_no, grp ORDER BY as_on_date),
'DD-MON-YYYY'
end start_date
from (
SELECT Account_No, Balance, As_on_date,
CASE WHEN balance >= 0 THEN NULL ELSE
row_number() OVER(PARTITION BY account_no ORDER BY as_on_date) -
sum(CASE WHEN balance < 0 THEN 1 ELSE 0 END) OVER(PARTITION BY account_no ORDER BY as_on_date)
end grp
FROM t
order by account_no, As_on_date;
ACCOUNT_NO
BALANCE
AS_ON_DATE
DAYS_PASSED
START_DATE
1001
-100
01-JAN-2013
1
01-JAN-2013
1001
-150
02-JAN-2013
2
01-JAN-2013
1001
200
03-JAN-2013
1001
-250
04-JAN-2013
1
04-JAN-2013
1001
-300
05-JAN-2013
2
04-JAN-2013
1001
-310
06-JAN-2013
3
04-JAN-2013 -
CAML Query to get Items based on Year and Month From Date Column
Hi All,
* As we knew that there are default columns in calendar like Stattdate,Title,Location..etc.
* I required the CAML Query to get the list items of calender of particular Month and Year,So that I can get number of items or evetns are in Calendar
Can any one help me how can I do this using caml query
SamarHi Stuart,
Thanks for your response,I had chosen 2nd option of our above mention suggestion.But when I try to fetech the data from a calendar it is showing below error .I
had checked the below code with oter lists by changing Type to text and it worked fine.Can you please help me how can I fetech for the calulated columns
Error
"One or more field
types are not installed properly. Go to the list settings page to delete these
fields. "
Code:
string year="2014";
string month="February";
SPSite mysite = SPContext.Current.Site;
SPWeb myweb = mysite.OpenWeb();
try
SPList mylist = myweb.Lists["Calendar"];
SPQuery myquery = new SPQuery();
myquery.Query = @"<Where>
<And>
<Eq>
<FieldRef Name='Year'/>
<Value Type='Calculated'>"
+ year + @"</Value>
</Eq>
<Eq>
<FieldRef Name='Month'
/>
<Value Type='Calculated'>"
+ month + @"</Value>
</Eq>
</And>
</Where>";
SPListItemCollection totaltiems = mylist.GetItems(myquery);
Label1.Text= "Total Number of Items is "+" "+totaltiems.Count.ToString();
catch (Exception ee)
Label1.Text = ee.Message;
finally
myweb.Dispose();
Calculated Columns
Samar -
Query for Billable item form MTL_SYSTEM_ITEMS_B for BOM billing item
Hi All,
I want to write query to get billing item from mtl_system_items_b for BOM ...Can anyone give me the idea for accessing the billing item..
In BOM
Routings - Resources(form) - Billing Item (Field) and Outside Processing Item (Field)LOV...i Want to know query to access these items..
Thanks
Raman Sharma
Edited by: 929841 on Apr 24, 2012 6:06 AMObtain FRD log file to find out why the trigger is fired twice.
R12: Forms Runtime Diagnostics (FRD), Tracing And Logging For Forms In Oracle Applications (Doc ID 438652.1)
Steps To Take FRD Trace in 11.5.10 & R12 (Doc ID 867943.1)
R12: How To Create An FRD (Forms Runtime Diagnostic) Log Using Forms 10g (Doc ID 445166.1)
How To Collect And Use Forms Trace (FRD) in Oracle Applications Release 12 (Doc ID 373548.1)
Thanks,
Hussein -
Oracle SQL query for getting specific special characters from a table
Hi all,
This is my table
Table Name- Table1
S.no Name
1 aaaaaaaa
2 a1234sgjghb
3 a@3$%jkhkjn
4 abcd-dfghjik
5 bbvxzckvbzxcv&^%#
6 ashgweqfg/gfjwgefj////
7 sdsaf$([]:'
8 <-fdsjgbdfsg
9 dfgfdgfd"uodf
10 aaaa bbbbz#$
11 cccc dddd-/mnm
The output has to be
S.no Name
3 a@3$%jkhkjn
5 bbvxzckvbzxcv&^%#
7 sdsaf$([]:'
8 <-fdsjgbdfsg
10 aaaa bbbbz#$
It has to return "Name" column which is having special characters,whereas some special chars like -, / ," and space are acceptable.
The Oracle query has to print columns having special characters excluding -,/," and space
Can anyone help me to get a SQL query for the above.
Thanks in advance.You can achieve it in multiple ways. Here are few.
SQL> with t
2 as
3 (
4 select 1 id, 'aaaaaaaa' name from dual union all
5 select 2 id, 'a1234sgjghb' name from dual union all
6 select 3 id, 'a@3$%jkhkjn' name from dual union all
7 select 4 id, 'abcd-dfghjik' name from dual union all
8 select 5 id, 'bbvxzckvbzxcv&^%#' name from dual union all
9 select 6 id, 'ashgweqfg/gfjwgefj////' name from dual union all
10 select 7 id, 'sdsaf$([]:''' name from dual union all
11 select 8 id, '<-fdsjgbdfsg' name from dual union all
12 select 9 id, 'dfgfdgfd"uodf' name from dual union all
13 select 10 id, 'aaaa bbbbz#$' name from dual union all
14 select 11 id, 'cccc dddd-/mnm' name from dual
15 )
16 select *
17 from t
18 where regexp_like(translate(name,'a-/" ','a'), '[^[:alnum:]]');
ID NAME
3 a@3$%jkhkjn
5 bbvxzckvbzxcv&^%#
7 sdsaf$([]:'
8 <-fdsjgbdfsg
10 aaaa bbbbz#$
SQL> with t
2 as
3 (
4 select 1 id, 'aaaaaaaa' name from dual union all
5 select 2 id, 'a1234sgjghb' name from dual union all
6 select 3 id, 'a@3$%jkhkjn' name from dual union all
7 select 4 id, 'abcd-dfghjik' name from dual union all
8 select 5 id, 'bbvxzckvbzxcv&^%#' name from dual union all
9 select 6 id, 'ashgweqfg/gfjwgefj////' name from dual union all
10 select 7 id, 'sdsaf$([]:''' name from dual union all
11 select 8 id, '<-fdsjgbdfsg' name from dual union all
12 select 9 id, 'dfgfdgfd"uodf' name from dual union all
13 select 10 id, 'aaaa bbbbz#$' name from dual union all
14 select 11 id, 'cccc dddd-/mnm' name from dual
15 )
16 select *
17 from t
18 where translate
19 (
20 lower(translate(name,'a-/" ','a'))
21 , '.0123456789abcdefghijklmnopqrstuvwxyz'
22 , '.'
23 ) is not null;
ID NAME
3 a@3$%jkhkjn
5 bbvxzckvbzxcv&^%#
7 sdsaf$([]:'
8 <-fdsjgbdfsg
10 aaaa bbbbz#$
SQL> -
Oracle query for getting discrepancy equip codes
I need help in getting a query for discrepancy equip_code
select distinct eq.dept_id,eq.drive_id,equip_code,eq.qc_subtype_id,staff_id
from qc_equipment_used eq, qc_daily qc
where eq.drive_id = qc.drive_id
and trunc(eq.create_time) = '06-aug-2012'
and out_of_service = 'N'
and eq.qc_subtype_id in (1026,1012)
and eq.drive_id = 'DRV2016637'
DEPT_ID|DRIVE_ID|EQUIP_CODE|QC_SUBTYPE_ID|STAFF_ID
95|DRV2016637|HEMORYA121|1012|0011
95|DRV2016637|HEMORYA121|1026|0011
95|DRV2016637|HEMORYA148|1012|0011
I need help in getting a query to show the user that
95|DRV2016637|HEMORYA148|1012|0011
was qc'd in the morning but not in the evening for 1026You still refuse to read {message:id=9360002} and follow the Forum Etiquette?
How sad for you, since less volunteers will help you. -
Hi,
We are trying to create a query for the open items (purchase orders ) in order to add some fields useful for users.
Would you be able to advise with the query needed to show us only the open items?
Best regards,
MBHi,
Try this one:
Select distinct t1.cardcode as Vendor, t1.CardName as Name, t1.docnum as PO#, t0.itemcode, t0.Dscription, t0.OpenQty as 'Open Qty', t0.linenum Row#, t1.DocCur as Currency, t0.price as 'Purchase Price', t0.whscode, t1.taxdate as "PO Date"
from dbo.por1 t0
inner join dbo.opor t1 on t1.docentry = t0.docentry
where t1.DocType = 'I' and t0.linestatus = 'O'
order by t1.docnum Desc, t0.linenum
Thanks,
Gordon -
Need a Query for getting ItemCost from PO Vendor wise
Hi,Experts We are not maintain different price list for some particular items , We raised the PO for Multiple vendors with differnt price for the same material. We need a query to find the Item cost with Various Vendor .
I need the query in the following format
Po Number, Vendor Name,Item Name, Item Description,Qty, Price,Tax.
Thanks
KamalHi,
Check this query which looks for the Item doctype Purchase Order and brings the data accordingly :
select t0.docnum as 'PO Number', t0.CardName as 'Vendor name', t1.itemcode as 'Item Name',
t1.Dscription as 'Item Description', t1.quantity as 'QTY', t1.Price as 'Price',
t1.vatsum as 'Tax Amount'
from OPOR t0 inner join POR1 t1 on t0.docentry = t1.docentry
where t0.doctype ='I'
Group by t1.itemcode, t1.Dscription, t0.docnum,
t0.cardname, t1.quantity, t1.Price, t1.vatsum
Order by t1.Itemcode
Check if it helps.
Kind Regards,
Jitin
SAP Business One Forum Team -
OIM sql Query for getting the status of the task which got failed
Hi Everyone,
We have a requirement like we need to get the status of a particular task(say Create User in OID resource - Completed\Rejected status) for the particular user.We are able to get the status of the resource provisioed to the user but not the status of the particular task getting trigerred for the user.can someone put some light on this.We need to get the SQL query for this.
Thanks in Advance.
Regards,
MKNHi
Use this sample query to get the task status, also check the cooments
SELECT USR.USR_LOGIN, OSI.SCH_KEY,SCH.SCH_STATUS,STA.STA_BUCKET FROM
OSI,SCH,STA,MIL,TOS,PKG,OIU,USR,OBJ,OST
WHERE OSI.MIL_KEY=MIL.MIL_KEY
AND SCH.SCH_KEY=OSI.SCH_KEY
AND STA.STA_STATUS=SCH.SCH_STATUS
AND TOS.PKG_KEY=PKG.PKG_KEY
AND MIL.TOS_KEY=TOS.TOS_KEY
AND OIU.USR_KEY=USR.USR_KEY
AND OIU.OST_KEY=OST.OST_KEY
AND OST.OBJ_KEY=OBJ.OBJ_KEY
AND OSI.ORC_KEY=OIU.ORC_KEY
AND OBJ.OBJ_NAME='AD User'
AND OST.OST_STATUS = 'Provisioning' -- filter accordinglly
AND STA.STA_BUCKET = 'Pending' -- filter accordinglly
AND PKG.PKG_NAME='AD User' -- filter accordinglly
AND MIL.MIL_NAME='System Validation' ---- filter accordinglly
Thanks,
Kuldeep -
Query for getting data for every quarter for financial year
Hi,
My problem is I need to get the data for every quarter for financial year and also I need data for every week for financial year.
For example for financial year 2012-13, Apr2012 to Jun2012 would be Q1, Jul2012 to Sep2012 would be Q2 and so on. Total 8quarters should come upto Apr2013.
In the same way 1st apr 2012 to 7th apr 2012 would be week1, 8th apr to 15th apr would be week2 and son on. How to write a query for this scenario in oracle. Can anybody help me on this. very urgent..
Thanks in advance.lakmesri wrote:
Hi,
My problem is I need to get the data for every quarter for financial year and also I need data for every week for financial year.
For example for financial year 2012-13, Apr2012 to Jun2012 would be Q1, Jul2012 to Sep2012 would be Q2 and so on. Total 8quarters should come upto Apr2013.
In the same way 1st apr 2012 to 7th apr 2012 would be week1, 8th apr to 15th apr would be week2 and son on. How to write a query for this scenario in oracle. Can anybody help me on this. very urgent..
Thanks in advance.
How can you get 8 quarters within a year ? I'b be concerned here.
lakmesri wrote:
Hi,
In the same way 1st apr 2012 to 7th apr 2012 would be week1, 8th apr to 15th apr would be week2 and son on. How to write a query for this scenario in oracle. Can anybody help me on this. very urgent..
Thanks in advance.
First, that question is really not clearly asked. Second how could it be urgent ? You even did not tell us your Oracle version, did not show any tables descr, output sample nor any effort on your side to work on.
Nicolas.
Maybe you are looking for
-
Hard drive unusable after installing in powered on MBP
Hey all, I have a 2010 13'' MBP that has a 250GB hard drive, and recently I had a chance to upgrade to a 2010 15'' model. Since the previous owner planned to move his HDD out of the Mac, I would have to install my own HDD. I've nearly filled the driv
-
Firefox 4 seems to be incompatible with Windowblinds skins
No matter which Windowblinds skin I use (with Windows XP), the slide to the right of Firefox 4 vanishes. When I remove Windowblinds, it reappears again, so the problem seems to be one of compatibility.
-
Archive log not shipped to standby.
Dear Experts, We have are using oracle 10.2.0.4.0 on AIX. And we have configured physical standby database which was working fine till date. suddenly i found that the MRP process is waiting for gap. i have all the archive logs on the primary system a
-
Transaction : classic use?
Hello, I've seen that to use transactions in Coherence, you need to get a transaction from the CacheFactory and put/get objects by calling methods on the transaction object: TransactionMap tmap = CacheFactory.getLocalTransaction(cache); tmap.setTrans
-
How to install oracle enterprise edition on windows 2000
I have tried installing oracle 8.04 enterprise edition for NT on windows 2000 for several times. But it always missed listening on some serives. could anyone help me? Thank you!