Create spatial indexes in parallel

更新时间:
复制 MD 格式

This feature uses the spatial sorting (GiST Sort) method to accelerate index creation. It parallelizes the creation process and significantly reduces disk read and write operations.

Precautions

The spatial sorting method applies only to point data. Using this method for other spatial data types degrades index query performance.

Usage

Note The number of parallel workers and the total worker memory specified in the following command examples are for reference only. You must configure these settings based on your actual requirements.
  1. Enable the GiST Sort feature.
    set polar_enable_gist_sort=on;
  2. Set the number of parallel workers.

    A higher number of parallel workers for data table scans increases the CPU load during queries. The number of parallel workers must not exceed the number of physical CPU cores.

    set max_parallel_maintenance_workers=4;
  3. Set the total memory for parallel workers. Set the value to at least 1 GB.
    set maintenance_work_mem='1GB';
  4. Create a GiST index.
    create index on t using gist(geom);
  5. To disable this feature, run the following command.
    set polar_enable_gist_sort=off;