SlideShare a Scribd company logo
1 of 88
Download to read offline
Title




    MySQL Idiosyncrasies
        that BITE
                                   2010.06




Ronald Bradford
http://ronaldbradford.com2010.06
MySQL Idiosyncrasies That BITE -      #odtug #mysql @ronaldbradford
Definitions




     idiosyncrasy
     [id-ee-uh-sing-kruh-see, -sin-]
     –noun,plural-sies.


     A characteristic, habit, mannerism, or the
     like, that is peculiar to an individual.
                                           http;//dictionary.com



MySQL Idiosyncrasies That BITE - 2010.06
Relational Database




     Strictly, a relational database is a collection of
     relations (frequently called tables). Other
     items are frequently considered part of the
     database, as they help to organize and
     structure the data, in addition to forcing the
     database to conform to a set of
     requirements.

                                           Source: http://en.wikipedia.org/wiki/Relational_database



MySQL Idiosyncrasies That BITE - 2010.06
Relational Database Structure/Requirements




     Relations or Tables
     Base and derived relations (e.g. views or result sets)
     Attributes (i.e. columns)
     Domain (i.e. column attributes and constraints)
     Constraints
     Stored procedures
     Indices


MySQL Idiosyncrasies That BITE - 2010.06
Oracle != MySQL




     Age
     Development philosophies
     Target audience
     Developer practices
     Installed versions



MySQL Idiosyncrasies That BITE - 2010.06
RDBMS Characteristics




     Data Integrity
     Transactions
     ACID
     Data Security
     ANSI SQL



MySQL Idiosyncrasies That BITE - 2010.06
These RDBMS characteristics
 are NOT enabled by default
        in MySQL


MySQL Idiosyncrasies That BITE - 2010.06
1. Data Integrity


MySQL Idiosyncrasies That BITE - 2010.06
Data Integrity - Expected




