<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: CDS View - Parameter vs. WHERE in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725963#M33997</link>
    <description>&lt;P&gt;Hi Horst,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Thank you. This makes my problem more clear. Can you clearify the part were you mention the context menu in ADT? Where can I view the DB-object of my CDS view? Do you mean the SQL View?&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Does this technique work differently on a HANA platform?&lt;/P&gt;
  &lt;P&gt;Edit:&lt;/P&gt;
  &lt;P&gt;I've just seen something interesting. I've tested the performance when totally discarding the CDS-parameters. Then I've just selected the records I want in the WHERE statement (when calling my CDS-view). This way the performance is &lt;STRONG&gt;excellent&lt;/STRONG&gt;. This way I've come to the conclusion that we cannot combine CDS-parameters with a WHERE clause when calling the CDS. This is killing the performance because the WHERE is beiïng performed on the resultset.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Aug 2018 06:26:03 GMT</pubDate>
    <dc:creator>schoutenk</dc:creator>
    <dc:date>2018-08-28T06:26:03Z</dc:date>
    <item>
      <title>CDS View - Parameter vs. WHERE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725958#M33992</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;I'm still learning to construct a solid CDS view. While I was developing I was curious about the performance of the CDS view while comparing the parameters versus the WHERE statement.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;I've constructed a CDS view:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;@AbapCatalog.sqlViewName: 'XXX'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Module Data'
@ClientDependent: true
define view XXX

with parameters p_idate:abap.dats,
                p_lang:abap.lang,
                p_objid:abap.numc(8)
  
-- The Main object
  as select distinct from hrp1000  as object
  
-- Module Credits
  left outer join hrp1741 as module_credits 
    on object.plvar = module_credits.plvar 
      and object.otjid = module_credits.otjid
                                
-- Module Capacity
  left outer join hrp1024 as capacity 
    on object.plvar = capacity.plvar
      and object.otjid = capacity.otjid
                                
-- Module Data
  left outer join hrp1746 as module_data 
    on object.plvar = module_data.plvar
      and object.otjid = module_data.otjid

{

    key object.objid             as ID,
    object.mc_short              as ShortName,
    object.stext                 as Name,
    object.begda                 as BeginDate,
    object.endda                 as EndDate,
    
    module_credits.cpmin         as MinCredits,
    module_credits.cpmax         as MaxCredits,
    module_credits.cpopt         as OptimumCredits,
    
    capacity.kapz1               as MinCapacity,
    capacity.kapz2               as OptimumCapacity,
    capacity.kapz3               as MaxCapacity,
    
    module_data.severity         as AcademicLevel,
    module_data.category         as Category,
    module_data.modrepeattype    as RepetitionType,
    module_data.waitl_level      as WaitingListLevel,
    module_data.waitl_number     as WaitlistInPercent,
    module_data.waitl_disabled   as WaitListIsDisabled,
    module_data.mult_sec_enabled as MltplSctnIsEnabled,

}
where object.plvar = '01'
  and object.otype = 'SM' 
  and object.objid = $parameters.p_objid
  and object.begda &amp;lt;= $parameters.p_idate 
  and object.endda &amp;gt;= $parameters.p_idate
  and object.langu = $parameters.p_lang
  and module_credits.begda &amp;lt;= $parameters.p_idate 
  and module_credits.endda &amp;gt;= $parameters.p_idate
  and capacity.begda &amp;lt;= $parameters.p_idate 
  and capacity.endda &amp;gt;= $parameters.p_idate
  and module_data.begda &amp;lt;= $parameters.p_idate 
  and module_data.endda &amp;gt;= $parameters.p_idate

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;The performance of this view is great. But I don't want to use the Objectid (OBJID) as a parameter. I just want to be able to select all objects which I need in each specific selection.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Performance when using the OBJID as parameter: ~120.000 microsec.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Performance when using the OBJID in the WHERE clause: ~800.000 microsec.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Why is the performance so much slower when using the OBJID in the WHERE clause instead of the OBJID as parameter?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 13:07:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725958#M33992</guid>
      <dc:creator>schoutenk</dc:creator>
      <dc:date>2018-08-15T13:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View - Parameter vs. WHERE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725959#M33993</link>
      <description>&lt;P&gt;&lt;/P&gt;
  &lt;P&gt;Sorry, I'm confused. What do you mean with &lt;/P&gt;
  &lt;P&gt;"OBJID as parameter" vs. "OBJID in the WHERE clause"?&lt;/P&gt;
  &lt;P&gt;Do you speak about the Open SQL Statement accessing the view, one time with object id passed as parameter and one time in its WHERE clause?&lt;/P&gt;
  &lt;P&gt;If yes, use SQL trace in ABAP Debugger or in ST05 in order to see the different SQL Statements generated by the DBI. That should give you a hint why the performance differs.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 13:26:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725959#M33993</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2018-08-15T13:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View - Parameter vs. WHERE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725960#M33994</link>
      <description>&lt;P&gt;Hi Horst, &lt;/P&gt;
  &lt;P&gt;Thanks for your quick reply.&lt;/P&gt;
  &lt;P&gt;Maybe my initial question wasn't clear enough. So I'll try to explain.&lt;/P&gt;
  &lt;P&gt;I've created an CDS view as the one stated above. I'm not pleased with the performance of this CDS-view.&lt;/P&gt;
  &lt;P&gt;I've tested out the difference of performance while passing my selection (the OBJID) through the CDS-view parameter and through the WHERE clause.&lt;/P&gt;
  &lt;P&gt;So I've got two calls:&lt;/P&gt;
  &lt;P&gt;First one (through parameter)&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;SELECT *
  FROM zcmod_dd_module_data( p_idate = @sy-datum, p_lang = @sy-langu, p_objid = '12345678' )
  INTO TABLE @DATA(lt_module_data).&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Second one (through WHERE clause)&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;SELECT *
  FROM zcmod_dd_module_data( p_idate = @sy-datum, p_lang = @sy-langu )
  INTO TABLE @DATA(lt_module_data)&lt;BR /&gt;    WHERE id = '12345678'.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;When I do a trace with ST05 the first call has a duration of 119.903 microseconds. &lt;/P&gt;
  &lt;P&gt;Here is the execution plan for this call:&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/200248-2018-08-16-08-11-38-c223-055-uitvoeringsplan-voor.png" /&gt;&lt;/P&gt;
  &lt;P&gt;The second call has a duration of 641.768 microseconds.&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;Here is the execution plan for this call.&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/200249-2018-08-16-08-14-25-c221-055-uitvoeringsplan-voor.png" /&gt;&lt;/P&gt;
  &lt;P&gt;The execution plan is exactly the same. So why is the selection on the CDS-view parameter faster than the WHERE-clause?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 06:18:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725960#M33994</guid>
      <dc:creator>schoutenk</dc:creator>
      <dc:date>2018-08-16T06:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View - Parameter vs. WHERE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725961#M33995</link>
      <description>&lt;P&gt;Interesting question. As Horst suggested, do a trace. &lt;/P&gt;
  &lt;P&gt;The observed performance and execution plans diverge. My guess based on the performance is that a WHERE variant does a full CDS query for all OBJIDs and filters that. &lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 06:27:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725961#M33995</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2018-08-16T06:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View - Parameter vs. WHERE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725962#M33996</link>
      <description>&lt;P&gt;So you must have &lt;STRONG&gt;two&lt;/STRONG&gt; different CDS views. One with a parameter for objid and one without. From these two CDS views different DB objects are instantiated. Please look at those (context menu in ADT) and check in ST05 the SQL statements that are used to access them.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;My guess is, that the DB objects are both DB functions. One with objid as parameter and one without. For the first one, objid is part of the WHERE condition within the function and for the second one it is not. For the second one, there is then an additional WHERE condition with objid on the result set of the function (or the whatsoever DB object).&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;That might explain the difference. It shouldn't be that large, but this is then more a DB specific problem.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 16:37:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725962#M33996</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2018-08-16T16:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View - Parameter vs. WHERE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725963#M33997</link>
      <description>&lt;P&gt;Hi Horst,&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Thank you. This makes my problem more clear. Can you clearify the part were you mention the context menu in ADT? Where can I view the DB-object of my CDS view? Do you mean the SQL View?&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Does this technique work differently on a HANA platform?&lt;/P&gt;
  &lt;P&gt;Edit:&lt;/P&gt;
  &lt;P&gt;I've just seen something interesting. I've tested the performance when totally discarding the CDS-parameters. Then I've just selected the records I want in the WHERE statement (when calling my CDS-view). This way the performance is &lt;STRONG&gt;excellent&lt;/STRONG&gt;. This way I've come to the conclusion that we cannot combine CDS-parameters with a WHERE clause when calling the CDS. This is killing the performance because the WHERE is beiïng performed on the resultset.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 06:26:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725963#M33997</guid>
      <dc:creator>schoutenk</dc:creator>
      <dc:date>2018-08-28T06:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View - Parameter vs. WHERE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725964#M33998</link>
      <description>&lt;P&gt;"Do you mean the SQL View?"&lt;/P&gt;
  &lt;P&gt;Yes. But it depends on the platform, how a CDS view with parameters is instantiated. It might be views or functions for platforms that do not directly support views with parameters.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 11:04:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/725964#M33998</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2018-08-28T11:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: CDS View - Parameter vs. WHERE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/13998515#M2038367</link>
      <description>&lt;P&gt;There where clause while calling acts as part of filtering in the SQL after the query hits the database, where as calling the CDS using parameters are passed as a part of CDS view definition. Hence the filtration of data is done in the DB during the execution of the call. Hence CDS with Parameters is faster compared to using where clause.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 18:05:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cds-view-parameter-vs-where/m-p/13998515#M2038367</guid>
      <dc:creator>akshayrajkumar</dc:creator>
      <dc:date>2025-01-27T18:05:25Z</dc:date>
    </item>
  </channel>
</rss>

