Skip to content

[IMPROVE] Omnichannel aggregations performance improvements#16755

Merged
sampaiodiego merged 12 commits intodevelopfrom
aggregate-performance
Mar 19, 2020
Merged

[IMPROVE] Omnichannel aggregations performance improvements#16755
sampaiodiego merged 12 commits intodevelopfrom
aggregate-performance

Conversation

@MarcosSpessatto
Copy link
Copy Markdown
Contributor

No description provided.

agents: await Users.findAllAverageServiceTime({ start, end, options }),
total: (await Users.findAllAverageServiceTime({ start, end })).length,
agents: await LivechatRooms.findAllAverageServiceTimeByAgents({ start, end, options }),
total: (await LivechatRooms.findAllAverageServiceTimeByAgents({ start, end })).length,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion is to change the way we get the total number of records without pagination, I mean, we don't need to get all data from the DB just to know the count/total number, actually, we are wasting computational resources since we're allocation all documents in memory just to get the length value.
IMO, we can use a native MongoDB feature that returns exactly the value we need. To achieve this we need to support an additional function parameter, allowing to set something like onlyCount parameter, also we'd need to return the cursor instead of array.

@renatobecker renatobecker changed the title [IMPROVE] Livechat aggregations performance improvements [IMPROVE] Omnichannel aggregations performance improvements Mar 14, 2020
@renatobecker
Copy link
Copy Markdown
Contributor

@MarcosSpessatto please, review the 2 commits I submitted.
Thanks.

@renatobecker
Copy link
Copy Markdown
Contributor

The code looks good.
I can't merge it anymore because I submitted 2 commits, so I'll ask to @sampaiodiego to do it.

# Conflicts:
#	app/livechat/server/lib/Livechat.js
#	app/models/server/models/LivechatRooms.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants