<?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>Question Re: Different query plan when trying to analyze performance in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486049#M4678213</link>
    <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;lars.breddemann&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;I think i found why the generated plans were different: I didn't take into account that the statement comes as a prepared statement from our server which obviously leads to a different query plan compared to a query with "fixed" parameters.&lt;/P&gt;&lt;P&gt;Another question (somewhat related): We found that our query runs considerably slower when we use the LOWER function to compare case insensitive. What could be the reason for this? Is there anything we can analyze to see why it differs that much? The query plans are hugely different there as well.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Apr 2022 13:34:07 GMT</pubDate>
    <dc:creator>puelo</dc:creator>
    <dc:date>2022-04-21T13:34:07Z</dc:date>
    <item>
      <title>Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaq-p/12486038</link>
      <description>&lt;P&gt;I am currently trying to analyze why one particular query performs worse than expected. While doing that i noticed that the query plan shown when executing the query manually does not match up with the query plan used when the query is dispatched by our server. This makes it very hard to analyze the performance issue, since i then only have the cached plan available and the manually executed query performs far better.&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;This is the query being executed (simplified):&lt;/STRONG&gt;&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;SELECT h.* FROM horse h
INNER JOIN horse_number hn ON hn.horse_id = h.id&lt;BR /&gt;INNER JOIN number n ON n.id = hn.number_id
WHERE lower(n.number) LIKE '%de 224%' escape '!' LIMIT 30;
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;STRONG&gt;And some table metrics:&lt;/STRONG&gt; &lt;BR /&gt; &lt;/P&gt;
  &lt;UL&gt; 
   &lt;LI&gt;hn.horse_id is indexed&lt;/LI&gt; 
   &lt;LI&gt;h.id is a primary key&lt;/LI&gt; 
   &lt;LI&gt;n.id is a primary key&lt;/LI&gt; 
   &lt;LI&gt;hn.number_id is a unique key&lt;/LI&gt; 
   &lt;LI&gt;n.number is indexed (not full text)&lt;/LI&gt; 
  &lt;/UL&gt;
  &lt;P&gt;&lt;STRONG&gt;Sizes (Rows):&lt;/STRONG&gt;&lt;/P&gt;
  &lt;UL&gt; 
   &lt;LI&gt;Horse: 2.8M&lt;/LI&gt; 
   &lt;LI&gt;Horse Number: 2.8M&lt;/LI&gt; 
   &lt;LI&gt;Number: 4.87M &lt;/LI&gt; 
  &lt;/UL&gt;
  &lt;P&gt;&lt;STRONG&gt;Here are the two plans (zoomed out):&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;1. Cached Plan (executed by our server):&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2038675-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;2. Plan for manual execution of the same query:&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2038676-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;And here are some performance metrics to highlight the difference in execution time&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;1. Executed by our server&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2038679-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;and a trace log where the execution can also be observed:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;# begin setAutoCommit (thread 130313, con-id 344489) at 2022-04-12 13:16:51.247386
# con info [con-id 344489, tx-id 26, cl-pid 24592, cl-ip 10.78.26.254, user: xxx, schema: xxx]&lt;BR /&gt;con_c44489.setautocommit(False)&lt;BR /&gt;# begin prepareStatement (thread 51835, con-id 344489) at 2022-04-12 13:16:51.247774&lt;BR /&gt;# con info [con-id 344489, tx-id 26, cl-pid 24592, cl-ip 10.78.26.254, user: xxx, schema: xxx]&lt;BR /&gt;cursor_140289778665472_c44489 = con_c44489.cursor()&lt;BR /&gt;# end prepareStatement (thread 51835, con-id 344489) at 2022-04-12 13:16:51.248029&lt;BR /&gt;# begin PreparedStatement_execute (thread 130313, con-id 344489) at 2022-04-12 13:16:51.249261&lt;BR /&gt;# con info [con-id 344489, tx-id 26, cl-pid 24592, cl-ip 10.78.26.254, user: xxx, schema: xxx]&lt;BR /&gt;cursor_140289778665472_c44489.execute(''' select horse0_.id as id1_135_, horse0_.created_by_account_id as created_by_account_id26_135_, horse0_.created_by_organization_id as created_by_organization_id27_135_, horse0_.creation_time as creation_time2_135_, horse0_.last_modified as last_modified3_135_, horse0_.modified_by_account_id as modified_by_account_id28_135_, horse0_.breed as breed4_135_, horse0_.breeding_name as breeding_name5_135_, horse0_.color as color6_135_, horse0_.dam_id as dam_id29_135_, horse0_.dam_name as dam_name7_135_, horse0_.dam_of_dam as dam_of_dam8_135_, horse0_.dam_of_sire as dam_of_sire9_135_, horse0_.date_of_birth as date_of_birth10_135_, horse0_.fei_id as fei_id11_135_, horse0_.first_breeding_activity_year as first_breeding_activity_year12_135_, horse0_.gender as gender13_135_, horse0_.height as height14_135_, horse0_.image_url as image_url15_135_, horse0_.is_pony as is_pony16_135_, horse0_.last_coggins_date as last_coggins_date17_135_, horse0_.last_vaccination_date as last_vaccination_date18_135_, horse0_.micro_chip_number as micro_chip_number19_135_, horse0_.name as name20_135_, horse0_.permanent_bridle_number as permanent_bridle_number21_135_, horse0_.sire_id as sire_id30_135_, horse0_.sire_name as sire_name22_135_, horse0_.sire_of_dam_id as sire_of_dam_id31_135_, horse0_.sire_of_dam_name as sire_of_dam_name23_135_, horse0_.sire_of_sire as sire_of_sire24_135_, horse0_.studbook_id as studbook_id32_135_, horse0_.ueln as ueln25_135_ from horse horse0_ inner join horse_national_registration nationalre1_ on horse0_.id=nationalre1_.horse_id inner join national_registration nationalre2_ on nationalre1_.national_registration_id=nationalre2_.id where lower(nationalre2_.number) like ? escape '!' limit ? ''', ('''%de 441410768301%''', 30))&lt;BR /&gt;# end PreparedStatement_execute (thread 130313, con-id 344489) at 2022-04-12 13:16:51.737367&lt;BR /&gt;# begin commit (thread 130312, con-id 344489) at 2022-04-12 13:16:54.044500&lt;BR /&gt;# con info [con-id 344489, tx-id 26, cl-pid 24592, cl-ip 10.78.26.254, user: xxx, schema: xxx]&lt;BR /&gt;con_c44489.commit()&lt;BR /&gt;# end commit (thread 130312, con-id 344489) at 2022-04-12 13:16:54.044659&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;2. Executed manually:&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2038680-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;As you can see the manual execution is a lot faster and judging by the complexity of the query the execution time when executed by our server seems far too high. What are the next steps i should be talking to analyze this further?&lt;/P&gt;
  &lt;P&gt;EDIT: Zooned in query plans:&lt;/P&gt;
  &lt;P&gt;1. Server&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2038687-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;2. Manual:&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2038686-image.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 12:36:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaq-p/12486038</guid>
      <dc:creator>puelo</dc:creator>
      <dc:date>2022-04-13T12:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486039#M4678203</link>
      <description>&lt;P&gt;Hi Tobias, &lt;/P&gt;&lt;P&gt;i can see 3 tables in your query, 3 table accesses in the plan of your manual execution,  but 2 table accesses in the cached plan. So this looks like a plan for a different query, right?&lt;/P&gt;&lt;P&gt;Regards, &lt;BR /&gt;Jörg&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 13:19:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486039#M4678203</guid>
      <dc:creator>Joerg_Brandeis</dc:creator>
      <dc:date>2022-04-13T13:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486040#M4678204</link>
      <description>&lt;P&gt; &lt;SPAN class="mention-scrubbed"&gt;jbrandeis&lt;/SPAN&gt; Thanks for the answer. It seems that both use all 3 tables tho (the query is 100% identical)&lt;/P&gt;&lt;P&gt;Cached (executed by Server):&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2038684-image.png" /&gt;&lt;BR /&gt;for query:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select horse0_.* from horse horse0_ &lt;BR /&gt;inner join horse_national_registration nationalre1_ on horse0_.id=nationalre1_.horse_id &lt;BR /&gt;inner join national_registration nationalre2_ on nationalre1_.national_registration_id=nationalre2_.id &lt;BR /&gt;where lower(nationalre2_.number) like ? escape '!' limit ?&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and executed manually:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2038685-image.png" /&gt;&lt;/P&gt;&lt;P&gt;for query:&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select horse0_.*  from horse horse0_ &lt;BR /&gt;inner join horse_national_registration nationalre1_ on horse0_.id=nationalre1_.horse_id &lt;BR /&gt;inner join national_registration nationalre2_ on nationalre1_.national_registration_id=nationalre2_.id &lt;BR /&gt;where lower(nationalre2_.number) like '%de 441410768301%' escape '!' limit 30 &lt;BR /&gt;WITH HINT(IGNORE_PLAN_CACHE)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Apr 2022 13:40:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486040#M4678204</guid>
      <dc:creator>puelo</dc:creator>
      <dc:date>2022-04-13T13:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486041#M4678205</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;jbrandeis&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;I also added the zoomed in version of the two query plans.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 13:43:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486041#M4678205</guid>
      <dc:creator>puelo</dc:creator>
      <dc:date>2022-04-13T13:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486042#M4678206</link>
      <description>&lt;P&gt;For my knowledge, how do you get this graphical visualisation of the server "cached plan" ? I only know the method via "execute PlanViz" menu when executing manually.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 16:35:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486042#M4678206</guid>
      <dc:creator>Cocquerel</dc:creator>
      <dc:date>2022-04-13T16:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486043#M4678207</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;mickael.cocquerel&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;I use the HANA Tools in Eclipse. In the administration tools under performance you can view the SQL Plan Cache, right-clicking on one row gives you the option to Visualize the plan:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2038702-image.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 16:50:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486043#M4678207</guid>
      <dc:creator>puelo</dc:creator>
      <dc:date>2022-04-13T16:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486044#M4678208</link>
      <description>&lt;P&gt;Hello Tobias, &lt;/P&gt;&lt;P&gt;I can't tell you why different plans are executed. &lt;/P&gt;&lt;P&gt;But the reason for the different performance is clearly visible. In the manual case, filtering is done directly at the table. In the server-side execution, the JOIN takes place first with the full set of data and filtering is done later. &lt;/P&gt;&lt;P&gt;Maybe the push-down of the WHERE condition works better if you already store the data in lowercase and don't need a LOWER function anymore.&lt;/P&gt;&lt;P&gt;Many greetings, &lt;/P&gt;&lt;P&gt;Jörg&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 06:17:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486044#M4678208</guid>
      <dc:creator>Joerg_Brandeis</dc:creator>
      <dc:date>2022-04-14T06:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486045#M4678209</link>
      <description>&lt;P&gt; &lt;SPAN class="mention-scrubbed"&gt;jbrandeis&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;Thanks! We eliminated the need to check with wildcards (so no LIKE '%%'). That, unsurprisingly, sped up the query significantly. It would still be interesting to find out why the other queries were executed differently. Do you think it might be worth a try to execute manually with different hints?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 10:13:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486045#M4678209</guid>
      <dc:creator>puelo</dc:creator>
      <dc:date>2022-04-14T10:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486046#M4678210</link>
      <description>&lt;P&gt;Generally speaking,  query optimisers are deterministic, i.e. given the same input they return the same output.&lt;/P&gt;&lt;P&gt;That means, the input (query text, context, data structure information, do parameters) must have been different, when the “bad” plan had been computed. &lt;/P&gt;&lt;P&gt;Maybe the data volume did change considerably since the “bad” plan had been created, but not enough to re-optimise the query. &lt;/P&gt;&lt;P&gt;One thing that struck me was the description of the indexing scheme. &lt;/P&gt;&lt;P&gt;Writing “column x is a primary key”, “column x is a unique key”, and “column x is indexed” is pretty much the same thing for column tables. Putting on a single column index on “number” does not seem helpful at this point - it doesn’t help with the LIKE condition and effectively doubles the storage size of the column. The table only has a few million entries anyhow - raw scanning should do quick business with that.&lt;/P&gt;&lt;P&gt;So, I’d probably go and try to reproduce the bad plan, by first removing the old plan from the query cache. If the plans still differ, the next step would be to activate and read the optimiser traces. &lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 23:43:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486046#M4678210</guid>
      <dc:creator>lbreddemann</dc:creator>
      <dc:date>2022-04-14T23:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486047#M4678211</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;lars.breddemann&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;The index on the number column was only added after we noticed the bad performance of the query in an, futile, attempt to remedy this.&lt;/P&gt;&lt;P&gt;The volume indeed has changed (~1M new entries in a somewhat short span of time) so this might be one route to investigate. I might have not read carefully enough, but do you know how long a query plan is cached for?&lt;/P&gt;&lt;P&gt;We will remove the index again and i'll try to clear the plan cache and try again.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2022 13:11:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486047#M4678211</guid>
      <dc:creator>puelo</dc:creator>
      <dc:date>2022-04-15T13:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486048#M4678212</link>
      <description>&lt;P&gt;Plan cache entries don’t have an “expiration date”; they may be invalidated or pushed out of the cache if not used anymore &amp;amp; more entries should be added to the already full cache&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2022 23:29:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486048#M4678212</guid>
      <dc:creator>lbreddemann</dc:creator>
      <dc:date>2022-04-15T23:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486049#M4678213</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;lars.breddemann&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;I think i found why the generated plans were different: I didn't take into account that the statement comes as a prepared statement from our server which obviously leads to a different query plan compared to a query with "fixed" parameters.&lt;/P&gt;&lt;P&gt;Another question (somewhat related): We found that our query runs considerably slower when we use the LOWER function to compare case insensitive. What could be the reason for this? Is there anything we can analyze to see why it differs that much? The query plans are hugely different there as well.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 13:34:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486049#M4678213</guid>
      <dc:creator>puelo</dc:creator>
      <dc:date>2022-04-21T13:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486050#M4678214</link>
      <description>&lt;P&gt;Ok, the difference between prepared and direct statements for optimisation can be significant. It's possible to also use prepared statements in HANA Studio (including for PlanViz), so the difference should be reproducible.&lt;/P&gt;&lt;P&gt;As for the impact of the LOWER function: this adds a lot of extra computation to the filtering.&lt;BR /&gt;With a direct equality filter, the filtering can be performed based on the column value dictionary, i.e. the valueID is retrieved from the columns' dictionary and then the colunm is scanned against this valueID via very efficient SIMD code. &lt;/P&gt;&lt;P&gt;As soon as the filter condition cannot be directly checked against the stored values, all possible values from the dictionary need to be materialised, computed based on the filter condition (in this case, all values need to be passed through the LOWER function). This requires additional memory and CPU time and instead of a simple equality test against the column valueIDs, the column needs to be checked against a whole array of matching value IDs. This is because different values, say "Test", "teST", and "TeSt" would all end up matching the condition lower(&amp;lt;column&amp;gt;) = "test". HANA now needs to check the column for entries with valueIDs that point to all three values ("Test", "teST", and "TeSt").&lt;/P&gt;&lt;P&gt;It should be easy to see, how this also impacts cardinality estimates considerably. which easly can change execution plans.&lt;/P&gt;&lt;P&gt;If reasonably possible, I'd try and avoid "dynamic case-insensitive" search. If this has to be enabled, I would look into pre-computing the result of the lower() function in a generated column and use this to filter against. This additional will require less or equal space than the original column and allow for efficient filtering. This approach is the functional equivalent of a function based index, say, in Oracle.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2022 05:28:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486050#M4678214</guid>
      <dc:creator>lbreddemann</dc:creator>
      <dc:date>2022-04-23T05:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486051#M4678215</link>
      <description>&lt;P&gt; &lt;SPAN class="mention-scrubbed"&gt;lars.breddemann&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;Thanks for the detailed answer. Yes, i was able to reproduce the bad performance in Eclipse with HANA Tools and a prepared statement. As you already said the step to "Materialize Results" takes the most time. We went with the solution where we add another column which will hold a completely case insensitive value so that we can search there instead. I will add a conclusion as an answer here.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2022 17:41:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486051#M4678215</guid>
      <dc:creator>puelo</dc:creator>
      <dc:date>2022-04-23T17:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Different query plan when trying to analyze performance</title>
      <link>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486052#M4678216</link>
      <description>&lt;P&gt;After the help of the comment section and more analyzing, the difference in query plans was caused by not using a prepared statement when executing the query manually, which obviously will have another query plan. After using the same prepared statement i was able to reproduce the bad performance and ultimately came to the conclusion that it was caused by a dynamic case insensitive search using the LOWER function.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2022 17:42:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/different-query-plan-when-trying-to-analyze-performance/qaa-p/12486052#M4678216</guid>
      <dc:creator>puelo</dc:creator>
      <dc:date>2022-04-23T17:42:56Z</dc:date>
    </item>
  </channel>
</rss>

