HTTP Transport#

The main purpose of HTTP transport is to reduce massive fetching overhead associated with large data sets (1M+ rows). It uses native Exasol commands EXPORT and IMPORT specifically designed to move large amounts of data. Data is transferred using streamed CSV file(s) with optional zlib compression. This is a powerful tool which helps to bypass the creation of intermediate Python objects altogether and dramatically increases performance.

PyExasol offloads HTTP communication and decompression to a separate thread using the threading module. The main thread deals with a simple pipe opened in binary mode. For more details on how the Variants work, check out the implementation of pyexasol.ExaConnection.export_to_callback() and pyexasol.ExaConnection.import_from_callback(). For how this can be used in parallel, see Parallel.

Parallel#

Note

Please check out the documentation Parallelism for PyExasol.

It is possible to run HTTP Transport in parallel. The workload may be distributed across multiple CPU cores and even across multiple servers.

Overview of How it Works#

  1. A parent process opens main connection to Exasol and spawns multiple child processes.

  2. Each child process:

  • connects to an individual Exasol node using the pyexasol.http_transport() function

  • gets an internal Exasol address (ipaddr:port/public_key string) using the .exa_address property

  • sends its internal Exasol address to the parent process

  1. The parent process collects a list of internal Exasol addresses from its child processes and runs either export_parallel()` or import_parallel() function to execute the SQL query.

  2. Each child process runs a callback function and reads or sends a chunk of data from or to Exasol.

  3. Parent process waits for the SQL query and child processes to finish.

../../../_images/parallel_export.png

Please note that PyExasol does not provide any specific way to send internal Exasol address strings from a child process to the parent process. You are free to choose your own way of inter-process communication. For example, you may use multiprocessing.Pipe.

Examples#

Example of EXPORT query executed in Exasol#

This is how the complete query looks from Exasol’s perspective.

EXPORT my_table INTO CSV
AT 'http://27.1.0.30:33601' FILE '000.csv'
AT 'http://27.1.0.31:41733' FILE '001.csv'
AT 'http://27.1.0.32:45014' FILE '002.csv'
AT 'http://27.1.0.33:42071' FILE '003.csv'
AT 'http://27.1.0.34:36669' FILE '004.csv'
AT 'http://27.1.0.35:36794' FILE '005.csv'
WITH COLUMN HEADERS
;