Select querry - performence
Hi all,
I want to clarify one thing...........
1. select F1 F2 F3
from X
into table itab
where F1 in s_F1
and F2 in s_F2.
2. Select * from X into table itab.
here itab type table of X.
which select statement will give less perfomence and is there any relation betwwen table size and perfomence of select querry?
If there is a relation let me know how to find it..........
Thanks,
kk.
Hi Kusuma,
the answer is, it depends (as you already have read in the other postings):
If both ranges are filled and you have an index on both fields (as the two first columns of the index - may be with the client in the first place), the first statement will probably run faster than the second in most cases, because it has to read less blocks from disk. This could be also incorrect if the selectivity of your ranges is bad and your table is huge.
If your ranges in the query are not filled, than both statements are equivalent and read the same amount from disk. If the table has more columns than three, then the first query may be a bit faster because it has not as many data to transfer between database and application.
If only the second range is filled and you have no suitable index on column F2, than the first query could run even longer than the second because some databases (Oracle and DB2, may be MS SQL Server too) could create execution plans which reads the table multiple times. It depends on your indexes and their statistics if it happens or not. In most cases, it will run not longer than the second statements, but in rare situation it could run considerably longer.
You see, SQL is complex and the execution depends heavily on the implementation in the database management system itself.
One additional comment. If your ranges contains only single values, it would be much better for the stability of your coding if you use FOR ALL ENTRIES. The database interface could create suitable junks of values if you use FOR ALL ENTRIES. If you use IN range, this could not be done and if the range gets to big (bigger than the maximum statement size), you'll get a dump. For simple queries with only two ranges this is not very likely, but if your example grows, it's getting more and more likely.
Best regards
Ralph Ganszky
Similar Messages
-
Dynamic select querry in sender jdbc adapter
Hi,
We are working on a scenario where in we will be using different source database tables , we were trying to see if it is possible that the select querry can be made dynamic so that the same communication channel can be used for all the different source tables.
Request all to come up with suggestions as to if this is possible.
Thanks ,
Pravesh Puria.Hi All,
Thanks VJ for your reply.
Let me reframe my question.
I have multiple database instances at source side. On all instances I have same table name.
My requirement is to poll all these instances table and fetch data.
Do I need to create multiple sender agreements or there is a way to dynamically change the datbase name in sender Communication channel.
Any other solution is also appreciated.
Same is the case with JMS adapter, Multiple instances of JMS are there at source side sending similar structure data in there own queue.
Request you to kindly response.
Regards,
Pravesh -
Dynamic select querry in sender JDBC channel
Hi,
We are working on a scenario where we need to read data from various database tables , we were trying to see if it is possible that the select querry can be set dynamically so that the same channel can be used to read from the various tables.
Request all to please come up with suggestions as to whether this is possible.
Thanks ,
Pravesh Puria.Hi All,
Thanks VJ for your reply.
Let me reframe my question.
I have multiple database instances at source side. On all instances I have same table name.
My requirement is to poll all these instances table and fetch data.
Do I need to create multiple sender agreements or there is a way to dynamically change the datbase name in sender Communication channel.
Any other solution is also appreciated.
Same is the case with JMS adapter, Multiple instances of JMS are there at source side sending similar structure data in there own queue.
Request you to kindly response.
Regards,
Pravesh -
Problem in select querry with select option
Hi all,
How have a problem with the select querry, Pls correct my querry
select opbel gpart betrw fdgrp into table lt_balance from dfkkop
where fdgrp in s_augrp
and hvorg = '5000'
and tvorg = '0100'.
Thanx in advance,
LineHi
I have tried this select querry, but I am unable to fetch the data in the internal table
select opbel gpart betrw fdgrp into correspondiing fields of table it_balance
from dfkkop
where fdgrp in s_augrp
and hvorg = '5000'
and tvorg = '0100'.
Can you please tell me what is wrong in this querry,
Line -
Select querry for hr records.
hi all,
i was writing a hr report to to get the employee no's based on the employment status given in the selection screen. i was using the standard screen from PNP databse.
but when i was giving the from and to date and the employment status . and i am using GET PERNR to fetch the records. but it is not considering the status.
so i wrote a select querry to check the records fetched after GET PERNR matches with the employment status given in the selection screen. but the select querry is not working.
SELECT SINGLE STAT2 INTO PERNR-STAT2 FROM PA0000
WHERE PERNR = PERNR-PERNR
AND BEGDA GE PN-BEGDA
AND ENDDA LE PN-ENDDA
AND STAT2 IN PNPSTAT2.
CHECK PERNR-STAT2 IN PNPSTAT2.
IF SY-SUBRC NE 0.
REJECT.
ENDIF.
so please some one give the select querry to get the records from pa0000 tables based on the date range given and the employment status given.Hi Praveen,
welcome to SDN.
Please check that did you pass
<b>Infotypes: 0000.</b>
in the declaration part of the statement.
Get Pernr will consider the status then.
Regards,
Amit
P.S. Please close the issue and reward points to helpful answer once Query is solved.
Message was edited by: Amit Khare -
How to make SELECT querry to work for CONVERSION EXIT
Dear All,
I want to select some data from from table J_1IEXCTAX , and to limit that retrieval I have WHERE clause for fields VALIDFROM and VALIDTO
My select querry is like
SELECT SINGLE RATE ECSRATE
FROM J_1IEXCTAX
INTO (J_1IEXCTAX-RATE,J_1IEXCTAX-ECSRATE)
WHERE J_1ICHID = J_1IMTCHID-J_1ICHID and
( VALIDFROM LE T_GRREC-BUDAT and
VALIDTO GE T_GRREC-BUDAT ).
But the field VALIDFROM and VALIDTO have data (i.e. dates) in different format
So my selection doesnt happen..
these formats can be converted to desired format using CONVERSION EXITs at their domain level...
But that increases coding and worsens performance.....
Could anybody give me some other solution?
Thanks in advance................
Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:58 AMHi,
write T_GRREC-BUDAT to gv_date as <specify the format>
now use gv_date in ur seelct query.
Regards,
Nagaraj -
Select querry using inner join
Hi Friends,
I need to fetch data from two tables, I used inner join but I am not able to fetch the data in some fields can any one tell me what is wrong in this select querry.
SELECT but000~partner
but000~name_org1
but000~name_first
but000~name_last
but000~bpext
FROM but000 INNER JOIN dfkkop ON but000partner = dfkkopgpart
INTO table lt_but000
WHERE but000~partner IN so_part
AND dfkkop~faedn IN so_faedn.
Thanx in advance,
Parvezhi Lutin,
SELECT but000~partner
but000~name_org1
but000~name_first
but000~name_last
but000~bpext
FROM but000 INNER JOIN dfkkop ON but000partner = dfkkopgpart <------check this condition,it has to *satisfy both table
INTO table lt_but000
WHERE but000~partner IN so_part
AND dfkkop~faedn IN so_faedn.
Regards,
siva
Message was edited by:
SivaKumar -
hi experts.
SELECT * INTO CORRESPONDING FIELDS OF TABLE it_sym FROM ismp
JOIN ismitop ON ( ismpismnr = ismitopismnr )
JOIN ismitpr ON ( ismpismnr = ismitprismnr )
WHERE ismp~ismnr IN s_sympt.
i am using this select querry but when the ismnr is not mensioned in any of ismitop or ismitpr but is ther e in ismp. the table it_sym is null.
i want full join. how should i write.
plz suggest the code.
with regards
ajayselect ismp~ismnr
ismp~ismtp
ismp~ismart
ismp~objnr
ismp~valdtfrm
ismp~valdtto
ismitop~opgrp
ismitop~opcod
ismitpr~prgrp
ismitpr~prcod
from ( ismp LEFT JOIN ismitop ON ( ismpismnr = ismitopismnr )
LEFT JOIN ismitpr ON ( ismpismnr = ismitprismnr ) )
into corresponding fields of table IT_SYM
WHERE ismp~ismnr IN s_sympt.
even after writing this the record has not been fetched if the data is not mainsioned in any table of corresponding ismnr.
please help..
ajay -
Select querry for maximum value
Hi,
I want to select fields A B C D from a database table TAB using some selection criteria from selection screen, but the greatest value of A has to be selected for all unique entries of B C and D. Please suggest an appropriate select querry.
PS: I cannot use SELECT and then DELETE ADJACENT DUPLICATES as it will effect performance in some cases.
Regards.Try using aggregate function MAX with SELECT statement.
MAX Returns the greatest value in the column determined by the database field f for the selected lines. Specifying DISTINCT does not change the result. NULL values are ignored unless all values in a column are NULL values. In this case, the result is NULL .
Have a look at below link:
[Select Clause|http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select_c.htm]
I hope it helps.
Best Regards,
Vibha
Please mark all the helpful answers -
Problem with for all entries in select querry
hi,
Hi,
I am using select queery like this
SELECT version COUNT( * )
from ztbi_default_va4
INTO CORRESPONDING FIELDS OF TABLE lit_new
FOR ALL ENTRIES IN lit_new1
WHERE network = lit_new1-network GROUP BY version.
this is not working showing error as:
The addition "FOR ALL ENTRIES" excludes all aggregate functions with
the exception of "COUNT( * )" as the single element of the SELECT clause.
I am using only count(*) ,not using othes like max,min etc,,,,,,,,,
please suggest any missing in syntax,,,,attach relavant code using count(*) with for all entreis
any help appriciated,,,,,
Thanks in advance,,,,Hi,
Try this -
TYPES: begin of t_data,
version TYPE version,
count type i,
end of t_data.
DATA: i_data TYPE STANDARD TABLE OF t_data,
wa_data TYPE t_data.
DATA: l_version TYPE version,
l_count TYPE i.
SELECT version COUNT( * )
from ztbi_default_va4
INTO CORRESPONDING FIELDS OF TABLE lit_new
FOR ALL ENTRIES IN lit_new1
WHERE network = lit_new1-network.
SORT lit_new.
LOOP AT lit_new INTO lwa_new.
IF lwa_new EQ l_version.
l_count = l_count + 1.
ELSE.
wa_data-version = l_version.
wa_data-count = l_count + 1.
APPEND wa_data TO i_data.
CLEAR: wa_data.
CLEAR: l_count.
ENDIF.
l_version = lwa_new-version.
CLEAR: lwa_new.
I hope this will do.
Make any necessary changes.
Regards,
Harsh Bansal -
Hi,
while debugging values are populating for mkpftbl but not to msegtbl. can anyone suggest where i am going wrong.
if sy-batch = 'X'.
select mblnr mjahr bldat cputm
from mkpf
into table mkpftbl
where bldat eq wtoday
and tcode2 eq ctcode2.
else.
select mblnr mjahr bldat cputm
into table mkpftbl
from mkpf
where mblnr in mblnr
and mjahr in mjahr
and tcode2 eq ctcode2.
endif.
if not mkpftbl[] is initial.
loop at mkpftbl.
select zeile charg matnr werks menge
into corresponding fields of table msegtbl
from mseg
Appending table msegtbl
for all entries in mkpftbl
where mblnr eq mkpftbl-wmblnr
and mjahr eq mkpftbl-wmjahr
and bwart eq cbwart
and werks eq splant.
*endloop.Hi Nihi
Try making the changes as highlighted below:
<u><b>Declaration:</b></u>
data: begin of mkpftbl occurs 0,
<b>wmblnr like mkpf-mblnr, "Material Document Number
wmjahr like mkpf-mjahr, "Material Document Year
wbldat like mkpf-bldat, "Document date in document
wcputm like mkpf-cputm, "Time of Entry</b>
end of mkpftbl.
data: begin of msegtbl occurs 0,
<b> wmblnr like mseg-mblnr, "Material Document Number
wmjahr like mseg-mjahr, "Material Document Year
wzeile like mseg-zeile, "Item in Material Document
wmatnr like mseg-matnr, "Material number
wwerks like mseg-werks, "plant
wcharg like mseg-charg, "batch number
wmenge like mseg-menge, "Quantity
wbldat like mkpf-bldat, "Document date in document
wcputm like mkpf-cputm, "Time of Entry</b>
end of msegtbl.
<u><b>Routine For Extraction:</b></u>
data: wrecord type i.
data: wtime type t.
data: wtoday type d.
move sy-datum to wtoday.
move sy-uzeit to wtime.
if wtime eq '000000'.
wtoday = wtoday - 1.
endif.
status = 1.
if sy-batch = 'X'.
select mblnr mjahr bldat cputm
from mkpf
into table mkpftbl
where bldat eq wtoday
and tcode2 eq ctcode2.
else.
select mblnr mjahr bldat cputm
into table mkpftbl
from mkpf
where mblnr in mblnr
and mjahr in mjahr
and tcode2 eq ctcode2.
endif.
if not mkpftbl[] is initial.
select <b>mblnr mjahr zeile matnr werks charg menge</b>
from mseg
<b>into table msegtbl</b>
for all entries in mkpftbl
where mblnr eq <b>mkpftbl-wmblnr</b>
and mjahr eq <b>mkpftbl-wmjahr</b>
and bwart eq cbwart
and werks eq splant.
status = 0.
endif.
Hope this helps you.
Kind Regards
Eswar -
G/L Accounts: JOINs between BKPF & BSIS & SKA1 in SELECT satetment??
Hi Experts,
About G/L Accounts, pls. clarify ma simple doubt that, am looking to pull the data from BKPF , BSIS & SKA1, so,
1) So, Wht culd be the best JOIN structure in SELECT statements, performence perspective, bcoz, I did not find any JOIN clue btwn BKPF & BSIS.
ThanQopened other thread
-
PL/SQL: how to use in parameter in select sql where clause
Hi
in a procedure, I need to apply 'in parameter' in 'where clause' along with other table fields. Purpose is to create dynamic select querry with multiple conditions.
select count(*) from table xx
where y_code=2008 and v_type in ('SI', 'TI', 'DI') ;
my requirement is replace 'and v_type in ('SI', 'TI', 'DI')' with in parameter. pls note in paramter may contain null value.
Regards... e.g. why on earth do you want to pass in a string to be appended to the WHERE clause of an SQL.I second that and I strongly advice NOT to do it. If you really want to do it, then come back and show us, how you would prevent SQL injection. This approach is too dangerous (and too complex) IMHO.
Do it straight forward as in the article of Tom Kyte (link in the post of BluShadow above) -
Hi ,
I have a table with SM30.
and my Select query for SD report takes what are the user ID;s maintained in the Ztable.
But If the enduser is a Internal User and not maintained in the Ztable he should be able to see all the sales orders.
If the entered user is maintained in the table he should be able to see only the customers which are assigned to it.
if he tries to see the customer which is not asigned to him
it should throw a error message.
Please let me know what I should do.
My Select querry is
SELECT
kunnr
FROM zsd_c2c_auth
INTO CORRESPONDING FIELDS OF
TABLE gt_c2c_auth
WHERE kunnr IN s_kunnr
AND syuname = sy-uname.
Thanks,
VarunIf current user is end user,it will not return any records after your select query as this user is not maintained in Z table. In this case,write ur select query again without user condition. It will give you desired results.
SELECT
kunnr
FROM zsd_c2c_auth
INTO CORRESPONDING FIELDS OF
TABLE gt_c2c_auth
WHERE kunnr IN s_kunnr
AND syuname = sy-uname.
->> If current user is not maintained i.e. he is end user,display all records
if sy-subrc NE 0 OR gt_c2c_auth[] is initial.
SELECT
kunnr
FROM zsd_c2c_auth
INTO CORRESPONDING FIELDS OF
TABLE gt_c2c_auth
WHERE kunnr IN s_kunnr.
endif.
Regards,
Aparna Gaikwad -
Sender JDBC Communication Update SQL Command Problem!
Hi all,
I am trying to do a SENDER JDBC Scenario in XI.
I fetch the Records from the table Once per day based on the Current Date.
I do not have any Update Credentials in the table.
I can only perform Select Querry.
But when i am trying to configure the SENDER JDBC Channel its asking me to enter value for Update SQL Command in Sender JDBC communication channel Process Parameters.
Its not accepting BLANK or ' * ' Values.
But i have only Select Querry credentials in the table. I can only pick the values cant Update the tables but.
In the Above scenario how can i configure the Sender JDBC CC without Updating the Table after fetching the value?
Please Advice
Regards,
Senthilprakash.Hi,
Specify the Update SQL Statement value as .
http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm
Thanks
SaNv...
Edited by: Sãnthosh Kûmãr V on Oct 8, 2008 10:44 AM
Edited by: Sãnthosh Kûmãr V on Oct 8, 2008 10:45 AM
Maybe you are looking for
-
Problem in inserting record in Siebel on demand's object thru web service
Hi All, We are working on Siebel on Demand (software as a service) CRM. We are using web service to communicate. We have WSDL files and we generated the code using Axis framework that comes along with Eclipse. We are able to login and logoff to the
-
Hi guys i have a mid 2010 MacBook Pro with the nvidia geforce 320m card I have 6GB Ram in the laptop when im on mac the VRAM is 256MB But when im on windows it says approx, Total memory 2934MB under display can anyone tell me how this works please?
-
WLC 4402 RADIUS Authentication with IAS
Hello I configured a WLAN with PEAP (CHAP v2)and Radius authentication to a Win 2003 IAS Radius Server. On the controller 4402 the layer 2 security is set to WPA1+WPA2 with 802.1x authentication. The IAS server don't use the configured policy when a
-
Refusing to trash events and error codes
Trying to move an event to trash and got this message: This file could not be moved: /Users/johngraham/Movies/iMovie Events.localized/THE SABINA REPORT* ( Error code: -43 ) Any ideas? What is error code -43? Is there a composite list of errors?
-
language, english