SlideShare ist ein Scribd-Unternehmen logo
1 von 55
Downloaden Sie, um offline zu lesen
Why Are Databases So &# %-ingWhy Are Databases So &# %-ing DifficultDifficult?!?!
Dave Stokes
MySQL Community Manager
David.Stokes@Oracle.com @Stoker
Slideshare.net/DavidMStokes
2
Safe Harbor Agreement
The following is intended to outline our general product
direction. It is intended for information purposes only, and
may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality,
and should not be relied upon in making purchasing
decision. The development, release, and timing of any
features or functionality described for Oracle’s products
remains at the sole discretion of Oracle.
Happy Birthday to MySQL
4
?
But what
have you
done for us
lately??
5
http://www.thecompletelistoffeatures.com/
6
http://www.thecompletelistoffeatures.com/
7
http://www.thecompletelistoffeatures.com/
8
So back to the subject at hand
Why AreWhy Are
DatabasesDatabases
So &# %-ingSo &# %-ing
DifficultDifficult?!?!
9
Databases are:
● Selfish
● Want entire system to self
● Messy
● Suck up memory, disk space,
bandwidth, sanity
● Growing all the time
● Needs updates
● Suck up a good part of your life
10
Databases are the Toddlers of Software
11
Problem #1
2% of
PHP Developers have
ANY
SQL training
12
Quiz #1
Select City.Name, Country.Name
FROM City
Join Country On (City.CountryCode = Country.Code)
WHERE City.Population > 2000000
ORDER By Country.Name, City.Name
● Can you describe the desired output of this query?
● Is the above SQL code good?
● Will it perform well for 10 records? 100000 records? 10^10 records?
13
Quiz #1 – First Answer
Select City.Name, Country.Name
FROM City
Join Country On (City.CountryCode = Country.Code)
WHERE City.Population > 2000000
ORDER By Country.Name, City.Name
Desired Output
● Return the name of the Cities and their
corresponding Countries with Populations over
two million and sort by Country and City names
14
Quiz #1 -Second Answer
Select City.Name, Country.Name
FROM City
Join Country On (City.CountryCode = Country.Code)
WHERE City.Population > 2000000
ORDER By Country.Name, City.Name
Is the above SQL code good?
● Syntax is good.
● But can not tell just by observation of the query
– May not be answering desired question
– May not map to the underlying data effectively
– Unless joining on foreign keys, may be wrong relationship between tables
– What are the units for population? Is is safe to assume here?
15
Quiz #1
Select City.Name, Country.Name
FROM City
Join Country On (City.CountryCode = Country.Code)
WHERE City.Population > 2000000
ORDER By Country.Name, City.Name
Will it perform well for 10 records?
100000 records? 10^10 records?
● No way to tell by observation!
16
Can you tell if PHP code is bad by observation?
<?php
$foo = 8;
if( $foo<10 )
if( $foo>5 )
echo "Greater than 5!";
else
echo "Less than 5!";
else
echo "Greater than 10!";
echo "<br />Another note.";
● http://code.tutsplus.com/tutorials/why-youre-a-
bad-php-programmer--net-18384
It can be
relatively easy
to recognize
BAD PHP
programs.
17
So why is SQL Different
SQL is a
Declarative
Language
18
So why is SQL Different
● In computer science, declarative programming is a
programming paradigm, a style of building the
structure and elements of computer programs, that
expresses the logic of a computation without
describing its control flow. Many languages applying
this style attempt to minimize or eliminate side
effects by describing what the program should
accomplish in terms of the problem domain,
rather than describing how to go about
accomplishing it as a sequence of the
programming language primitives (the how being
left up to the language's implementation).
● https://en.wikipedia.org/wiki/Declarative_programming
19
PHP Object/Procedural vs. SQL Declaritive
Dave's First Bad Analog
● PHP
– Build Pizza
● SQL
– Order Pizza
20
Mix and/or Match
Can you Mix and Match
Declarative with Object
Orientated/Procedural
Programing Languages??
21
Yes but carefully
$QUERY = “Select City.Name, Country.Name
FROM City
Join Country On (City.CountryCode =
Country.Code)
WHERE City.Population > 2000000
ORDER By Country.Name, City.Name”;
$res = $mysqli->query($QUERY);
$row = $res->fetch_assoc();
22
SQL
● SQL Structured Query Language is a special-purpose
programming language designed for managing data
held in a relational database management system
(RDBMS), or for stream processing in a relational
data stream management system (RDSMS).
● Originally based upon relational algebra and tuple
relational calculus, SQL consists of a data definition
language, data manipulation language, and a data
control language. The scope of SQL includes data
insert, query, update and delete, schema creation
and modification, and data access control.
● https://en.wikipedia.org/wiki/SQL
23
What many of the audience members look like right now!
Oh No! He
said the words
relational
algebra and
tuple relational
calculus!
24
Problem #2 – Joins
● A SQL join clause combines
records from two or more
tables in a relational
database. It creates a set that
can be saved as a table or
used as it is. A JOIN is a
means for combining fields
from two tables (or more) by
using values common to
each.
● https://en.wikipedia.org/wiki/Join_(SQ
L)
25
Print out, post on your cube wall!
26
●
A JOIN is a means for combining fields from two tables (or
more) by using values common to each.
Join Country On
(City.CountryCode
= Country.Code)
27
Data Helpers
● Do not make every column as large as it possible can be. A BIGINT will take
8 bytes to store, 8 bytes to read off disk, 8 bytes to send over the network,
etc.
– Your are not going to have 18,446,744,073,709,551,615 customers even
if your customer_id is a BIGINT.
● If you can get by with a simple character set like LATIN1 great, otherwise
stick to UTF8mb4 but realize you are going from one to three bytes for
storage.
● SELECT the columns you are going to use, avoid the * wildcard
– The less you move disk/memory/net the better!
28
Problem #2 – Let Database Do the Heavy Lifiting
● Need SUM, AVG, AMX, MIN, STD, STDDEV_POP, STDDEV_SAMP,
STDDEV, VARIANCE, VAR_SAMP, VAR_POP
● Sorting easier outside of your application!
● Joins!!!!!
● Do not INDEX everything
● Use Foreign Keys
29
Key
For right now say
'KEY'
but think
'INDEX'
30
B-Tree
31
Indexes
● INDEX columns
– On the right side of WHERE
– Used in joins
● INDEXES have overhead – so do not index everything
– Maintenance
– Insert/update/delete
– Use mysqlindexcheck
● Finds Duplicate Indexes
– Use Sys Schema
● Find Unused Indexes
32
Foreign Keys
● A foreign key is a field (or collection of fields) in one table that
uniquely identifies a row of another table. In simpler words, the
foreign key is defined in a second table, but it refers to the primary
key in the first table. For example, a table called Employee has a
primary key called employee_id. Another table called Employee
Details has a foreign key which references employee_id in
order to uniquely identify the relationship between both the
tables.
● The table containing the foreign key is called the child table, and the
table containing the candidate key is called the referenced or parent
table. In database relational modeling and implementation, a unique
key is a set of zero, one or more attributes, the value(s) of which are
guaranteed to be unique for each tuple (row) in a relation. The value
or combination of values of unique key attributes for any tuple
cannot be duplicated for any other tuple in that relation.
● https://en.wikipedia.org/wiki/Foreign_key
33
Foreign Keys
CREATE TABLE
employee (
e_id INT NOT NULL,
name CHAR(20),
PRIMARY KEY (e_id)
):
CREATE TABLE building (
office_nbr INT NOT NULL,
description CHAR(20),
e_id INT NOT NULL,
PRIMARY KEY (office_nbr),
FOREIGN KEY (e_id),
REFERENCES employee
(e_id)
ON UPDATE CASCADE,
ON DELETE CASCADE);
34
Now Add Data
INSERT INTO employee VALUES
(10.'Larry'), (20,'Shemp'),(30,'Moe');
INSERT INTO building VALUES
(100,'Corner Office',10),
(101,'Lobby',40);
SELECT FROM employee
JOIN BUILDING (employee.e_id = building.e_id);
e_id name office_nbr description e_id
10 Larry 100 Corner Office 10
40 Moe 101 Lobby 40
Where is SHEMP????
35
How do we find Shemp?
mysql> SELECT * FROM employee
LEFT JOIN building ON(employee.e_id=building.e_id);
e_id name office_nbr description e_id
10 Larry 100 Corner Office 10
40 Moe 101 Lobby 40
20 Shemp NULL NULL NULL
36
FK save you from messy data
mysql> INSERT INTO building VALUES (120,'Cubicle',77);
ERROR 1452 (23000): Cannot add or update a child row: a
foreign key constraint fails (`test`.`building`, CONSTRAINT
`building_ibfk_1` FOREIGN KEY (`e_id`) REFERENCES
`employee` (`e_id`) ON DELETE CASCADE ON UPDATE
CASCADE)
Who is employee 77?
37
Using Cascade
mysql> DELETE FROM employee WHERE e_id=40;
mysql> SELECT * FROM employee LEFT JOIN building ON
(employee.e_id=building.e_id);
e_id name office_nbr description e_id
10 Larry 100 Corner Office 10
20 Shemp NULL NULL NULL
38
Updates
mysql> UPDATE employee SET e_id=21 WHERE e_id=20;
mysql> SELECT * FROM employee LEFT JOIN building ON
(employee.e_id=building.e_id);
e_id name office_nbr description e_id
10 Larry 100 Corner Office 10
21 Shemp NULL NULL NULL
39
Slide to test if audience is still awake
40
Problem #2 – Bad Programming
41
● What is the N+1 Query Problem ?
● This problem occurs when the code needs to load the children
of a parent-child relationship (the “many” in the “one-to-many”).
Most ORMs have lazy-loading enabled by default, so queries
are issued for the parent record, and then one query
for EACH child record. As you can expect, doing N+1
queries instead of a single query will flood your database with
queries, which is something we can and should avoid.
● http://www.sitepoint.com/silver-bullet-n1-problem/
42
N+1 Problem
function get_author_id( $name )
{
$res = $db->query( "SELECT id FROM
authors WHERE name=?",
array( $name ) );
$id = null;
while( $res->fetchInto( $row ) ) { $id =
$row[0]; }
return $id;
}
function get_books( $id )
{
$res = $db->query( "SELECT id FROM
books WHERE author_id=?",
array( $id ) );
$ids = array();
while( $res->fetchInto( $row ) ) { $ids []=
$row[0]; }
return $ids;
}
function get_book( $id )
{
$res = $db->query( "SELECT * FROM
books WHERE id=?", array( $id ) );
while( $res->fetchInto( $row ) ) { return
$row; }
return null;
}
$author_id = get_author_id( 'Jack
Herrington' );
$books = get_books( $author_id );
foreach( $books as $book_id ) {
$book = get_book( $book_id );
var_dump( $book );
}
http://www.ibm.com/developerworks/library/os-php-dbmistake/
Three queries!!!!
43
N+1 Continued
function get_books( $name )
{
$res = $db->query(
"SELECT books.* FROM authors,books WHERE
books.author_id=authors.id AND
authors.name=?",
array( $name ) );
$rows = array();
while( $res->fetchInto( $row ) ) { $rows []= $row; }
return $rows;
}
$books = get_books( 'Jack Herrington' );
var_dump( $books );
One read to get the same data!!!! Yea!!!
44
Transactions!!!
● A transaction symbolizes a unit of work performed within a database
management system (or similar system) against a database, and treated in a
coherent and reliable way independent of other transactions. A transaction generally
represents any change in database. Transactions in a database environment have
two main purposes:
– To provide reliable units of work that allow correct recovery from failures and keep a
database consistent even in cases of system failure, when execution stops (completely or
partially) and many operations upon a database remain uncompleted, with unclear status.
– To provide isolation between programs accessing a database concurrently. If this isolation
is not provided, the program's outcome are possibly erroneous.
● A database transaction, by definition, must be atomic, consistent, isolated and
durable. Database practitioners often refer to these properties of database
transactions using the acronym ACID.
●
Transactions provide an "all-or-nothing" proposition, stating that each work-
unit performed in a database must either complete in its entirety or have no
effect whatsoever. Further, the system must isolate each transaction from other
transactions, results must conform to existing constraints in the database, and
transactions that complete successfully must get written to durable storage.
– https://en.wikipedia.org/wiki/Database_transaction
45
More Transactions!!
● InnoDB or NDB only!
● Start with
– Do your SELECT & UPDATE
to change data
● COMMIT to save
ROLLBACK to undo
● SAVEPOINT foo
ROLLBACK foo
– Intermediate rollback point
● Note MySQL SQL Mode is
STRICT by DEFAULT
– So watch for missing data
46
Save Points
Use SAVEPOINT to engineer more complex transactions.
47
Problem #3 – Query Plans
48
What is a Query Plan?
● After your query syntax is
checked, the optimizer looks for
the most efficient way to gather
the data requested.
– Each column add roughly 1
factorial to the complexity
– Is the data in memory
● Dive to disk is 100,000
time slower
– Are indexes fresh? Are there
indexes?
MySQL wants to create a query
plan for each execution of each
query
49
Things to tune
● innodb_stats_persistent=ON will store statistics between restarts so
your servers does not have to re-learn the best way to run the query
● innodb_stats_auto_recalc (default on, 10%) will automatically redo
stats after a limit of DML changes to a table
● Higher cardinality helps
– Design your indexes accordingly!!
● See MySQL Manual 14.3.11.1 Configuring Persistent Optimizer
Statistics Parameters for details
● Also add skip-name-resolve to keep bad DNS zone transfers from
killing your application
50
● Check return codes
<?php
// we connect to example.com and port 3307
$link = mysql_connect('example.com:3307', 'mysql_user',
'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
Some Programming Advice
51
● Check return codes
// Create connection
conn = new mysqli($servername, $username, $password, $dbname);
/ Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
Some More Programming Advice
52
● Scrub all data coming into your database
– Less SQL Injection, more data integrity
● Think in SETs of data not ROWs
– Let database do heavy lifting
● Try to write good SQL
– Learn to use Visual Explain
– Actively look to reduce/combine queries
● Use Sys Schema to find indexes not being used, redundant
indexes and slow query log for queries that are running slow and
without indexes
Some Programming Advice
53
MySQl Group Replication
54
Books to Buy!!!!!!
Bill Karwin SQL Antipatterns CJ Date SQL and Relational Theory
55
Q/A
● David.Stokes@Oracle.com
● OpenSourceDBA.Wordpress.com
● @Stoker
● Slideshare.net/davidmstokes
● https://joind.in/14913

Weitere ähnliche Inhalte

Was ist angesagt?

Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...Dave Stokes
 
New awesome features in MySQL 5.7
New awesome features in MySQL 5.7New awesome features in MySQL 5.7
New awesome features in MySQL 5.7Zhaoyang Wang
 
Confoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesConfoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesDave Stokes
 
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...Dave Stokes
 
cPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturescPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturesDave Stokes
 
MySQL Server Defaults
MySQL Server DefaultsMySQL Server Defaults
MySQL Server DefaultsMorgan Tocker
 
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoMySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoDave Stokes
 
Scaling MySQl 1 to N Servers -- Los Angelese MySQL User Group Feb 2014
Scaling MySQl 1 to N Servers -- Los Angelese MySQL User Group Feb 2014Scaling MySQl 1 to N Servers -- Los Angelese MySQL User Group Feb 2014
Scaling MySQl 1 to N Servers -- Los Angelese MySQL User Group Feb 2014Dave Stokes
 
MySql's NoSQL -- best of both worlds on the same disks
MySql's NoSQL -- best of both worlds on the same disksMySql's NoSQL -- best of both worlds on the same disks
MySql's NoSQL -- best of both worlds on the same disksDave Stokes
 
Dutch PHP Conference 2021 - MySQL Indexes and Histograms
Dutch PHP Conference 2021 - MySQL Indexes and HistogramsDutch PHP Conference 2021 - MySQL Indexes and Histograms
Dutch PHP Conference 2021 - MySQL Indexes and HistogramsDave Stokes
 
MySQL 5.7 in a Nutshell
MySQL 5.7 in a NutshellMySQL 5.7 in a Nutshell
MySQL 5.7 in a NutshellEmily Ikuta
 
MySQL 5.7 -- SCaLE Feb 2014
MySQL 5.7 -- SCaLE Feb 2014MySQL 5.7 -- SCaLE Feb 2014
MySQL 5.7 -- SCaLE Feb 2014Dave Stokes
 
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016Dave Stokes
 
MySQL Indexes and Histograms - RMOUG Training Days 2022
MySQL Indexes and Histograms - RMOUG Training Days 2022MySQL Indexes and Histograms - RMOUG Training Days 2022
MySQL Indexes and Histograms - RMOUG Training Days 2022Dave Stokes
 
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...
MySQL High Availability Solutions - Avoid loss of service by reducing the r...Olivier DASINI
 
InnoDB Tablespace Encryption
InnoDB Tablespace Encryption InnoDB Tablespace Encryption
InnoDB Tablespace Encryption Satya Bodapati
 
MySQL 8.0 Operational Changes
MySQL 8.0 Operational ChangesMySQL 8.0 Operational Changes
MySQL 8.0 Operational ChangesDave Stokes
 
MySQL Document Store for Modern Applications
MySQL Document Store for Modern ApplicationsMySQL Document Store for Modern Applications
MySQL Document Store for Modern ApplicationsOlivier DASINI
 

Was ist angesagt? (20)

My sql 5.6&MySQL Cluster 7.3
My sql 5.6&MySQL Cluster 7.3My sql 5.6&MySQL Cluster 7.3
My sql 5.6&MySQL Cluster 7.3
 
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
Open Source 1010 and Quest InSync presentations March 30th, 2021 on MySQL Ind...
 
New awesome features in MySQL 5.7
New awesome features in MySQL 5.7New awesome features in MySQL 5.7
New awesome features in MySQL 5.7
 
Confoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesConfoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New Features
 
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...
 
cPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturescPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven Features
 
MySQL Server Defaults
MySQL Server DefaultsMySQL Server Defaults
MySQL Server Defaults
 
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoMySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
 
Scaling MySQl 1 to N Servers -- Los Angelese MySQL User Group Feb 2014
Scaling MySQl 1 to N Servers -- Los Angelese MySQL User Group Feb 2014Scaling MySQl 1 to N Servers -- Los Angelese MySQL User Group Feb 2014
Scaling MySQl 1 to N Servers -- Los Angelese MySQL User Group Feb 2014
 
MySql's NoSQL -- best of both worlds on the same disks
MySql's NoSQL -- best of both worlds on the same disksMySql's NoSQL -- best of both worlds on the same disks
MySql's NoSQL -- best of both worlds on the same disks
 
Dutch PHP Conference 2021 - MySQL Indexes and Histograms
Dutch PHP Conference 2021 - MySQL Indexes and HistogramsDutch PHP Conference 2021 - MySQL Indexes and Histograms
Dutch PHP Conference 2021 - MySQL Indexes and Histograms
 
MySQL 5.7 in a Nutshell
MySQL 5.7 in a NutshellMySQL 5.7 in a Nutshell
MySQL 5.7 in a Nutshell
 
MySQL 5.7 -- SCaLE Feb 2014
MySQL 5.7 -- SCaLE Feb 2014MySQL 5.7 -- SCaLE Feb 2014
MySQL 5.7 -- SCaLE Feb 2014
 
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016
 
MySQL Indexes and Histograms - RMOUG Training Days 2022
MySQL Indexes and Histograms - RMOUG Training Days 2022MySQL Indexes and Histograms - RMOUG Training Days 2022
MySQL Indexes and Histograms - RMOUG Training Days 2022
 
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
 
InnoDB Tablespace Encryption
InnoDB Tablespace Encryption InnoDB Tablespace Encryption
InnoDB Tablespace Encryption
 
MySQL 8.0 Operational Changes
MySQL 8.0 Operational ChangesMySQL 8.0 Operational Changes
MySQL 8.0 Operational Changes
 
MySQL Document Store for Modern Applications
MySQL Document Store for Modern ApplicationsMySQL Document Store for Modern Applications
MySQL Document Store for Modern Applications
 
MySQL JSON Functions
MySQL JSON FunctionsMySQL JSON Functions
MySQL JSON Functions
 

Ähnlich wie PNWPHP -- What are Databases so &#%-ing Difficult

Database Basics with PHP -- Connect JS Conference October 17th, 2015
Database Basics with PHP -- Connect JS Conference October 17th, 2015Database Basics with PHP -- Connect JS Conference October 17th, 2015
Database Basics with PHP -- Connect JS Conference October 17th, 2015Dave Stokes
 
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
MySQL Without the SQL -- Oh My!  Longhorn PHP ConferenceMySQL Without the SQL -- Oh My!  Longhorn PHP Conference
MySQL Without the SQL -- Oh My! Longhorn PHP ConferenceDave Stokes
 
SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP Dave Stokes
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsDave Stokes
 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)Dave Stokes
 
Five Database Mistakes and how to fix them -- Confoo Vancouver
Five Database Mistakes and how to fix them -- Confoo VancouverFive Database Mistakes and how to fix them -- Confoo Vancouver
Five Database Mistakes and how to fix them -- Confoo VancouverDave Stokes
 
What Your Database Query is Really Doing
What Your Database Query is Really DoingWhat Your Database Query is Really Doing
What Your Database Query is Really DoingDave Stokes
 
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020
MySQL Goes to 8!  FOSDEM 2020 Database Track, January 2nd, 2020MySQL Goes to 8!  FOSDEM 2020 Database Track, January 2nd, 2020
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020Geir Høydalsvik
 
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQLSql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQLPrashant Kumar
 
SQL For Programmers -- Boston Big Data Techcon April 27th
SQL For Programmers -- Boston Big Data Techcon April 27thSQL For Programmers -- Boston Big Data Techcon April 27th
SQL For Programmers -- Boston Big Data Techcon April 27thDave Stokes
 
MySQL Without the MySQL -- Oh My!
MySQL Without the MySQL -- Oh My!MySQL Without the MySQL -- Oh My!
MySQL Without the MySQL -- Oh My!Dave Stokes
 
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfRivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfFrederic Descamps
 
SQL Pass Architecture SQL Tips & Tricks
SQL Pass Architecture SQL Tips & TricksSQL Pass Architecture SQL Tips & Tricks
SQL Pass Architecture SQL Tips & TricksIke Ellis
 
L1 Intro to Relational DBMS LP.pdfIntro to Relational .docx
L1 Intro to Relational DBMS LP.pdfIntro to Relational .docxL1 Intro to Relational DBMS LP.pdfIntro to Relational .docx
L1 Intro to Relational DBMS LP.pdfIntro to Relational .docxDIPESH30
 
Performance tuning
Performance tuningPerformance tuning
Performance tuningami111
 

Ähnlich wie PNWPHP -- What are Databases so &#%-ing Difficult (20)

Database Basics with PHP -- Connect JS Conference October 17th, 2015
Database Basics with PHP -- Connect JS Conference October 17th, 2015Database Basics with PHP -- Connect JS Conference October 17th, 2015
Database Basics with PHP -- Connect JS Conference October 17th, 2015
 
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
MySQL Without the SQL -- Oh My!  Longhorn PHP ConferenceMySQL Without the SQL -- Oh My!  Longhorn PHP Conference
MySQL Without the SQL -- Oh My! Longhorn PHP Conference
 
SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
 
Ebook11
Ebook11Ebook11
Ebook11
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query Optimizations
 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
 
Five Database Mistakes and how to fix them -- Confoo Vancouver
Five Database Mistakes and how to fix them -- Confoo VancouverFive Database Mistakes and how to fix them -- Confoo Vancouver
Five Database Mistakes and how to fix them -- Confoo Vancouver
 
What Your Database Query is Really Doing
What Your Database Query is Really DoingWhat Your Database Query is Really Doing
What Your Database Query is Really Doing
 
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020
MySQL Goes to 8!  FOSDEM 2020 Database Track, January 2nd, 2020MySQL Goes to 8!  FOSDEM 2020 Database Track, January 2nd, 2020
MySQL Goes to 8! FOSDEM 2020 Database Track, January 2nd, 2020
 
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQLSql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
 
SQL For Programmers -- Boston Big Data Techcon April 27th
SQL For Programmers -- Boston Big Data Techcon April 27thSQL For Programmers -- Boston Big Data Techcon April 27th
SQL For Programmers -- Boston Big Data Techcon April 27th
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
 
MySQL Without the MySQL -- Oh My!
MySQL Without the MySQL -- Oh My!MySQL Without the MySQL -- Oh My!
MySQL Without the MySQL -- Oh My!
 
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfRivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
 
SQL Pass Architecture SQL Tips & Tricks
SQL Pass Architecture SQL Tips & TricksSQL Pass Architecture SQL Tips & Tricks
SQL Pass Architecture SQL Tips & Tricks
 
My sql102
My sql102My sql102
My sql102
 
L1 Intro to Relational DBMS LP.pdfIntro to Relational .docx
L1 Intro to Relational DBMS LP.pdfIntro to Relational .docxL1 Intro to Relational DBMS LP.pdfIntro to Relational .docx
L1 Intro to Relational DBMS LP.pdfIntro to Relational .docx
 
Performance tuning
Performance tuningPerformance tuning
Performance tuning
 
Golden Hammer - Shawn Oden
Golden Hammer - Shawn OdenGolden Hammer - Shawn Oden
Golden Hammer - Shawn Oden
 

Mehr von Dave Stokes

Locking Down Your MySQL Database.pptx
Locking Down Your MySQL Database.pptxLocking Down Your MySQL Database.pptx
Locking Down Your MySQL Database.pptxDave Stokes
 
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesLinuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesDave Stokes
 
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019Dave Stokes
 
Windowing Functions - Little Rock Tech fest 2019
Windowing Functions - Little Rock Tech fest 2019Windowing Functions - Little Rock Tech fest 2019
Windowing Functions - Little Rock Tech fest 2019Dave Stokes
 
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019Dave Stokes
 
Develop PHP Applications with MySQL X DevAPI
Develop PHP Applications with MySQL X DevAPIDevelop PHP Applications with MySQL X DevAPI
Develop PHP Applications with MySQL X DevAPIDave Stokes
 
The Proper Care and Feeding of MySQL Databases
The Proper Care and Feeding of MySQL DatabasesThe Proper Care and Feeding of MySQL Databases
The Proper Care and Feeding of MySQL DatabasesDave Stokes
 
MySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHPMySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHPDave Stokes
 
MySQL 8 Server Optimization Swanseacon 2018
MySQL 8 Server Optimization Swanseacon 2018MySQL 8 Server Optimization Swanseacon 2018
MySQL 8 Server Optimization Swanseacon 2018Dave Stokes
 
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018MySQL Without The SQL -- Oh My! PHP[Tek] June 2018
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018Dave Stokes
 
Presentation Skills for Open Source Folks
Presentation Skills for Open Source FolksPresentation Skills for Open Source Folks
Presentation Skills for Open Source FolksDave Stokes
 
ConFoo MySQL Replication Evolution : From Simple to Group Replication
ConFoo  MySQL Replication Evolution : From Simple to Group ReplicationConFoo  MySQL Replication Evolution : From Simple to Group Replication
ConFoo MySQL Replication Evolution : From Simple to Group ReplicationDave Stokes
 
Making MySQL Agile-ish
Making MySQL Agile-ishMaking MySQL Agile-ish
Making MySQL Agile-ishDave Stokes
 
PHP Database Programming Basics -- Northeast PHP
PHP Database Programming Basics -- Northeast PHPPHP Database Programming Basics -- Northeast PHP
PHP Database Programming Basics -- Northeast PHPDave Stokes
 
MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017Dave Stokes
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017Dave Stokes
 
MySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document StoreMySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document StoreDave Stokes
 
Why Your Database Queries Stink -SeaGl.org November 11th, 2016
Why Your Database Queries Stink -SeaGl.org November 11th, 2016Why Your Database Queries Stink -SeaGl.org November 11th, 2016
Why Your Database Queries Stink -SeaGl.org November 11th, 2016Dave Stokes
 
All Things Open 2016 -- Database Programming for Newbies
All Things Open 2016 -- Database Programming for NewbiesAll Things Open 2016 -- Database Programming for Newbies
All Things Open 2016 -- Database Programming for NewbiesDave Stokes
 
MySQL as a Document Store
MySQL as a Document StoreMySQL as a Document Store
MySQL as a Document StoreDave Stokes
 

Mehr von Dave Stokes (20)

Locking Down Your MySQL Database.pptx
Locking Down Your MySQL Database.pptxLocking Down Your MySQL Database.pptx
Locking Down Your MySQL Database.pptx
 
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre FeaturesLinuxfest Northwest 2022 - MySQL 8.0 Nre Features
Linuxfest Northwest 2022 - MySQL 8.0 Nre Features
 
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
MySQL 8.0 Features -- Oracle CodeOne 2019, All Things Open 2019
 
Windowing Functions - Little Rock Tech fest 2019
Windowing Functions - Little Rock Tech fest 2019Windowing Functions - Little Rock Tech fest 2019
Windowing Functions - Little Rock Tech fest 2019
 
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
 
Develop PHP Applications with MySQL X DevAPI
Develop PHP Applications with MySQL X DevAPIDevelop PHP Applications with MySQL X DevAPI
Develop PHP Applications with MySQL X DevAPI
 
The Proper Care and Feeding of MySQL Databases
The Proper Care and Feeding of MySQL DatabasesThe Proper Care and Feeding of MySQL Databases
The Proper Care and Feeding of MySQL Databases
 
MySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHPMySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHP
 
MySQL 8 Server Optimization Swanseacon 2018
MySQL 8 Server Optimization Swanseacon 2018MySQL 8 Server Optimization Swanseacon 2018
MySQL 8 Server Optimization Swanseacon 2018
 
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018MySQL Without The SQL -- Oh My! PHP[Tek] June 2018
MySQL Without The SQL -- Oh My! PHP[Tek] June 2018
 
Presentation Skills for Open Source Folks
Presentation Skills for Open Source FolksPresentation Skills for Open Source Folks
Presentation Skills for Open Source Folks
 
ConFoo MySQL Replication Evolution : From Simple to Group Replication
ConFoo  MySQL Replication Evolution : From Simple to Group ReplicationConFoo  MySQL Replication Evolution : From Simple to Group Replication
ConFoo MySQL Replication Evolution : From Simple to Group Replication
 
Making MySQL Agile-ish
Making MySQL Agile-ishMaking MySQL Agile-ish
Making MySQL Agile-ish
 
PHP Database Programming Basics -- Northeast PHP
PHP Database Programming Basics -- Northeast PHPPHP Database Programming Basics -- Northeast PHP
PHP Database Programming Basics -- Northeast PHP
 
MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017
 
MySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document StoreMySQL's JSON Data Type and Document Store
MySQL's JSON Data Type and Document Store
 
Why Your Database Queries Stink -SeaGl.org November 11th, 2016
Why Your Database Queries Stink -SeaGl.org November 11th, 2016Why Your Database Queries Stink -SeaGl.org November 11th, 2016
Why Your Database Queries Stink -SeaGl.org November 11th, 2016
 
All Things Open 2016 -- Database Programming for Newbies
All Things Open 2016 -- Database Programming for NewbiesAll Things Open 2016 -- Database Programming for Newbies
All Things Open 2016 -- Database Programming for Newbies
 
MySQL as a Document Store
MySQL as a Document StoreMySQL as a Document Store
MySQL as a Document Store
 

Kürzlich hochgeladen

Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.soniya singh
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$kojalkojal131
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)Delhi Call girls
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445ruhi
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.soniya singh
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663Call Girls Mumbai
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.CarlotaBedoya1
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersDamian Radcliffe
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLimonikaupta
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 

Kürzlich hochgeladen (20)

Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 

PNWPHP -- What are Databases so &#%-ing Difficult

  • 1. Why Are Databases So &# %-ingWhy Are Databases So &# %-ing DifficultDifficult?!?! Dave Stokes MySQL Community Manager David.Stokes@Oracle.com @Stoker Slideshare.net/DavidMStokes
  • 2. 2 Safe Harbor Agreement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decision. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
  • 4. 4 ? But what have you done for us lately??
  • 8. 8 So back to the subject at hand Why AreWhy Are DatabasesDatabases So &# %-ingSo &# %-ing DifficultDifficult?!?!
  • 9. 9 Databases are: ● Selfish ● Want entire system to self ● Messy ● Suck up memory, disk space, bandwidth, sanity ● Growing all the time ● Needs updates ● Suck up a good part of your life
  • 10. 10 Databases are the Toddlers of Software
  • 11. 11 Problem #1 2% of PHP Developers have ANY SQL training
  • 12. 12 Quiz #1 Select City.Name, Country.Name FROM City Join Country On (City.CountryCode = Country.Code) WHERE City.Population > 2000000 ORDER By Country.Name, City.Name ● Can you describe the desired output of this query? ● Is the above SQL code good? ● Will it perform well for 10 records? 100000 records? 10^10 records?
  • 13. 13 Quiz #1 – First Answer Select City.Name, Country.Name FROM City Join Country On (City.CountryCode = Country.Code) WHERE City.Population > 2000000 ORDER By Country.Name, City.Name Desired Output ● Return the name of the Cities and their corresponding Countries with Populations over two million and sort by Country and City names
  • 14. 14 Quiz #1 -Second Answer Select City.Name, Country.Name FROM City Join Country On (City.CountryCode = Country.Code) WHERE City.Population > 2000000 ORDER By Country.Name, City.Name Is the above SQL code good? ● Syntax is good. ● But can not tell just by observation of the query – May not be answering desired question – May not map to the underlying data effectively – Unless joining on foreign keys, may be wrong relationship between tables – What are the units for population? Is is safe to assume here?
  • 15. 15 Quiz #1 Select City.Name, Country.Name FROM City Join Country On (City.CountryCode = Country.Code) WHERE City.Population > 2000000 ORDER By Country.Name, City.Name Will it perform well for 10 records? 100000 records? 10^10 records? ● No way to tell by observation!
  • 16. 16 Can you tell if PHP code is bad by observation? <?php $foo = 8; if( $foo<10 ) if( $foo>5 ) echo "Greater than 5!"; else echo "Less than 5!"; else echo "Greater than 10!"; echo "<br />Another note."; ● http://code.tutsplus.com/tutorials/why-youre-a- bad-php-programmer--net-18384 It can be relatively easy to recognize BAD PHP programs.
  • 17. 17 So why is SQL Different SQL is a Declarative Language
  • 18. 18 So why is SQL Different ● In computer science, declarative programming is a programming paradigm, a style of building the structure and elements of computer programs, that expresses the logic of a computation without describing its control flow. Many languages applying this style attempt to minimize or eliminate side effects by describing what the program should accomplish in terms of the problem domain, rather than describing how to go about accomplishing it as a sequence of the programming language primitives (the how being left up to the language's implementation). ● https://en.wikipedia.org/wiki/Declarative_programming
  • 19. 19 PHP Object/Procedural vs. SQL Declaritive Dave's First Bad Analog ● PHP – Build Pizza ● SQL – Order Pizza
  • 20. 20 Mix and/or Match Can you Mix and Match Declarative with Object Orientated/Procedural Programing Languages??
  • 21. 21 Yes but carefully $QUERY = “Select City.Name, Country.Name FROM City Join Country On (City.CountryCode = Country.Code) WHERE City.Population > 2000000 ORDER By Country.Name, City.Name”; $res = $mysqli->query($QUERY); $row = $res->fetch_assoc();
  • 22. 22 SQL ● SQL Structured Query Language is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS). ● Originally based upon relational algebra and tuple relational calculus, SQL consists of a data definition language, data manipulation language, and a data control language. The scope of SQL includes data insert, query, update and delete, schema creation and modification, and data access control. ● https://en.wikipedia.org/wiki/SQL
  • 23. 23 What many of the audience members look like right now! Oh No! He said the words relational algebra and tuple relational calculus!
  • 24. 24 Problem #2 – Joins ● A SQL join clause combines records from two or more tables in a relational database. It creates a set that can be saved as a table or used as it is. A JOIN is a means for combining fields from two tables (or more) by using values common to each. ● https://en.wikipedia.org/wiki/Join_(SQ L)
  • 25. 25 Print out, post on your cube wall!
  • 26. 26 ● A JOIN is a means for combining fields from two tables (or more) by using values common to each. Join Country On (City.CountryCode = Country.Code)
  • 27. 27 Data Helpers ● Do not make every column as large as it possible can be. A BIGINT will take 8 bytes to store, 8 bytes to read off disk, 8 bytes to send over the network, etc. – Your are not going to have 18,446,744,073,709,551,615 customers even if your customer_id is a BIGINT. ● If you can get by with a simple character set like LATIN1 great, otherwise stick to UTF8mb4 but realize you are going from one to three bytes for storage. ● SELECT the columns you are going to use, avoid the * wildcard – The less you move disk/memory/net the better!
  • 28. 28 Problem #2 – Let Database Do the Heavy Lifiting ● Need SUM, AVG, AMX, MIN, STD, STDDEV_POP, STDDEV_SAMP, STDDEV, VARIANCE, VAR_SAMP, VAR_POP ● Sorting easier outside of your application! ● Joins!!!!! ● Do not INDEX everything ● Use Foreign Keys
  • 29. 29 Key For right now say 'KEY' but think 'INDEX'
  • 31. 31 Indexes ● INDEX columns – On the right side of WHERE – Used in joins ● INDEXES have overhead – so do not index everything – Maintenance – Insert/update/delete – Use mysqlindexcheck ● Finds Duplicate Indexes – Use Sys Schema ● Find Unused Indexes
  • 32. 32 Foreign Keys ● A foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another table. In simpler words, the foreign key is defined in a second table, but it refers to the primary key in the first table. For example, a table called Employee has a primary key called employee_id. Another table called Employee Details has a foreign key which references employee_id in order to uniquely identify the relationship between both the tables. ● The table containing the foreign key is called the child table, and the table containing the candidate key is called the referenced or parent table. In database relational modeling and implementation, a unique key is a set of zero, one or more attributes, the value(s) of which are guaranteed to be unique for each tuple (row) in a relation. The value or combination of values of unique key attributes for any tuple cannot be duplicated for any other tuple in that relation. ● https://en.wikipedia.org/wiki/Foreign_key
  • 33. 33 Foreign Keys CREATE TABLE employee ( e_id INT NOT NULL, name CHAR(20), PRIMARY KEY (e_id) ): CREATE TABLE building ( office_nbr INT NOT NULL, description CHAR(20), e_id INT NOT NULL, PRIMARY KEY (office_nbr), FOREIGN KEY (e_id), REFERENCES employee (e_id) ON UPDATE CASCADE, ON DELETE CASCADE);
  • 34. 34 Now Add Data INSERT INTO employee VALUES (10.'Larry'), (20,'Shemp'),(30,'Moe'); INSERT INTO building VALUES (100,'Corner Office',10), (101,'Lobby',40); SELECT FROM employee JOIN BUILDING (employee.e_id = building.e_id); e_id name office_nbr description e_id 10 Larry 100 Corner Office 10 40 Moe 101 Lobby 40 Where is SHEMP????
  • 35. 35 How do we find Shemp? mysql> SELECT * FROM employee LEFT JOIN building ON(employee.e_id=building.e_id); e_id name office_nbr description e_id 10 Larry 100 Corner Office 10 40 Moe 101 Lobby 40 20 Shemp NULL NULL NULL
  • 36. 36 FK save you from messy data mysql> INSERT INTO building VALUES (120,'Cubicle',77); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`test`.`building`, CONSTRAINT `building_ibfk_1` FOREIGN KEY (`e_id`) REFERENCES `employee` (`e_id`) ON DELETE CASCADE ON UPDATE CASCADE) Who is employee 77?
  • 37. 37 Using Cascade mysql> DELETE FROM employee WHERE e_id=40; mysql> SELECT * FROM employee LEFT JOIN building ON (employee.e_id=building.e_id); e_id name office_nbr description e_id 10 Larry 100 Corner Office 10 20 Shemp NULL NULL NULL
  • 38. 38 Updates mysql> UPDATE employee SET e_id=21 WHERE e_id=20; mysql> SELECT * FROM employee LEFT JOIN building ON (employee.e_id=building.e_id); e_id name office_nbr description e_id 10 Larry 100 Corner Office 10 21 Shemp NULL NULL NULL
  • 39. 39 Slide to test if audience is still awake
  • 40. 40 Problem #2 – Bad Programming
  • 41. 41 ● What is the N+1 Query Problem ? ● This problem occurs when the code needs to load the children of a parent-child relationship (the “many” in the “one-to-many”). Most ORMs have lazy-loading enabled by default, so queries are issued for the parent record, and then one query for EACH child record. As you can expect, doing N+1 queries instead of a single query will flood your database with queries, which is something we can and should avoid. ● http://www.sitepoint.com/silver-bullet-n1-problem/
  • 42. 42 N+1 Problem function get_author_id( $name ) { $res = $db->query( "SELECT id FROM authors WHERE name=?", array( $name ) ); $id = null; while( $res->fetchInto( $row ) ) { $id = $row[0]; } return $id; } function get_books( $id ) { $res = $db->query( "SELECT id FROM books WHERE author_id=?", array( $id ) ); $ids = array(); while( $res->fetchInto( $row ) ) { $ids []= $row[0]; } return $ids; } function get_book( $id ) { $res = $db->query( "SELECT * FROM books WHERE id=?", array( $id ) ); while( $res->fetchInto( $row ) ) { return $row; } return null; } $author_id = get_author_id( 'Jack Herrington' ); $books = get_books( $author_id ); foreach( $books as $book_id ) { $book = get_book( $book_id ); var_dump( $book ); } http://www.ibm.com/developerworks/library/os-php-dbmistake/ Three queries!!!!
  • 43. 43 N+1 Continued function get_books( $name ) { $res = $db->query( "SELECT books.* FROM authors,books WHERE books.author_id=authors.id AND authors.name=?", array( $name ) ); $rows = array(); while( $res->fetchInto( $row ) ) { $rows []= $row; } return $rows; } $books = get_books( 'Jack Herrington' ); var_dump( $books ); One read to get the same data!!!! Yea!!!
  • 44. 44 Transactions!!! ● A transaction symbolizes a unit of work performed within a database management system (or similar system) against a database, and treated in a coherent and reliable way independent of other transactions. A transaction generally represents any change in database. Transactions in a database environment have two main purposes: – To provide reliable units of work that allow correct recovery from failures and keep a database consistent even in cases of system failure, when execution stops (completely or partially) and many operations upon a database remain uncompleted, with unclear status. – To provide isolation between programs accessing a database concurrently. If this isolation is not provided, the program's outcome are possibly erroneous. ● A database transaction, by definition, must be atomic, consistent, isolated and durable. Database practitioners often refer to these properties of database transactions using the acronym ACID. ● Transactions provide an "all-or-nothing" proposition, stating that each work- unit performed in a database must either complete in its entirety or have no effect whatsoever. Further, the system must isolate each transaction from other transactions, results must conform to existing constraints in the database, and transactions that complete successfully must get written to durable storage. – https://en.wikipedia.org/wiki/Database_transaction
  • 45. 45 More Transactions!! ● InnoDB or NDB only! ● Start with – Do your SELECT & UPDATE to change data ● COMMIT to save ROLLBACK to undo ● SAVEPOINT foo ROLLBACK foo – Intermediate rollback point ● Note MySQL SQL Mode is STRICT by DEFAULT – So watch for missing data
  • 46. 46 Save Points Use SAVEPOINT to engineer more complex transactions.
  • 47. 47 Problem #3 – Query Plans
  • 48. 48 What is a Query Plan? ● After your query syntax is checked, the optimizer looks for the most efficient way to gather the data requested. – Each column add roughly 1 factorial to the complexity – Is the data in memory ● Dive to disk is 100,000 time slower – Are indexes fresh? Are there indexes? MySQL wants to create a query plan for each execution of each query
  • 49. 49 Things to tune ● innodb_stats_persistent=ON will store statistics between restarts so your servers does not have to re-learn the best way to run the query ● innodb_stats_auto_recalc (default on, 10%) will automatically redo stats after a limit of DML changes to a table ● Higher cardinality helps – Design your indexes accordingly!! ● See MySQL Manual 14.3.11.1 Configuring Persistent Optimizer Statistics Parameters for details ● Also add skip-name-resolve to keep bad DNS zone transfers from killing your application
  • 50. 50 ● Check return codes <?php // we connect to example.com and port 3307 $link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); Some Programming Advice
  • 51. 51 ● Check return codes // Create connection conn = new mysqli($servername, $username, $password, $dbname); / Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2"; if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . $conn->error; Some More Programming Advice
  • 52. 52 ● Scrub all data coming into your database – Less SQL Injection, more data integrity ● Think in SETs of data not ROWs – Let database do heavy lifting ● Try to write good SQL – Learn to use Visual Explain – Actively look to reduce/combine queries ● Use Sys Schema to find indexes not being used, redundant indexes and slow query log for queries that are running slow and without indexes Some Programming Advice
  • 54. 54 Books to Buy!!!!!! Bill Karwin SQL Antipatterns CJ Date SQL and Relational Theory
  • 55. 55 Q/A ● David.Stokes@Oracle.com ● OpenSourceDBA.Wordpress.com ● @Stoker ● Slideshare.net/davidmstokes ● https://joind.in/14913