Reddit's database has only two tables
> Adding a column to 10 million rows takes locks and doesn’t work.<p>It does not take locks, other than for very briefly.<p>1. Make a new empty table that has the same structure as the table you wish to add a column to. Add your new column to the empty table.<p>2. Put triggers on the old table that, whenever a row is added or updated, makes a copy of the row in the new table or updates the copy already there.<p>3. Run a background process that goes through the old table doing dummy updates:<p><pre><code>    UPDATE table SET some_col = some_col WHERE ...
</code></pre>
where the WHERE clause picks a small number of rows (e.g., just go through the primary key sequentially). Since you aren't actually modifying the table, all this does is trigger the trigger on the specified rows.<p>4. When you've hit everything with a dummy update, rename the current table to a temp name, and rename the new table to the current table. This is the only step that needs a lock.<p>There are tools for MySQL to automate much of this. There was a post either here or on Reddit a while back about this which linked to them. I'm sorry but I didn't save a link to it so you'll have to search if you want it.