Why is the same SQLite query being 30 times slower when fetching only twice as many results?

前端 未结 3 2043
清酒与你
清酒与你 2021-02-01 15:16

I have been working on speeding up a query I\'m using for about a week now and asked several questions about it here ( How can I speed up fetching the results after running an s

3条回答
  •  心在旅途
    2021-02-01 16:09

    I suggest you try using an R*Tree index, They're designed for efficient range queries.


    I haven't actually used R*Tree much, just read the documentation, but I think you might be using it incorrectly. You may want to try changing your query to use

    WHERE convexhull_edges.rtMin <= spectrum.scan_start_time AND convexhull_edges.rtMax >= spectrum.scan_start_time AND
    convexhull_edges.mzMin <= MSMS_precursor.ion_mz AND convexhull_edges.mzMax >= MSMS_precursor.ion_mz
    

    which should be equivalent to your current query, but I think should be faster (You should be picking a range out of the R*Tree, rather than comparing the point to the range)

提交回复
热议问题