-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Reducing DB interactions at mongoBackend] Avoid update csub when notifications are sent #1476
Comments
Considering option 2 (accumulate and cosolidate at refresh time) a solution is to use one update() for each field: To update count, being
To update lastNotified, being the last notification time:
(Not sure if the above is 100% correct syntax) Actually, the above is expressed in mongo query language. In our code, the collectionUpdate() function has to be used. The first argument of the update() above should be mapped to a BSONObj in the
Of course 2 update() is worse than 1 update() :). However, I cannot figure out how to do this with just one operation. Maybe an important optimization would be to use a bulk update to update all the cache documents: https://docs.mongodb.org/manual/reference/method/Bulk.find.updateOne/#Bulk.find.updateOne (not essential for #1476 completion, as we can assume that refresh wouldn't be too frecuent in production cases, i.e. in the order of tens of senconds; an issue should be opened about it). As additional comment (Final thought: maybe "refresh" is not a good name for the operation. At least I tend to think in "refresh" as an exclusive DB -> cache operation. Maybe "sync" is better. Not sure anyway). |
Yeah, I think mongoSubCacheSync might be a better name when this is included. Now, the current mongoSubCacheRefresh* function throws away the cache and replaces it with what was found in the db. When lastNotificationTime and count is no longer maintained in the DB, this will have to be changed. mongoSubCacheRefresh must get smarter.
|
Implemented in PR #1536. However, some modifications has bene deferred related with
|
Finished in PR #1544 |
Currently, each time a notification is sent, the csub is updated to increase
count
and set the newlastNotification
. This is inefficent.A better approach should be implemented. A couple of ideas:
count
orlastNotification
in DB (although it could be a problem considering the current NGSIv2 JSON for subscriptions, which takes into account both fields)The text was updated successfully, but these errors were encountered: