FHIR Chat · time-complexity · cql

Stream: cql

Topic: time-complexity


view this post on Zulip Marisa Hoenig (Jul 16 2021 at 19:57):

Does anyone know if there's information about the time complexity of CQL functions? I haven't been able to find anything.

Specifically, our application runs several functions that loop through long lists of valuesets to try to find a match, and we have a theory that this may be impacting our app's initial load time since it waits for CQL to finish running.

view this post on Zulip JP (Jul 16 2021 at 21:21):

CQL only rarely prescribes the specific algorithm for implementing operations or functions. That means that the time-complexity of a given function is frequently implementation specific. The Java engine doesn't have that information published anywhere, nor do I think we've actually done the analysis except in cases where we have seen performance hotspots.

If you're using the Java engine and can give me a repro I'd be happy to take a look at it for you. I have less familiarity with the JS engine.

view this post on Zulip Marisa Hoenig (Jul 16 2021 at 21:46):

Thanks JP. We will likely try to do some analysis ourselves since we think it might have to do with the number of codes we're looping through. We're using the JS engine and specifically talking about functions like these if you'd like to take a look: https://github.com/chronic-care/covid-ed-ig/blob/4af9853775a4241b1e267e7b10cdcf9f9b674a5d/input/cql/COVID19EmergencyDeptAssessment.cql#L638-L644

view this post on Zulip JP (Jul 16 2021 at 22:01):

A simple implementation of that would be ~ O(N * M) where N is the number of active conditions and M is the number of code in the set you're checking against, so it'd be pretty expensive. I _think_ that's what the JS engine is doing here:

https://github.com/cqframework/cql-execution/blob/96b472a3633f4389a4745b1b88e768c2b74cc50a/src/datatypes/clinical.js#L51

@Chris Moesel ?


Last updated: Apr 12 2022 at 19:14 UTC