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
Hello guys,
I am using badgerhold as an in-memory database. The size of the database is around 200 records. The use case involves filtering based on multiple fields as an and operation. Consider the following sample code that demonstrates the issue:
the output of the above code shows the pattern that the query applied on both fields is being run, for an and operation.
This is sub optimal since the second query does not need to be executed if the first query has failed. Especially since the second query it quite computationally expensive in our case. This behaviour has caused latency increase in our API.
Is there an alternative to this or a quick fix that we can do on our side? If not, please provide a fix/udpate for this.
Badgerhold version: v4.0.2
Thanks,
kaustubh-murumkar
The text was updated successfully, but these errors were encountered:
Yep, you're right, it doesn't short circuit the logic like you'd expect. That can definitely be done, but it may end up being a little tricky. The current logic stores the query criteria in a map fieldCriteria map[string][]*Criterion which isn't in a guaranteed order.
I'll look into this more, but as a work around you can use a function in your query to run the logic exactly how you want: Where("field").MatchFunc(func(ra *RecordAccess) (bool, error))
Hello guys,
I am using badgerhold as an in-memory database. The size of the database is around 200 records. The use case involves filtering based on multiple fields as an and operation. Consider the following sample code that demonstrates the issue:
the output of the above code shows the pattern that the query applied on both fields is being run, for an
and
operation.This is sub optimal since the second query does not need to be executed if the first query has failed. Especially since the second query it quite computationally expensive in our case. This behaviour has caused latency increase in our API.
Is there an alternative to this or a quick fix that we can do on our side? If not, please provide a fix/udpate for this.
Badgerhold version: v4.0.2
Thanks,
kaustubh-murumkar
The text was updated successfully, but these errors were encountered: