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

GT LT operation very slow #106

Open
DreamVersion opened this issue Nov 18, 2022 · 3 comments
Open

GT LT operation very slow #106

DreamVersion opened this issue Nov 18, 2022 · 3 comments

Comments

@DreamVersion
Copy link

query like
query :=clover.NewQuery("stat"). Where(clover.Field("stat_time").GtEq("2022-11-14"). And(clover.Field("stat_time").LtEq("2022-11-15")). And(clover.Field("ad_id").Eq("1749344214764583"))). Sort(clover.SortOption{Field: "stat_time", Direction: 1})
very fast.
but
query :=clover.NewQuery("stat"). Where(clover.Field("ad_id").Eq("1749344214764583")). And(clover.Field("stat_time").LtEq("2022-11-15")). And(clover.Field("stat_time").GtEq("2022-11-14")). Sort(clover.SortOption{Field: "stat_time", Direction: 1})
very slow.
Why?

@ostafen
Copy link
Owner

ostafen commented Nov 18, 2022

Can you tell me which version of the library you are using and the size of your collection?
If the collection is big, you should probably use indexes, which are available in the v2 version
Anyway, using string dates is not a good idea for comparison

@DreamVersion
Copy link
Author

I'm using v2 version and collection about 140Mb. I try to use time.Time type, but get the same result. I see only support one index, then ad_id is the index.
The size of docs when ad_id="1749344214764583" is about 10. Range query of this 10 docs expects to be very fast.

@ostafen
Copy link
Owner

ostafen commented Nov 19, 2022

So do you have an index set on ad_id?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants