Closed stutiredboy closed 5 years ago
@stutiredboy thank you for creating this issue.
To reiterate my comment from the forum: the fact that the update using an index is 3-4x slower than without an index is to be expected, and is fundamental to any SQL database. Therefore, there is not much we can do about this.
The reason why I requested to create an issue is the new test case at the bottom: that using a single assignment in UPDATE is actually making the query slower. This is unexpected. I am renaming the issue accordingly.
cc @BramGruneir
Something missed, because it will take a very long time to create secondary index, before the prepare, we have to move the secondary index creation before insert in oltp_common.lua
differ:
198a199,205
> if sysbench.opt.create_secondary then
> print(string.format("Creating a secondary index on 'sbtest%d'...",
> table_num))
> con:query(string.format("CREATE INDEX k_%d ON sbtest%d(k)",
> table_num, table_num))
> end
>
235,240d241
< if sysbench.opt.create_secondary then
< print(string.format("Creating a secondary index on 'sbtest%d'...",
< table_num))
< con:query(string.format("CREATE INDEX k_%d ON sbtest%d(k)",
< table_num, table_num))
< end
We haven't gotten to this. If you still have an issue like it, please open a new one.
QUESTION
Discussion: https://forum.cockroachlabs.com/t/is-it-reasonable-update-noindex-faster-than-update-index/1713/6
How to reproduce:
--cache=32GiB --max-sql-memory=32GiB
Suggestion From @knz, I have tried to change the update index to
UPDATE sbtest* SET k = $1 WHERE id = $2
,the $1 is integer 1 in the test, but the index update is now 5x slower.differ for sysbench oltp_common.lua
Thanks.