-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
perf: poor performance on small table without index, likely due to contention #16252
Comments
@spencerkimball Can you perform a bit of initial triage given your recent work on high contention scenarios? |
Without the index, that's 20 full scans of the table per second. This table is being used as a queue, so there are probably more tombstones than there is actual data. These add to the cost of the full table scan but not the properly-indexed query (because the deleted tombstones generally have lower IDs, when we add the index we don't have to scan them. I'm not sure that we need contention-related effects to explain what's going on here. |
Hmm, that's a good point. We might be scanning over a ton of deleted keys to find the first non-deleted key. Should be straightforward to verify that with a simple test. I don't have any good thoughts on how to fix this, though. |
We're not even looking for the first non-deleted key. We're looking for the first non-deleted key whose We should, on the other hand, think about how we could make it more apparent to the user that this index is necessary. A |
Although of course ideally we'd find out some sort of optimization that fixes this (besides users using sane indexes - something we clearly weren't), there may be two metrics you could perhaps add to the admin console:
Once you drill down to a specific query the warnings in the sql shell may be of interest (as well as the TRACE and EXPLAIN output, perhaps). But in order to decide what's going in ("the cluster seems slow and pulling a lot of cpu"), some metrics in the admin console hinting what's going on could be a first step into determining what's going on. |
I wonder if there is some way to keep track of the non-deleted span of keys for a range. Seems a bit challenging to do at the MVCC/Replica level, but perhaps this could be added to the sstable metadata as part of compactions and iterators could indicate that they are interested in non-deleted keys. |
Any improvement here will have to wait until 1.2. |
Closing this for #17229. |
Not sure how actionable this is, but user @Freeaqingme reported very poor behavior in production with the following schema and queries. The main issue seemed to be contention from the full table scan associated with the first
SELECT
statement below, but the actual behavior was extremely bad. Adding an index onwebhostingServerFqdn
appears to have completely resolved the situation. When unhappy, reads would routinely have to wait ~2s for single overlapping requests, and would still take ~300ms after having cleared the command queue. The leader node for theprocessing
table would be constantly maxed out on CPU. Since many operations in this setting take >500ms,SendNextTimeout
kicks in and makes an even bigger mess.I can understand that an insertion-heavy schema with full table scans performs poorly due to contention, but I don't understand why individual operations should take ~1s; it seems that the contention somehow causes a more fundamental badness that shouldn't be there. I think one would be able to strip this schema down to the bare necessities and to repro the bad behavior with load similar to the one explained below.
The text was updated successfully, but these errors were encountered: