-
Notifications
You must be signed in to change notification settings - Fork 87
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
Support indexes on all compatible types #875
Conversation
e8fa087
to
9fd65e1
Compare
98df568
to
f958e6f
Compare
1ec063c
to
cb6ada9
Compare
f958e6f
to
de8cfd9
Compare
cb6ada9
to
2b02c66
Compare
de8cfd9
to
035cb69
Compare
2b02c66
to
8232f73
Compare
ac66008
to
2a4d8b1
Compare
8232f73
to
c7ae7af
Compare
1dcdc90
to
1fdf6b5
Compare
c7ae7af
to
549af93
Compare
02cedea
to
376729d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it's worth writing a test for this, but we could try to prove that the index exists in Core and is being used by opening 2 realms - one with indexed fields, the other with non-indexed fields, then adding 10000 objects and querying for a single object. The test should expect that the query utilizing the index completes much faster.
generator/test/error_test_data/bool_not_allowed_as_primary_key.dart
Outdated
Show resolved
Hide resolved
Added test of 1.000 lookups against 100.000 objects and compared indexed vs not-indexed for all indexable types, and assert the speedup is at least 10 fold. |
c70cccc
to
c34a1e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its good, I have couple of questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nits for the tests, otherwise looks good.
expect(allNotIndexed.length, max); | ||
|
||
// Inefficient, but fast enough for this test | ||
final searchOrder = (List.generate(max, (i) => i)..shuffle(Random(42))).take(1000).toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
final searchOrder = (List.generate(max, (i) => i)..shuffle(Random(42))).take(1000).toList(); | |
final random = Random(42); | |
final searchOrder = List.generate(1000, i => random.nextInt(max)); |
I know perf doesn't matter that much, it's just a little easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem is it can create duplicates. That is what I avoid above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can, but do we care?
try { | ||
// skip timestamp for now, as timestamps are not indexed properly it seems | ||
if (fieldName != 'timestamp') { | ||
expect(indexedTime, lessThan(notIndexedTime)); // indexed should be faster |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be stricter here - something like expect(indexedTime, lessThan(0.5 * notIndexedTime))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used to have
expect(indexedTime * 10, lessThan(notIndexedTime));
but I was asked to loosen it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. but maybe 2 would be fine 😄
However, it is not possible to use bool (or bool?) as primary key.
Co-authored-by: Nikola Irinchev <[email protected]>
Allow (and correctly apply)
@Indexed()
onint, bool, String, ObjectId, Uuid,
andDateTime
(and the nullable version as well).Fix #797,