Using index for attr:defined queries #180

Closed
ajselvig opened this Issue Dec 24, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@ajselvig
Contributor

ajselvig commented Dec 24, 2015

I can't figure out how to use a field's index to query records that have that field defined:

field :foo, index: true

Seems like this should use the index, but the query uses a regular filter statement and I get the perf warning:

Model.where(:foo.defined => true)

Doesn't it seem like this query should be able to be done with getAll on the index?

@nviennot

This comment has been minimized.

Show comment
Hide comment
@nviennot

nviennot Dec 24, 2015

Owner

Yeah, I'm not sure what RQL I should generate to use the index.
Any suggestions?

Owner

nviennot commented Dec 24, 2015

Yeah, I'm not sure what RQL I should generate to use the index.
Any suggestions?

@ajselvig

This comment has been minimized.

Show comment
Hide comment
@ajselvig

ajselvig Dec 25, 2015

Contributor

I believe it's something like:

r.table("models").between( r.minval, r.maxval, {"left_bound" => "open", "index" => "foo"})
Contributor

ajselvig commented Dec 25, 2015

I believe it's something like:

r.table("models").between( r.minval, r.maxval, {"left_bound" => "open", "index" => "foo"})
@ajselvig

This comment has been minimized.

Show comment
Hide comment
@ajselvig

ajselvig Dec 25, 2015

Contributor

(this is 50x faster than the corresponding filter statement for my particular dataset)

Contributor

ajselvig commented Dec 25, 2015

(this is 50x faster than the corresponding filter statement for my particular dataset)

@nviennot nviennot closed this in 60294fc Dec 26, 2015

@ajselvig

This comment has been minimized.

Show comment
Hide comment
@ajselvig

ajselvig Dec 27, 2015

Contributor

Works perfect, thanks!

Contributor

ajselvig commented Dec 27, 2015

Works perfect, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment