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

ST_Intersects takes too long time #672

Closed
gpetit opened this issue May 4, 2016 · 14 comments
Closed

ST_Intersects takes too long time #672

gpetit opened this issue May 4, 2016 · 14 comments

Comments

@gpetit
Copy link
Contributor

gpetit commented May 4, 2016

I'm using the last realease of OrbisGIS.

I'm trying to select buildings from the departement 56 (table "BATI_INDIFFERENCIE") which intersects the agglomeration of Vannes.

So I created a unique polygon that represent my study area (table STUDY).
Then I created spatial indexes on both tables.

Now, I execute the following SQL instruction

DROP TABLE IF EXISTS TOTO;
CREATE TABLE TOTO AS SELECT a.* 
    FROM BATI_INDIFFERENCIE a, STUDY b 
WHERE a.THE_GEOM && b.THE_GEOM and ST_INTERSECTS(a.THE_GEOM, b.THE_GEOM);

The process is really too long (no result after 5mn).

I tried with or without spatial index on both tables, but the result is the same

@ebocher @nicolas-f

@nicolas-f
Copy link
Member

Can you post the WKT of STUDY.the_geom ?

@gpetit
Copy link
Contributor Author

gpetit commented May 4, 2016

STUDY.zip

I upload the shape file instead, because the WKT is too long for GitHub

@nicolas-f
Copy link
Member

You test geometry is composed by 31789 points. That explains the query time.

@nicolas-f
Copy link
Member

In order to optimize this, I would go for a st_polygonize.

@gpetit
Copy link
Contributor Author

gpetit commented May 4, 2016

Yes this geometry is complex (even if it's a simple geometry and there is no hole), but this kind of process used to works well in the past.

I'll try ST_Polygonize

@nicolas-f
Copy link
Member

Sorry I was talking about tessellate

create table studypol as select * from st_explode('select ST_TESSELLATE(the_geom) the_geom from study');

@nicolas-f
Copy link
Member

then use spatial index on studypol

@gpetit
Copy link
Contributor Author

gpetit commented May 4, 2016

Thanks @nicolas-f it works. The process takes 47s but I have a result !

@nicolas-f
Copy link
Member

I'm curious to know how many times PostGIS require to do intersection with a 31789 points geometry and thousands of buildings.

@gpetit
Copy link
Contributor Author

gpetit commented May 4, 2016

No result with QGis after 10mn (QGis freezed).
... but there is no spatial indexes

@ebocher
Copy link
Member

ebocher commented May 4, 2016

Tested on a local postgis server, this is the same pb

@gpetit
Copy link
Contributor Author

gpetit commented May 4, 2016

... and same with spatial indexes on QGis --> freeze

@ebocher
Copy link
Member

ebocher commented May 11, 2016

Solved ?

@gpetit
Copy link
Contributor Author

gpetit commented May 11, 2016

Yes we can close

@gpetit gpetit closed this as completed May 11, 2016
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

No branches or pull requests

3 participants