<?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: HANA - Scalar Function not executing in parallel in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413895#M49684</link>
    <description>&lt;P&gt;Lars,&lt;/P&gt;&lt;P&gt;But it's not at all interesting for a database to run Scalar Function in sequential mode. This is not good and leaves the perfromance too low.&lt;/P&gt;&lt;P&gt;About use Table Function or plain SQL.&lt;/P&gt;&lt;OL&gt;
&lt;LI&gt;Plain SQL not solve my problem. I have  a medium complex logic to execute. I could not transcribe my need into a single plain SQL.&lt;/LI&gt;&lt;LI&gt;I created Table Function with the required logic using ARRAYS to store data and return a table with the values I need. However, the performance of a Table Function using ARRAYS and internal SQL queries is very very poor.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I am using ARRAYS because I can not use DML into Calculation SQLScript based or in a Table Funcion.&lt;/P&gt;</description>
    <pubDate>Fri, 31 Mar 2017 14:53:45 GMT</pubDate>
    <dc:creator>former_member235648</dc:creator>
    <dc:date>2017-03-31T14:53:45Z</dc:date>
    <item>
      <title>HANA - Scalar Function not executing in parallel</title>
      <link>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaq-p/413889</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;My cenario is: &lt;/P&gt;&lt;OL&gt;
&lt;LI&gt;1 Graph Calc view calling &lt;/LI&gt;&lt;LI&gt;  1 SQLScript View that execute a SQL with 2 scalar function &lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;
I have 2 ScalarFunction in HANA to execute some complex-logic for a data range.
I execute both separately and time results are: &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select value, Scalar_Function1(value) from table &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;  --&amp;gt; 14sec &lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select value, Scalar_Function2(value) from table &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;  --&amp;gt;16sec &lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So, if I try execute the both ScalarFunction on same SQL the result time is: &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select value, Scalar_Function1(value), Scalar_Function2(value) from table &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG&gt;&lt;EM&gt; --&amp;gt;30sec &lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I think hana is not running this SQL statement in parallel mode.
What is necessary to do for parallel execution of this Functions?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 11:18:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaq-p/413889</guid>
      <dc:creator>former_member235648</dc:creator>
      <dc:date>2017-03-30T11:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: HANA - Scalar Function not executing in parallel</title>
      <link>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413890#M49679</link>
      <description>&lt;P&gt;what Hana version? What does the explain plan looking like? How many parallel threads provide your system?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 12:04:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413890#M49679</guid>
      <dc:creator>lbreddemann</dc:creator>
      <dc:date>2017-03-30T12:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: HANA - Scalar Function not executing in parallel</title>
      <link>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413891#M49680</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The HANA version is "SAP HANA SPS 10 Database Maintenance Revision 102.01"&lt;/P&gt;&lt;P&gt;About the thread system configurations this is the propertis defined:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;max_comm_thread = 20&lt;/LI&gt;&lt;LI&gt;max_pop_thread = 32&lt;/LI&gt;&lt;LI&gt;max_server_pop_thread = 100&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Explain does not show me much. It looks like he's not showing me the explain of my function.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/28094-explain.png" /&gt;&lt;/P&gt;&lt;P&gt;I modified the functions to try to understand why they were so slow.
