Skip to content
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

perf: improve perf inside search #2663

Closed
wants to merge 9 commits into from
11 changes: 10 additions & 1 deletion src/drive/web/modules/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,16 @@ export const prepareSuggestionQuery = () => ({
$or: [{ $exists: false }, { $eq: false }]
}
},
fields: ['_id', 'trashed', 'dir_id', 'name', 'path', 'type', 'mime'],
fields: [
'_id',
'trashed',
'dir_id',
'name',
'path',
'type',
'mime',
'metadata'
Copy link
Contributor

Choose a reason for hiding this comment

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

Une chose est sûre, c'est qu'on peut pas garder metadata au complet. Soit on arrive à aller lire quelques champs particuliers, soit on change la façon de checker si c'est une note. Car metadata sur les notes, ça peut vite peser des centaines de ko par note.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

j'ai recréé un helper isNote, car les metadata peuvent être volumineuses.

Copy link
Contributor

@Crash-- Crash-- Aug 22, 2022

Choose a reason for hiding this comment

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

I don't know if I like this idea.

You can add to the select(['metadata.title', 'metadata.version']) . title + version are not so big. So the helper can be if(metata.title && metadata.version && file.endsWith... && ...) .

See a test query with metadata.datetime to see the result.

Capture d’écran 2022-08-22 à 11 31 33

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have only one note in my local Drive.
When adding:

    'metadata.content',
    'metadata.schema',
    'metadata.title',
    'metadata.version'

as fields, the size of request increase
from 650ko / 39,87 ko transferred in 538ms
to 657,97 ko / 41,61ko transferred in 578ms.

Capture d’écran 2022-08-22 à 12 03 37
Capture d’écran 2022-08-22 à 12 05 08

That is quite huge, I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not what I suggested. I suggested to only add version + title. Not schema + content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

perfect
Capture d’écran 2022-08-22 à 14 11 58
PR updated

],
indexedFields: ['_id'],
limit: 1000
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,16 @@ describe('SuggestionProvider', () => {
// Then
expect(mockClient.collection).toHaveBeenCalledWith('io.cozy.files')
expect(mockFindAll).toHaveBeenCalledWith(null, {
fields: ['_id', 'trashed', 'dir_id', 'name', 'path', 'type', 'mime'],
fields: [
'_id',
'trashed',
'dir_id',
'name',
'path',
'type',
'mime',
'metadata'
],
indexedFields: ['_id'],
limit: 1000,
partialFilter: {
Expand Down