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

GPKG: add ST_EnvIntersects() for faster spatial filtering when there is no spatial index #7621

Merged
merged 1 commit into from
Apr 29, 2023

Conversation

rouault
Copy link
Member

@rouault rouault commented Apr 20, 2023

Execution time can be ~ 1.5x faster.

Before:

$ time ogrinfo nz-building-outlines.gpkg -sql "select count(*) from \"nz-building-outlines\" where st_maxx(geometry)>=1500000 and st_maxy(geometry)>= 5200000 and st_minx(geometry) <=1800000 and st_miny(geometry) <= 5800000" -al -q

Layer name: SELECT
OGRFeature(SELECT):0
  count(*) (Integer) = 701300

real	0m0,909s
user	0m0,633s
sys	0m0,276s

After:

$ time ogrinfo nz-building-outlines.gpkg -sql "select count(*) from \"nz-building-outlines\" where ST_EnvelopesIntersects(geometry, 1500000, 5200000 ,1800000 ,5800000)" -al -q

Layer name: SELECT
OGRFeature(SELECT):0
  count(*) (Integer) = 701300

real	0m0,605s
user	0m0,310s
sys	0m0,290s

…is no spatial index

Execution time can be ~ 1.5x faster.

Before:
```
$ time ogrinfo nz-building-outlines.gpkg -sql "select count(*) from \"nz-building-outlines\" where st_maxx(geometry)>=1500000 and st_maxy(geometry)>= 5200000 and st_minx(geometry) <=1800000 and st_miny(geometry) <= 5800000" -al -q

Layer name: SELECT
OGRFeature(SELECT):0
  count(*) (Integer) = 701300

real	0m0,909s
user	0m0,633s
sys	0m0,276s
```

After:
```
$ time ogrinfo nz-building-outlines.gpkg -sql "select count(*) from \"nz-building-outlines\" where ST_EnvelopesIntersects(geometry, 1500000, 5200000 ,1800000 ,5800000)" -al -q

Layer name: SELECT
OGRFeature(SELECT):0
  count(*) (Integer) = 701300

real	0m0,605s
user	0m0,310s
sys	0m0,290s
```
@rouault rouault added this to the 3.7.0 milestone Apr 20, 2023
@jratike80
Copy link
Collaborator

Is the somehow ungrammatical ST_EnvelopesIntersects alias there because SpatiaLite has it also?

@rouault
Copy link
Member Author

rouault commented Apr 20, 2023

Is the somehow ungrammatical ST_EnvelopesIntersects alias there because SpatiaLite has it also?

yes

@rouault rouault merged commit 6a8eeed into OSGeo:master Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants