Mysql
Upcoming SlideShare
Loading in...5
×
 

Mysql

on

  • 725 views

 

Statistics

Views

Total Views
725
Views on SlideShare
710
Embed Views
15

Actions

Likes
0
Downloads
14
Comments
0

2 Embeds 15

http://chr.ishenry.com 14
http://174.143.169.75 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Mysql Mysql Presentation Transcript

    • MySQL Essentials 2012 Chris Henry @chrishnrySunday, January 20, 13
    • hello.Sunday, January 20, 13
    • MySQL @ Behance Powers Be.net 17 Dell R710s 120GB XFS Filesystem Percona 5.5Sunday, January 20, 13
    • What Version of MySQL? - Does it actually matter? Fuck yes. mysql> SELECT VERSION() Welcome to the MySQL monitor. Your MySQL connection id is 54248515 Server version: 5.5.24-55-log Percona Server (GPL), Release rel26.0, Revision 256Sunday, January 20, 13
    • Percona • Why? http://www.percona.com/ • Percona Toolkit http://www.percona.com/software/percona- toolkitSunday, January 20, 13
    • MySQL Engines • Pluggable architecture. • INNODB vs MyISAM • Transactions • Locking • Fulltext • Should be InnoDB for most things http://dev.mysql.com/doc/refman/5.5/en/ storage-engines.htmlSunday, January 20, 13
    • Configuration • table_open_cache • innodb_buffer_pool • max_connections • key_buffer_sizeSunday, January 20, 13
    • Slow Log my.cnf slow-query-log-file = /var/lib/mysqllogs/slow-log long-query-time = 2Sunday, January 20, 13
    • Tuning - Easy Wins • skip-name-resolve • Linux SwappinessSunday, January 20, 13
    • Slow Log Output # Query_time: 0.015029 Lock_time: 0.000044 Rows_sent: 481 Rows_examined: 5080 Rows_affected: 0 Rows_read: 481 # Bytes_sent: 4888 Tmp_tables: 1 Tmp_disk_tables: 0 Tmp_table_sizes: 126992 # Filesort: Yes Filesort_on_disk: No Merge_passes: 0 # InnoDB_IO_r_ops: 0 InnoDB_IO_r_bytes: 0 InnoDB_IO_r_wait: 0.000000 # InnoDB_rec_lock_wait: 0.000000 InnoDB_queue_wait: 0.000000 SELECT DISTINCT proj.id FROM projects proj INNER JOIN project_summary ps ON proj.id=ps.proj_id WHERE proj.published = 1 AND proj.privacy2 = 1 ORDER BY ps.apps DESC LIMIT 0, 481;Sunday, January 20, 13
    • EXPLAIN Output *************************** 1. row *************************** id: 1 select_type: SIMPLE table: proj type: ref possible_keys: PRIMARY,published,privacy2, key: privacy2 key_len: 2 ref: const,const rows: 1 filtered: 100.00 Extra: Using index; Using temporary; Using filesort *************************** 2. row *************************** id: 1 select_type: SIMPLE table: ps type: ref possible_keys: proj_id key: proj_id key_len: 4 ref: be_net2.proj.id rows: 1 filtered: 100.00 Extra: Distinct 2 rows in set, 1 warning (0.00 sec)Sunday, January 20, 13
    • Table Design • Data Types • Relations • Normal FormSunday, January 20, 13
    • Data Types • Right tool for the job • Numeric • String • Temporal • SpatialSunday, January 20, 13
    • Integer Data Types • How big? • Signed or unsigned? • What the hell does that number in parens mean? • Integer types are great for storing things like type attributes.Sunday, January 20, 13
    • Integer Table CREATE TABLE IF NOT EXISTS `integers` ( `tiny` tinyint(4) NOT NULL, `tiny_zerofill` tinyint(10) unsigned zerofill NOT NULL, `small` smallint(6) NOT NULL, `medium` mediumint(9) NOT NULL, `int` int(11) NOT NULL, `int_unsigned` int(10) unsigned NOT NULL, `big` bigint(20) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;Sunday, January 20, 13
    • Decimals • Fixed Point • DECIMAL (5,2)Sunday, January 20, 13
    • Text Datatypes • CHAR (0 to 255) • VARCHAR (0 to 65,535) + lengthSunday, January 20, 13
    • Bigger Text Datatypes • TINYTEXT • TEXT • MEDIUMTEXT • LONGTEXT http://dev.mysql.com/doc/refman/5.5/en/string-type-overview.htmlSunday, January 20, 13
    • Character Sets + Collation • A Character Set is a set of symbols and encodings. • Collation is the set of rules for comparing characters. • utf8 / utf8_unicode_ci is best bet for most Western languages.Sunday, January 20, 13
    • Temporal • DATE • TIME • DATETIME • TIMESTAMP http://dev.mysql.com/doc/refman/5.5/en/date-and-time-types.htmlSunday, January 20, 13
    • Table Design • Primary Key • Compound Keys • Indexes http://dev.mysql.com/doc/refman/5.5/en/date-and-time-types.htmlSunday, January 20, 13
    • Querying • Sakila Database • DVD Rental Store http://dev.mysql.com/doc/sakila/en/index.htmlSunday, January 20, 13
    • That’s it! Thank you all for coming! Feedback is welcome!Sunday, January 20, 13