CREATE TABLE sample_data (
  i TINYINT UNSIGNED NOT NULL,
                                                       ✔
  c CHAR(2) NULL,
  t TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET latin1;
INSERT INTO sample_data(i) VALUES (0), (100), (255);
Query OK, 3 rows affected (0.00 sec)
SELECT * FROM sample_data;
+-----+------+---------------------+
| i   | c    | t                   |
+-----+------+---------------------+
|   0 | NULL | 2010-06-06 13:28:44 |
| 100 | NULL | 2010-06-06 13:28:44 |
| 255 | NULL | 2010-06-06 13:28:44 |
+-----+------+---------------------+
3 rows in set (0.00 sec)



MySQL Idiosyncrasies That BITE - 2010.06
Data Integrity - Unexpected




                                                      ✘
mysql> INSERT INTO sample_data (i) VALUES (-1), (9000);

mysql> SELECT * FROM sample_data;
+-----+------+---------------------+
| i   | c    | t                   |
+-----+------+---------------------+
|   0 | NULL | 2010-06-06 13:28:44 |
| 100 | NULL | 2010-06-06 13:28:44 |
| 255 | NULL | 2010-06-06 13:28:44 |
|   0 | NULL | 2010-06-06 13:32:52 |
| 255 | NULL | 2010-06-06 13:32:52 |
+-----+------+---------------------+
5 rows in set (0.01 sec)




MySQL Idiosyncrasies That BITE - 2010.06
Data Integrity - Warnings




mysql> INSERT INTO sample_data (i) VALUES (-1), (9000);
Query OK, 2 rows affected, 2 warnings (0.00 sec)
mysql> SHOW WARNINGS;
+---------+------+--------------------------------------------+
| Level   | Code | Message                                    |
+---------+------+--------------------------------------------+
| Warning | 1264 | Out of range value for column 'i' at row 1 |
| Warning | 1264 | Out of range value for column 'i' at row 2 |
+---------+------+--------------------------------------------+




MySQL Idiosyncrasies That BITE - 2010.06
Data Integrity - Unexpected (2)




mysql> INSERT INTO sample_data (c)
    -> VALUES ('A'),('BB'),('CCC');
                                                        ✘
mysql> SELECT * FROM sample_data WHERE c IS NOT NULL;
+---+------+---------------------+
| i | c    | t                   |
+---+------+---------------------+
| 0 | A    | 2010-06-06 13:34:59 |
| 0 | BB   | 2010-06-06 13:34:59 |
| 0 | CC   | 2010-06-06 13:34:59 |
+---+------+---------------------+
3 rows in set (0.09 sec)




MySQL Idiosyncrasies That BITE - 2010.06
Data Integrity - Warnings (2)




mysql> INSERT INTO sample_data (c) VALUES ('A'),('BB'),('CCC');
Query OK, 3 rows affected, 2 warnings (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 1

mysql> SHOW WARNINGS;
+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+   Only listed
| Warning | 1364 | Field 'i' doesn't have a default value |
| Warning | 1265 | Data truncated for column 'c' at row 3 |   for 1 row
+---------+------+----------------------------------------+
2 rows in set (0.01 sec)




MySQL Idiosyncrasies That BITE - 2010.06
SHOW WARNINGS

                                    http://dev.mysql.com/doc/refman/5.1/en/show-warnings.html



MySQL Idiosyncrasies That BITE - 2010.06
Using SQL_MODE for Data Integrity




SQL_MODE = STRICT_ALL_TABLES;




                                  http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html



MySQL Idiosyncrasies That BITE - 2010.06
Data Integrity - Expected




mysql> SET SESSION SQL_MODE=STRICT_ALL_TABLES;
mysql> TRUNCATE TABLE sample_data;
                                                                 ✔
mysql> INSERT INTO sample_data(i) VALUES (0), (100), (255);

mysql> INSERT INTO sample_data (i) VALUES (-1), (9000);
ERROR 1264 (22003): Out of range value for column 'i' at row 1

mysql> SELECT * FROM sample_data;
+-----+------+---------------------+
| i   | c    | t                   |
+-----+------+---------------------+
|   0 | NULL | 2010-06-06 14:39:48 |
| 100 | NULL | 2010-06-06 14:39:48 |
| 255 | NULL | 2010-06-06 14:39:48 |
+-----+------+---------------------+
3 rows in set (0.00 sec)




MySQL Idiosyncrasies That BITE - 2010.06
Data Integrity with Dates - Expected




mysql> SET SESSION SQL_MODE='';
mysql> INSERT INTO sample_date (d) VALUES ('2010-02-31');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> SHOW WARNINGS;
+---------+------+----------------------------------------+
| Level   | Code | Message                                |



                                                                           ✘
+---------+------+----------------------------------------+
| Warning | 1265 | Data truncated for column 'd' at row 1 |
+---------+------+----------------------------------------+
mysql> SELECT * FROM sample_date;
+------------+
| d          |
+------------+
| 0000-00-00 |



                                                                           ✔
+------------+

mysql> SET SESSION SQL_MODE=STRICT_ALL_TABLES;
mysql> INSERT INTO sample_date (d) VALUES ('2010-02-31');
ERROR 1292 (22007): Incorrect date value: '2010-02-31' for column 'd' at
row 1




MySQL Idiosyncrasies That BITE - 2010.06
Data Integrity with Dates - Unexpected




mysql>
mysql>
            TRUNCATE TABLE sample_date;
            INSERT INTO sample_date (d) VALUES ('2010-00-00');
                                                                 ✘
mysql>      INSERT INTO sample_date (d) VALUES ('2010-00-05');
mysql>      INSERT INTO sample_date (d) VALUES ('0000-00-00');

mysql> SELECT * FROM sample_date;
+------------+
| d          |
+------------+
| 2010-00-00 |
| 2010-00-05 |
| 0000-00-00 |
+------------+
3 rows in set (0.00 sec)




MySQL Idiosyncrasies That BITE - 2010.06
Using SQL_MODE for Date Integrity




SQL_MODE =
      STRICT_ALL_TABLES,
      NO_ZERO_DATE,
      NO_ZERO_IN_DATE;



                                  http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html



MySQL Idiosyncrasies That BITE - 2010.06
Data Integrity with Dates - Expected




mysql> SET SESSION
SQL_MODE='STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE';
                                                                            ✔
mysql> TRUNCATE TABLE sample_date;

mysql> INSERT INTO sample_date (d)         VALUES ('2010-00-00');
ERROR 1292 (22007): Incorrect date         value: '2010-00-00' for column
'd' at row 1
mysql> INSERT INTO sample_date (d)         VALUES ('2010-00-05');
ERROR 1292 (22007): Incorrect date         value: '2010-00-05' for column
'd' at row 1
mysql> INSERT INTO sample_date (d)         VALUES ('0000-00-00');
ERROR 1292 (22007): Incorrect date         value: '0000-00-00' for column
'd' at row 1
mysql> SELECT * FROM sample_date;
Empty set (0.00 sec)




MySQL Idiosyncrasies That BITE - 2010.06
2. Transactions


MySQL Idiosyncrasies That BITE - 2010.06
Transactions Example - Tables




DROP TABLE IF EXISTS parent;
CREATE TABLE parent (
  id   INT UNSIGNED NOT NULL AUTO_INCREMENT,
  val VARCHAR(10) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY (val)
) ENGINE=InnoDB DEFAULT CHARSET latin1;

DROP TABLE IF EXISTS child;
CREATE TABLE child (
  id        INT UNSIGNED NOT NULL AUTO_INCREMENT,
  parent_id INT UNSIGNED NOT NULL,
  created   TIMESTAMP NOT NULL,
PRIMARY KEY (id),
INDEX (parent_id)
) ENGINE=InnoDB DEFAULT CHARSET latin1;



MySQL Idiosyncrasies That BITE - 2010.06
Transactions Example - SQL




START TRANSACTION;
INSERT INTO parent(val) VALUES("a");
INSERT INTO child(parent_id,created)
           VALUES(LAST_INSERT_ID(),NOW());
INSERT INTO parent(val) VALUES("a");
ROLLBACK;
SELECT * FROM parent;
SELECT * FROM child;




MySQL Idiosyncrasies That BITE - 2010.06
Transactions Example - Expected




...
mysql> INSERT INTO parent (val) VALUES("a");
                                                        ✔
ERROR 1062 (23000): Duplicate entry 'a' for key 'val'

mysql> ROLLBACK;

mysql> SELECT * FROM parent;
Empty set (0.00 sec)

mysql> SELECT * FROM child;
Empty set (0.00 sec)




MySQL Idiosyncrasies That BITE - 2010.06
Transactions Example - Using MyISAM




ALTER TABLE child ENGINE=MyISAM;
ALTER TABLE parent ENGINE=MyISAM;
TRUNCATE TABLE child;
TRUNCATE TABLE parent;

START TRANSACTION;
INSERT INTO parent(val) VALUES("a");
INSERT INTO child(parent_id,created)
            VALUES(LAST_INSERT_ID(),NOW());
INSERT INTO parent (val) VALUES("a");
ROLLBACK;
SELECT * FROM parent;
SELECT * FROM child;




MySQL Idiosyncrasies That BITE - 2010.06
Transactions Example - Unexpected




mysql> INSERT INTO parent (val) VALUES("a");
ERROR 1062 (23000): Duplicate entry 'a' for key 'val'
                                                        ✘
mysql> ROLLBACK;
mysql> SELECT * FROM parent;
+----+-----+
| id | val |
+----+-----+
| 1 | a    |
+----+-----+
1 row in set (0.00 sec)
mysql> SELECT * FROM child;
+----+-----------+---------------------+
| id | parent_id | created             |
+----+-----------+---------------------+
| 1 |          1 | 2010-06-03 13:53:38 |
+----+-----------+---------------------+
1 row in set (0.00 sec)




MySQL Idiosyncrasies That BITE - 2010.06
Transactions Example - Unexpected (2)




mysql> ROLLBACK;
Query OK, 0 rows affected, 1 warning (0.00 sec)
                                                      ✘
mysql> SHOW WARNINGS;
+---------+-------+-------------------------------------
| Level   | Code | Message
|
+---------+------+--------------------------------------
| Warning | 1196 | Some non-transactional changed tables
couldn't be rolled back |
+---------+------+--------------------------------------




MySQL Idiosyncrasies That BITE - 2010.06
Transactions Solution




       mysql> SET GLOBAL storage_engine=InnoDB;


       # my.cnf
       [mysqld]
       default-storage-engine=InnoDB

       # NOTE: Requires server restart




http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_default-storage-engine



       MySQL Idiosyncrasies That BITE - 2010.06
Why use Non Transactional Tables?




     No transaction overhead
          Much faster
          Less disk writes
          Lower disk space requirements
          Less memory requirements

          http://dev.mysql.com/doc/refman/5.1/en/storage-engine-compare-transactions.html




MySQL Idiosyncrasies That BITE - 2010.06
3. Variable Scope


MySQL Idiosyncrasies That BITE - 2010.06
Variable Scope Example




mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL);

mysql> SHOW CREATE TABLE test1G
CREATE TABLE `test1` (
  `id` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1




MySQL Idiosyncrasies That BITE - 2010.06
Variable Scope Example (2)




mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |                             Changing in
+----------------+--------+                           MySQL 5.5
| storage_engine | MyISAM |
+----------------+--------+

mysql> SET GLOBAL storage_engine='InnoDB';
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+




MySQL Idiosyncrasies That BITE - 2010.06
Variable Scope Example (3)




mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
                                                       ✘
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+

mysql> DROP TABLE test1;
mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL);

mysql> SHOW CREATE TABLE test1G
CREATE TABLE `test1` (
  `id` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1




MySQL Idiosyncrasies That BITE - 2010.06
Variable Scope Example (4)




mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+

mysql> SHOW SESSION VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | MyISAM |
+----------------+--------+




MySQL Idiosyncrasies That BITE - 2010.06
Variable Scope Syntax




     SHOW [GLOBAL | SESSION] VARIABLES;
     SET [GLOBAL | SESSION] variable = value;
     Default is GLOBAL since 5.0.2




                                         http://dev.mysql.com/doc/refman/5.1/en/set-option.html
                                      http://dev.mysql.com/doc/refman/5.1/en/user-variables.html



MySQL Idiosyncrasies That BITE - 2010.06
4. Storage Engines


MySQL Idiosyncrasies That BITE - 2010.06
Storage Engines Example - Creation




CREATE TABLE test1 (
  id INT UNSIGNED NOT NULL
                                                   ✘
) ENGINE=InnoDB DEFAULT CHARSET latin1;

SHOW CREATE TABLE test1G
*************************** 1. row *************
Table: test1
Create Table: CREATE TABLE `test1` (
  `id` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1




MySQL Idiosyncrasies That BITE - 2010.06
Storage Engines Example - Unexpected




CREATE TABLE test1 (
  id INT UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET latin1;
Query OK, 0 rows affected, 2 warnings (0.13 sec)
SHOW WARNINGS;
+---------+------+-----------------------------------------------+
| Level   | Code | Message                                       |
+---------+------+-----------------------------------------------+
| Warning | 1286 | Unknown table engine 'InnoDB'                 |
| Warning | 1266 | Using storage engine MyISAM for table 'test1' |
+---------+------+-----------------------------------------------+
2 rows in set (0.00 sec)




MySQL Idiosyncrasies That BITE - 2010.06
Storage Engines Example - Cause




    mysql> SHOW ENGINES;
+------------+---------+-------------------------+--------------+------+------------+
| Engine     | Support | Comment                 | Transactions | XA   | Savepoints |
+------------+---------+-------------------------+--------------+------+------------+
| InnoDB     | NO      | Supports transaction... | NULL         | NULL | NULL       |
| MEMORY     | YES     | Hash based, stored i... | NO           | NO   | NO         |
| MyISAM     | DEFAULT | Default engine as ... | NO             | NO   | NO         |




MySQL Idiosyncrasies That BITE - 2010.06
Storage Engines Example - Unexpected (2)




mysql> CREATE TABLE test1
id INT UNSIGNED NOT NULL
) ENGINE=InnDB DEFAULT CHARSET latin1;
                                                                 ✘
Query OK, 0 rows affected, 2 warnings (0.11 sec)

mysql> SHOW WARNINGS;
+---------+------+-----------------------------------------------+
| Level   | Code | Message                                       |
+---------+------+-----------------------------------------------+
| Warning | 1286 | Unknown table engine 'InnDB'                  |
| Warning | 1266 | Using storage engine MyISAM for table 'test1' |
+---------+------+-----------------------------------------------+




MySQL Idiosyncrasies That BITE - 2010.06
Using SQL_MODE for Storage Engines




SQL_MODE =
      STRICT_ALL_TABLES,
      NO_ZERO_DATE,
      NO_ZERO_IN_DATE,
      NO_ENGINE_SUBSTITUTION;

                                  http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html



MySQL Idiosyncrasies That BITE - 2010.06
Storage Engines Example - Solution




SET SESSION SQL_MODE=NO_ENGINE_SUBSTITUTION;        ✔
DROP TABLE IF EXISTS test3;
CREATE TABLE test3 (
  id INT UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET latin1;

ERROR 1286 (42000): Unknown table engine 'InnoDB'




MySQL Idiosyncrasies That BITE - 2010.06
5. ACID


MySQL Idiosyncrasies That BITE - 2010.06
Atomicity -
                      All or nothing


MySQL Idiosyncrasies That BITE - 2010.06
Atomicity - Table




DROP TABLE IF EXISTS test1;
CREATE TABLE test1(
  id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  val CHAR(1) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET latin1;




MySQL Idiosyncrasies That BITE - 2010.06
Atomicity - Data




INSERT INTO test1(val) VALUES ('a'),('b'),('c'),('d'),('e'),
('f'),('g');

mysql> SELECT * FROM test1;
+----+-----+
| id | val |
+----+-----+
| 1 | a    |
| 2 | b    |
| 3 | c    |
| 4 | d    |
| 5 | e    |
| 6 | f    |
| 7 | g    |
+----+-----+
7 rows in set (0.00 sec)

mysql> UPDATE test1 SET id = 10 - id;



MySQL Idiosyncrasies That BITE - 2010.06
Atomicity - Unexpected




mysql> UPDATE test1 SET id = 10 - id;
ERROR 1062 (23000): Duplicate entry '7' for key
                                                  ✘
'PRIMARY'
mysql> SELECT * FROM test1;
+----+-----+
| id | val |
+----+-----+
| 9 | a    |
| 8 | b    |
| 3 | c    |
| 4 | d    |
| 5 | e    |
| 6 | f    |
| 7 | g    |
+----+-----+




MySQL Idiosyncrasies That BITE - 2010.06
Atomicity - Unexpected (2)




mysql> ROLLBACK;
Query OK, 0 rows affected (0.00 sec)
                                           ✘
mysql> SELECT * FROM test1;
+----+-----+
| id | val |
+----+-----+
| 9 | a    |
| 8 | b    |
...




MySQL Idiosyncrasies That BITE - 2010.06
Atomicity - Transactional Table




ALTER TABLE test1 ENGINE=InnoDB;
DELETE FROM test1 WHERE id > 5;
SELECT * FROM test1;
                                           ✘
+----+-----+
| id | val |
+----+-----+
| 3 | c    |
| 4 | d    |
| 5 | e    |
+----+-----+
ROLLBACK;
SELECT * FROM test1;
+----+-----+
| id | val |
+----+-----+
| 3 | c    |
| 4 | d    |
| 5 | e    |
+----+-----+




MySQL Idiosyncrasies That BITE - 2010.06
Atomicity - The culprit




mysql> SHOW GLOBAL VARIABLES LIKE 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit    | ON    |
+---------------+-------+




MySQL Idiosyncrasies That BITE - 2010.06
Atomicity - Recommendations




     Always wrap SQL in transactions
          START TRANSACTION | BEGIN [WORK]
          COMMIT




MySQL Idiosyncrasies That BITE - 2010.06
Isolation -
     Transactions do not affect
        other transactions


MySQL Idiosyncrasies That BITE - 2010.06
Transaction Isolation - Levels




       READ-UNCOMMITTED
       READ-COMMITTED
       REPEATABLE-READ
       SERIALIZABLE


                                 http://dev.mysql.com/doc/refman/5.1/en/set-transaction.html
http://ronaldbradford.com/blog/understanding-mysql-innodb-transaction-isolation-2009-09-24/



  MySQL Idiosyncrasies That BITE - 2010.06
Transaction Isolation - Default




     The default is
          REPEATABLE-READ

     SET GLOBAL tx_isolation = 'READ-COMMITTED';


     This is a mistake


               http://ronaldbradford.com/blog/dont-assume-common-terminology-2010-03-03/

MySQL Idiosyncrasies That BITE - 2010.06
Oracle READ COMMITTED
           !=
 MySQL READ-COMMITTED

MySQL Idiosyncrasies That BITE - 2010.06
Transaction Isolation - Binary Logging Errors




SET GLOBAL tx_isolation='READ-COMMITTED';
Query OK, 0 rows affected (0.00 sec)
                                                      ✘
mysql> insert into test1 values (1,'x');
ERROR 1598 (HY000): Binary logging not possible.
Message: Transaction level 'READ-COMMITTED' in InnoDB is
not safe for binlog mode 'STATEMENT'




MySQL Idiosyncrasies That BITE - 2010.06
Durability -
                  No committed
               transactions are lost


MySQL Idiosyncrasies That BITE - 2010.06
Data Safety




     MyISAM writes/flushes data every statement
          Does not flush indexes (*)
     InnoDB can relax durability
          Every transaction / per second

     innodb_flush_log_at_trx_commit
     sync_binlog
     innodb_support_xa
MySQL Idiosyncrasies That BITE - 2010.06
Auto Recovery




     InnoDB has it
     MyISAM does not - (*) Indexes


     MYISAM-RECOVER=FORCE,BACKUP
     REPAIR TABLE
     myisamchk


MySQL Idiosyncrasies That BITE - 2010.06
Recovery Time




     InnoDB is consistent
          Redo Log file size
          Slow performance in Undo
     MyISAM grows with data volume




MySQL Idiosyncrasies That BITE - 2010.06
InnoDB Auto Recovery Example




InnoDB: Log scan progressed past the checkpoint lsn 0 188755039
100624 16:37:44 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
                                                                           ✔
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 0 193997824
InnoDB: Doing recovery: scanned up to log sequence number 0 195151897
InnoDB: 1 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 105565 row operations to undo
InnoDB: Trx id counter is 0 18688
100624 16:37:45 InnoDB: Starting an apply batch of log records to the
database...
InnoDB: Progress in percents: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
19 ... 99
InnoDB: Apply batch completed
InnoDB: Last MySQL binlog file position 0 12051, file name ./binary-log.
000003
InnoDB: Starting in background the rollback of uncommitted transactions
...




MySQL Idiosyncrasies That BITE - 2010.06
MyISAM Repair needed Example




100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/
descriptions' is marked as crashed and should be repaired
100126 22:44:35 [Warning] Checking table:   './XXX/descriptions'
                                                                        ✘
100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/taggings'
is marked as crashed and should be repaired
100126 22:44:35 [Warning] Checking table:   './XXX/taggings'
100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/vehicle'
is marked as crashed and should be repaired




MySQL Idiosyncrasies That BITE - 2010.06
6. Data Security


MySQL Idiosyncrasies That BITE - 2010.06
User Privileges - Practices




Best Practice
CREATE USER goodguy@localhost IDENTIFIED BY 'sakila';
GRANT CREATE,SELECT,INSERT,UPDATE,DELETE ON odtug.* TO
                                                                                                ✔
goodguy@localhost;



Normal Practice
CREATE USER superman@'%';
GRANT ALL ON *.* TO superman@'%';
                                                                                                ✘
                                           http://dev.mysql.com/doc/refman/5.1/en/create-user.html
                                                  http://dev.mysql.com/doc/refman/5.1/en/grant.html


MySQL Idiosyncrasies That BITE - 2010.06
User Privileges - Normal Bad Practice




     GRANT ALL ON *.* TO user@’%’
          *.* gives you access to all tables in all schemas
          @’%’ give you access from any external location
          ALL gives you
          ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY
          TABLES, CREATE USER, CREATE VIEW, DELETE, DROP, EVENT, EXECUTE, FILE,
          INDEX, INSERT, LOCK TABLES, PROCESS, REFERENCES, RELOAD, REPLICATION
          CLIENT, REPLICATION SLAVE, SELECT, SHOW DATABASES, SHOW VIEW,
          SHUTDOWN, SUPER, TRIGGER, UPDATE, USAGE



MySQL Idiosyncrasies That BITE - 2010.06
User Privileges - Why SUPER is bad




     SUPER
          Bypasses read_only
          Bypasses init_connect
          Can Disable binary logging
          Change configuration dynamically
          No reserved connection


MySQL Idiosyncrasies That BITE - 2010.06
SUPER and Read Only




$ mysql -ugoodguy -psakila odtug
mysql> insert into test1(id) values(1);
                                                      ✔
ERROR 1290 (HY000): The MySQL server is running with the
--read-only option so it cannot execute this statement




$ mysql -usuperman odtug
mysql> insert into test1(id) values(1);
Query OK, 1 row affected (0.01 sec)
                                                      ✘

MySQL Idiosyncrasies That BITE - 2010.06
SUPER and Init Connect




#my.cnf
[client]
init_connect=SET NAMES utf8


This specifies to use UTF8 for communication with client
and data




MySQL Idiosyncrasies That BITE - 2010.06
SUPER and Init Connect (2)




✔                       $ mysql -usuperman odtug
$ mysql -ugoodguy -psakila odtug
                                                              ✘
                        mysql> SHOW SESSION VARIABLES LIKE
mysql> SHOW SESSION VARIABLES LIKE 'ch%';
                        'character%';
+--------------------------+----------+
                        +--------------------------+----------+
| Variable_name             | Value
                        | Variable_name|           | Value    |
+--------------------------+----------+
                        +--------------------------+----------+
| character_set_client | character_set_client
                            | utf8     |           | latin1   |
| character_set_connection | utf8      |
                        | character_set_connection | latin1   |
| character_set_database character_set_database
                        |   | latin1   |           | latin1   |
| character_set_filesystem | binary    |
                        | character_set_filesystem | binary   |
| character_set_results | character_set_results
                            | utf8     |           | latin1   |
| character_set_server | character_set_server
                            | latin1   |           | latin1   |
| character_set_system | character_set_system
                            | utf8     |           | utf8     |
+--------------------------+----------+
                        +--------------------------+----------+




 MySQL Idiosyncrasies That BITE - 2010.06
SUPER and Binary Log




mysql> SHOW MASTER STATUS;
+-------------------+----------+--------------+------------------+
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| binary-log.000001 |      354 |              |                  |
+-------------------+----------+--------------+------------------+

mysql> DROP TABLE time_zone_leap_second;
mysql> SET SQL_LOG_BIN=0;
mysql> DROP TABLE time_zone_name;
mysql> SET SQL_LOG_BIN=1;
mysql> DROP TABLE time_zone_transition;
mysql> SHOW MASTER STATUS;
+-------------------+----------+--------------+------------------+
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| binary-log.000001 |      674 |              |                  |
+-------------------+----------+--------------+------------------+




MySQL Idiosyncrasies That BITE - 2010.06
SUPER and Binary Log (2)




$ mysqlbinlog binary-log.000001 --start-position=354 --stop-position=674

# at 354
#100604 18:00:08 server id 1 end_log_pos 450 Query thread_id=1 exec_time=0
error_code=0
use mysql/*!*/;
SET TIMESTAMP=1275688808/*!*/;



                                                                           ✘
DROP TABLE time_zone_leap_second
/*!*/;
# at 579
#100604 18:04:31 server id 1 end_log_pos 674 Query thread_id=2 exec_time=0
error_code=0
use mysql/*!*/;
SET TIMESTAMP=1275689071/*!*/;
DROP TABLE time_zone_transition
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;




MySQL Idiosyncrasies That BITE - 2010.06
SUPER and reserved connection




$ mysql -uroot                                         ✔
mysql> show global variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 3     |
+-----------------+-------+
1 row in set (0.07 sec)

mysql> show global status like 'threads_connected';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| Threads_connected | 4     |
+-------------------+-------+



MySQL Idiosyncrasies That BITE - 2010.06
SUPER and reserved connection - Unexpected




$ mysql -uroot
ERROR 1040 (HY000): Too many connections
                                                                                  ✘
mysql> SHOW PROCESSLIST;
+----+------+-----------+-------+---------+------+------------+---------------
| Id | User | Host      | db    | Command | Time | State      | Info
+----+------+-----------+-------+---------+------+------------+---------------
| 13 | root | localhost | odtug | Query   | 144 | User sleep | UPDATE test1 ...
| 14 | root | localhost | odtug | Query   | 116 | Locked      | select * from test1
| 15 | root | localhost | odtug | Query   |   89 | Locked     | select * from test1




MySQL Idiosyncrasies That BITE - 2010.06
7. ANSI SQL


MySQL Idiosyncrasies That BITE - 2010.06
Group By Example




SELECT country, COUNT(*) AS color_count
FROM   flags
GROUP BY country;


                                           ✔
+-----------+-------------+
| country    | color_count |
+-----------+-------------+
| Australia |            3 |
| Canada     |           2 |
| Japan      |           2 |
| Sweden     |           2 |
| USA        |           3 |
+-----------+-------------+


SELECT country, COUNT(*)



                                           ✘
FROM   flags;
+-----------+----------+
| country   | COUNT(*) |
+-----------+----------+
| Australia |       12 |
+-----------+----------+




MySQL Idiosyncrasies That BITE - 2010.06
Group By Example (2)




SET SESSION sql_mode=ONLY_FULL_GROUP_BY;
                                                                                       ✔
SELECT country, COUNT(*)
FROM   flags;

ERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...)
   with no GROUP columns is illegal if there is no GROUP BY clause




                                           http://ExpertPHPandMySQL.com   Chapter 1 - Pg 31



MySQL Idiosyncrasies That BITE - 2010.06
Using SQL_MODE for ANSI SQL




SQL_MODE =
      STRICT_ALL_TABLES,
      NO_ZERO_DATE,
      NO_ZERO_IN_DATE,
      NO_ENGINE_SUBSTITUTION,
      ONLY_FULL_GROUP_BY;


MySQL Idiosyncrasies That BITE - 2010.06
8. Case Sensitivity


MySQL Idiosyncrasies That BITE - 2010.06
Case Sensitivity String Comparison




  SELECT 'USA' = UPPER('usa');
+----------------------+
| 'USA' = UPPER('usa') |
+----------------------+
|                    1 |
+----------------------+

SELECT 'USA' = 'USA', 'USA' = 'Usa', 'USA' = 'usa',
       'USA' = 'usa' COLLATE latin1_general_cs AS different;
+---------------+---------------+---------------+-----------+
| 'USA' = 'USA' | 'USA' = 'Usa' | 'USA' = 'usa' | different |
+---------------+---------------+---------------+-----------+
|             1 |             1 |             1 |         0 |
+---------------+---------------+---------------+-----------+




SELECT name, address, email
FROM   customer
                                                                ✘
WHERE name = UPPER('bradford')




MySQL Idiosyncrasies That BITE - 2010.06
Case Sensitivity Tables




# Server 1

mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL);
mysql> INSERT INTO test1 VALUES(1);
mysql> INSERT INTO TEST1 VALUES(2);

# Server 2

mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL);
mysql> INSERT INTO test1 VALUES(1);
mysql> INSERT INTO TEST1 VALUES(2);
ERROR 1146 (42S02): Table 'test.TEST1' doesn't exist




MySQL Idiosyncrasies That BITE - 2010.06
Case Sensitivity Tables (2)




# Server 1 - Mac OS X / Windows Default
mysql> SHOW GLOBAL VARIABLES LIKE 'lower%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_file_system | ON    |
| lower_case_table_names | 2     |
+------------------------+-------+

# Server 2 - Linux Default
mysql> SHOW GLOBAL VARIABLES LIKE 'lower%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_file_system | OFF   |
| lower_case_table_names | 0     |
+------------------------+-------+




MySQL Idiosyncrasies That BITE - 2010.06
Other Gotchas


MySQL Idiosyncrasies That BITE - 2010.06
Other features the BITE




     Character Sets
       Data/Client/Application/Web
     Sub Queries
       Rewrite as JOIN when possible
     Views
       No always efficient
     Cascading Configuration Files
     SQL_MODE's not to use
MySQL Idiosyncrasies That BITE - 2010.06
Conclusion


MySQL Idiosyncrasies That BITE - 2010.06
DON'T
                   ASSUME
MySQL Idiosyncrasies That BITE - 2010.06
Conclusion - The story so far




MySQL Idiosyncrasies that BITE
Definitions, Relational Database [Structure/Requirements], Oracle != MySQL, RDBMS Characteristics,
Data Integrity [Expected | Unexpected | Warnings | Unexpected (2) | Warnings (2) ],
Using SQL_MODE for Data Integrity,
Data Integrity [ Expected ], Data Integrity with Dates [Expected | Unexpected ],
Using SQL_MODE for Date Integrity, Data Integrity with Dates [Expected ],
Transactions Example [ Tables | SQL | Expected | Using MyISAM | Unexpected [ (2)],
Transactions Solution, Why use Non Transactional Tables?
Variable Scope Example [ | (2)| (3)| [4])| Syntax
Storage Engines Example [Creation | Unexpected | Cause | Unexpected (2) ]
Using SQL_MODE for Storage Engines, Storage Engines Example [Solution]
Atomicity [ Table | Data | Unexpected | Unexpected (2) | Transactional Table | The culprit | Recommendations ]
Transaction Isolation [ Levels | Default | Binary Logging ]
Durablilty [ Auto Recovery]
User Privileges [Practices | Normal Bad Practice | Why SUPER is bad ]
SUPER and [ Read Only | Init Connect [(2)] | Binary Log [2] | Reserved Connection [2] ]
Group by Example [2], Using SQL_MODE for ANSI SQL
Case Sensitivity [ String Comparison | Tables [2] ]
More Gotchas, Character Sets, Sub Queries, Views
Conclusion [ DON'T ASSUME | The Story so far | SQL_MODE ] RonaldBradford.com




MySQL Idiosyncrasies That BITE - 2010.06
Conclusion - SQL_MODE




     SQL_MODE =

                                                                                                ✔
     ALLOW_INVALID_DATES, ANSI_QUOTES, ERROR_FOR_DIVISION_ZERO,
     HIGH_NOT_PRECEDENCE,IGNORE_SPACE,NO_AUTO_CREATE_USER,
     NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES,
     NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,
     NO_FIELD_OPTIONS,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,
     NO_UNSIGNED_SUBTRACTION,NO_ZERO_DATE,
     NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY (5.1.11),
     PAD_CHAR_TO_FULL_LENGTH (5.1.20), PIPES_AS_CONCAT,
     REAL_AS_FLOAT,STRICT_ALL_TABLES, STRICT_TRANS_TABLES
                                                                                                ✘
     ANSI, DB2, MAXDB, MSSQL, MYSQL323, MYSQL40, ORACLE,
     POSTGRESQL,TRADITIONAL
                                  http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html
                                                                                                ?
MySQL Idiosyncrasies That BITE - 2010.06
RonaldBradford.com

  MySQL4OracleDBA.com


MySQL Idiosyncrasies That BITE - 2010.06

More Related Content

What's hot

Applied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System PresentationApplied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System PresentationRichard Crowley
 
Mysqlconf2013 mariadb-cassandra-interoperability
Mysqlconf2013 mariadb-cassandra-interoperabilityMysqlconf2013 mariadb-cassandra-interoperability
Mysqlconf2013 mariadb-cassandra-interoperabilitySergey Petrunya
 
15 MySQL Basics #burningkeyboards
15 MySQL Basics #burningkeyboards15 MySQL Basics #burningkeyboards
15 MySQL Basics #burningkeyboardsDenis Ristic
 
Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2Sergey Petrunya
 
Introduction To Lamp P2
Introduction To Lamp P2Introduction To Lamp P2
Introduction To Lamp P2Amzad Hossain
 
MySQL 8 for Developers
MySQL 8 for DevelopersMySQL 8 for Developers
MySQL 8 for DevelopersGeorgi Sotirov
 
Cat database
Cat databaseCat database
Cat databasetubbeles
 
Lecture2 mysql by okello erick
Lecture2 mysql by okello erickLecture2 mysql by okello erick
Lecture2 mysql by okello erickokelloerick
 
16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboardsDenis Ristic
 
Tracking Data Updates in Real-time with Change Data Capture
Tracking Data Updates in Real-time with Change Data CaptureTracking Data Updates in Real-time with Change Data Capture
Tracking Data Updates in Real-time with Change Data CaptureScyllaDB
 
MySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesMySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesDamien Seguy
 
Data Love Conference - Window Functions for Database Analytics
Data Love Conference - Window Functions for Database AnalyticsData Love Conference - Window Functions for Database Analytics
Data Love Conference - Window Functions for Database AnalyticsDave Stokes
 
The Ring programming language version 1.9 book - Part 36 of 210
The Ring programming language version 1.9 book - Part 36 of 210The Ring programming language version 1.9 book - Part 36 of 210
The Ring programming language version 1.9 book - Part 36 of 210Mahmoud Samir Fayed
 

What's hot (20)

Applied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System PresentationApplied Partitioning And Scaling Your Database System Presentation
Applied Partitioning And Scaling Your Database System Presentation
 
Mysqlconf2013 mariadb-cassandra-interoperability
Mysqlconf2013 mariadb-cassandra-interoperabilityMysqlconf2013 mariadb-cassandra-interoperability
Mysqlconf2013 mariadb-cassandra-interoperability
 
15 MySQL Basics #burningkeyboards
15 MySQL Basics #burningkeyboards15 MySQL Basics #burningkeyboards
15 MySQL Basics #burningkeyboards
 
w_dzon05
w_dzon05w_dzon05
w_dzon05
 
MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
 
Hanya contoh saja dari xampp
Hanya contoh saja dari xamppHanya contoh saja dari xampp
Hanya contoh saja dari xampp
 
Practica controlconcurrencia
Practica controlconcurrenciaPractica controlconcurrencia
Practica controlconcurrencia
 
Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2Common Table Expressions in MariaDB 10.2
Common Table Expressions in MariaDB 10.2
 
Introduction To Lamp P2
Introduction To Lamp P2Introduction To Lamp P2
Introduction To Lamp P2
 
MySQL Functions
MySQL FunctionsMySQL Functions
MySQL Functions
 
MySQL 8 for Developers
MySQL 8 for DevelopersMySQL 8 for Developers
MySQL 8 for Developers
 
Cat database
Cat databaseCat database
Cat database
 
Lecture2 mysql by okello erick
Lecture2 mysql by okello erickLecture2 mysql by okello erick
Lecture2 mysql by okello erick
 
16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards
 
My SQL
My SQLMy SQL
My SQL
 
Intro to my sql
Intro to my sqlIntro to my sql
Intro to my sql
 
Tracking Data Updates in Real-time with Change Data Capture
Tracking Data Updates in Real-time with Change Data CaptureTracking Data Updates in Real-time with Change Data Capture
Tracking Data Updates in Real-time with Change Data Capture
 
MySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queriesMySQL Kitchen : spice up your everyday SQL queries
MySQL Kitchen : spice up your everyday SQL queries
 
Data Love Conference - Window Functions for Database Analytics
Data Love Conference - Window Functions for Database AnalyticsData Love Conference - Window Functions for Database Analytics
Data Love Conference - Window Functions for Database Analytics
 
The Ring programming language version 1.9 book - Part 36 of 210
The Ring programming language version 1.9 book - Part 36 of 210The Ring programming language version 1.9 book - Part 36 of 210
The Ring programming language version 1.9 book - Part 36 of 210
 

Viewers also liked

2008111807581919
20081118075819192008111807581919
2008111807581919psy101618
 
The Building Blocks of Great Video
The Building Blocks of Great VideoThe Building Blocks of Great Video
The Building Blocks of Great VideoPhil Nottingham
 
Lookbook "The ballet of the Tsars"
Lookbook "The ballet of the Tsars"Lookbook "The ballet of the Tsars"
Lookbook "The ballet of the Tsars"Patricia Rosales
 
On needle settings of tuck stitch fully fashioned,22rib diamond design fully-...
On needle settings of tuck stitch fully fashioned,22rib diamond design fully-...On needle settings of tuck stitch fully fashioned,22rib diamond design fully-...
On needle settings of tuck stitch fully fashioned,22rib diamond design fully-...MD. SAJJADUL KARIM BHUIYAN
 
Because i believe i can
Because i believe i canBecause i believe i can
Because i believe i cansaurabh gupta
 
MDD and modeling tools research
MDD and modeling tools researchMDD and modeling tools research
MDD and modeling tools researchRoger Xia
 
Ten years analysing large code bases: a perspective
Ten years analysing large code bases: a perspectiveTen years analysing large code bases: a perspective
Ten years analysing large code bases: a perspectiveRoberto Di Cosmo
 
Basic Object Oriented Concepts
Basic Object Oriented ConceptsBasic Object Oriented Concepts
Basic Object Oriented ConceptsScott Lee
 
Ikp'ko;b0yp
Ikp'ko;b0ypIkp'ko;b0yp
Ikp'ko;b0ypnoylove
 
Covestro y Ercros. tarragona
Covestro y Ercros. tarragonaCovestro y Ercros. tarragona
Covestro y Ercros. tarragonaoblanca
 
Baiguullaga organition 2012
Baiguullaga organition 2012Baiguullaga organition 2012
Baiguullaga organition 2012oyundariubuns
 
Financial management ....the millieum financial management
Financial management ....the millieum financial managementFinancial management ....the millieum financial management
Financial management ....the millieum financial managementraufik tajuddin
 

Viewers also liked (20)

2008111807581919
20081118075819192008111807581919
2008111807581919
 
The Building Blocks of Great Video
The Building Blocks of Great VideoThe Building Blocks of Great Video
The Building Blocks of Great Video
 
Lookbook "The ballet of the Tsars"
Lookbook "The ballet of the Tsars"Lookbook "The ballet of the Tsars"
Lookbook "The ballet of the Tsars"
 
Futsalf
FutsalfFutsalf
Futsalf
 
On needle settings of tuck stitch fully fashioned,22rib diamond design fully-...
On needle settings of tuck stitch fully fashioned,22rib diamond design fully-...On needle settings of tuck stitch fully fashioned,22rib diamond design fully-...
On needle settings of tuck stitch fully fashioned,22rib diamond design fully-...
 
CAMPUSMATE
CAMPUSMATECAMPUSMATE
CAMPUSMATE
 
Because i believe i can
Because i believe i canBecause i believe i can
Because i believe i can
 
Pemerintahan Daendeles di Indonesia
Pemerintahan  Daendeles di IndonesiaPemerintahan  Daendeles di Indonesia
Pemerintahan Daendeles di Indonesia
 
MDD and modeling tools research
MDD and modeling tools researchMDD and modeling tools research
MDD and modeling tools research
 
Ten years analysing large code bases: a perspective
Ten years analysing large code bases: a perspectiveTen years analysing large code bases: a perspective
Ten years analysing large code bases: a perspective
 
OpenStack Havana Release
OpenStack Havana ReleaseOpenStack Havana Release
OpenStack Havana Release
 
Basic Object Oriented Concepts
Basic Object Oriented ConceptsBasic Object Oriented Concepts
Basic Object Oriented Concepts
 
Abb v2
Abb v2Abb v2
Abb v2
 
Propuesta de malla curricular
Propuesta de malla curricularPropuesta de malla curricular
Propuesta de malla curricular
 
Ikp'ko;b0yp
Ikp'ko;b0ypIkp'ko;b0yp
Ikp'ko;b0yp
 
Covestro y Ercros. tarragona
Covestro y Ercros. tarragonaCovestro y Ercros. tarragona
Covestro y Ercros. tarragona
 
Baiguullaga organition 2012
Baiguullaga organition 2012Baiguullaga organition 2012
Baiguullaga organition 2012
 
Poríferos e cnidários 3C- 2015
Poríferos e cnidários 3C- 2015Poríferos e cnidários 3C- 2015
Poríferos e cnidários 3C- 2015
 
Financial management ....the millieum financial management
Financial management ....the millieum financial managementFinancial management ....the millieum financial management
Financial management ....the millieum financial management
 
Freefixer log
Freefixer logFreefixer log
Freefixer log
 

Similar to MySQL Idiosyncrasies That Bite

OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenNETWAYS
 
MySQL Best Practices - OTN
MySQL Best Practices - OTNMySQL Best Practices - OTN
MySQL Best Practices - OTNRonald Bradford
 
Fluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_publicFluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_publicSaewoong Lee
 
Introduction databases and MYSQL
Introduction databases and MYSQLIntroduction databases and MYSQL
Introduction databases and MYSQLNaeem Junejo
 
PHP mysql Introduction database
 PHP mysql  Introduction database PHP mysql  Introduction database
PHP mysql Introduction databaseMudasir Syed
 
Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015mushupl
 
MySQL Best Practices - OTN LAD Tour
MySQL Best Practices - OTN LAD TourMySQL Best Practices - OTN LAD Tour
MySQL Best Practices - OTN LAD TourRonald Bradford
 
Short Intro to PHP and MySQL
Short Intro to PHP and MySQLShort Intro to PHP and MySQL
Short Intro to PHP and MySQLJussi Pohjolainen
 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Mydbops
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)Valeriy Kravchuk
 
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Tesora
 
4. Data Manipulation.ppt
4. Data Manipulation.ppt4. Data Manipulation.ppt
4. Data Manipulation.pptKISHOYIANKISH
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 MinutesSveta Smirnova
 
Bt0075, rdbms and my sql
Bt0075, rdbms and my sqlBt0075, rdbms and my sql
Bt0075, rdbms and my sqlsmumbahelp
 
关系数据库存储树形结构数据的理想实践 20100222
关系数据库存储树形结构数据的理想实践 20100222关系数据库存储树形结构数据的理想实践 20100222
关系数据库存储树形结构数据的理想实践 20100222Cabin WJ
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfzJoshua Thijssen
 

Similar to MySQL Idiosyncrasies That Bite (20)

OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
 
MySQL Best Practices - OTN
MySQL Best Practices - OTNMySQL Best Practices - OTN
MySQL Best Practices - OTN
 
Fluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_publicFluentd 20150918 no_demo_public
Fluentd 20150918 no_demo_public
 
Introduction databases and MYSQL
Introduction databases and MYSQLIntroduction databases and MYSQL
Introduction databases and MYSQL
 
PHP mysql Introduction database
 PHP mysql  Introduction database PHP mysql  Introduction database
PHP mysql Introduction database
 
Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015
 
My sql1
My sql1My sql1
My sql1
 
MySQL Best Practices - OTN LAD Tour
MySQL Best Practices - OTN LAD TourMySQL Best Practices - OTN LAD Tour
MySQL Best Practices - OTN LAD Tour
 
Short Intro to PHP and MySQL
Short Intro to PHP and MySQLShort Intro to PHP and MySQL
Short Intro to PHP and MySQL
 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
 
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
 
4. Data Manipulation.ppt
4. Data Manipulation.ppt4. Data Manipulation.ppt
4. Data Manipulation.ppt
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
 
Bt0075, rdbms and my sql
Bt0075, rdbms and my sqlBt0075, rdbms and my sql
Bt0075, rdbms and my sql
 
Curso de MySQL 5.7
Curso de MySQL 5.7Curso de MySQL 5.7
Curso de MySQL 5.7
 
Instalar MySQL CentOS
Instalar MySQL CentOSInstalar MySQL CentOS
Instalar MySQL CentOS
 
Mysql56 replication
Mysql56 replicationMysql56 replication
Mysql56 replication
 
关系数据库存储树形结构数据的理想实践 20100222
关系数据库存储树形结构数据的理想实践 20100222关系数据库存储树形结构数据的理想实践 20100222
关系数据库存储树形结构数据的理想实践 20100222
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfz
 

More from Ronald Bradford

Successful Scalability Principles - Part 1
Successful Scalability Principles - Part 1Successful Scalability Principles - Part 1
Successful Scalability Principles - Part 1Ronald Bradford
 
MySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsMySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsRonald Bradford
 
The History and Future of the MySQL ecosystem
The History and Future of the MySQL ecosystemThe History and Future of the MySQL ecosystem
The History and Future of the MySQL ecosystemRonald Bradford
 
Lessons Learned Managing Large AWS Environments
Lessons Learned Managing Large AWS EnvironmentsLessons Learned Managing Large AWS Environments
Lessons Learned Managing Large AWS EnvironmentsRonald Bradford
 
Monitoring your technology stack with New Relic
Monitoring your technology stack with New RelicMonitoring your technology stack with New Relic
Monitoring your technology stack with New RelicRonald Bradford
 
MySQL Scalability Mistakes - OTN
MySQL Scalability Mistakes - OTNMySQL Scalability Mistakes - OTN
MySQL Scalability Mistakes - OTNRonald Bradford
 
Successful MySQL Scalability
Successful MySQL ScalabilitySuccessful MySQL Scalability
Successful MySQL ScalabilityRonald Bradford
 
Capturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLCapturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLRonald Bradford
 
10x Performance Improvements
10x Performance Improvements10x Performance Improvements
10x Performance ImprovementsRonald Bradford
 
LIFTOFF - MySQLCamp for the Oracle DBA
LIFTOFF - MySQLCamp for the Oracle DBALIFTOFF - MySQLCamp for the Oracle DBA
LIFTOFF - MySQLCamp for the Oracle DBARonald Bradford
 
IGNITION - MySQLCamp for the Oracle DBA
IGNITION - MySQLCamp for the Oracle DBAIGNITION - MySQLCamp for the Oracle DBA
IGNITION - MySQLCamp for the Oracle DBARonald Bradford
 
10x Performance Improvements - A Case Study
10x Performance Improvements - A Case Study10x Performance Improvements - A Case Study
10x Performance Improvements - A Case StudyRonald Bradford
 
Dolphins Now And Beyond - FOSDEM 2010
Dolphins Now And Beyond - FOSDEM 2010Dolphins Now And Beyond - FOSDEM 2010
Dolphins Now And Beyond - FOSDEM 2010Ronald Bradford
 
Drizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and EcosystemDrizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and EcosystemRonald Bradford
 
MySQL for the Oracle DBA - Object Management
MySQL for the Oracle DBA - Object ManagementMySQL for the Oracle DBA - Object Management
MySQL for the Oracle DBA - Object ManagementRonald Bradford
 
Know Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express EditionKnow Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express EditionRonald Bradford
 
MySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersMySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersRonald Bradford
 
MySQL For Oracle Developers
MySQL For Oracle DevelopersMySQL For Oracle Developers
MySQL For Oracle DevelopersRonald Bradford
 
The Ideal Performance Architecture
The Ideal Performance ArchitectureThe Ideal Performance Architecture
The Ideal Performance ArchitectureRonald Bradford
 

More from Ronald Bradford (20)

Successful Scalability Principles - Part 1
Successful Scalability Principles - Part 1Successful Scalability Principles - Part 1
Successful Scalability Principles - Part 1
 
MySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsMySQL Backup and Recovery Essentials
MySQL Backup and Recovery Essentials
 
The History and Future of the MySQL ecosystem
The History and Future of the MySQL ecosystemThe History and Future of the MySQL ecosystem
The History and Future of the MySQL ecosystem
 
Lessons Learned Managing Large AWS Environments
Lessons Learned Managing Large AWS EnvironmentsLessons Learned Managing Large AWS Environments
Lessons Learned Managing Large AWS Environments
 
Monitoring your technology stack with New Relic
Monitoring your technology stack with New RelicMonitoring your technology stack with New Relic
Monitoring your technology stack with New Relic
 
MySQL Scalability Mistakes - OTN
MySQL Scalability Mistakes - OTNMySQL Scalability Mistakes - OTN
MySQL Scalability Mistakes - OTN
 
Successful MySQL Scalability
Successful MySQL ScalabilitySuccessful MySQL Scalability
Successful MySQL Scalability
 
Capturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQLCapturing, Analyzing and Optimizing MySQL
Capturing, Analyzing and Optimizing MySQL
 
10x Performance Improvements
10x Performance Improvements10x Performance Improvements
10x Performance Improvements
 
LIFTOFF - MySQLCamp for the Oracle DBA
LIFTOFF - MySQLCamp for the Oracle DBALIFTOFF - MySQLCamp for the Oracle DBA
LIFTOFF - MySQLCamp for the Oracle DBA
 
IGNITION - MySQLCamp for the Oracle DBA
IGNITION - MySQLCamp for the Oracle DBAIGNITION - MySQLCamp for the Oracle DBA
IGNITION - MySQLCamp for the Oracle DBA
 
10x Performance Improvements - A Case Study
10x Performance Improvements - A Case Study10x Performance Improvements - A Case Study
10x Performance Improvements - A Case Study
 
Dolphins Now And Beyond - FOSDEM 2010
Dolphins Now And Beyond - FOSDEM 2010Dolphins Now And Beyond - FOSDEM 2010
Dolphins Now And Beyond - FOSDEM 2010
 
Drizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and EcosystemDrizzle - Status, Principles and Ecosystem
Drizzle - Status, Principles and Ecosystem
 
SQL v No SQL
SQL v No SQLSQL v No SQL
SQL v No SQL
 
MySQL for the Oracle DBA - Object Management
MySQL for the Oracle DBA - Object ManagementMySQL for the Oracle DBA - Object Management
MySQL for the Oracle DBA - Object Management
 
Know Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express EditionKnow Your Competitor - Oracle 10g Express Edition
Know Your Competitor - Oracle 10g Express Edition
 
MySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and DevelopersMySQL For Oracle DBA's and Developers
MySQL For Oracle DBA's and Developers
 
MySQL For Oracle Developers
MySQL For Oracle DevelopersMySQL For Oracle Developers
MySQL For Oracle Developers
 
The Ideal Performance Architecture
The Ideal Performance ArchitectureThe Ideal Performance Architecture
The Ideal Performance Architecture
 

Recently uploaded

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 

MySQL Idiosyncrasies That Bite

  • 1. Title MySQL Idiosyncrasies that BITE 2010.06 Ronald Bradford http://ronaldbradford.com2010.06 MySQL Idiosyncrasies That BITE - #odtug #mysql @ronaldbradford
  • 2. Definitions idiosyncrasy [id-ee-uh-sing-kruh-see, -sin-] –noun,plural-sies. A characteristic, habit, mannerism, or the like, that is peculiar to an individual. http;//dictionary.com MySQL Idiosyncrasies That BITE - 2010.06
  • 3. Relational Database Strictly, a relational database is a collection of relations (frequently called tables). Other items are frequently considered part of the database, as they help to organize and structure the data, in addition to forcing the database to conform to a set of requirements. Source: http://en.wikipedia.org/wiki/Relational_database MySQL Idiosyncrasies That BITE - 2010.06
  • 4. Relational Database Structure/Requirements Relations or Tables Base and derived relations (e.g. views or result sets) Attributes (i.e. columns) Domain (i.e. column attributes and constraints) Constraints Stored procedures Indices MySQL Idiosyncrasies That BITE - 2010.06
  • 5. Oracle != MySQL Age Development philosophies Target audience Developer practices Installed versions MySQL Idiosyncrasies That BITE - 2010.06
  • 6. RDBMS Characteristics Data Integrity Transactions ACID Data Security ANSI SQL MySQL Idiosyncrasies That BITE - 2010.06
  • 7. These RDBMS characteristics are NOT enabled by default in MySQL MySQL Idiosyncrasies That BITE - 2010.06
  • 8. 1. Data Integrity MySQL Idiosyncrasies That BITE - 2010.06
  • 9. Data Integrity - Expected CREATE TABLE sample_data ( i TINYINT UNSIGNED NOT NULL, ✔ c CHAR(2) NULL, t TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET latin1; INSERT INTO sample_data(i) VALUES (0), (100), (255); Query OK, 3 rows affected (0.00 sec) SELECT * FROM sample_data; +-----+------+---------------------+ | i | c | t | +-----+------+---------------------+ | 0 | NULL | 2010-06-06 13:28:44 | | 100 | NULL | 2010-06-06 13:28:44 | | 255 | NULL | 2010-06-06 13:28:44 | +-----+------+---------------------+ 3 rows in set (0.00 sec) MySQL Idiosyncrasies That BITE - 2010.06
  • 10. Data Integrity - Unexpected ✘ mysql> INSERT INTO sample_data (i) VALUES (-1), (9000); mysql> SELECT * FROM sample_data; +-----+------+---------------------+ | i | c | t | +-----+------+---------------------+ | 0 | NULL | 2010-06-06 13:28:44 | | 100 | NULL | 2010-06-06 13:28:44 | | 255 | NULL | 2010-06-06 13:28:44 | | 0 | NULL | 2010-06-06 13:32:52 | | 255 | NULL | 2010-06-06 13:32:52 | +-----+------+---------------------+ 5 rows in set (0.01 sec) MySQL Idiosyncrasies That BITE - 2010.06
  • 11. Data Integrity - Warnings mysql> INSERT INTO sample_data (i) VALUES (-1), (9000); Query OK, 2 rows affected, 2 warnings (0.00 sec) mysql> SHOW WARNINGS; +---------+------+--------------------------------------------+ | Level | Code | Message | +---------+------+--------------------------------------------+ | Warning | 1264 | Out of range value for column 'i' at row 1 | | Warning | 1264 | Out of range value for column 'i' at row 2 | +---------+------+--------------------------------------------+ MySQL Idiosyncrasies That BITE - 2010.06
  • 12. Data Integrity - Unexpected (2) mysql> INSERT INTO sample_data (c) -> VALUES ('A'),('BB'),('CCC'); ✘ mysql> SELECT * FROM sample_data WHERE c IS NOT NULL; +---+------+---------------------+ | i | c | t | +---+------+---------------------+ | 0 | A | 2010-06-06 13:34:59 | | 0 | BB | 2010-06-06 13:34:59 | | 0 | CC | 2010-06-06 13:34:59 | +---+------+---------------------+ 3 rows in set (0.09 sec) MySQL Idiosyncrasies That BITE - 2010.06
  • 13. Data Integrity - Warnings (2) mysql> INSERT INTO sample_data (c) VALUES ('A'),('BB'),('CCC'); Query OK, 3 rows affected, 2 warnings (0.00 sec) Records: 3 Duplicates: 0 Warnings: 1 mysql> SHOW WARNINGS; +---------+------+----------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------+ Only listed | Warning | 1364 | Field 'i' doesn't have a default value | | Warning | 1265 | Data truncated for column 'c' at row 3 | for 1 row +---------+------+----------------------------------------+ 2 rows in set (0.01 sec) MySQL Idiosyncrasies That BITE - 2010.06
  • 14. SHOW WARNINGS http://dev.mysql.com/doc/refman/5.1/en/show-warnings.html MySQL Idiosyncrasies That BITE - 2010.06
  • 15. Using SQL_MODE for Data Integrity SQL_MODE = STRICT_ALL_TABLES; http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html MySQL Idiosyncrasies That BITE - 2010.06
  • 16. Data Integrity - Expected mysql> SET SESSION SQL_MODE=STRICT_ALL_TABLES; mysql> TRUNCATE TABLE sample_data; ✔ mysql> INSERT INTO sample_data(i) VALUES (0), (100), (255); mysql> INSERT INTO sample_data (i) VALUES (-1), (9000); ERROR 1264 (22003): Out of range value for column 'i' at row 1 mysql> SELECT * FROM sample_data; +-----+------+---------------------+ | i | c | t | +-----+------+---------------------+ | 0 | NULL | 2010-06-06 14:39:48 | | 100 | NULL | 2010-06-06 14:39:48 | | 255 | NULL | 2010-06-06 14:39:48 | +-----+------+---------------------+ 3 rows in set (0.00 sec) MySQL Idiosyncrasies That BITE - 2010.06
  • 17. Data Integrity with Dates - Expected mysql> SET SESSION SQL_MODE=''; mysql> INSERT INTO sample_date (d) VALUES ('2010-02-31'); Query OK, 1 row affected, 1 warning (0.00 sec) mysql> SHOW WARNINGS; +---------+------+----------------------------------------+ | Level | Code | Message | ✘ +---------+------+----------------------------------------+ | Warning | 1265 | Data truncated for column 'd' at row 1 | +---------+------+----------------------------------------+ mysql> SELECT * FROM sample_date; +------------+ | d | +------------+ | 0000-00-00 | ✔ +------------+ mysql> SET SESSION SQL_MODE=STRICT_ALL_TABLES; mysql> INSERT INTO sample_date (d) VALUES ('2010-02-31'); ERROR 1292 (22007): Incorrect date value: '2010-02-31' for column 'd' at row 1 MySQL Idiosyncrasies That BITE - 2010.06
  • 18. Data Integrity with Dates - Unexpected mysql> mysql> TRUNCATE TABLE sample_date; INSERT INTO sample_date (d) VALUES ('2010-00-00'); ✘ mysql> INSERT INTO sample_date (d) VALUES ('2010-00-05'); mysql> INSERT INTO sample_date (d) VALUES ('0000-00-00'); mysql> SELECT * FROM sample_date; +------------+ | d | +------------+ | 2010-00-00 | | 2010-00-05 | | 0000-00-00 | +------------+ 3 rows in set (0.00 sec) MySQL Idiosyncrasies That BITE - 2010.06
  • 19. Using SQL_MODE for Date Integrity SQL_MODE = STRICT_ALL_TABLES, NO_ZERO_DATE, NO_ZERO_IN_DATE; http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html MySQL Idiosyncrasies That BITE - 2010.06
  • 20. Data Integrity with Dates - Expected mysql> SET SESSION SQL_MODE='STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE'; ✔ mysql> TRUNCATE TABLE sample_date; mysql> INSERT INTO sample_date (d) VALUES ('2010-00-00'); ERROR 1292 (22007): Incorrect date value: '2010-00-00' for column 'd' at row 1 mysql> INSERT INTO sample_date (d) VALUES ('2010-00-05'); ERROR 1292 (22007): Incorrect date value: '2010-00-05' for column 'd' at row 1 mysql> INSERT INTO sample_date (d) VALUES ('0000-00-00'); ERROR 1292 (22007): Incorrect date value: '0000-00-00' for column 'd' at row 1 mysql> SELECT * FROM sample_date; Empty set (0.00 sec) MySQL Idiosyncrasies That BITE - 2010.06
  • 22. Transactions Example - Tables DROP TABLE IF EXISTS parent; CREATE TABLE parent ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, val VARCHAR(10) NOT NULL, PRIMARY KEY (id), UNIQUE KEY (val) ) ENGINE=InnoDB DEFAULT CHARSET latin1; DROP TABLE IF EXISTS child; CREATE TABLE child ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, parent_id INT UNSIGNED NOT NULL, created TIMESTAMP NOT NULL, PRIMARY KEY (id), INDEX (parent_id) ) ENGINE=InnoDB DEFAULT CHARSET latin1; MySQL Idiosyncrasies That BITE - 2010.06
  • 23. Transactions Example - SQL START TRANSACTION; INSERT INTO parent(val) VALUES("a"); INSERT INTO child(parent_id,created) VALUES(LAST_INSERT_ID(),NOW()); INSERT INTO parent(val) VALUES("a"); ROLLBACK; SELECT * FROM parent; SELECT * FROM child; MySQL Idiosyncrasies That BITE - 2010.06
  • 24. Transactions Example - Expected ... mysql> INSERT INTO parent (val) VALUES("a"); ✔ ERROR 1062 (23000): Duplicate entry 'a' for key 'val' mysql> ROLLBACK; mysql> SELECT * FROM parent; Empty set (0.00 sec) mysql> SELECT * FROM child; Empty set (0.00 sec) MySQL Idiosyncrasies That BITE - 2010.06
  • 25. Transactions Example - Using MyISAM ALTER TABLE child ENGINE=MyISAM; ALTER TABLE parent ENGINE=MyISAM; TRUNCATE TABLE child; TRUNCATE TABLE parent; START TRANSACTION; INSERT INTO parent(val) VALUES("a"); INSERT INTO child(parent_id,created) VALUES(LAST_INSERT_ID(),NOW()); INSERT INTO parent (val) VALUES("a"); ROLLBACK; SELECT * FROM parent; SELECT * FROM child; MySQL Idiosyncrasies That BITE - 2010.06
  • 26. Transactions Example - Unexpected mysql> INSERT INTO parent (val) VALUES("a"); ERROR 1062 (23000): Duplicate entry 'a' for key 'val' ✘ mysql> ROLLBACK; mysql> SELECT * FROM parent; +----+-----+ | id | val | +----+-----+ | 1 | a | +----+-----+ 1 row in set (0.00 sec) mysql> SELECT * FROM child; +----+-----------+---------------------+ | id | parent_id | created | +----+-----------+---------------------+ | 1 | 1 | 2010-06-03 13:53:38 | +----+-----------+---------------------+ 1 row in set (0.00 sec) MySQL Idiosyncrasies That BITE - 2010.06
  • 27. Transactions Example - Unexpected (2) mysql> ROLLBACK; Query OK, 0 rows affected, 1 warning (0.00 sec) ✘ mysql> SHOW WARNINGS; +---------+-------+------------------------------------- | Level | Code | Message | +---------+------+-------------------------------------- | Warning | 1196 | Some non-transactional changed tables couldn't be rolled back | +---------+------+-------------------------------------- MySQL Idiosyncrasies That BITE - 2010.06
  • 28. Transactions Solution mysql> SET GLOBAL storage_engine=InnoDB; # my.cnf [mysqld] default-storage-engine=InnoDB # NOTE: Requires server restart http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_default-storage-engine MySQL Idiosyncrasies That BITE - 2010.06
  • 29. Why use Non Transactional Tables? No transaction overhead Much faster Less disk writes Lower disk space requirements Less memory requirements http://dev.mysql.com/doc/refman/5.1/en/storage-engine-compare-transactions.html MySQL Idiosyncrasies That BITE - 2010.06
  • 30. 3. Variable Scope MySQL Idiosyncrasies That BITE - 2010.06
  • 31. Variable Scope Example mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL); mysql> SHOW CREATE TABLE test1G CREATE TABLE `test1` ( `id` int(10) unsigned NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 MySQL Idiosyncrasies That BITE - 2010.06
  • 32. Variable Scope Example (2) mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | Changing in +----------------+--------+ MySQL 5.5 | storage_engine | MyISAM | +----------------+--------+ mysql> SET GLOBAL storage_engine='InnoDB'; mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | +----------------+--------+ | storage_engine | InnoDB | +----------------+--------+ MySQL Idiosyncrasies That BITE - 2010.06
  • 33. Variable Scope Example (3) mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine'; +----------------+--------+ ✘ | Variable_name | Value | +----------------+--------+ | storage_engine | InnoDB | +----------------+--------+ mysql> DROP TABLE test1; mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL); mysql> SHOW CREATE TABLE test1G CREATE TABLE `test1` ( `id` int(10) unsigned NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 MySQL Idiosyncrasies That BITE - 2010.06
  • 34. Variable Scope Example (4) mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | +----------------+--------+ | storage_engine | InnoDB | +----------------+--------+ mysql> SHOW SESSION VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | +----------------+--------+ | storage_engine | MyISAM | +----------------+--------+ MySQL Idiosyncrasies That BITE - 2010.06
  • 35. Variable Scope Syntax SHOW [GLOBAL | SESSION] VARIABLES; SET [GLOBAL | SESSION] variable = value; Default is GLOBAL since 5.0.2 http://dev.mysql.com/doc/refman/5.1/en/set-option.html http://dev.mysql.com/doc/refman/5.1/en/user-variables.html MySQL Idiosyncrasies That BITE - 2010.06
  • 36. 4. Storage Engines MySQL Idiosyncrasies That BITE - 2010.06
  • 37. Storage Engines Example - Creation CREATE TABLE test1 ( id INT UNSIGNED NOT NULL ✘ ) ENGINE=InnoDB DEFAULT CHARSET latin1; SHOW CREATE TABLE test1G *************************** 1. row ************* Table: test1 Create Table: CREATE TABLE `test1` ( `id` int(10) unsigned NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 MySQL Idiosyncrasies That BITE - 2010.06
  • 38. Storage Engines Example - Unexpected CREATE TABLE test1 ( id INT UNSIGNED NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET latin1; Query OK, 0 rows affected, 2 warnings (0.13 sec) SHOW WARNINGS; +---------+------+-----------------------------------------------+ | Level | Code | Message | +---------+------+-----------------------------------------------+ | Warning | 1286 | Unknown table engine 'InnoDB' | | Warning | 1266 | Using storage engine MyISAM for table 'test1' | +---------+------+-----------------------------------------------+ 2 rows in set (0.00 sec) MySQL Idiosyncrasies That BITE - 2010.06
  • 39. Storage Engines Example - Cause mysql> SHOW ENGINES; +------------+---------+-------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +------------+---------+-------------------------+--------------+------+------------+ | InnoDB | NO | Supports transaction... | NULL | NULL | NULL | | MEMORY | YES | Hash based, stored i... | NO | NO | NO | | MyISAM | DEFAULT | Default engine as ... | NO | NO | NO | MySQL Idiosyncrasies That BITE - 2010.06
  • 40. Storage Engines Example - Unexpected (2) mysql> CREATE TABLE test1 id INT UNSIGNED NOT NULL ) ENGINE=InnDB DEFAULT CHARSET latin1; ✘ Query OK, 0 rows affected, 2 warnings (0.11 sec) mysql> SHOW WARNINGS; +---------+------+-----------------------------------------------+ | Level | Code | Message | +---------+------+-----------------------------------------------+ | Warning | 1286 | Unknown table engine 'InnDB' | | Warning | 1266 | Using storage engine MyISAM for table 'test1' | +---------+------+-----------------------------------------------+ MySQL Idiosyncrasies That BITE - 2010.06
  • 41. Using SQL_MODE for Storage Engines SQL_MODE = STRICT_ALL_TABLES, NO_ZERO_DATE, NO_ZERO_IN_DATE, NO_ENGINE_SUBSTITUTION; http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html MySQL Idiosyncrasies That BITE - 2010.06
  • 42. Storage Engines Example - Solution SET SESSION SQL_MODE=NO_ENGINE_SUBSTITUTION; ✔ DROP TABLE IF EXISTS test3; CREATE TABLE test3 ( id INT UNSIGNED NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET latin1; ERROR 1286 (42000): Unknown table engine 'InnoDB' MySQL Idiosyncrasies That BITE - 2010.06
  • 43. 5. ACID MySQL Idiosyncrasies That BITE - 2010.06
  • 44. Atomicity - All or nothing MySQL Idiosyncrasies That BITE - 2010.06
  • 45. Atomicity - Table DROP TABLE IF EXISTS test1; CREATE TABLE test1( id INT UNSIGNED NOT NULL AUTO_INCREMENT, val CHAR(1) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET latin1; MySQL Idiosyncrasies That BITE - 2010.06
  • 46. Atomicity - Data INSERT INTO test1(val) VALUES ('a'),('b'),('c'),('d'),('e'), ('f'),('g'); mysql> SELECT * FROM test1; +----+-----+ | id | val | +----+-----+ | 1 | a | | 2 | b | | 3 | c | | 4 | d | | 5 | e | | 6 | f | | 7 | g | +----+-----+ 7 rows in set (0.00 sec) mysql> UPDATE test1 SET id = 10 - id; MySQL Idiosyncrasies That BITE - 2010.06
  • 47. Atomicity - Unexpected mysql> UPDATE test1 SET id = 10 - id; ERROR 1062 (23000): Duplicate entry '7' for key ✘ 'PRIMARY' mysql> SELECT * FROM test1; +----+-----+ | id | val | +----+-----+ | 9 | a | | 8 | b | | 3 | c | | 4 | d | | 5 | e | | 6 | f | | 7 | g | +----+-----+ MySQL Idiosyncrasies That BITE - 2010.06
  • 48. Atomicity - Unexpected (2) mysql> ROLLBACK; Query OK, 0 rows affected (0.00 sec) ✘ mysql> SELECT * FROM test1; +----+-----+ | id | val | +----+-----+ | 9 | a | | 8 | b | ... MySQL Idiosyncrasies That BITE - 2010.06
  • 49. Atomicity - Transactional Table ALTER TABLE test1 ENGINE=InnoDB; DELETE FROM test1 WHERE id > 5; SELECT * FROM test1; ✘ +----+-----+ | id | val | +----+-----+ | 3 | c | | 4 | d | | 5 | e | +----+-----+ ROLLBACK; SELECT * FROM test1; +----+-----+ | id | val | +----+-----+ | 3 | c | | 4 | d | | 5 | e | +----+-----+ MySQL Idiosyncrasies That BITE - 2010.06
  • 50. Atomicity - The culprit mysql> SHOW GLOBAL VARIABLES LIKE 'autocommit'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | autocommit | ON | +---------------+-------+ MySQL Idiosyncrasies That BITE - 2010.06
  • 51. Atomicity - Recommendations Always wrap SQL in transactions START TRANSACTION | BEGIN [WORK] COMMIT MySQL Idiosyncrasies That BITE - 2010.06
  • 52. Isolation - Transactions do not affect other transactions MySQL Idiosyncrasies That BITE - 2010.06
  • 53. Transaction Isolation - Levels READ-UNCOMMITTED READ-COMMITTED REPEATABLE-READ SERIALIZABLE http://dev.mysql.com/doc/refman/5.1/en/set-transaction.html http://ronaldbradford.com/blog/understanding-mysql-innodb-transaction-isolation-2009-09-24/ MySQL Idiosyncrasies That BITE - 2010.06
  • 54. Transaction Isolation - Default The default is REPEATABLE-READ SET GLOBAL tx_isolation = 'READ-COMMITTED'; This is a mistake http://ronaldbradford.com/blog/dont-assume-common-terminology-2010-03-03/ MySQL Idiosyncrasies That BITE - 2010.06
  • 55. Oracle READ COMMITTED != MySQL READ-COMMITTED MySQL Idiosyncrasies That BITE - 2010.06
  • 56. Transaction Isolation - Binary Logging Errors SET GLOBAL tx_isolation='READ-COMMITTED'; Query OK, 0 rows affected (0.00 sec) ✘ mysql> insert into test1 values (1,'x'); ERROR 1598 (HY000): Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT' MySQL Idiosyncrasies That BITE - 2010.06
  • 57. Durability - No committed transactions are lost MySQL Idiosyncrasies That BITE - 2010.06
  • 58. Data Safety MyISAM writes/flushes data every statement Does not flush indexes (*) InnoDB can relax durability Every transaction / per second innodb_flush_log_at_trx_commit sync_binlog innodb_support_xa MySQL Idiosyncrasies That BITE - 2010.06
  • 59. Auto Recovery InnoDB has it MyISAM does not - (*) Indexes MYISAM-RECOVER=FORCE,BACKUP REPAIR TABLE myisamchk MySQL Idiosyncrasies That BITE - 2010.06
  • 60. Recovery Time InnoDB is consistent Redo Log file size Slow performance in Undo MyISAM grows with data volume MySQL Idiosyncrasies That BITE - 2010.06
  • 61. InnoDB Auto Recovery Example InnoDB: Log scan progressed past the checkpoint lsn 0 188755039 100624 16:37:44 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. ✔ InnoDB: Reading tablespace information from the .ibd files... InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer... InnoDB: Doing recovery: scanned up to log sequence number 0 193997824 InnoDB: Doing recovery: scanned up to log sequence number 0 195151897 InnoDB: 1 transaction(s) which must be rolled back or cleaned up InnoDB: in total 105565 row operations to undo InnoDB: Trx id counter is 0 18688 100624 16:37:45 InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percents: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... 99 InnoDB: Apply batch completed InnoDB: Last MySQL binlog file position 0 12051, file name ./binary-log. 000003 InnoDB: Starting in background the rollback of uncommitted transactions ... MySQL Idiosyncrasies That BITE - 2010.06
  • 62. MyISAM Repair needed Example 100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/ descriptions' is marked as crashed and should be repaired 100126 22:44:35 [Warning] Checking table: './XXX/descriptions' ✘ 100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/taggings' is marked as crashed and should be repaired 100126 22:44:35 [Warning] Checking table: './XXX/taggings' 100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/vehicle' is marked as crashed and should be repaired MySQL Idiosyncrasies That BITE - 2010.06
  • 63. 6. Data Security MySQL Idiosyncrasies That BITE - 2010.06
  • 64. User Privileges - Practices Best Practice CREATE USER goodguy@localhost IDENTIFIED BY 'sakila'; GRANT CREATE,SELECT,INSERT,UPDATE,DELETE ON odtug.* TO ✔ goodguy@localhost; Normal Practice CREATE USER superman@'%'; GRANT ALL ON *.* TO superman@'%'; ✘ http://dev.mysql.com/doc/refman/5.1/en/create-user.html http://dev.mysql.com/doc/refman/5.1/en/grant.html MySQL Idiosyncrasies That BITE - 2010.06
  • 65. User Privileges - Normal Bad Practice GRANT ALL ON *.* TO user@’%’ *.* gives you access to all tables in all schemas @’%’ give you access from any external location ALL gives you ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE USER, CREATE VIEW, DELETE, DROP, EVENT, EXECUTE, FILE, INDEX, INSERT, LOCK TABLES, PROCESS, REFERENCES, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE, SELECT, SHOW DATABASES, SHOW VIEW, SHUTDOWN, SUPER, TRIGGER, UPDATE, USAGE MySQL Idiosyncrasies That BITE - 2010.06
  • 66. User Privileges - Why SUPER is bad SUPER Bypasses read_only Bypasses init_connect Can Disable binary logging Change configuration dynamically No reserved connection MySQL Idiosyncrasies That BITE - 2010.06
  • 67. SUPER and Read Only $ mysql -ugoodguy -psakila odtug mysql> insert into test1(id) values(1); ✔ ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement $ mysql -usuperman odtug mysql> insert into test1(id) values(1); Query OK, 1 row affected (0.01 sec) ✘ MySQL Idiosyncrasies That BITE - 2010.06
  • 68. SUPER and Init Connect #my.cnf [client] init_connect=SET NAMES utf8 This specifies to use UTF8 for communication with client and data MySQL Idiosyncrasies That BITE - 2010.06
  • 69. SUPER and Init Connect (2) ✔ $ mysql -usuperman odtug $ mysql -ugoodguy -psakila odtug ✘ mysql> SHOW SESSION VARIABLES LIKE mysql> SHOW SESSION VARIABLES LIKE 'ch%'; 'character%'; +--------------------------+----------+ +--------------------------+----------+ | Variable_name | Value | Variable_name| | Value | +--------------------------+----------+ +--------------------------+----------+ | character_set_client | character_set_client | utf8 | | latin1 | | character_set_connection | utf8 | | character_set_connection | latin1 | | character_set_database character_set_database | | latin1 | | latin1 | | character_set_filesystem | binary | | character_set_filesystem | binary | | character_set_results | character_set_results | utf8 | | latin1 | | character_set_server | character_set_server | latin1 | | latin1 | | character_set_system | character_set_system | utf8 | | utf8 | +--------------------------+----------+ +--------------------------+----------+ MySQL Idiosyncrasies That BITE - 2010.06
  • 70. SUPER and Binary Log mysql> SHOW MASTER STATUS; +-------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +-------------------+----------+--------------+------------------+ | binary-log.000001 | 354 | | | +-------------------+----------+--------------+------------------+ mysql> DROP TABLE time_zone_leap_second; mysql> SET SQL_LOG_BIN=0; mysql> DROP TABLE time_zone_name; mysql> SET SQL_LOG_BIN=1; mysql> DROP TABLE time_zone_transition; mysql> SHOW MASTER STATUS; +-------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +-------------------+----------+--------------+------------------+ | binary-log.000001 | 674 | | | +-------------------+----------+--------------+------------------+ MySQL Idiosyncrasies That BITE - 2010.06
  • 71. SUPER and Binary Log (2) $ mysqlbinlog binary-log.000001 --start-position=354 --stop-position=674 # at 354 #100604 18:00:08 server id 1 end_log_pos 450 Query thread_id=1 exec_time=0 error_code=0 use mysql/*!*/; SET TIMESTAMP=1275688808/*!*/; ✘ DROP TABLE time_zone_leap_second /*!*/; # at 579 #100604 18:04:31 server id 1 end_log_pos 674 Query thread_id=2 exec_time=0 error_code=0 use mysql/*!*/; SET TIMESTAMP=1275689071/*!*/; DROP TABLE time_zone_transition /*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; MySQL Idiosyncrasies That BITE - 2010.06
  • 72. SUPER and reserved connection $ mysql -uroot ✔ mysql> show global variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 3 | +-----------------+-------+ 1 row in set (0.07 sec) mysql> show global status like 'threads_connected'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | Threads_connected | 4 | +-------------------+-------+ MySQL Idiosyncrasies That BITE - 2010.06
  • 73. SUPER and reserved connection - Unexpected $ mysql -uroot ERROR 1040 (HY000): Too many connections ✘ mysql> SHOW PROCESSLIST; +----+------+-----------+-------+---------+------+------------+--------------- | Id | User | Host | db | Command | Time | State | Info +----+------+-----------+-------+---------+------+------------+--------------- | 13 | root | localhost | odtug | Query | 144 | User sleep | UPDATE test1 ... | 14 | root | localhost | odtug | Query | 116 | Locked | select * from test1 | 15 | root | localhost | odtug | Query | 89 | Locked | select * from test1 MySQL Idiosyncrasies That BITE - 2010.06
  • 74. 7. ANSI SQL MySQL Idiosyncrasies That BITE - 2010.06
  • 75. Group By Example SELECT country, COUNT(*) AS color_count FROM flags GROUP BY country; ✔ +-----------+-------------+ | country | color_count | +-----------+-------------+ | Australia | 3 | | Canada | 2 | | Japan | 2 | | Sweden | 2 | | USA | 3 | +-----------+-------------+ SELECT country, COUNT(*) ✘ FROM flags; +-----------+----------+ | country | COUNT(*) | +-----------+----------+ | Australia | 12 | +-----------+----------+ MySQL Idiosyncrasies That BITE - 2010.06
  • 76. Group By Example (2) SET SESSION sql_mode=ONLY_FULL_GROUP_BY; ✔ SELECT country, COUNT(*) FROM flags; ERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause http://ExpertPHPandMySQL.com Chapter 1 - Pg 31 MySQL Idiosyncrasies That BITE - 2010.06
  • 77. Using SQL_MODE for ANSI SQL SQL_MODE = STRICT_ALL_TABLES, NO_ZERO_DATE, NO_ZERO_IN_DATE, NO_ENGINE_SUBSTITUTION, ONLY_FULL_GROUP_BY; MySQL Idiosyncrasies That BITE - 2010.06
  • 78. 8. Case Sensitivity MySQL Idiosyncrasies That BITE - 2010.06
  • 79. Case Sensitivity String Comparison SELECT 'USA' = UPPER('usa'); +----------------------+ | 'USA' = UPPER('usa') | +----------------------+ | 1 | +----------------------+ SELECT 'USA' = 'USA', 'USA' = 'Usa', 'USA' = 'usa', 'USA' = 'usa' COLLATE latin1_general_cs AS different; +---------------+---------------+---------------+-----------+ | 'USA' = 'USA' | 'USA' = 'Usa' | 'USA' = 'usa' | different | +---------------+---------------+---------------+-----------+ | 1 | 1 | 1 | 0 | +---------------+---------------+---------------+-----------+ SELECT name, address, email FROM customer ✘ WHERE name = UPPER('bradford') MySQL Idiosyncrasies That BITE - 2010.06
  • 80. Case Sensitivity Tables # Server 1 mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL); mysql> INSERT INTO test1 VALUES(1); mysql> INSERT INTO TEST1 VALUES(2); # Server 2 mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL); mysql> INSERT INTO test1 VALUES(1); mysql> INSERT INTO TEST1 VALUES(2); ERROR 1146 (42S02): Table 'test.TEST1' doesn't exist MySQL Idiosyncrasies That BITE - 2010.06
  • 81. Case Sensitivity Tables (2) # Server 1 - Mac OS X / Windows Default mysql> SHOW GLOBAL VARIABLES LIKE 'lower%'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_file_system | ON | | lower_case_table_names | 2 | +------------------------+-------+ # Server 2 - Linux Default mysql> SHOW GLOBAL VARIABLES LIKE 'lower%'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | lower_case_file_system | OFF | | lower_case_table_names | 0 | +------------------------+-------+ MySQL Idiosyncrasies That BITE - 2010.06
  • 82. Other Gotchas MySQL Idiosyncrasies That BITE - 2010.06
  • 83. Other features the BITE Character Sets Data/Client/Application/Web Sub Queries Rewrite as JOIN when possible Views No always efficient Cascading Configuration Files SQL_MODE's not to use MySQL Idiosyncrasies That BITE - 2010.06
  • 85. DON'T ASSUME MySQL Idiosyncrasies That BITE - 2010.06
  • 86. Conclusion - The story so far MySQL Idiosyncrasies that BITE Definitions, Relational Database [Structure/Requirements], Oracle != MySQL, RDBMS Characteristics, Data Integrity [Expected | Unexpected | Warnings | Unexpected (2) | Warnings (2) ], Using SQL_MODE for Data Integrity, Data Integrity [ Expected ], Data Integrity with Dates [Expected | Unexpected ], Using SQL_MODE for Date Integrity, Data Integrity with Dates [Expected ], Transactions Example [ Tables | SQL | Expected | Using MyISAM | Unexpected [ (2)], Transactions Solution, Why use Non Transactional Tables? Variable Scope Example [ | (2)| (3)| [4])| Syntax Storage Engines Example [Creation | Unexpected | Cause | Unexpected (2) ] Using SQL_MODE for Storage Engines, Storage Engines Example [Solution] Atomicity [ Table | Data | Unexpected | Unexpected (2) | Transactional Table | The culprit | Recommendations ] Transaction Isolation [ Levels | Default | Binary Logging ] Durablilty [ Auto Recovery] User Privileges [Practices | Normal Bad Practice | Why SUPER is bad ] SUPER and [ Read Only | Init Connect [(2)] | Binary Log [2] | Reserved Connection [2] ] Group by Example [2], Using SQL_MODE for ANSI SQL Case Sensitivity [ String Comparison | Tables [2] ] More Gotchas, Character Sets, Sub Queries, Views Conclusion [ DON'T ASSUME | The Story so far | SQL_MODE ] RonaldBradford.com MySQL Idiosyncrasies That BITE - 2010.06
  • 87. Conclusion - SQL_MODE SQL_MODE = ✔ ALLOW_INVALID_DATES, ANSI_QUOTES, ERROR_FOR_DIVISION_ZERO, HIGH_NOT_PRECEDENCE,IGNORE_SPACE,NO_AUTO_CREATE_USER, NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES, NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION, NO_FIELD_OPTIONS,NO_KEY_OPTIONS,NO_TABLE_OPTIONS, NO_UNSIGNED_SUBTRACTION,NO_ZERO_DATE, NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY (5.1.11), PAD_CHAR_TO_FULL_LENGTH (5.1.20), PIPES_AS_CONCAT, REAL_AS_FLOAT,STRICT_ALL_TABLES, STRICT_TRANS_TABLES ✘ ANSI, DB2, MAXDB, MSSQL, MYSQL323, MYSQL40, ORACLE, POSTGRESQL,TRADITIONAL http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html ? MySQL Idiosyncrasies That BITE - 2010.06
  • 88. RonaldBradford.com MySQL4OracleDBA.com MySQL Idiosyncrasies That BITE - 2010.06