Latest Content
Fun MySQL fact of the day: descending means ascending
If you'd believe it, I told you only a partial truth again yesterday and Tuesday. While it's true that records are sorted in key-order in an InnoDB index, there's some yet more interesting finesse to it. In fact, would you believe me if I told you that records are ... read more
Fun MySQL fact of the day: in defence of auto_increment
Monday's introduction to auto_increment
maybe wasn't as glowing as it should have been, but we really shouldn't let one little auto_increment
really is an invaluable tool, and today we'll consider why. ... read more
Fun MySQL fact of the day: the table is a lie
Over the course of the last several weeks, you may have caught me telling partial truths or using "weird" or inconsistent words when talking about MySQL and InnoDB. And now, before we move on to the rest of this week, it's time to clear a few things up. ... read more
Fun MySQL fact of the day: auto_increment
is mostly monotonic
On Friday, I left you with a cliff-hanger suggesting that foregoing the use of foreign key constraints can result in undetectable account/identity takeovers, data leakage, data loss, corruption, and so on, and so on. And it can. And not only by accident, but also by a really fun MySQL ... read more
Fun MySQL fact of the day: foreign keys are important
A Foreign Key is a table constraint that allows a database index to remain consistent based on the existence (or non-existence) of another row in a another table. For example, MySQL will prevent the removal of a referenced row until all other referencing rows have first been removed. It will ... read moreFun MySQL fact of the day: necessarily coarse locks
If, like me, you're curious why, in yesterday's example, InnoDB acquires a next-key lock before and a gap lock after the records it is updating with equality in a secondary index when usingREPEATABLE READ
(what a mouthful!), then today's Fun MySQL fact is for you! I found myself ... read more
Fun MySQL fact of the day: the phantom record menace
Yesterday, we created an index to prevent a full table scan from locking the entirelist_of_things
table during a single UPDATE
. I mentioned it was an improvement to the problem, but not a complete fix. Today, we'll see why. ... read more
Fun MySQL fact of the day: tenant lock-out
A couple weeks ago, we very briefly touched on the subject about MySQL/InnoDB locking only single records. And since we're on the topic of multi-tenant schemas, I think it's a good time to focus on this subject. For now, we'll focus on using MySQL's default isolation,REPEATABLE READ
. ... read more
Fun MySQL fact of the day: REPLACE
your expectations
So, if we agree that we should avoid using INSERT ... ON DUPLICATE KEY UPDATE
and INSERT IGNORE
, surely we can use REPLACE INTO
to upsert a row, right?! And yes, you can, if you want a DoS