Why does this SQL batch INSERT hold locks for minutes?

Why does this SQL batch INSERT hold locks for minutes. The SQL code inserts millions of rows in one statement. In MySQL that holds locks until done. In SQL a huge insert blocks all other writes.

#whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlbatchinsert #sqllock...

https://www.youtube.com/watch?v=jsfy-AaKG20

Why does this SQL batch INSERT hold locks for minutes? #sqlreliability

YouTube

Why does this SQL prepared statement reuse the wrong plan?

Why does this SQL prepared statement reuse the wrong plan. The SQL code uses a prepared statement with different param values. In MySQL the first execution picks a plan. In SQL later values may need a different plan but get the wrong one.

#whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldatain...

https://www.youtube.com/watch?v=PJT_qVSjNBc

Why does this SQL prepared statement reuse the wrong plan? #sqlreliability

YouTube

Why does this SQL subquery run a thousand times?

Why does this SQL subquery run a thousand times in production. The SQL code uses a correlated subquery in SELECT. In MySQL it executes once per row. In SQL one query can become millions of executions.

#whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlcorrelatedsubquery #...

https://www.youtube.com/watch?v=HDQwetsWSX4

Why does this SQL subquery run a thousand times? #sqldebugging

YouTube

Why does this SQL aggregate undercount?

Why does this SQL aggregate undercount in production. The SQL code groups by a rounded timestamp, collapsing multiple events into one bucket. In SQL analytics this undercounts traffic.

#whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlaggregatebug #sqlgroupby #sqlreporting #sqlda...

https://www.youtube.com/watch?v=ocsEflqOh5Q

Why does this SQL aggregate undercount? #sqlcodereview

YouTube

Why does this SQL INSERT create duplicate IDs after rollback?

Why does this SQL INSERT create duplicate IDs after rollback. The SQL code relies on sequential auto increment. In MySQL rollback consumes the value and the next insert gets a gap. In SQL systems expecting contiguous IDs this breaks logic.

#whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqlda...

https://www.youtube.com/watch?v=udaZivmnDgQ

Why does this SQL INSERT create duplicate IDs after rollback? #sqlengineering

YouTube

Why does this SQL JSON extract never use the index?

Why does this SQL JSON extract never use the index. The SQL code queries JSON with JSON_EXTRACT. In MySQL that cannot use a regular index. In SQL use a generated column with an index.

#whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqljson #sqljsonextract #sqlindex #sq...

https://www.youtube.com/watch?v=7ybwR_o8Wh8

Why does this SQL JSON extract never use the index? #sqlperformance

YouTube

Why does this SQL gap lock block an insert you never touched?

Why does this SQL gap lock block an insert you never touched. The SQL code uses SELECT FOR UPDATE. In MySQL InnoDB locks the gap. In SQL another session cannot insert in that range.

#whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlgaplock #sqlforupdate #sql...

https://www.youtube.com/watch?v=dJR8VO6OSeU

Why does this SQL gap lock block an insert you never touched? #sqlrange

YouTube

Why does this SQL UNIQUE constraint allow multiple NULLs?

Why does this SQL UNIQUE constraint allow multiple NULLs. The SQL code adds UNIQUE on a nullable column. In SQL NULL is not equal to NULL so unique allows many NULLs. In SQL this breaks deduplication logic.

#whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqluniqu...

https://www.youtube.com/watch?v=EY-UOebdlEI

Why does this SQL UNIQUE constraint allow multiple NULLs? #sqlnull

YouTube

Why does this SQL cache stampede?

Why does this SQL cache stampede under load. The SQL layer recomputes values on expiry without a lock, so every request hits the database. In SQL services this melts the backend.

#whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlcachestampede #sqlcacherefresh #sqldatabaseload #sqlperfo...

https://www.youtube.com/watch?v=BCmzcODQV2Q

Why does this SQL cache stampede? #sqlcachestampede

YouTube

Why does this SQL CHAR comparison match wrong with trailing spaces?

Why does this SQL CHAR comparison match wrong with trailing spaces. The SQL code uses CHAR which pads with spaces. In MySQL 'a' and 'a ' compare equal. In SQL lookups you can match the wrong row.

#whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlchar ...

https://www.youtube.com/watch?v=CyfztMPBd5o

Why does this SQL CHAR comparison match wrong with trailing spaces? #sqlreliability

YouTube