Performance tunning for select statements using likp lips and vbrp
Dear all,
I have a report where i am using select statements using first on likp the for all entries of likp i am taking data from lips and then for all entries in lips i am taking data from vbrp by matching VGBEL and VGPOS. Now the problem is that when it fetches data from vbrp it is taking lot of time around 13mins. to fetch data from vbrp. How can i overcome the problem.
regards
Amit
Hi,
there is also no secondary index for preceding document in VBFA table.
You will also have to create it here.
Regards,
Przemysław
Similar Messages
-
Need to Improve pefromance for select statement using MSEG table
Hi all,
We are using a select statement using MSEG table
which takes a very long time to run the program which is scheduled in back ground.
Please see the history below.;
1) Previously this program was using SELECT-ENDSELECT statement inside the loop i.e.
LOOP AT I_MCHB.
To get Material Doc. Details
SELECT MBLNR
MJAHR
ZEILE INTO (MSEG-MBLNR,MSEG-MJAHR,MSEG-ZEILE)
UP TO 1 ROWS
FROM MSEG
WHERE CHARG EQ I_MCHB-CHARG
AND MATNR EQ I_MCHB-MATNR
AND WERKS EQ I_MCHB-WERKS
AND LGORT EQ I_MCHB-LGORT.
ENDSELECT.
Endloop.
The program was taking 1 hr for 20 k data
2)The above statement was replaced by ALL ENTRIES to remove the SELECT-ENDSELECT from the loop.
***GET MATERIAL DOC NUMBER AND FINANCIAL YEAR DETAILS FROM MSEG TABLE
SELECT MBLNR
MJAHR
ZEILE
MATNR
CHARG
WERKS
LGORT
INTO TABLE I_MSEG
FROM MSEG
FOR ALL ENTRIES IN I_MCHB
WHERE CHARG EQ I_MCHB-CHARG
AND MATNR EQ I_MCHB-MATNR
AND WERKS EQ I_MCHB-WERKS
AND LGORT EQ I_MCHB-LGORT.
3)After getting the further technical analysis from BASIS team , And with the suggestion to optimize the program by changing the INDEX RANGE SCAN to
MSEG~M.
SELECT MBLNR
MJAHR
ZEILE
MATNR
CHARG
WERKS
LGORT
INTO TABLE I_MSEG
FROM MSEG
FOR ALL ENTRIES IN I_MCHB
WHERE MATNR EQ I_MCHB-MATNR
AND WERKS EQ I_MCHB-WERKS
AND LGORT EQ I_MCHB-LGORT.
At present the program is taking 3 to 4 hrs in back ground .
The table is complete table scan using index
MSEG~M.
Please suggest to improve the performance of this
many many thanks
deepakThe benchmark should be the join, and I can not see how any of your solutions can be faster than the join
SELECT .....
INTO TABLE ....
UP TO 1 ROWS
FROM mchb as a
INNER JOIN mseg as b
ON amatnr EQ bmatnr
AND awerks EQ bwerks
AND algort EQ blgort
And acharg EQ bcharg
WHERE a~ ....
The WHERE condition must come from the select on MCHB, the field list from the total results
you want.
If you want to compare, must compare your solutions plus the select to fill I_MCHB.
Siegfried
Edited by: Siegfried Boes on Dec 20, 2007 2:28 PM -
How to get accurate values for select statement using single column
Hi All,
Below is my query which runs fine
Select Distinct Top 4
FiscalYearId,
FiscalMonthOfYearId
From ODS.Common.tODS_Date
Inner Join
UTL.Utility.tUTL_ProcessDate
On tODS_Date.DateShort < tUTL_ProcessDate.ProcessDate
And tUTL_ProcessDate.DatabaseName = 'ODS'
Order By
FiscalYearId Desc,
FiscalMonthOfYearId Desc
Below is the generate output
FiscalYearId FiscalMonthOfYearId
2014 2
2014 1
2013 12
2013 11
But i want to use this query in one of my where clause condition as its being used in the where clause it can only return 1 row.So, i tried something like this
Select Distinct Top 4
FiscalMonthOfYearId
From ODS.Common.tODS_Date
Inner Join
UTL.Utility.tUTL_ProcessDate
On tODS_Date.DateShort < tUTL_ProcessDate.ProcessDate
And tUTL_ProcessDate.DatabaseName = 'ODS'
Order By
FiscalMonthOfYearId Desc
And the result set of this one gives me the output like
FiscalMonthOfYearId
12
11
10
9
Which is not correct,( if you see the result set above).
Can someone please help me with any ides on this.If you want to use this query in the WHERE clause, then use it with EXISTS option which allows to return more than 1 column.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
'Missing select' error for update statement using WITH clause
Hi,
I am getting the below error for update statement using WITH clause
SQL Error: ORA-00928: missing SELECT keyword
UPDATE A
set A.col1 = 'val1'
where
A.col2 IN (
WITH D AS
SELECT col2 FROM
(SELECT col2, MIN(datecol) col3 FROM DS
WHERE <conditions>
GROUP BY PATIENT) D2
WHERE
<conditions on A.col4 and D2.col3>Hi,
The format of a query using WITH is:
WITH d AS
SELECT ... -- sub_query
SELECT ... -- main query
You don't have a main query. The keyword FROM has to come immediately after the right ')' that ends the last WITH clause sub-query.
That explains the problem based on what you posted. I can't tell if the real problem is in the conditions that you didn't post.
I hope this answers your question.
If not, post a complete test script that people can run to re-create the problem and test their ideas. Include a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
Timesten create a lock for select statement through sqldev
When use ttisql connect to TimesTen Release 7.0.6.15.0 at autocommit=1, there is no lock for select statement.
but when I use sql developer (driver is ttjdbc5.jar, regardless of version) to connect, even with autocommit=1, there will be locks for select statement.
Is it a bug? How can I achieve the same no locks for select statement through sql developer?Thanks.-your update tells me that you are connected to a remote timesten data store using the client driver
-the ttXactAdmin output indicates that SqlNavigator has a shared lock on the database itself: this will not interfere with anybody else' read operations, and I believe that until such time as you actually attempt some kind of DML against the data store that th IX lock on the database lock will not interfere with any other DML either.
-a shared database lock will always be acquired for any transaction in TimesTen. You can test this for yourself from ttisql: set autocommit off, perform a simple update and do not commit the transaction. Then open a separate session and execute ttxactadmin - you will the IX database lock as well as the various locks on tables and indexes.
-I believe this pretty much proves my original thinking: that sqlDeveloper attaches to TimesTen in transaction mode. However, the IX lock on the database will not interfere with anybody else's work and should not be a problem. -
How to write SELECT statement using tables ekko,ekpo and eket?
Hi,
I got a problem in performance tuning using below tables?
how to write SELECT statement using tables EKKO,EKPO and EKET and in conditon ( WHERE clause) use only fields
ekko~ebeln IN ebeln
ekko~loekz EQ ' '
ekko~lifnr IN lifnr
ekko~ekorg IN ekorg
ekko~ekgrp IN ekgrp
ekpo~werks IN werks
ekpo~pstyp EQ '3'
ekpo~loekz EQ space
ekpo~elikz EQ space
ekpo~menge NE 0
eket~rsnum NE space.
Thanks in Advance.
bye.Hi,
ekko~ebeln IN ebeln
ekko~loekz EQ ' '
ekko~lifnr IN lifnr
ekko~ekorg IN ekorg
ekko~ekgrp IN ekgrp
ekpo~werks IN werks
ekpo~pstyp EQ '3'
ekpo~loekz EQ space
ekpo~elikz EQ space
ekpo~menge NE 0 " Remove this from where clause
eket~rsnum NE space. " Remove this from where clause
' instead delete the entries after fetching into the table
DELETE it_itab WHERE menge EQ '0' AND rsnum EQ ' '.
Regards
Bala Krishna -
Create object type from multiple tables for select statement
Hi there,
I have 3 tables as given below and I wish to create an object type to group selected columns as 'attribute' from multiple tables.
I need to create 2 input parameters to pass in - 'attribute' and 'attribute value' in PL/SQL and these 2 parameters will be
passing in with 'column name' and 'column value'. e.g. 'configuration' - the column name, 'eval' - the column value.
Then, the PL/SQL will execute the select statement with the column and column value provided to output the record.
Pls advise and thank you.
table ccitemnumber
name null type
ccitemnumber not null varchar2(20)
configuration varchar2(20)
item_type varchar2(30)
table productmodel
productmodelnumber not null varchar2(6)
description varchar2(60)
accesstimems number
numberofheads varchar2(2)
generation varchar2(10)
numberofdiscs varchar2(2)
factoryapplication varchar2(150)
table topmodel
stmodelnumber not null varchar2(30)
productfamily varchar2(60
formfactor varchar2(10)
modelheight varchar2(10)
formattedcapacity number
formattedcapacity_uom varchar2(20)
object type in database
configuration varchar2(20)
item_type varchar2(30)
numberofheads varchar2(2)
generation varchar2(10)
numberofdiscs varchar2(2)
factoryapplication varchar2(150)
modelheight varchar2(10)
formattedcapacity number
formattedcapacuser12043838 wrote:
Reason to do this as these fields are required to be grouped together as they are created in different tables. They are treated as 'attribute' (consists of many columns) of the part number. So, the PL/SQL is requested to design in a way able for user to pass in the column name and column value or part number, then the select statement should be able to query for the records. Another reason is a new column can be added easily without keep modifying those effected programs. Reuseable too.This basically equates to ... hard to code, hard to maintain, and poor performance.
Are you really sure you want to do this? This isn't going to be easy-street as you seem to think it is, but it's a one way street to a poorly performing system with security vulnerabilities (google SQL Injection).
I would highly recommend you reconsider your design decision here. -
Create new tag for selected text using API?
Hello,
I want to add new tag for the selected text just like 'Create Tag from selection' .
is it possible to create tag for selected text using acrobat api?
please,help me.As per sample of snippetRunner for adding tag for selected text.
I tried below code
PDPage pg;
AVDoc avDoc = AVAppGetActiveDoc();
PDDoc pd = AVDocGetPDDoc(avDoc);
pg = PDDocAcquirePage(pd, 0);
ASAtom theSelectionType = AVDocGetSelectionType(avDoc);
if (theSelectionType == ASAtomFromString("Text")){
PDTextSelect ts = static_cast<PDTextSelect>(AVDocGetSelection(avDoc));
PDSTreeRoot pdsTreeRoot;
CosObj pageObj = PDPageGetCosObj (pg);
PDSElement newElem;
PDSElementCreate(pd, &newElem);
char buf1[64];
strcpy (buf1, "A new structure element");
// set its type as "Document" standard type
PDSElementSetType(newElem, ASAtomFromString ("Document"));
// set its title
PDSElementSetTitle(newElem, reinterpret_cast<const ASUns8*> (buf1), strlen(buf1));
PDSTreeRootInsertKid (pdsTreeRoot, aElem, kPDSAfterLast);
PDSElementInsertMCAsKid // here something i have to add
If i have PDTextSelect how i can add tag for selected text.like user add tag using "CreateTagForSelectedText" option.
please,help me.
thanks. -
Converting a delete statement using VPD policies and context
Hello,
I'm trying to convert a delete statement in a update statement using VPD policies and context.
+/* Supose the user 'user1' already exists. This is an application user */+
conn user1/pwd
create table user1.test_a (
id number(4),
description varchar2(100),
deleted number(1)
+);+
alter table user1.test_a add constraint test_a_pk primary key (id);
insert into user1.test_a (1, 'abc', 0);
insert into user1.test_a (2, 'def', 0);
commit;
I'd like to convert each physical deletion into a logical deletion: statements like "delete from user1.test_a where id = 1" must be converted into "update user1.test_a set deleted = 1 where id = 1".
I've found the following way: I will create a policy to avoid physical deletion. Additionally, the policy function should update the deletion flag too.
conn user1/pwd
+/* Create context package */+
create or replace package user1.pkg_security_context is
procedure p_set_ctx(
i_test_a_id in user1.test_a.id %type
+);+
end;
+/+
create or replace package body user1.pkg_security_context is
procedure p_set_ctx (
i_test_a_id in user1.test_a.id %type
+) is+
begin
dbms_session.set_context( 'user1_ctx', 'test_a_id', i_test_a_id );
end;
end;
+/+
show errors
+/* Create trigger to set the context before deletion */+
create or replace trigger user1.test_a_bef_trg
before delete on user1.test_a
for each row
declare
pragma autonomous_transaction;
begin
-- only commits the preceding update, not the delete that fired the trigger.
commit;
user1.pkg_security_context.p_set_ctx( :old.id );
end;
+/+
show errors
create context user1_ctx using user1.pkg_security_context;
+/* Policy function */+
create or replace function user1.f_policy_chk_dels (
object_schema in varchar2,
object_name in varchar2
+) return varchar2+
is
out_string varchar2(400) default '1=2 ';
+/*+
* out_string is the return value.
* - 'WHERE 1=2' means 'nothing to access'
begin
if ( loc_logged_usr_authorized > 0 ) then
+/*+
* Set the flag deleted to 1
update user1.test_a set deleted = 1 where id = sys_context( 'user1_ctx', 'test_a_id' );
out_string := out_string || 'or 1=1 ';
end if;
return out_string;
end;
+/+
show errors
+/*+
* Create policy
begin
dbms_rls.add_policy(
object_schema => 'user1' ,
object_name => 'test_a' ,
policy_name => 'policy_chk_dels' ,
function_schema => 'user1' , -- function schema
policy_function => 'f_policy_chk_dels' , -- policy function
statement_types => 'DELETE'
+);+
end;
+/+
When I try to delete a record of the table test_a:
conn user1/pwd
SQL> delete from ilogdia.oplsimulaciones sim where sim.id = 9999;
+0 rows deleted+
No rows has been deleted, but the update stmt does not work. That means, the "deleted" flag has not been updated.
Any ideas?
Thank you in advance.
Marco A. Serrano
Edited by: albrotar on Oct 15, 2012 8:42 AM
Edited by: albrotar on Oct 15, 2012 8:42 AM
Edited by: albrotar on Oct 15, 2012 8:43 AMThe policy function is applied once per statement execution. The policy function executes first and the UPDATE statement, presumably, updates no rows because the context is not yet populated. The row-level populates the context (I'm assuming that your session can even see context values populated by an autonomous transaction-- I would guess it could but I'd have to test that) after the UPDATE statement is already complete. The COMMIT in the row-level trigger is also pointless-- it only applies to changes made by the current autonomous transaction, of which there are none-- it cannot apply to changes made in other autonomous transactions. Declaring the row-level trigger to use autonomous transactions doesn't seem to accomplish anything other than to open the question of whether the values set in the context by the autonomous transaction are visible in the caller's transaction.
Even if this, somehow, did work, using autonomous transactions would be a very bad idea since Oracle is free to roll-back a partially executed statement (and the work done by its triggers) and re-execute it. Oracle does that with some regularity to maintain write consistency.
Justin -
Face time with wifi only. I have a 4Gs iPhone traveling to Japan. Can I use face time with another 4Gs or IMacback in the States using just wifi and with I have my Celluar Data and Data Roaming off?
Thanks, After changing my settings in face time per your suggestion, (it needed to be done), I turned off cellular data and data roaming and made a call using face time. It worked! Great way to stay in touch while overseas without the need for those egregious phone data plans.
-
Performance Tuning -To find the execution time for Select Statement
Hi,
There is a program that takes 10 hrs to execute. I need tune its performance. The program is basically reading few tables like KNA1,ANLA,ANLU,ADRC etc and updates to Custom table. I did my analysis and found few performance techniques for ABAP coding.
Now my problem is, to get this object approved I need to submit the execution statistics to client.I checked both ST05 and SE30. I heard of a Tcode where we can execute a select statement and note its time, then modify and find its improved Performance. Can anybody suggest me on this.
Thanks,
Rajani.Hi,
This is documentation regarding performance analysis. Hope this will be useful
It is a general practice to use Select * from <database> This statement populates all the values of the structure in the database.
The effect is many fold:-
It increases the time to retrieve data from database
There is large amount of unused data in memory
It increases the processing time from work area or internal tables
It is always a good practice to retrieve only the required fields. Always use the syntax Select f1 f2 fn from <database>
e.g. Do not use the following statement:-
Data: i_mara like mara occurs 0 with header line.
Data: i_marc like marc occurs 0 with header line.
Select * from mara
Into table i_mara
Where matnr in s_matnr.
Select * from marc
Into table i_marc
For all entries in i_mara
Where matnr eq i_mara-matnr.
Instead use the following statement:-
Data: begin of i_mara occurs 0,
Matnr like mara-matnr,
End of i_mara.
Data: begin of i_marc occurs 0,
Matnr like marc-matnr,
Werks like marc-werks,
End of i_marc.
Select matnr from mara
Into table i_mara
Where matnr in s_matnr. -
Advice required on a select statement using "FOR ALL ENTRIES"
Hi,
this is really intresting ...
I have a small requirement where in i have to find out
the valid entries in my internal table (T_MATNR) by using a select statement to a check table (MARA) which has all the fields present in the internal table T_MATNR.
Select statement is
SELECT MATNR
MTART
from MARA
for all entries in T_MATNR
into table T_MATNR
where matnr eq T_MATNR-MATNR.
If you observe the itab in the option 'FOR ALL ENTRIES' and the destination table is the same. I want to know whether this is correct? will it cause any performance issue? right now this statement is working fine for me.Hi,
U have to use
SELECT MATNR
MTART
from MARA
<b>into table I_MATNR(different table)</b>
for all entries in T_MATNR
where matnr eq T_MATNR-MATNR.
If u r specifying both same table name then for what entries it will retrieve, if u have alreay selected some entries and appending u can use
SELECT MATNR
MTART
from MARA
<b>into table T_MATNR</b>where matnr eq T_MATNR-MATNR.
then
SELECT MATNR
MTART
from MARA
<b>appending table T_MATNR</b>
for all entries in T_MATNR
where matnr eq T_MATNR-MATNR.
In this way u can do.
Hope u got it. -
Performance Issue in Select Statement (For All Entries)
Hello,
I have a report where i have two select statement
First Select Statement:
Select A B C P Q R
from T1 into Table it_t1
where ....
Internal Table it_t1 is populated with 359801 entries through this select statement.
Second Select Statement:
Select A B C X Y Z
from T2 in it_t2 For All Entries in it_t1
where A eq it_t1-A
and B eq it_t1-B
and C eq it_t1-C
Now Table T2 contains more than 10 lac records and at the end of select statement it_t2 is populated with 844003 but it takes a lot of time (15 -20 min) to execute second select statement.
Can this code be optimized?
Also i have created respective indexes on table T1 and T2 for the fields in Where Condition.
Regards,If you have completed all the steps mentioned by others, in the above thread, and still you are facing issues then,.....
Use a Select within Select.
First Select Statement:
Select A B C P Q R package size 5000
from T1 into Table it_t1
where ....
Second Select Statement:
Select A B C X Y Z
from T2 in it_t2 For All Entries in it_t1
where A eq it_t1-A
and B eq it_t1-B
and C eq it_t1-C
do processing........
endselect
This way, while using for all entries on T2, your it_t1, will have limited number of entries and thus the 2nd select will be faster.
Thanks,
Juwin -
Performance Issie in SQL Statement Using Hints
Hi,
I am using Oracle version 10G.
I am using a INSERT statement as:
INSERT /*+ PARALLEL (TEST,4) */ INTO TEST(COL1,COL2,COL3) SELECT COL1,COL2,COL3 FROM DUMMY;
For increasing the Performance I am using the above statement.
Will the usage of Hints increase the Performance?
Any help will be highly needful.
Thanks and Regardsuser598986 wrote:
I am using Oracle version 10G.
I am using a INSERT statement as:
INSERT /*+ PARALLEL (TEST,4) */ INTO TEST(COL1,COL2,COL3) SELECT COL1,COL2,COL3 FROM DUMMY;
For increasing the Performance I am using the above statement.
Will the usage of Hints increase the Performance?The way you're asking the question suggests that you're not sure what this particular hint is supposed to imply.
Using this hint suggests that you want to take advantage of direct-path parallel DML operations. Note that you explicitly need to enable parallel DML in your session, it is disabled by default, because it has some significant implications and restrictions. You should think about parallelizing the query on DUMMY, too, if it is not marked as PARALLEL in the dictionary, because otherwise you're combining a parallel DML operation with a serial query which might not be that efficient.
Note that there is no general answer to the question if this particular hint will actually increase the performance of the DML statement. There are many things to consider, among them are if your system scales reasonably with parallel operations and if the underlying object structure actually allows to benefit from the parallel operation. There are cases where a serial operation might be faster than a parallel operation.
For more information about direct-path and parallel execution, its implications and restrictions, see the documentation:
http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_9014.htm#i2163698
http://download.oracle.com/docs/cd/B28359_01/server.111/b28313/usingpe.htm#CACEJACE
You can use the EXPLAIN PLAN and the DBMS_XPLAN.DISPLAY function to get the execution plan of your statement that shows you what kind of parallel operations the optimizer estimates to perform.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Runtime error for SELECT statement
Hi All,
I have written a SELECT statement as follows in my code.
select budat pernr aufnr vornr from AFRU
into corresponding fields of table it_vornr
for all entries in it_cats_tmp
where budat = it_cats_tmp-workdate
and pernr = it_cats_tmp-pernr
and aufnr = it_cats_tmp-rnplnr.
The table IT-CATS_TMP is having around 3000+ lines.
When control moves to this statement, the system is throwing Runtime error or its taking around 30 minutes time to execute.
If i query the same table (AFRU) in SE11 for the same set of conditions, the table displays relevent data immediately.
What might be the reason for this delay/Runtime Error?
Shall i need to change the syntax for better performance?
Your guidelines are highly appreciated......
Regards
PavanHi
1. Try to put WHERE conditions for KEY FIELDS.
Solution: Create a RANGE for the key fields & put that in SELECT Query.
DATA: gr_rueck TYPE RANGES OF afru-rueck.
SELECT .. WHERE rueck IN gr_rueck.
2. Avoid using CORRESPONDING FIELDS OF TABLE in SELECT.
Solution: Change internal table fields ORDER.
TYPES:
BEGIN OF TY_VORNR,
budat TYPE ..
pernr TYPE ..
aufnr TYPE ..
vornr TYPE ..
... " Other fields
END OF TY_VORNR.
SELECT .. INTO TABLE IT_VORNR ...
Maybe you are looking for
-
Unicode - How to pass character variable to hex variable?
Hi, DATA : XTAB(2) TYPE x, XSEPARATOR(1) TYPE c. How do I transfer contents of XSEPARATOR into XTAB without causing a Unicode error? I have read that a Class CL_ABAP_CHAR_UTILITIES can be used, but I dont know how ...
-
Hello Everyone, I'd like to know the geographical info(country, region, city,...etc) of client using java API.Is this possible? I have searched on the web.However, I could not get any info. Could someone let me know whether it is possible or not,Plea
-
If I try to download the 64 bit I tunes, the options are to fix or delete. If I choose delete (so that later) I can reinstall the 64 bit, will all my current data in library lost
-
I have a Macbook Pro connected to a 24" cinema monitor. Recently when I wish to use the camera it tells me that it cannot connect as it is being operated by another programme but I do not have any other programme. Can anybody advise how I can overcom
-
Hi, I am trying to find a flash member from the first 100 sprites. But somehow it does not work. My code never comes to the output of the "flash!!!" but in my message window i can find the symbol #flash. Any ideas what I am doing wrong here: for (n=1