You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Typesense driver makes a lot of unnecessary requests to the server. Real life example: I have a collection with over 10000 documents in it. Each document is updated hourly. Each update changes one model attribute, which triggers 2 request to typesense server. That's 5.5 completely unnecessary requests per second.
20k documents will cause 11 requests per second, 100k documents - 55 requests per second.
I know that typesense server is fast and performant, but still, that requests congest the bandwidth, tcp connections and other resources.
1. Unnecessary updates
At the moment, typesence-driver updates the document on any model update, even if the changed field is not in the schema. This can cause performance problems if there are a lot of updates.
Now, when I update any field in my model, typesense-driver will try to update the remote index:
MyModel::first()->update([
'some_field' => 'test',
]);
// typesense-driver sends GET to /collections/my-model// typesense-driver sends POST to /collections/my-model/documents/importMyModel::first()->update([
'some_date' => now(),
]);
// typesense-driver sends GET to /collections/my-model// typesense-driver sends POST to /collections/my-model/documents/import
My suggestion is to check if the changed fields are in the schema before updating the document. For example, using the getChanges() model method.
The problem that I see here is how to handle computed attributes (ones that use appends array and getter function).
Typesense driver makes a lot of unnecessary requests to the server. Real life example: I have a collection with over 10000 documents in it. Each document is updated hourly. Each update changes one model attribute, which triggers 2 request to typesense server. That's 5.5 completely unnecessary requests per second.
20k documents will cause 11 requests per second, 100k documents - 55 requests per second.
I know that typesense server is fast and performant, but still, that requests congest the bandwidth, tcp connections and other resources.
1. Unnecessary updates
At the moment,
typesence-driver
updates the document on any model update, even if the changed field is not in the schema. This can cause performance problems if there are a lot of updates.For example:
Now, when I update any field in my model,
typesense-driver
will try to update the remote index:My suggestion is to check if the changed fields are in the schema before updating the document. For example, using the
getChanges()
model method.The problem that I see here is how to handle computed attributes (ones that use
appends
array and getter function).2. Unnecessary collection info retrieval
Upon every update, typesense driver makes a GET request to retrieve a collection info.
I suggest getting that info from schema (
getCollectionSchema
method).Metadata
Typsense Version: 5.0
OS: Ubuntu 20.04
The text was updated successfully, but these errors were encountered: