Skip to Content

How to write SQL queries to run in Parallel

Dear all,

It would be great help if you can provide some inputs on how to write SQL functions/procedures to run in parallel. For example, need to write stored procedures or functions to run for more than 10000 articles within 2 to 3 minutes as per business expectations. The business logic involves lot of checks and validations based on article type.

Please help me out how to take it forward on writing SQL queries insde stored procedures/functions to run in parallel.

Regards,

Yogesh

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Sep 01, 2014 at 12:44 AM

    HI Yogesh

    There is nothing you need to specifically do in order to gain parallel processing in SAP HANA.

    Even a single SQL command will internally split up into sub-tasks that are then executed in parallel if possible.

    For stored procedures you need to keep an eye on not preventing parallel processing, e.g. by using write-enabled procedures or cross-engine development (CE-functions and SQL mixed in one procedure).

    You may consider table partitioning as a way to employ larger factors of parallelism, but beware that this is a rather big change and that it will affect all coding that accesses the partitioned tables.

    Beyond these things, there are only few means to directly influence parallelism. It's really an automatic feature of the SAP HANA environment.

    - Lars

    Add comment
    10|10000 characters needed characters exceeded

    • Thomas Jung Yogesh Krishnamurthy

      There are certain rules within SQLScript which you should follow if you want to optimize your code for parallelization.

      Some things to keep in mind about parallel processing are statements will be executed in parallel unless any of the following occur: Any local scalar parameters or variables are used in the procedure, if any read/write procedures or DML/DDL operations are executed within the procedure, if any imperative logic is used, or if any SQL statements are used which are not assigned to a variable.