GanosBase uses multiple CPU cores to speed up queries and computation on raster data. It supports two forms of parallelism: parallel SQL query execution and parallel raster-level operations.
How it works
Parallel SQL query execution
PostgreSQL distributes a query across multiple CPU cores by generating parallel query plans and balancing the workload across workers. This reduces query latency when scanning large datasets.
All read-only functions that compute raster objects in GanosBase support parallel queries, including functions that query raster attributes.
When to use it: Scanning a large number of raster objects to filter by spatial extent or attribute values.
Parallel raster-level operations
GanosBase splits a raster object into subsets and processes each subset on a separate CPU core. The operation completes when all subsets finish. This reduces the total time for computation-intensive tasks on large raster objects.
When to use it: Computing statistics, building pyramids, or running other intensive operations on large raster objects.
The following functions support parallel raster-level operations:
Prerequisites
Before enabling parallel operations, configure the following parameters.
Set max_prepared_transactions
Set max_prepared_transactions to the same value as max_connections. The default value of this parameter is 0. This ensures each connection can have one transaction in the prepared state.
Changing max_prepared_transactions requires a restart of your instance.
Set the degree of parallelism
The ganos.parallel.degree parameter is a Grand Unified Configuration (GUC) parameter that controls the default degree of parallelism (DOP). Its default value is 1, which disables parallel execution.
Set it to a value greater than 1 to enable parallelism. For functions that support parallel raster-level operations, pass a parallel value directly in the function call to override the default DOP:
SELECT ST_ImportFrom(
'chunk_table',
'OSS://<akxxxx>:<ak_secretxxxx>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc',
'{}',
'{"parallel": 4}'
);If a function call does not specify a DOP, or the DOP is set to 0, the system uses the value of ganos.parallel.degree.
Set transactional consistency
Use the ganos.parallel.transaction GUC parameter to control how parallel transactions behave:
| Value | Behavior |
|---|---|
transaction_commit (default) | Parallel transactions commit or roll back with the primary transaction |
fast_commit | Parallel transactions commit immediately and cannot be rolled back |
Usage notes
To get optimal performance, use
ST_CreateChunkTableto create a chunk table before running parallel operations.If a parallel function cannot return a temporary chunk table created by an anonymous user, create a chunk table first and pass it in the
chunktableparameter.