Oracle Database
MySQL
(
)
Oracle OpenWorld Unconference presented by JPOUG
2012/04/06
1
• DB
–
–
Oracle MySQL
RDBMS
Oracle MySQL 8 2
• Twitter @sh2nd
•
id:sh2
•
2
•
• Oracle Database
• MySQL
Oracle Database MySQL
MySQL
Oracle Database
…
…
3
MySQL
4
MySQL
• 2001/01 MySQL 3.23
RHEL 2.1/3
• 2003/03 MySQL 4.0
UNION
• 2004/10 MySQL 4.1
(Microsoft Code Page 932)
4.1.12
RHEL 4
Windows Shift_JIS
• 2005/10 MySQL 5.0
RHEL 5
• 2008/11 MySQL 5.1
RHEL 6
• 2010/12 MySQL 5.5
4
UTF-8
InnoDB
5
Oracle Database
•
Oracle 7 8
1980
2
1990
3
4
5
6
2000
7
8.0
8.1
2010
9.1 9.2
10.1 11.1 11.2
10.2
3.23 4.0 4.1 5.0
• Oracle Database
3
4
5
6
7
8.0
8.1
9.1
9.2
SYSTEM
10.1 RBO
10.2
11.1
11.2
5.1
5.5
CBO
Statspack
AL32UTF8
AWR
• MySQL
4.0 UNION
4.1
5.0
5.1
5.5 4
UTF-8
6
7
• OLTP SQL
•
SQL
SQL
•
• Java
ORA-4031
PreparedStatement
■
preparedStatement = connection.prepareStatement("SELECT c FROM sbtest WHERE id = ?");
preparedStatement.setInt(1, getRandomId()); //
resultSet = preparedStatement.executeQuery();
■
statement = connection.createStatement();
resultSet = statement.executeQuery("SELECT c FROM sbtest WHERE id = " + getRandomId());
8
SQL
• Oracle Database SQL
•
Oracle Database
SQL
SGA
Parse
Cursor Miss
Cache
Soft
Parse
Miss
Hard
Parse
Library Cache Hit
Execute
Cursor Cache Hit
SQL
9
•
SQL
SQL
Hard Parse
SGA
Parse
Cursor Miss
Cache
Soft
Parse
Miss
Hard
Parse
Library Cache Hit
Execute
Cursor Cache Hit
■Load Profile (Per Second)
Parses:
2,131.6
Hard parses:
2,089.3
■Instance Efficiency Percentages
Library Hit %:
43.30
Execute to Parse %:
0.15
Parse CPU to Parse Elapsd %: 48.35
Soft Parse %:
Latch Hit %:
% Non-Parse CPU:
1.98
98.95
35.32
10
•
SQL
SQL Soft Parse
SGA
Parse
Cursor Miss
Cache
Soft
Parse
Miss
Hard
Parse
Library Cache Hit
Execute
Cursor Cache Hit
■Load Profile (Per Second)
Parses:
6,350.8
Hard parses:
0.1
■Instance Efficiency Percentages
Library Hit %:
100.00
Execute to Parse %:
0.01
Parse CPU to Parse Elapsd %:
82.69
Soft Parse %:
Latch Hit %:
% Non-Parse CPU:
100.00
99.94
93.37
11
PreparedStatement
•
PreparedStatement
SQL
SGA
Parse
Cursor Miss
Cache
Soft
Parse
Miss
Hard
Parse
Library Cache Hit
Execute
Cursor Cache Hit
■Load Profile (Per Second)
Parses:
11.0
Hard parses:
0.4
■Instance Efficiency Percentages
Library Hit %:
99.96
99.85
Execute to Parse %:
Parse CPU to Parse Elapsd %: 35.40
Soft Parse %:
Latch Hit %:
% Non-Parse CPU:
96.49
99.93
99.96
12
13
• SysBench OLTP
Java
–
– Oracle Database MySQL
–
–
– PreparedStatement
(Apache Commons DBCP)
•
– Scientific Linux 6.2 64bit KVM
CentOS 5.7 64bit
– Core i5-2400S (Quad-Core 2.50GHz)
2
– Oracle Database 11g R2 SGA_TARGET = 4G
– MySQL 5.5.22 innodb_buffer_pool_size = 1024M
•
–C
–B
– P PreparedStatement
14
Oracle Database
•
(
)
15
Oracle Database
•
(
)
16
Oracle Database
• ※1 SESSION_CACHED_CURSORS = 50
PGA
CBP
SESSION_CACHED_CURSORS 11g R1
0
• ※2 CURSOR_SHARING = FORCE
SQL
CB50
Hard Parse
CBFORCE
• ※3
Oracle Database
• ※3
11g R1
(Java
)
17
MySQL
•
SysBench OLTP tps (read-only, 1M recs, uniform)
0.0
100.0
200.0
300.0
400.0
500.0
600.0
700.0
800.0
CBP
CB-
C--
-B-
---
MySQL
18
MySQL
• PreparedStatement
•
•
19
20
Client-Side PreparedStatement
• MySQL JDBC
Client-Side PreparedStatement
prepare
prepare
SELECT * FROM t WHERE id = ?
Client
Program
execute
JDBC
Driver
execute
param1 = 100
Database
Server
RDBMS
prepare
Client
Program
execute
JDBC
Driver
execute
SELECT * FROM t WHERE id = 100
MySQL
Server
MySQL
•
MySQL
JDBC
SQL
21
SQL
• MySQL SQL
SQL
• NESTED LOOPS JOIN
MERGE JOIN HASH JOIN
MySQL 5.6
Batched Key Access
MERGE JOIN
MariaDB
5.3
HASH JOIN
•
Oracle Database
MySQL 5.6
Oracle Database
MySQL
Table Pullout
SELECT * FROM sales WHERE cust_id IN (SELECT cust_id FROM customers);
⇒ MySQL sales
1
customer
⇒ Oracle Database
SELECT sales.* FROM sales s INNER JOIN customers c ON s.cust_id = c.cust_id;
22
Server-Side PreparedStatement
• MySQL
4.1
useServerPrepStmts true
•
MySQL
SQL
SQL
MySQL
RDBMS
MySQL
•
MySQL
JDBC
SQL
2
Parse
SQL
Execute&Fetch
Parse
Execute&Fetch
SQL
SQL
MySQL
Oracle Database
MySQL
23
MySQL
Server-Side PreparedStatement
• PreparedStatement
SysBench OLTP tps (read-only, 1M recs, uniform)
0.0
100.0
200.0
300.0
400.0
500.0
600.0
700.0
800.0
CBP
CB-
C--
-B-
---
MySQL
MySQL Server-Side
24
• MySQL(InnoDB)
– Oracle Database
– IBM DB2
– Microsoft SQL Server
– PostgreSQL
– MySQL(InnoDB)
•
INDEX UNIQUE SCAN INDEX RANGE
SCAN
• SysBench OLTP
SELECT
SELECT
SELECT
SELECT
SELECT
c FROM sbtest WHERE id = ?
c FROM sbtest WHERE id BETWEEN ? AND ?
SUM(k) FROM sbtest WHERE id BETWEEN ? AND ?
c FROM sbtest WHERE id BETWEEN ? AND ? ORDER BY c
DISTINCT c FROM sbtest WHERE id BETWEEN ? AND ? ORDER BY c
25
Oracle
•
(
)
26
• MySQL
MySQL
Oracle Database
…
• Oracle Database
–
Apache
–
7
11g R1
prefork
SQL
• MySQL
–
–
–
27
Oracle
•
(
)
28
29
• Oracle Database
–
–
–
• MySQL
–
–
–
DB
30
• MySQL
Oracle Database 15
Oracle 8i
•
OLTP
Database
MySQL
Oracle
Exadata
Business
Intelligence Data Warehouse
• DB
…
31
• SysBench: a system performance benchmark
http://sysbench.sourceforge.net/
•
IT
Web
(11)
JDBC
PreparedStatement
http://www.atmarkit.co.jp/fjava/rensai2/webopt11/webopt11.html
32
1.
2.
PostgreSQL
3. Oracle Database
4. MySQL
33
© Copyright 2026 Paperzz