Post on 30-Jan-2016
transcript
MySQL The Commercial OpenSource Database
David AxmarkCo-Founder, VP of Community
Relations & Open Sourcerer
MySQL AB Creators of MySQLBrussels 2003 02-08
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Topics
● MySQL Popularity● MySQL History, how we work as a
company and how we make money● Technical features & Storage engines● MySQL version 4.0 and beyond● Questions
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
MySQL is Different
● The MySQL project was started to make money (but not only for this!)
● MySQL server has been developed by a company (with paid developers) not by volunteers. But we could not have done it without lots of help with bug reports and feedback...
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
How many installations
● Difficult to judge because of free download and distribution
● MySQL is included in all
– major Linux distributions (RedHat, Suse, Mandrake mm)
– MacOS X – Solaris & Sun's Linux
● Over 29000 server downloads per day through mysql.com
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
MySQL Web Numbers
● Links according to Google.com– MySQL.com 38500– Oracle.com 16300– Postgresql.org 7550
● Mentions according to Google.com– MySQL 7.29M– Oracle 7.53M– Postgresql 2.33M
● Numbers from 2003-02-07
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Third Party commercial interest
● Overture.com lets you pay to appear at the top of search listings for a word (number/max $). Here are some numbers for some common database words– MySQL 22 $0.97 $0.57 $0.56– Oracle 49 $6.80 $1.50 $1.10– DB2 13 $5.00 $3.50 $1.03– Sybase 15 $0.19 $0.17 $0.15– Postgres 3 $0.75 $0.05 $0.05
● Firebird gives a lot of hits for Pontiac Firebirds so I have not included that
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Some MySQL Books
●There exists LOTS of MySQL books in many languages
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Some References
● NASA / US Census Bureu (Web sites)● Yahoo Finance & 15+ other parts of Yahoo● Slashdot.org, Freshmeat.net & Linux.com (Web)● Google.com (Web)● Novell (Included with OS)● Nortel(InSight) / Ericsson / Alcatel / Telia / Nokia● Cisco, Compaq, Veritas (Embedded)● And thousands of other commercial customers
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Some Awards and notable events● 1998 WEBTechniques
● 1998 CNET: Best affordable database
● 1998 2002 Linux Journal: Readers choice
● 2000 2001 Linux Magazine: Editors choice
● 2001 MySQL AB is formed and takes investment
● 2001 Oracle introduces MySQL migration kit
● 2001 Linux New Media (Germany): Best commercial software
● 2002 Linux Journal: Editors choice
● 2003: Guldmusen for Sweden's best IT Product
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
MySQL AB
● Distributed company● Head office in Uppsala,
Sweden, Other (sales and admin) offices in USA, Finland and Germany
● Currently about 65 people in over 14 countries
● Developers mostly working from home
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
MySQL AB & Making Money
● We get this question all the time!● By Commercial Licenses● By Support Agreements● By Training Courses● By Professional Services (Consulting)● By Certification (Beta version available NOW!)● By Partnership Agreements
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Training
● Advanced MySQL training is now provided by MySQL AB (In English, German, French, Swedish and Finnish for the moment)
● Examples of scheduled courses: Paris & London 17-21 Mar
Paris & London 10-14 Mar Hamburg 24-28 Mar
● mysql.com/training
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Documentation
● MySQL has very good documentation as a on line reference
● About 600 pages, updated as new code is written
– We write code and documentation at the same time (and we have done that from the start!)
● A printed version in English is available (from O'Reilly)
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
MySQL Features● An extended subset of ANSI SQL89.● Versioning ACID transaction support (InnoDB)● Numerous extensions like SELECT .... LIMIT 10,10● Few limits: disk, memory and OS set the limits● Handles large datasets (hundreds of GB)● Can be extended with User Defined Functions(UDF) in C● Embeddable engine (MySQL server as a library)● Full text search● Support for > 4GB tables and easy BLOB support● Master Slave Replication for data redundancy● Per table choice of backend (with/without transactions)
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Language Support• PHP
• C
• Java (JDBC)
• Ruby
• Guile
• ADA
• Dylan
• Common Lisp
• Lasso
• Perl
• Python
• Pike
• C++
• TCL
• Delphi
• Rexx
• ODBC
• And lots more ...
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Supported platforms
Native Threads (Multi CPU) NovellSun Solaris 2.5+ QNXLinux (x86, PPC, Sparc ...)HPUX 11+ Emulated threads (Single CPU)
IBM AIX 4+ BSDI 2.xApple MacOS X FreeBSD 2.xDEC (Tru64) UNIX HPUX 10.20BSDI 3+ NetBSD Intel/AlphaFreeBSD 3+ OpenBSD 2.xIBM OS/2 Sun SunOS 4SCO Unixware 7 SCO OpenserverSGI Irix 6.x AmigaOSWindows 95, 98, NT, 2k, XP
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
EWeek Benchmark
● Done in January 2002
● According to Eweek the first independent full scale test of relational in 7 years.
MySQL (4.0), Oracle (9i), IBM DB2 (7.2), Microsoft SQL Server (2000 SP2) and Sybase (12.5) was tested
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Eweek
This shows the response times of the different databases.
It better to be at the bottom
MySQL is the yellow line under the Red Oracle line
The application was a online bookstore with 50 Million books in the main table (using 7 very large indexes). 60 clients -> BEA WebLogic on a 6 CPU -> Database on a 4 CPU
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Citations from the Eweek article
● "The Oracle and MySQL drivers had the best combination of a complete JDBC feature set and stability."
● "Of the five databases we tested, only Oracle9i and MySQL were able to run our Nile application as originally written for 8 hours without problems."
● "SQL Server and MySQL were the easiest to tune, and Oracle9i was the most difficult because it has so many separate memory caches that can be adjusted."
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Storage Engines
● A storage engine is a low level data storage / retrieval module (disk or memory)
● This allows you to choose locking and speed trade offs per table (instead of when choosing db!)
● MySQL supported multiple storage engines from the very beginning
● CREATE TABLE (key int, value char(10), PRIMARY INDEX key) TYPE=HEAP;
● ALTER TABLE table_name TYPE=InnoDB;
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
The Storage Engine Concept
Parse OptimizeRetrieve
Store
MySQL
MyI
SA
M
InnoD
B
InM
emor
y
MySQL DatabaseManagement Level
Table Handler /Storage Engine
Level
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Storage Engine: MyISAM
● Developed by MySQL AB (replaced original ISAM)● Static, dynamic and compressed (read-only) row
formats but no transactions● Text and compressed indexes● Data and indexes in separate files ● Fast read/write performance but low r/w
concurrency● Extremely good concurrency in the select and
insert at end case (logs)● External check and repair program (myisamchk)● Especially useful for websites & logging
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Storage Engine: InnoDB
● Actively developed code from InnoBase Oy & MySQL AB
● Full transactions (ACID) with versioning row level locking with automatic cleanup (no vaccum!)
– Consistent reads (Oracle style MVCC)● Better concurrency than MyISAM for read/write on the same
table
● Uses table spaces instead of individual files
● MySQL AB provides full support for InnoDB
● Is included in MySQL 4 & the MySQL Max binarys
● Has now been in active use under heavy load. Was for example used for the FIFA world cup site
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Storage Engine: Hash/InMemory
● Developed by MySQL AB● Completely in Memory with very fast hash based
indexing● Useful for
– Temporary tables– Lookup tables
● Bad for range queries (Already fixed in MySQL 4.1)
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
High Availiabilty by Replication
● MySQL supports many sites that need high reliability
– This is done by "mirroring" the data to many machines● The single Master logs all SQL commands that update data
● Slaves connect to the master or another slave to read, and rerun the updates
● Examples of users are
– Yahoo– Slashdot.org– Mobile.de (sells used cars, over 300M page views/month)
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Tips and Tricks
● Temporary tables– Stays around until you drop them or your tread dies– Can be in memory (TYPE=heap), on disk (TYPE=MyISAM
or TYPE=InnoDB)– CREATE TEMPORARY TABLE type=MyISAM ... SELECT a+b as isum, ...
– CREATE TEMPORARY TABLE TYPE=Heap sums (PRIMARY KEY (id), INDEX (total), comment TEXT) SELECT t1.id, SUM(t2.number) AS total FROM t1,t2 WHERE t1.id = t2.id GROUP BY t1.id;
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Active Versions
● We are now working on 4 different MySQL major versions at the same time
● 3.23 Stable Production Release● 4.0 Feature Freeze Release (Gamma)
– Planed to be stable this month ● 4.1 Out in Source code for some months
– Binaries planned this month● 5.0 We will soon open the source code
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Version 4.0● Gamma (Release Candidate) now● Versioning ACID Transactions with very good transaction
isolation (Repetable Read) using InnoDB
– DB2, MS SQL and PostgreSQL uses only Read Commited● Embedded server library
– Use MySQL internal to you application without a separate process
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
4.0: Multiple table DELETE
● Allows you to delete rows in multiple tables bases of conditions from multiple tables
● Like saying that you want to delete all rows found by a SELECT
● Syntax inspired by MS Access● DELETE t1,t2 FROM t1,t2,t3 WHERE t1.id=t2.id and t2.id=t3.id
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
4.0: Dynamic Setting of Variables
● Change options on the fly (per thread and globally)
– No need to restart server to change cache sizes– Possible to set larger buffers for specific commands
● SET GLOBAL SORT_BUFFER=1*1024*1024– This will set the sort buffer (used by ORDER BY queries)
for all new connections ● SET SESSION SORT_BUFFER=32*1024*1024
– Will set the same buffer but only for the current connection● SELECT @@GLOBAL.SORT_BUFFER
– Returns the default size of the variable
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
4.0: Query Cache
● Improves the speed of queries on read mostly tables. Most (all?) websites has some query that will run many times a second
● 3x speed improvement for web sites not uncommon ● Does not change semantics at all!● To enable add a line to my.cnf
– query_cache_size = 128MB– Or set it on a running server
● SET @@GLOBAL.QUERY_CACHE_SIZE=128*1024*1024
– Turns the Query Cache on with 128 MB memory
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
4.0: Handler (Navigation) Interface
● Used when porting old database application with a navigational (direct ISAM) interface
● Also useful when you are doing a user interface that navigates a lot of data
● This interface gives "Dirty" reads (but no other MySQL commands are affected!)
● HANDLER table_name OPEN;● HANDLER table_name READ index_name > ("Banana") LIMIT 10;
● HANDLER table_name READ index_name PREVIOUS;
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
4.0: Replication
● Replication uses two threads
– One to read the all queries and store them on disk in case
– One to do the updates– This makes sure that the slave always catches up
to the latest changes even if it was executing a slow update when the server went down
● LOAD DATA INFILE commands are now replicated properly
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
4.0: Other Features
● SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+apples -bananas' IN BOOLEAN MODE);
– Find all records with the word "apples" but not the word "bananas" using a full text index
● SELECT SQL_CALC_FOUND_ROWS ... LIMIT 10● SELECT FOUND_ROWS();
– Make it possible to display the total number of rows even with a limit. For "10 out of 124 items shown" things
● Hash functions: SELECT SHA1("foo")● GRANT .. MAX_QUERIES_PER_HOUR=# MAX_UPDATES_PER_HOUR=# MAX_CONNECTIONS_PER_HOUR=#
– Limit a user (Very useful for ISP use)
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
4.0: Faster ...
● SELECT COUNT(DISTINCT ...) ...● Bulk loading of data
● Bulk updates of full text indexes
● Removing all the rows in a table
– TRUNCATE TABLE table_name;● SELECT * FROM table WHERE blob_col like "%keyword%"
– Uses a fast turbo Boyer More stringsearch● CREATE TABLE foo DATA DIRECTORY="/path/to/dir" INDEX DIRECTORY="/path/to/dir"
– Support for spreading MyISAM files over many disks● Multithreaded index rebuilding in myisamchk
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Version 4.1● Alpha release in February● BitKeeper source tree available since July● SELECT row1 FROM table1 WHERE a=(SELECT b FROM table2)
– Sub Select. Yes, we know this is very late : (● Done by Sanja Belkin in Lugansk, Ukraine
● SELECT * FROM table1, (SELECT b from table2) WHERE ...
● UPDATE t1,t2,t3 SET t1.c1=Val,t2.c2=val2 WHERE t1.id=t2.id and t2.id=t3.id
– Derived tables & Multiple table UPDATE● Both done by Sinisa Milivojevic in Larnaka, Cyprus
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Version 4.1
● Multidimensional data support (OpenGIS)
– 2d and 3d data– New point, line, multipoint, polygon etc datatypes
● UNICODE support● Both done by Alexander Barkov, Ramil Kalimullin and Alexey
Botchkov in Izhevsk, Russia● Online help for SQL syntax in the command line client
– Done by Victor Vagin and Sergey Glukov, Izhevsk, Russia
● Secure MySQL client server connections with SSL● InMemory tables can use B Tree keys (so they also can
handle ranges queries well)● Better windows support (WAX Kishkin, Siberia, Russia)
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
4.1: Prepared Statement
● Instead of sending a query direct you do
– Prepare SELECT foo from bar where a=?– Do ("1")– Do ("2")
● Also works with binary data without quoting
● The client server protocol has been extended for this
● The whole protocol is now fully binary so it runs even faster– Done by Venu Anugati, San Fransisco, USA
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Version 5.0● Stored Procedures (we be starting with ANSI 99 Syntax)
– Project lead Per Erik Martin in Uppsala, Sweden with two other full time developers backing him up
● Referential Integrety (Foreign keys)
● Online backup of MyISAM tables
● New column types:
– BIT– True VARCHAR (no space trimming)– ARRAY
● Warning/Info system
– Notify sysadmin when something may/goes wrong
– Give feedback while a slow command is running
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
MyODBC & Windows
● MySQL is actively developed and tested on Windows– But windows is still not recommended as a high load
platform (UNIX performs much better)● MyODBC active developed again by a MySQL AB
– Cursor support– Transaction support– Lots of small annoying long lived quirks fixed
● A ODBC 3.5 compliant driver was released in January
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
MySQL Command Center (mysqlcc)● Graphical MySQL client written
in C++ using the QT toolkit for UNIX & Windows
● Create/drop databases
● Create/edit/drop tables
● Write and execute SQL-queries
● Syntax Highlighting editor
● List of server variables and status
● View and kill other user-processes
● And much more...
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Free Databases are Better
● Freedom & Independence! – You have the ultimate documentation, the source! You do
not have to depend of documentation from any vendor to learn
● People spend time on good bug reports when the possibility of a quick fix exits
● A lot testing since you get more users even for advanced features (Replication and Full text search)
● Lots of code written by others (for us especially in the client area)
● Result: Low Total Cost of Ownership
© 2002 MySQL AB Creators of MySQL MySQL is a registered trademark of MySQL AB
Questions!
Now it is your turn to ask questions!
For more information about MySQL see:
www.MySQL.com