hquxmu / ai-contest

Automatically exported from code.google.com/p/ai-contest
0 stars 0 forks source link

Lock Contention with MySQL Database #108

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If you're getting lock contention then switching the affected tables from 
myisam to innodb should clear that up.

General rule of thumb is that read heavy tables get myisam, and write heavy 
tables get innodb.

Original issue reported on code.google.com by donald.s...@gmail.com on 11 Sep 2010 at 5:27

GoogleCodeExporter commented 9 years ago
Also, loading data into the rankings table should be done with 'load data 
infile' instead of a shitload of insert statements, as it will run a lot faster 
that way.  If rankings becomes InnoDB then nobody will be blocked on the insert 
at the end if the primary index is (leaderboard_id,submission_id).  In fact the 
key scheme in there now is pretty suboptimal as there are separate keys for 
leaderboard_id and submission_id and you're always accessing them with both.

Just generate a tab-delimited tmpfile in process_ratings.py containing the 
values you want to insert, pipe it through unix sort so as to sort the keys, 
and load data infile that sucker and your insert will be super duper fast 
without locking anything.

Original comment by andy.sloane on 11 Sep 2010 at 5:42

GoogleCodeExporter commented 9 years ago
We're not getting locks anymore (haven't had since we straightened out the 
schema and indexes). 

I agree that doing the tempfile import would be faster, but we aren't hitting 
any walls on that yet.

Original comment by danie...@gmail.com on 17 Sep 2010 at 1:07