ngsi-timeseries-api
ngsi-timeseries-api copied to clipboard
Crate version check still needed?
Is your feature request related to a problem? Please describe. Everytime we get a notification, we issue a query to get the Crate version. As @chicco785 noted in PR #299, we could actually cache this so that we don't have to waste a query on each notification. Perhaps we could even get rid of it altogether.
Describe the solution you'd like
Review the _adjust_gh_44
method of Crate translator as this is the only reason we do the version check. It looks like the SQL tweak is only needed for Crate < 2.3
. So one option would be to drop support for Crate versions older than 2.3
, change _adjust_gh_44
accordingly (hopefully give it a better name) and ditch the get_db_version
method. Alternatively, we could cache the version upfront to avoid issuing the query on each and every notification---but keep in mind the deployment issue noted in PR #299.
Additional context
Have a look at PR #299 which fixed a performance hotspot by moving the version call outside of a loop.
I suspect that also for the differences between crate 3 and 4 we may need the version check. But I may be wrong.
I've had a quick look at it. If we won't need any more changes than you pushed to PR #300 so far, then your stuff is actually backward compatible between v4 and v3 (but not v2). In fact,
ON CONFLICT (column_ident [, ...]) DO UPDATE SET...
is supported both in v3 and v4
- https://crate.io/docs/crate/reference/en/3.3/sql/statements/insert.html
- https://crate.io/docs/crate/reference/en/4.1/sql/statements/insert.html
Ditto for column-policy
- https://crate.io/docs/crate/reference/en/3.3/sql/statements/create-table.html#column-policy
- https://crate.io/docs/crate/reference/en/4.1/sql/statements/create-table.html#column-policy
Of course, we'll need more testing to make sure stuff still works as advertised regardless of syntax, like you found out yourself the hard way---crate/crate#9854 :-)
Stale issue message