EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB485907: Enable bulk insert and improve report execution performance against Hive, Impala, and Spark gateways


Rachana Thota

Software Engineer, Senior • MicroStrategy


This article provides a solution for improving report execution performance while using bulk insert against Hive, Impala, and Spark gateways.

Description

Some use cases require a large amount of data to be inserted into a database table. A typical example in Strategy is a data mart report, or a multi-statement SQL report where a temp table is created to store intermediate results. If the data of a temporary table is inserted using an 'insert into values' query, you can enable parameterized queries to turn on bulk insert and therefore improve performance.
 

ka04W000000Od2KQAS_0EM4W000006yuSp.jpeg

 
Sample parameterized query SQL:


INSERT INTO DMTABLE (Customer_ID, Customer_Name) VALUES (?, ?)

 
However, you may notice the inserts are still very slow for HDFS based gateways, such as Hive, Impala and Spark. A possible reason for this is mentioned in this article.
 

Solutions

Follow the solutions below to improve bulk insert performance after parameterized queries are enabled for the following gateways:
 

  • Hive
  • Spark and Impala

Hive

Bulk insert is supported in Hive ODBC and JDBC with the following settings in addition to enabling parameterized queries:
 

  • NATIVE QUERY: OFF
  • VLDB Syntax Change
  • Tuning Performance via PARAM_QUERY_ROWSET_SIZE

 
NATIVE QUERY: OFF
 

  • For Intelligence servers on a Linux machine, find the ODBC.ini file and change the DSN for Hive Connection setting. Set the property to "UseNativeQuery=0".
     
  • For Intelligence servers on Windows machines, open the ODBC Data Source Administrator, configure the Hive DSN, open Advanced Options, and deselect Use Native Query as shown below.
     
ka04W000000Od2KQAS_0EM4W000006yupU.jpeg

VLDB Syntax Change
 

  • In Developer, open the database instance for your Hive connection. Select the Database connection type. The example below uses Hive 2.x.
     
ka04W000000Od2KQAS_0EM4W000006yv2E.jpeg
  • Upgrade the Database connection type's configuration. Click Upgrade to see the database types script file. The example below uses Z:\BIN\x64\DATABASE.PDS.
     
ka04W000000Od2KQAS_0EM4W000006yv32.jpeg
  • Change the insert pattern for the your Hive database type. In this example, it is Hive 2.x.
     
    Open the database type script file you found in step 2. Edit the file, find the Hive 2.x DSSOBJECT section, and locate the
    "Insert Into Values Pattern"
    property. Change the value to
    "insert into #0 values (##0)"
    and save the file.
     
    Before the pattern change:
     
ka04W000000Od2KQAS_0EM4W000006yv3q.jpeg
  •  
    After the pattern change:
     
ka04W000000Od2KQAS_0EM4W000006yv4A.jpeg
  • Go back to upgrade database connection type in step 2. Click Load to read the script and in the left column, select your Hive 2.x connection type and move it to right. Click OK.
     
ka04W000000Od2KQAS_0EM4W000006yv5D.jpeg
  • Restart the Intelligence server. Execute the report that triggers the temp table insert to Hive. The Hive Monitor WebUI, the actual insert statement inserts multiple rows in one statement. If a large number of rows are inserted, the insert is grouped with a few hundreds rows per statement.

 
Tuning Performance via PARAM_QUERY_ROWSET_SIZE
 

  • You can also test the performance for an ODBC driver by changing the batch size. Modify
    PARAM_QUERY_ROWSET_SIZE
    in the ODBCConfig.ini file and add a new section similar to the one shown in the image below.
     
  • To change the
    PARAM_QUERY_ROWSET_SIZE
    parameter, add the lines shown below (adjusting for a number of rows to insert at a time) to the ODBCConfig.ini file located at:
     
    • Windows platform:
      <Installation Path>\Common Files\Strategy
    • Linux platform:
      <Installation Path>/MicroStrategy/install
    • Developer Machine: z:\bin\x64\
ka04W000000Od2KQAS_0EM4W000006yv5X.jpeg

Strategy's in-house test results for Hive:
 

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsODBC35 minutes5 minutes, 2 secondsDrivers

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsODBC35 minutes5 minutes, 2 secondsDrivers

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsODBC35 minutes5 minutes, 2 secondsDrivers

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsODBC35 minutes5 minutes, 2 secondsDrivers

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsODBC35 minutes5 minutes, 2 secondsDrivers

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsODBC35 minutes5 minutes, 2 secondsDrivers

 

Spark and Impala

Bulk insert is supported in Spark and Impala ODBC and JDBC with the following settings once parameterized queries are turned ON:
 

  • NATIVE QUERY: OFF
  • Tuning Performance via PARAM_QUERY_ROWSET_SIZE

 
NATIVE QUERY: OFF
 
While creating the DSN, make sure Use Native Query is not selected.
 
Tuning Performance via PARAM_QUERY_ROWSET_SIZE
 
You can also test the performance for an ODBC driver by changing the batch size. Modify the batch size in the z:\bin\x64\ODBCConfig.ini file and add a new section similar to the one shown in the image below. You must enter the database ID, database name, and the batch size you want to test the driver with.
 

ka04W000000Od2KQAS_0EM4W000006yv5c.jpeg

 
Strategy's in-house test results for Spark:
 

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsSpark ODBC24 minutes, 10 seconds2 minutes, 11 secondsImpala ODBC15 minutesThis driver currently does not support a large ROWSET size. Strategy is working with the vendor to resolve this issue.

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsSpark ODBC24 minutes, 10 seconds2 minutes, 11 secondsImpala ODBC15 minutesThis driver currently does not support a large ROWSET size. Strategy is working with the vendor to resolve this issue.

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsSpark ODBC24 minutes, 10 seconds2 minutes, 11 secondsImpala ODBC15 minutesThis driver currently does not support a large ROWSET size. Strategy is working with the vendor to resolve this issue.

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsSpark ODBC24 minutes, 10 seconds2 minutes, 11 secondsImpala ODBC15 minutesThis driver currently does not support a large ROWSET size. Strategy is working with the vendor to resolve this issue.

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsSpark ODBC24 minutes, 10 seconds2 minutes, 11 secondsImpala ODBC15 minutesThis driver currently does not support a large ROWSET size. Strategy is working with the vendor to resolve this issue.

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsSpark ODBC24 minutes, 10 seconds2 minutes, 11 secondsImpala ODBC15 minutesThis driver currently does not support a large ROWSET size. Strategy is working with the vendor to resolve this issue.

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsSpark ODBC24 minutes, 10 seconds2 minutes, 11 secondsImpala ODBC15 minutesThis driver currently does not support a large ROWSET size. Strategy is working with the vendor to resolve this issue.

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsSpark ODBC24 minutes, 10 seconds2 minutes, 11 secondsImpala ODBC15 minutesThis driver currently does not support a large ROWSET size. Strategy is working with the vendor to resolve this issue.

Execution Time
 PARAM_QUERY_ROWSET_SIZE = 32768 rowsPARAM_QUERY_ROWSET_SIZE = 1048576 rowsSpark ODBC24 minutes, 10 seconds2 minutes, 11 secondsImpala ODBC15 minutesThis driver currently does not support a large ROWSET size. Strategy is working with the vendor to resolve this issue.

 
 


Comment

0 comments

Details

Knowledge Article

Published:

January 26, 2023

Last Updated:

January 27, 2023