-
Notifications
You must be signed in to change notification settings - Fork 96
Feature: move documents count to analytics node (if exists) #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
arekborucki
commented
Dec 3, 2025
coyotte508
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH not sure - it's something very specific to our atlas deployment (unless proven otherwise)
IMO it's fine to keep current code (a small improvement would be to make 4 separate http requests maybe, and display immediately the dropdown with loading icons for each count)
But current code works well enough IMO not a priority
|
yes, my concern is that it's an optimization for us for a specific collection, and it's an open source project. Other users would possibly have different results, and this optimization is not relevant for them (eg if their analytics node is delayed or w/e) Maybe an alternative is adding an env var for read preference to use by default? And use that for all the "read" queries (including where we used That way for our case we can make mongoku use the analytics node always, by changing the env var, and it doesn't impact other projects |
…CE, MONGOKU_READ_PREFERENCE_TAGS)
src/api/servers.remote.ts
Outdated
| { | ||
| maxTimeMS: mongo.getCountTimeout(), | ||
| readPreference: ReadPreference.secondaryPreferred, | ||
| readPreference: readPref, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be applied to all read calls, or maybe we can just set it in the MongoClientWithMappings constructor:
Mongoku/src/lib/server/mongo.ts
Lines 132 to 138 in 0292d46
| constructor(url: string, _id: string, name: string) { | |
| super(url); | |
| this.url = url; | |
| this._id = _id; | |
| this.name = name; | |
| } | |
super(url, {readPreference: ...});(to avoid editing every db call)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me fix it