Within the function only the following SQL runs:
&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;EM&gt;&lt;STRONG&gt;Select 1 from dummy;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The function is executed for 6248 record, and the -Memory Allocated is 355 GB.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 19:44:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413891#M49680</guid>
      <dc:creator>former_member235648</dc:creator>
      <dc:date>2017-03-30T19:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: HANA - Scalar Function not executing in parallel</title>
      <link>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413892#M49681</link>
      <description>&lt;P&gt;Alright, I had a quick look into this in my instance (SPS11) and to me, it seems that the scalar functions get executed together in the single JECalculate POP. There doesn't seem to be an option for parallel processing within the function, so it's feeding whatever goes into the POP through this single lane. &lt;/P&gt;&lt;P&gt;To improve on that, you might want to look into table functions or plain SQL instead as these can operate on whole sets at once instead of single records.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 22:34:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413892#M49681</guid>
      <dc:creator>lbreddemann</dc:creator>
      <dc:date>2017-03-30T22:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: HANA - Scalar Function not executing in parallel</title>
      <link>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413893#M49682</link>
      <description>&lt;P&gt;Just a suggestion, since I haven't tried it out myself. &lt;/P&gt;&lt;P&gt;Scalar functions allow multiple parameters. You could check if a "function(value1, value2)" would execute faster than two separate function calls.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 05:59:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413893#M49682</guid>
      <dc:creator>BenedictV</dc:creator>
      <dc:date>2017-03-31T05:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: HANA - Scalar Function not executing in parallel</title>
      <link>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413894#M49683</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Yes, I can put more then 1 parameter, but Scalar Function returns only one value. I have two Scalar Function because I need two different values.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 14:38:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413894#M49683</guid>
      <dc:creator>former_member235648</dc:creator>
      <dc:date>2017-03-31T14:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: HANA - Scalar Function not executing in parallel</title>
      <link>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413895#M49684</link>
      <description>&lt;P&gt;Lars,&lt;/P&gt;&lt;P&gt;But it's not at all interesting for a database to run Scalar Function in sequential mode. This is not good and leaves the perfromance too low.&lt;/P&gt;&lt;P&gt;About use Table Function or plain SQL.&lt;/P&gt;&lt;OL&gt;
&lt;LI&gt;Plain SQL not solve my problem. I have  a medium complex logic to execute. I could not transcribe my need into a single plain SQL.&lt;/LI&gt;&lt;LI&gt;I created Table Function with the required logic using ARRAYS to store data and return a table with the values I need. However, the performance of a Table Function using ARRAYS and internal SQL queries is very very poor.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I am using ARRAYS because I can not use DML into Calculation SQLScript based or in a Table Funcion.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 14:53:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413895#M49684</guid>
      <dc:creator>former_member235648</dc:creator>
      <dc:date>2017-03-31T14:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: HANA - Scalar Function not executing in parallel</title>
      <link>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413896#M49685</link>
      <description>&lt;P&gt;Hello Vitor, since you are in SPS10, I am sure you can use scalar functions to return multiple values. You can call it like: Select function1(param1,NULL).return1, function1(NULL,param2).return2 from table; &lt;/P&gt;&lt;P&gt;I just used simple selects from DUMMY, so I am not able to check how it performs comparatively. But you can give it a try.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 18:00:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413896#M49685</guid>
      <dc:creator>BenedictV</dc:creator>
      <dc:date>2017-03-31T18:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: HANA - Scalar Function not executing in parallel</title>
      <link>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413897#M49686</link>
      <description>&lt;P&gt;There are many ways to answer this comment, pointing out that we haven't seen your code so far, or that you haven't mentioned anything about data volumes and expected performance, or that there are many successful implementations on HANA that do complex computations on large datasets really quick (indicating that there might be a better way to solve the issue than your approach) - but the most striking point of your comment is that there is no further question in it. Just the statement that your code runs too slow on HANA. With that statement alone, there is nothing I can do for you.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 23:52:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413897#M49686</guid>
      <dc:creator>lbreddemann</dc:creator>
      <dc:date>2017-03-31T23:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: HANA - Scalar Function not executing in parallel</title>
      <link>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413898#M49687</link>
      <description>&lt;P&gt;Hi Lars,&lt;/P&gt;&lt;P&gt;I understand your point.&lt;/P&gt;&lt;P&gt;I will consider that use of Scalar Functions will not solve my problem because is not possible run on or more function in parallel.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 11:47:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413898#M49687</guid>
      <dc:creator>former_member235648</dc:creator>
      <dc:date>2017-04-03T11:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: HANA - Scalar Function not executing in parallel</title>
      <link>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413899#M49688</link>
      <description>&lt;P&gt;Fine with me.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 23:34:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/hana-scalar-function-not-executing-in-parallel/qaa-p/413899#M49688</guid>
      <dc:creator>lbreddemann</dc:creator>
      <dc:date>2017-04-03T23:34:03Z</dc:date>
    </item>
  </channel>
</rss>

