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
It is no longer "painfully slow", it just doesn't work anymore. It returns the error, mentioned previously, after every query execution. Note: my document count is now around 60,000 for this table.
I'm currently looking into #1064. I will include your kind of workload into the testing. It's plausible that .count() could take a long time in general, because it's a naive O(n) function, but it should not fail with such a small table.
I'm not sure. An efficient count involving a range query that uses the index or primary key, or a count of the entire table, is feasible. It's been something we've meant to do for a while (at least it would improve automatic resharding). This is tracked in issue #152.
I'd like to get better performance for count in, but I'm not sure of the scope yet (i.e. we can obviously do it on the full table, but what can we do for more sophisticated queries). We'll see what we can do here as part of 1.9/2.0 planning.
I'm a bit confused about what you mean by: "the most complex count query we do is against different values in top level document attributes" would you mind clarifying?
I'm a bit confused about what you mean by: "the most complex count query we do is against different values in top level document attributes" would you mind clarifying?
Sure. We have a requirement to understand the number of documents which match certain states. The table contains a "status" field which the count query would use.
So in order to get that type of query working efficiently we would need to implement #1118. I'm actually starting to think we should just do that for 1.9.
I feel like #1118 might be a bit of an overkill here for a few reasons:
People would have to register map/reduce queries to do fast counts. These would also be map/reduce queries that would require inverse functions (we could probably abstract it out, though).
Doing incremental map/reduce requires UI/CLI support (so people can list/add/delete jobs), and ReQL support (for same reason, but also to register jobs).
It's a non-trivial feature, and adding features before 2.0 worries me.
An alternative solution might be to implement constant time count for two cases:
This seems relatively easy to do, and the way to speed up the type of queries mentioned by @dbettin (and many other queries) is to just create a secondary index, and do count on that.
@jdoliner -- would this be hard? Is this schedulable for 1.9?
Also, I'm going to go to CVS and buy a surgical mask so I don't get people sick, so we may be able to hash this out in person.
...I should also note, when I'm doing ~2k/sec writes on Ubuntu 13.10, count query from data explorer, appears to always error out. (when run while doing writes)
RqlRuntimeError: Query interrupted. Did you shut down the server? in:
r.db("ml").table("sample_compounds").count()
@mlucy i have added #2637 i am assuming the count query looks at the btree only but if the btree is large lots of documents, and those documents are small so they are in the index it can lead to slow count perfomance.
This issue is really a dup of #152 (and will be partially improved by #2637 -- thanks @wojons for opening it). Would anyone be opposed if I closed this? I bumped #152 so hopefully it won't be a problem for much longer.
I think there's another issue here, which is that the performance falls off a cliff under write load. If that's happening for count queries, it's probably happening for all aggregations. I'll open a separate issue for that.
RethinkDB count() function is always slow.I testing it since 1.12 till the latest stable. the table count might be fine but once there are intermediate opetation it simple cannot be use. very slow.
@PrakashThapa This is probably because the intermediate operations cause RethinkDB to compute every result item before counting it. For certain types of operations (specifically getAll and between operations), we will make counts very fast with #3949. This is still a few releases away though unfortunately.
@danielmewes is this getting any closer? we need to be able to do .count against indexes (getall or between). our data set has 7mb records and it is far too slow. engineering our own solution outside Rethink is complexity I would prefer to avoid.
Reacted by Egor Kislitsyn and Alisson Cavalcante Agiani
@lucasjans The solution outlined in #3949 (comment) is going to solve your use case. However I can't tell for sure yet when we will ship this, as it's only one among a bunch of other features we are working on.
Activity
dbettin commentedon Aug 12, 2013
It is no longer "painfully slow", it just doesn't work anymore. It returns the error, mentioned previously, after every query execution. Note: my document count is now around 60,000 for this table.
Let me know if you need further info.
srh commentedon Aug 12, 2013
It seems like you might be seeing the same thing as in #1064 (which is badly titled).
srh commentedon Aug 12, 2013
I'm currently looking into #1064. I will include your kind of workload into the testing. It's plausible that
.count()could take a long time in general, because it's a naive O(n) function, but it should not fail with such a small table.dbettin commentedon Aug 12, 2013
Ok thanks. This is running on a Digital Ocean 32GB/320GB SSD VM
Also, It is my understanding the naivety of the count query will be addressed in the near term too, is that a correct understanding?
srh commentedon Aug 12, 2013
I'm not sure. An efficient count involving a range query that uses the index or primary key, or a count of the entire table, is feasible. It's been something we've meant to do for a while (at least it would improve automatic resharding). This is tracked in issue #152.
coffeemug commentedon Aug 12, 2013
I'd like to get better performance for
countin, but I'm not sure of the scope yet (i.e. we can obviously do it on the full table, but what can we do for more sophisticated queries). We'll see what we can do here as part of 1.9/2.0 planning.dbettin commentedon Aug 13, 2013
Thanks @coffeemug. This is a pressing issue for us. It would be great to see this resolved in 1.9.
Also, note, our counts are not that sophisticated; the most complex count query we do is against different values in top level document attributes.
jdoliner commentedon Aug 13, 2013
I'm a bit confused about what you mean by: "the most complex count query we do is against different values in top level document attributes" would you mind clarifying?
jdoliner commentedon Aug 13, 2013
I'm a bit confused about what you mean by: "the most complex count query we do is against different values in top level document attributes" would you mind clarifying?
dbettin commentedon Aug 13, 2013
Sure. We have a requirement to understand the number of documents which match certain states. The table contains a "status" field which the count query would use.
Ex:
r.table('table').count(r.row['status'].contains('deployed')).run(conn)jdoliner commentedon Aug 13, 2013
So in order to get that type of query working efficiently we would need to implement #1118. I'm actually starting to think we should just do that for 1.9.
coffeemug commentedon Aug 13, 2013
I feel like #1118 might be a bit of an overkill here for a few reasons:
An alternative solution might be to implement constant time count for two cases:
r.table('foo').count()r.table('foo').between(null, null, index='bar').count()This seems relatively easy to do, and the way to speed up the type of queries mentioned by @dbettin (and many other queries) is to just create a secondary index, and do count on that.
@jdoliner -- would this be hard? Is this schedulable for 1.9?
Also, I'm going to go to CVS and buy a surgical mask so I don't get people sick, so we may be able to hash this out in person.
coffeemug commentedon Aug 13, 2013
On second thought what I said may not actually work (since counting the total number of docs in an index doesn't help with @dbettin's query).
coffeemug commentedon Aug 13, 2013
And by that I mean it could work, but would require some gymnastics during index creation on the part of the user.
41 remaining items
nickpoorman commentedon Jul 2, 2014
...I should also note, when I'm doing ~2k/sec writes on Ubuntu 13.10,
countquery from data explorer, appears to always error out. (when run while doing writes)wojons commentedon Jul 2, 2014
@nickpoorman are you on the irc?
nickpoorman commentedon Jul 2, 2014
@wojons yes
wojons commentedon Jul 2, 2014
@mlucy i have added #2637 i am assuming the count query looks at the btree only but if the btree is large lots of documents, and those documents are small so they are in the index it can lead to slow count perfomance.
coffeemug commentedon Jul 2, 2014
This issue is really a dup of #152 (and will be partially improved by #2637 -- thanks @wojons for opening it). Would anyone be opposed if I closed this? I bumped #152 so hopefully it won't be a problem for much longer.
nickpoorman commentedon Jul 2, 2014
I would not be opposed
coffeemug commentedon Jul 2, 2014
Closing. Please reopen if there is anything in the scope of this issue that isn't covered by #152/#2637.
mlucy commentedon Jul 3, 2014
I think there's another issue here, which is that the performance falls off a cliff under write load. If that's happening for count queries, it's probably happening for all aggregations. I'll open a separate issue for that.
PrakashThapa commentedon Apr 18, 2015
RethinkDB
count()function is always slow.I testing it since 1.12 till the latest stable. the table count might be fine but once there are intermediate opetation it simple cannot be use. very slow.danielmewes commentedon Apr 18, 2015
@PrakashThapa This is probably because the intermediate operations cause RethinkDB to compute every result item before counting it. For certain types of operations (specifically
getAllandbetweenoperations), we will make counts very fast with #3949. This is still a few releases away though unfortunately.lucasjans commentedon Apr 19, 2016
@danielmewes is this getting any closer? we need to be able to do
.countagainst indexes (getall or between). our data set has 7mb records and it is far too slow. engineering our own solution outside Rethink is complexity I would prefer to avoid.danielmewes commentedon Apr 21, 2016
@lucasjans The solution outlined in #3949 (comment) is going to solve your use case. However I can't tell for sure yet when we will ship this, as it's only one among a bunch of other features we are working on.