BIDMCDigitalPsychiatry / LAMP-platform

The LAMP Platform (issues and documentation).
https://docs.lamp.digital/
13 stars 10 forks source link

Intensive JSONata queries can cause server issues #457

Open lukeoftheshire opened 2 years ago

lukeoftheshire commented 2 years ago

LAMP-server allows for JSONata document transformation queries to be executed server-side via the LAMP.API.query() function. LAMP adds some additional functions to JSONata that allow a user to query the LAMP database, which can speed up the time for some queries significantly.

However, JSONata performance seems to drop off quite substantially when processing big chunks of data. This would not be an issue except that the server can hang or even crash while this processing is happening, which is also undesirable.

Additionally, there don't seem to be any protections or limitations on the maximum call stack size for JSONata queries. This can cause issues if multiple recursive calls (for example), are made in a single query - as one might do to get an unknown number of sensorevents over a set period of time. This can be avoided in some cases through tail recursion (https://docs.jsonata.org/programming#tail-call-optimization-tail-recursion) but is not immediately obvious, and can be tricky to write -- with little room for error.

As JSONata queries can be made throught the LAMP data portal (also known as the data studio), this represents a potential issue should a collaborator or other user write a resource-intensive query.

ZCOEngineer commented 2 years ago

@avaidyam we need to discuss on what we can do here. if you have any suggestion on this please let us know.

avaidyam commented 2 years ago

@ZCOEngineer You won't need to worry about this issue as your team was not assigned - this has to do with the API design and data visualization.