home.social

#sqlbug — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #sqlbug, aggregated by home.social.

  1. Why does this SQL ORDER BY in subquery get ignored?

    Why does this SQL ORDER BY in subquery get ignored. The SQL code uses ORDER BY inside a derived table. In MySQL without LIMIT the optimizer ignores it. In SQL the order you expect is not the order you get.

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

    youtube.com/watch?v=f4mdNHOjKTg

  2. Why does this SQL phantom read show rows that vanish?

    Why does this SQL phantom read show rows that vanish. The SQL code runs REPEATABLE READ. In MySQL another transaction can insert matching rows. In SQL you see rows in one read that disappear in the next.

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

    youtube.com/watch?v=2HZvRkzESXA

  3. Why does this SQL ORDER BY RAND() melt the database?

    Why does this SQL ORDER BY RAND() melt the database. The SQL code uses ORDER BY RAND() for random rows. In MySQL that sorts the entire table. In SQL one query can take down the server.

    #whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlorderbyrand #sqlrandom #sqlsort ...

    youtube.com/watch?v=2G3tRvhnyJM

  4. Why does this SQL SUM return NULL for empty?

    Why does this SQL SUM return NULL for empty result. The SQL code sums a column without COALESCE. In SQL SUM of zero rows returns NULL not zero. In SQL APIs this breaks calculations and causes NaN downstream.

    #whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlsum #sqlnull #sql...

    youtube.com/watch?v=gG4KtBljZ-o

  5. What's wrong with this SQL REPLACE deleting related rows?

    What's wrong with this SQL REPLACE deleting related rows. The SQL code uses REPLACE instead of INSERT ON DUPLICATE. In MySQL REPLACE deletes then inserts, firing deletes on child tables. In SQL this cascades to data loss.

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

    youtube.com/watch?v=fIHKcR7Dh28

  6. What's wrong with this SQL dividing integers?

    What's wrong with this SQL dividing integers losing decimals. The SQL code divides two integer columns. In SQL integer division truncates to integer. In SQL analytics this undercounts rates and percentages.

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

    youtube.com/watch?v=xULrs5LG75M

  7. What's wrong with this SQL connection using wrong charset?

    What's wrong with this SQL connection using wrong charset. The SQL code connects without specifying charset. In MySQL wrong default corrupts Unicode. In SQL you get mojibake in the database.

    #whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlcharset #sqlutf8 #sq...

    youtube.com/watch?v=io54Ac5fdeQ

  8. What's wrong with this SQL INSERT ON DUPLICATE overwriting everything?

    What's wrong with this SQL INSERT ON DUPLICATE overwriting everything. The SQL code uses ON DUPLICATE KEY UPDATE with VALUES(). In SQL on duplicate it overwrites even columns you did not mean to change. In SQL upserts this corrupts data.

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

    youtube.com/watch?v=a-oSg485bdE

  9. What's wrong with this SQL DISTINCT hiding duplicate inserts?

    What's wrong with this SQL DISTINCT hiding duplicate inserts. The SQL code uses DISTINCT to dedupe. In SQL DISTINCT masks the fact that duplicates were written. In SQL the root cause stays and grows.

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

    youtube.com/watch?v=hhCIBFoiC6M

  10. Why does this SQL retry backoff melt servers?

    Why does this SQL retry backoff melt servers during outages. The SQL job retries on a fixed schedule without jitter, so all workers stampede at once. In SQL pipelines this keeps the outage alive.

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

    youtube.com/watch?v=ZWGlA3LIntI

  11. Why does this SQL MERGE overwrite when it should not?

    Why does this SQL MERGE overwrite when it should not. The SQL code uses MERGE with a WHEN MATCHED that always runs. In SQL the logic can overwrite rows you intended to skip. In SQL sync jobs this corrupts data.

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

    youtube.com/watch?v=FzZuQz1s4oE

  12. What's wrong with this SQL query doubling the boundary row?

    What's wrong with this SQL query doubling the boundary row in a report. The SQL code uses BETWEEN for a date range. In SQL BETWEEN is inclusive on both ends so the boundary gets counted twice if used in a join.

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

    youtube.com/watch?v=DuZMlxodwwo

  13. What's wrong with this SQL COALESCE preventing index use?

    What's wrong with this SQL COALESCE preventing index use. The SQL code filters with COALESCE(column, default). In MySQL functions on columns block indexes. In SQL the query scans the whole table.

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

    youtube.com/watch?v=OrPyGHSBlqQ

  14. 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...

    youtube.com/watch?v=jsfy-AaKG20

  15. 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...

    youtube.com/watch?v=PJT_qVSjNBc

  16. 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 #...

    youtube.com/watch?v=HDQwetsWSX4

  17. 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...

    youtube.com/watch?v=udaZivmnDgQ

  18. 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...

    youtube.com/watch?v=7ybwR_o8Wh8

  19. 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...

    youtube.com/watch?v=dJR8VO6OSeU

  20. 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...

    youtube.com/watch?v=EY-UOebdlEI

  21. 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 ...

    youtube.com/watch?v=CyfztMPBd5o

  22. Why does this SQL UPDATE lock the entire table?

    Why does this SQL UPDATE lock the entire table. The SQL code updates with a condition that has no index. In MySQL it locks every row it scans. In SQL services one update blocks all other writes.

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

    youtube.com/watch?v=hxJMh219sf0

  23. What's wrong with this SQL DATE function blocking the index?

    What's wrong with this SQL DATE function blocking the index. The SQL code wraps a datetime column in DATE(). In MySQL functions on columns prevent index use. In SQL this turns indexed lookups into full scans.

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

    youtube.com/watch?v=zTRYlHVjZ5A

  24. Why does this SQL counter lose updates?

    Why does this SQL counter lose updates under concurrency. The SQL code reads then writes without locking, so concurrent increments overwrite each other. In SQL services this undercounts events.

    #whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlracecondition #sqlcounterbug #sqlcon...

    youtube.com/watch?v=_Al7OSnYuPM

  25. Why does this SQL stored procedure break when you add a column?

    Why does this SQL stored procedure break when you add a column. The SQL code uses SELECT * in a procedure. In SQL the result shape changes on schema change. In SQL procedures that call it crash.

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

    youtube.com/watch?v=0tiKd1P5qXQ

  26. Why does this SQL partition skip data?

    Why does this SQL partition skip data in reporting. The SQL query filters on a partition boundary with the wrong timezone, so rows land in the wrong partition. In SQL analytics this miscounts totals.

    #whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlpartition #sqltimezonebug #sqlr...

    youtube.com/watch?v=8Yw6CZspyrM

  27. Why does this SQL STRAIGHT_JOIN make it worse?

    Why does this SQL STRAIGHT_JOIN make it worse. The SQL code forces join order with STRAIGHT_JOIN. In MySQL you override the optimizer. In SQL the wrong order can be orders of magnitude slower.

    #whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlstraightjoin #sqloptimizer #sq...

    youtube.com/watch?v=j7h31WUcamA

  28. Why does this SQL EXPLAIN lie about the actual cost?

    Why does this SQL EXPLAIN lie about the actual cost. The SQL code trusts EXPLAIN row estimates. In MySQL EXPLAIN shows estimates not reality. In SQL use EXPLAIN ANALYZE to see actual execution.

    #whatswrongwiththissqlquery #sqlbug #sqlproductionbug #sqldebugging #sqldatabase #sqlcodereview #sqlperformance #sqlreliability #sqlanalytics #sqldataintegrity #sqlengineering #sqlexplain #sqlanalyze #sq...

    youtube.com/watch?v=Ty3YH0gWRPM

  29. What's wrong with this SQL OR killing the index?

    What's wrong with this SQL OR killing the index on a search. The SQL code uses OR on two indexed columns. In MySQL OR often prevents index usage. In SQL APIs one OR turns a millisecond query into seconds.

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

    youtube.com/watch?v=QeUScSkvDfg

  30. CHAR vs VARCHAR Comparison Returns ZERO Rows?!

    STRING COMPARISON IS BROKEN! CHAR pads with spaces, VARCHAR doesn't! 'test' does NOT equal 'test '! Your WHERE clause returns ZERO rows! This breaks string matching! Watch!

    #sql #sqlbug #char #varchar #trailingspaces #comparisonfails #sqlfails #productionbug #sqlshorts #sqlwtf #stringcomparison #padding

    youtube.com/watch?v=aE5TuRmO_PQ

  31. CHAR vs VARCHAR Comparison Returns ZERO Rows?!

    STRING COMPARISON IS BROKEN! CHAR pads with spaces, VARCHAR doesn't! 'test' does NOT equal 'test '! Your WHERE clause returns ZERO rows! This breaks string matching! Watch!

    #sql #sqlbug #char #varchar #trailingspaces #comparisonfails #sqlfails #productionbug #sqlshorts #sqlwtf #stringcomparison #padding

    youtube.com/watch?v=aE5TuRmO_PQ

  32. CHAR vs VARCHAR Comparison Returns ZERO Rows?!

    STRING COMPARISON IS BROKEN! CHAR pads with spaces, VARCHAR doesn't! 'test' does NOT equal 'test '! Your WHERE clause returns ZERO rows! This breaks string matching! Watch!

    #sql #sqlbug #char #varchar #trailingspaces #comparisonfails #sqlfails #productionbug #sqlshorts #sqlwtf #stringcomparison #padding

    youtube.com/watch?v=aE5TuRmO_PQ

  33. Auto-Increment IDs Have GAPS Forever?!

    IDs are BROKEN! Failed INSERT consumes the auto-increment ID! User #1, skip #2, User #3! Your IDs have permanent GAPS! This breaks ID-based logic! Watch this chaos!

    #sql #sqlbug #autoincrement #primarykey #idgaps #failedinsert #sqlfails #productionbug #sqlshorts #sqlwtf #identitycolumn #dataintegrity

    youtube.com/watch?v=qF3obGJL_MY