I was asked today about what is the cost of adding an index on a frequently updated column ( like a timestamp, count, or weight )… typically my answer is it depends. But for this question it was narrowed down to a specific case. An update on a secondary index based on a PK lookup. I decided to try and give an exact answer. I hacked the Juice DB Benchmark to attack my medium sized table ( which magically already had a count column in it ). I then cranked up the test. A few more details Query 23 updated a column without an index, queries 21,23,24 updated the d_count column. query 21 adds 5 to the count, query 22 adds 150, query 24 subtracts 1…. here are the results:
With a solo index on d_count:
Run Number: 86 threads: 8 Length : 340 LoadType: upd Total Test Runtime = 375.245010137558 seconds, limiting results to 300 seconds however QNum: 21 ... QCount: 78448 ... QTime: 0.003985 ... Max: 0.095937 ... FlatTime: 0.003673 …[Read more]