F
F
freeeeez2020-01-10 16:12:12
MySQL
freeeeez, 2020-01-10 16:12:12

How to optimize query with ST_CROSSES?

Mariadb 10.4.8
I am looking for a match with custom points, two points are given, I am looking for routes from the database (line field), whether this route contains this point. The search is performed by building a buffer around a point and the presence of an intersection of a line and a polygon.
Request:

SELECT * FROM search WHERE ST_CROSSES(line,ST_BUFFER(ST_GEOMFROMTEXT('POINT(55.7562903 37.6170739)'),0.2)) and ST_CROSSES(line,ST_BUFFER(ST_GEOMFROMTEXT('POINT(59.93427559999999 30.335136)'),0.2)) LIMIT 0,1

On 100,000 records, this query is completed in 1 second. Is there any way to speed it up or is this the limit? Is there any other possible implementation of finding the intersection of two points and a line that is faster?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lev Zabudkin, 2020-01-15
@zabudkin

Will it not be faster? :

SELECT * FROM search WHERE ST_CROSSES(line,ST_BUFFER(ST_GEOMFROMTEXT('POINT(55.7562903 37.6170739)'),0.2)) and ST_CROSSES(line,ST_BUFFER(ST_GEOMFROMTEXT('POINT(59.93427559999999 30.335136)'),0.2)) FETCH FIRST 1 ROWS ONLY

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question