MassBank / MassBank-web

The web server application and directly connected components for a MassBank web server
14 stars 22 forks source link

Peak search gets slow with large query spectra #192

Open sneumann opened 5 years ago

sneumann commented 5 years ago

Hi, with larger query peak lists the peak search slows down. Seems that in https://github.com/MassBank/MassBank-web/blob/9fd2ddf5bd3240d3cab8dca1e1f228c044008728/MassBank-Project/MassBank-lib/src/main/java/massbank/web/peaksearch/PeakSearchByPeak.java#L71 there is a loop iterating over the peak list, making that part O(n). I can think of two ways to speed things up:

1) it might be possible to increase speed if there is an additional integer mz index, and in addition to the query ? <= PK_PEAK_MZ AND PK_PEAK_MZ <= ? there is also an round(?) == round(PK_PEAK_MZ). Needs to be checked. 2) instead of using hits and the loop over peaks, one could attempt to create a "monster" query, which solves the loop as part of the SQL logic.

Yours, Steffen