‎2007 Jun 08 11:12 AM
Hi All,
How the performance is improved when we use the view in the select statement rather than using database table name directly with join statement?
‎2007 Jun 08 11:55 AM
1. First remove occurs 0 and occurs 0,
use types and delcare structure.
then declare internal table.
ex-
types: begin of ty_lfa1,
kunnr like kna1-kunnr,'end of ty_kna1.
data : i_kna1 type standard table of ty_kna1 with header line.
instead of inner join use for allentries.
into corresponding fields of will decrease performance.
delete adjacent duplicates from itab_final comparing matnr lgort.
place it outside the loop.
 before every select statenet check sy-subrc = 0.if sucessful the write another one.
 dont' loop an internal table more than once.
and for better performane follow below points
Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
Avoid for all entries in JOINS
Try to avoid joins and use FOR ALL ENTRIES.
Try to restrict the joins to 1 level only ie only for tables
Avoid using Select *.
Avoid having multiple Selects from the same table in the same object.
Try to minimize the number of variables to save memory.
The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
Avoid creation of index as far as possible
Avoid operators like <>, > , < & like % in where clause conditions
Avoid select/select single statements in loops.
Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.
Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
Avoid using ORDER BY in selects
Avoid Nested Selects
Avoid Nested Loops of Internal Tables
Try to use FIELD SYMBOLS.
Try to avoid into Corresponding Fields of
Avoid using Select Distinct, Use DELETE ADJACENT
Go through the following Document
Check the following Links
http://www.sapgenie.com/abap/performance.htm
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
check the below link
http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
See the following link if it's any help:
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
Check also http://service.sap.com/performance
regards
Suresh.D
‎2007 Jun 08 12:32 PM
Hi,
Generally speaking, View are more closly binded with database as it is part of database . so decideing field types and structure doesnot table time also link are automatically esatblished this time is alos saved ...
instead, select stmt decides at runtime what filed will be fetched, this takes some time...
So performance is improved using views rather than select statement.
Jogdand M B
‎2007 Jun 08 1:03 PM
It partly depends on the database - I've seen it where a JOIN is quicker (but only maginally) than a view.
The first time the ABAP runs it does take a bit longer, but after that it uses the execution path and so runs faster.
Defining a view means that the join has to be rebuilt every time it is used.