Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(query): refactor geometry functions #16870

Merged
merged 4 commits into from
Nov 20, 2024

Conversation

b41sh
Copy link
Member

@b41sh b41sh commented Nov 19, 2024

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

refactor geometry functions to improve performance

  • Remove geos dependencies, use GeomProcessor to read SRID, avoid repeated deserialization.
  • Remove the parse_to_subtype function, avoid redundant data copying when parse geometry data
  • Optimize geometry function code structure

for example:

The execution time for calculating 500,000 rows geometry st_distance has been reduced from 9.097 secs to 5.951 secs

CREATE OR REPLACE TABLE test AS
SELECT
    number AS id,
    'SRID=4326;POINT(100 200)' as geom,
    'SRID=4326;POINT(300 200)' as geom2
FROM numbers(500000);

old
select st_distance(to_geometry(geom), to_geometry(geom2)) from test;
500000 rows read in 9.097 sec. Processed 500 thousand rows, 38.15 MiB (54.96 thousand rows/s, 4.19 MiB/s)

new
select st_distance(to_geometry(geom), to_geometry(geom2)) from test;
500000 rows read in 5.951 sec. Processed 500 thousand rows, 38.15 MiB (84.01 thousand rows/s, 6.41 MiB/s)

fixes: #[Link the issue here]

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-refactor this PR changes the code base without new features or bugfix label Nov 19, 2024
@b41sh b41sh marked this pull request as ready for review November 19, 2024 07:21
@b41sh b41sh added this pull request to the merge queue Nov 20, 2024
Merged via the queue into databendlabs:main with commit 918b9c2 Nov 20, 2024
74 checks passed
@b41sh b41sh deleted the refactor-geometry-functions branch November 20, 2024 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-refactor this PR changes the code base without new features or bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants