SlideShare ist ein Scribd-Unternehmen logo
1 von 142
Downloaden Sie, um offline zu lesen
Frédéric Descamps
Community Manager
MySQL
From IOT to
MySQL HeatWave
Database Service in OCI
Oracle Pi Day - March 14th 2022
Who am I ?
about.me/lefred
Copyright @ 2022 Oracle and/or its affiliates.
2
@lefred
MySQL Evangelist
using MySQL since version 3.21
devops believer
living in
born at PiDay !
h ps://lefred.be
 
Frédéric Descamps
Copyright @ 2022 Oracle and/or its affiliates.
3
@lefred
MySQL Evangelist
using MySQL since version 3.21
devops believer
living in
born at PiDay !
h ps://lefred.be
 
Frédéric Descamps
Copyright @ 2022 Oracle and/or its affiliates.
3
IoT
the Internet of Things
Copyright @ 2022 Oracle and/or its affiliates.
4
IoT - the Internet of Things
The Internet of Things describes the network of physical objects—“things”—that are
embedded with sensors, software, and other technologies for the purpose of connecting
and exchanging data with other devices and systems over the internet.
These devices range from ordinary household objects to sophisticated industrial tools. With
more than 7 billion connected IoT devices today, experts are expecting this number to grow
to 22 billion by 2025.
Copyright @ 2022 Oracle and/or its affiliates.
5
MySQL
the most popular Open Source Relational Database
Management System
Copyright @ 2022 Oracle and/or its affiliates.
6
MySQL HeatWave
MySQL is the most popular Open Source Database and it's developed by Oracle.
MySQL is a relational database management system (RDMBS) but also a NoSQL Document
Store.
Copyright @ 2022 Oracle and/or its affiliates.
7
MySQL HeatWave
MySQL is the most popular Open Source Database and it's developed by Oracle.
MySQL is a relational database management system (RDMBS) but also a NoSQL Document
Store.
MySQL is also available in Oracle Cloud Inftrastructure (OCI) as a managed service.
HeatWave is a massively, high performance, in-memory query accelerator for OCI MySQL
Database Service that accelerates MySQL performance by orders of magnitude for
analytics and mixed workload.
Copyright @ 2022 Oracle and/or its affiliates.
7
Raspberry Pi
hardware & software
Copyright @ 2022 Oracle and/or its affiliates.
8
Hardware
A Raspberry Pi Model B:
Copyright @ 2022 Oracle and/or its affiliates.
9
Hardware
A DHT22 sensor providing mesure for temperature and humidity:
Copyright @ 2022 Oracle and/or its affiliates.
10
Hardware
This is the assembly schema:
Copyright @ 2022 Oracle and/or its affiliates.
11
Software
On the Raspberry the following packages are required:
Python
pip
mysql-connector-python (from pip)
Adafruit_Python_DHT (from pip)
Copyright @ 2022 Oracle and/or its affiliates.
12
Software
On the Raspberry the following packages are required:
Python
pip
mysql-connector-python (from pip)
Adafruit_Python_DHT (from pip)
We will also create our own program and a systemd script to manage it (start/stop/status):
metrics_to_MySQL.py
piday_metrics@.service
Copyright @ 2022 Oracle and/or its affiliates.
12
Architecture
Deploy our Database in OCI
Copyright @ 2022 Oracle and/or its affiliates.
13
OCI Architecture - simpli ed
Copyright @ 2022 Oracle and/or its affiliates.
14
Deploy in OCI
Once you have an Oracle Cloud account, you can just use the link on the next slide to
deploy the required architecture using a Oracle Resource Manager Stack (Terraform).
This will create all the necessary resources:
A VCN
The Public and Private Subnets
An Internet Gateway
The Security Lists
A compute instance with MySQL Router installed and con gured
A MySQL Database Service Instance
Copyright @ 2022 Oracle and/or its affiliates.
15
Deploy in OCI - Stack
h ps://github.com/lefred/oci-iot-mds
Copyright @ 2022 Oracle and/or its affiliates.
16
Deploy in OCI - Stack (2)
Copyright @ 2022 Oracle and/or its affiliates.
17
Deploy in OCI - Stack (3)
Copyright @ 2022 Oracle and/or its affiliates.
18
Deploy in OCI - Stack (4)
Copyright @ 2022 Oracle and/or its affiliates.
19
Deploy in OCI - Stack (5)
Copyright @ 2022 Oracle and/or its affiliates.
20
Deploy in OCI - Stack (6)
Copyright @ 2022 Oracle and/or its affiliates.
21
Deploy in OCI - Stack (7)
Copyright @ 2022 Oracle and/or its affiliates.
22
Deploy in OCI - Stack (8)
Copyright @ 2022 Oracle and/or its affiliates.
23
Deploy in OCI - Stack (9)
Copyright @ 2022 Oracle and/or its affiliates.
24
Deploy in OCI - Created Resources
Copyright @ 2022 Oracle and/or its affiliates.
25
Deploy in OCI - Created Resources (2)
Copyright @ 2022 Oracle and/or its affiliates.
26
Database Design
Schema, tables, collections, ... how to store the data?
Copyright @ 2022 Oracle and/or its affiliates.
27
MySQL 8.0
With MySQL 8.0, you can mix relational tables and JSON Documents.
Copyright @ 2022 Oracle and/or its affiliates.
28
MySQL 8.0
With MySQL 8.0, you can mix relational tables and JSON Documents.
SQL + NoSQL = MySQL Document Store
Copyright @ 2022 Oracle and/or its affiliates.
28
Built on the
MySQL JSON
Data type
and Proven
MySQL
Server
Technology
Provides a schema exible JSON Document Store
No SQL required
No need to de ne all possible a ributes, tables, etc.
Uses new X DevAPI (available on premise and in OCI only !)
Can leverage generated column to extract JSON values into materialized
columns that can be indexed for fast SQL searches.
Document can be ~1GB
It's a column in a row of a table
It cannot exceed max_allowed_packet
Allows use of modern programming styles
No more embedded strings of SQL in your code
Easy to read
Also works with relational Tables
Proven MySQL Technology
Copyright @ 2022 Oracle and/or its affiliates.
29
Design
name
short_name
temperature
humidity
public_ip
...
{ {
Copyright @ 2022 Oracle and/or its affiliates.
30
Design - explanations
For realtime (current) information, we use a collection of JSON documents where each
document represents the state of a device with the lastest values it collected.
For historical data generally used for analytics, we use relational tables that we will use later
with HeatWave if we need to improve the performance.
Copyright @ 2022 Oracle and/or its affiliates.
31
Design - connection to the MySQL Instance
We use port 6448 (X Protocol) on the Public IP of the Compute Instance where MySQL
Router is deployed.
Copyright @ 2022 Oracle and/or its affiliates.
32
Design - schema and collection creation
Copyright @ 2022 Oracle and/or its affiliates.
33
Design - relational tables creation
Copyright @ 2022 Oracle and/or its affiliates.
34
At some point, dealing with historical data
like archiving, deleting old records can
become a heavy operation.
HeatWave has been designed to deal with a
huge amount of data but on MySQL,
partitioning is a solution to deal with these
operations.
Design - relational tables creation
Copyright @ 2022 Oracle and/or its affiliates.
35
Design - relational tables creation: partitioning
SQL
SQL>
> alter
alter table
table humidity_history
humidity_history add
add day_date
day_date date
date as
as (
(date
date(
(time_stamp
time_stamp)
))
) stored
stored,
,
drop
drop primary
primary key
key,
, add
add primary
primary key
key (
(id
id,
, day_date
day_date)
);
;
SQL
SQL>
> alter
alter table
table humidity_history
humidity_history partition
partition by
by range
range columns
columns(
(day_date
day_date)
) (
(
partition
partition p0_before2022
p0_before2022 values
values less than
less than(
('2022-01-01'
'2022-01-01')
),
,
partition
partition p2022_01
p2022_01 values
values less than
less than(
('2022-02-01'
'2022-02-01')
),
,
partition
partition p2022_02
p2022_02 values
values less than
less than(
('2022-03-01'
'2022-03-01')
),
,
partition
partition p2022_03
p2022_03 values
values less than
less than(
('2022-04-01'
'2022-04-01')
),
,
partition
partition p2022_04
p2022_04 values
values less than
less than(
('2022-05-01'
'2022-05-01')
),
,
partition
partition p2022_05
p2022_05 values
values less than
less than(
('2022-06-01'
'2022-06-01')
),
,
.
..
..
.
partition
partition p2023_12
p2023_12 values
values less than
less than(
('2024-01-01'
'2024-01-01')
),
,
partition
partition p9_future
p9_future values
values less than
less than(
(maxvalue
maxvalue)
))
);
;
see h ps://dev.mysql.com/doc/refman/8.0/en/partitioning-management-range-list.html
Copyright @ 2022 Oracle and/or its affiliates.
36
Dedicated User
MySQL user creation
Copyright @ 2022 Oracle and/or its affiliates.
37
MySQL Dedicated User for IoT
It's a best practice that every applications use their own user to access MySQL.
In our case we will create one for all our devices.
We create a user with the required priveleges to write data from our Rasbperry Pi:
SQL
SQL>
> create
create user
user piday identified
piday identified with
with 'mysql_native_password'
'mysql_native_password'
by
by 'Fred140376#'
'Fred140376#';
;
SQL
SQL>
> grant
grant select
select,
, insert
insert,
, update
update on
on piday
piday.
.*
* to
to piday
piday;
;
Copyright @ 2022 Oracle and/or its affiliates.
38
Collecting Data
from Raspberry Pi to MySQL
Copyright @ 2022 Oracle and/or its affiliates.
39
We need Adafruit_DHT module to read the sensor:
import
import Adafruit_DHT
Adafruit_DHT
sensor
sensor=
=Adafruit_DHT
Adafruit_DHT.
.DHT22
DHT22
gpio
gpio=
=4
4
humidity
humidity,
, temperature
temperature =
= Adafruit_DHT
Adafruit_DHT.
.read_retry
read_retry(
(sensor
sensor,
, gpio
gpio)
)
Reading from the Sensor
I am using Python on the Raspberry Pi.
Copyright @ 2022 Oracle and/or its affiliates.
40
Connection to MySQL
Of course all the connectors maintained by Oracle MySQL support the X Dev API
Copyright @ 2022 Oracle and/or its affiliates.
41
Connection to MySQL - Python
import
import mysqlx
mysqlx
connect_args
connect_args =
= {
{
'host'
'host':
: '130.61.38.177'
'130.61.38.177',
,
'port'
'port':
: 6448
6448,
,
'user'
'user':
: 'piday'
'piday',
,
'password'
'password':
: 'Fred140376#'
'Fred140376#',
,
'ssl-mode'
'ssl-mode':
: 'DISABLED'
'DISABLED',
,
}
};
;
session
session =
= mysqlx
mysqlx.
.get_session
get_session(
(**
**connect_args
connect_args)
)
Copyright @ 2022 Oracle and/or its affiliates.
42
The code : /opt/PiDayMySQL/metrics_to_MySQL.py
import
import sys
sys
import
import time
time
import
import urllib
urllib.
.request
request
from
from datetime
datetime import
import datetime
datetime
import
import Adafruit_DHT
Adafruit_DHT
import
import mysqlx
mysqlx
rasbpy_id
rasbpy_id =
= "1"
"1"
if
if len
len(
(sys
sys.
.argv
argv)
) >
> 1
1:
:
rasbpy_id
rasbpy_id =
= str
str(
(sys
sys.
.argv
argv[
[1
1]
])
)
sensor
sensor =
= Adafruit_DHT
Adafruit_DHT.
.DHT22
DHT22
gpio
gpio =
= 4
4
Copyright @ 2022 Oracle and/or its affiliates.
43
The code : /opt/PiDayMySQL/metrics_to_MySQL.py (2)
connect_args
connect_args =
= {
{
'host'
'host':
: '130.61.46.6'
'130.61.46.6',
,
'port'
'port':
: 6448
6448,
,
'user'
'user':
: 'piday'
'piday',
,
'password'
'password':
: 'Fred140376#'
'Fred140376#',
,
'ssl-mode'
'ssl-mode':
: 'DISABLED'
'DISABLED',
,
'schema'
'schema':
: 'piday'
'piday'
}
};
;
Copyright @ 2022 Oracle and/or its affiliates.
44
The code : /opt/PiDayMySQL/metrics_to_MySQL.py (3)
def
def connect
connect(
()
):
:
global
global external_ip
external_ip
global
global session
session
global
global schema
schema
global
global tbl_temperature_history
tbl_temperature_history,
, tbl_humidity_history
tbl_humidity_history,
, tbl_publicip_history
tbl_publicip_history
global
global col_devices
col_devices
external_ip
external_ip =
= urllib
urllib.
.request
request.
.urlopen
urlopen(
(
'https://api.ipify.org'
'https://api.ipify.org')
).
.read
read(
()
).
.decode
decode(
('utf8'
'utf8')
)
session
session =
= mysqlx
mysqlx.
.get_session
get_session(
(**
**connect_args
connect_args)
)
schema
schema =
= session
session.
.get_schema
get_schema(
('piday'
'piday')
)
tbl_temperature_history
tbl_temperature_history =
= schema
schema.
.get_table
get_table(
('temperature_history'
'temperature_history')
)
tbl_humidity_history
tbl_humidity_history =
= schema
schema.
.get_table
get_table(
('humidity_history'
'humidity_history')
)
tbl_publicip_history
tbl_publicip_history =
= schema
schema.
.get_table
get_table(
('publicip_history'
'publicip_history')
)
col_devices
col_devices =
= schema
schema.
.get_collection
get_collection(
('devices'
'devices')
)
connect
connect(
()
)
Copyright @ 2022 Oracle and/or its affiliates.
45
The code : /opt/PiDayMySQL/metrics_to_MySQL.py (4)
while
while(
(True
True)
):
:
if
if not
not session
session.
.is_open
is_open(
()
):
:
connect
connect(
()
)
humidity
humidity,
, temperature
temperature =
= Adafruit_DHT
Adafruit_DHT.
.read_retry
read_retry(
(sensor
sensor,
, gpio
gpio)
)
if
if humidity
humidity is
is not
not None
None and
and temperature
temperature is
is not
not None
None:
:
# Find the device and its last ip
# Find the device and its last ip
res
res =
= col_devices
col_devices.
.find
find(
("_id='{}'"
"_id='{}'".
.format
format(
(rasbpy_id
rasbpy_id)
))
).
.fields
fields(
(
'_id'
'_id',
, 'publicip'
'publicip')
).
.execute
execute(
()
)
device
device =
= res
res.
.fetch_one
fetch_one(
()
)
if
if device
device:
:
old_public_ip
old_public_ip =
= device
device[
['publicip'
'publicip']
]
else
else:
:
print
print(
("device with _id: {} not found !"
"device with _id: {} not found !".
.format
format(
(rasbpy_id
rasbpy_id)
))
)
print
print(
("sleeping 1 min..."
"sleeping 1 min...")
)
time
time.
.sleep
sleep(
(60
60)
)
continue
continue
Copyright @ 2022 Oracle and/or its affiliates.
46
The code : /opt/PiDayMySQL/metrics_to_MySQL.py (5)
patch_json
patch_json =
= {
{}
}
humidity_s
humidity_s =
= "{0:0.1f}%"
"{0:0.1f}%".
.format
format(
(humidity
humidity)
)
temperature_s
temperature_s =
= "{0:0.1f}C"
"{0:0.1f}C".
.format
format(
(temperature
temperature)
)
patch_json
patch_json[
['humidity'
'humidity']
] =
= humidity_s
humidity_s
patch_json
patch_json[
['temperature'
'temperature']
] =
= temperature_s
temperature_s
patch_json
patch_json[
['publicip'
'publicip']
] =
= external_ip
external_ip
patch_json
patch_json[
['last_update'
'last_update']
] =
= datetime
datetime.
.now
now(
()
).
.strftime
strftime(
(
"%Y-%m-%d %H:%M:%S"
"%Y-%m-%d %H:%M:%S")
)
print
print(
('Temp={} Humidity={}'
'Temp={} Humidity={}'.
.format
format(
(temperature_s
temperature_s,
, humidity_s
humidity_s)
))
)
col_devices
col_devices.
.modify
modify(
("_id='{}'"
"_id='{}'".
.format
format(
(rasbpy_id
rasbpy_id)
)
)
).
.patch
patch(
(patch_json
patch_json)
).
.execute
execute(
()
)
if
if old_public_ip
old_public_ip !=
!= external_ip
external_ip:
:
tbl_publicip_history
tbl_publicip_history.
.insert
insert(
([
['device_id'
'device_id',
, 'ip_address'
'ip_address']
])
).
.values
values(
(
rasbpy_id
rasbpy_id,
, external_ip
external_ip)
).
.execute
execute(
()
)
Copyright @ 2022 Oracle and/or its affiliates.
47
The code : /opt/PiDayMySQL/metrics_to_MySQL.py (6)
tbl_temperature_history
tbl_temperature_history.
.insert
insert(
([
['time_stamp'
'time_stamp',
, 'device_id'
'device_id',
, 'value'
'value']
])
).
.values
values(
(
datetime
datetime.
.now
now(
()
).
.strftime
strftime(
("%Y-%m-%d %H:%M:%S"
"%Y-%m-%d %H:%M:%S")
),
,
rasbpy_id
rasbpy_id,
, temperature
temperature)
).
.execute
execute(
()
)
tbl_humidity_history
tbl_humidity_history.
.insert
insert(
([
['time_stamp'
'time_stamp',
, 'device_id'
'device_id',
, 'value'
'value']
])
).
.values
values(
(
datetime
datetime.
.now
now(
()
).
.strftime
strftime(
("%Y-%m-%d %H:%M:%S"
"%Y-%m-%d %H:%M:%S")
),
,
rasbpy_id
rasbpy_id,
, humidity
humidity)
).
.execute
execute(
()
)
else
else:
:
print
print(
('Failed to get reading. Try again!'
'Failed to get reading. Try again!')
)
time
time.
.sleep
sleep(
(1
1)
)
Copyright @ 2022 Oracle and/or its affiliates.
48
Systemd script
/etc/systemd/system/piday_metrics@.service
[Unit]
Description=Sending DHT22 metrics from Raspberry Pi to MySQL Database Service
After=network.target
[Service]
Type=simple
User=root
Restart=on-failure
ExecStart=/usr/bin/python /opt/PiDayMySQL/metrics_to_MySQL.py %s
[Install]
WantedBy=multi-user.target
Copyright @ 2022 Oracle and/or its affiliates.
49
Testing
running our script
Copyright @ 2022 Oracle and/or its affiliates.
50
Start the service on the Raspberry Pi
[
[raspberry ~
raspberry ~]
]$
$ sudo
sudo systemctl start piday_metrics@00006227543c0000000000000001
systemctl start piday_metrics@00006227543c0000000000000001
Copyright @ 2022 Oracle and/or its affiliates.
51
Start the service on the Raspberry Pi
[
[raspberry ~
raspberry ~]
]$
$ sudo
sudo systemctl start piday_metrics@00006227543c0000000000000001
systemctl start piday_metrics@00006227543c0000000000000001
Copyright @ 2022 Oracle and/or its affiliates.
51
Checking the data
Copyright @ 2022 Oracle and/or its affiliates.
52
Checking the data
without any single line of SQL ;-)
Copyright @ 2022 Oracle and/or its affiliates.
52
Improvements
using MQTT Broker
Copyright @ 2022 Oracle and/or its affiliates.
53
OCI Architectures - improved (1)
Copyright @ 2022 Oracle and/or its affiliates.
54
OCI Architectures - improved (2)
Copyright @ 2022 Oracle and/or its affiliates.
55
HeatWave
MySQL on Steroid
Copyright @ 2022 Oracle and/or its affiliates.
56
Analyzing the collected data
Let's get some statistics on the metrics we collected so far:
SQL
SQL >
> select
select *
* from
from (
(select
select device_id
device_id,
, max
max(
(value
value)
) as
as `
`max temp
max temp`
`,
, min
min(
(value
value)
) as
as `
`min temp
min temp`
`,
,
avg
avg(
(value
value)
) as
as `
`avg temp
avg temp`
` from
from temperature_history
temperature_history group
group by
by device_id
device_id)
) a
a
natural
natural join
join (
(select
select device_id
device_id,
, max
max(
(value
value)
) as
as `
`max humidity
max humidity`
`,
, min
min(
(value
value)
) as
as `
`min humidity
min humidity`
`,
,
avg
avg(
(value
value)
) as
as `
`avg humidity
avg humidity`
` from
from humidity_history
humidity_history group
group by
by device_id
device_id)
) b
b ;
;
+
+------------------------------+----------+----------+-----------+--------------+--------------+--------------+
------------------------------+----------+----------+-----------+--------------+--------------+--------------+
|
| device_id
device_id |
| max
max temp
temp |
| min
min temp
temp |
| avg
avg temp
temp |
| max humidity
max humidity |
| min humidity
min humidity |
| avg humidity
avg humidity |
|
+
+------------------------------+----------+----------+-----------+--------------+--------------+--------------+
------------------------------+----------+----------+-----------+--------------+--------------+--------------+
|
| 00006227543
00006227543c0000000000000001
c0000000000000001 |
| 142.94
142.94 |
| 9.00
9.00 |
| 11.711163
11.711163 |
| 169.86
169.86 |
| 40.00
40.00 |
| 45.206324
45.206324 |
|
|
| 00006227543
00006227543c0000000000000002
c0000000000000002 |
| 29.99
29.99 |
| 20.00
20.00 |
| 22.513379
22.513379 |
| 65.00
65.00 |
| 55.00
55.00 |
| 60.000385
60.000385 |
|
|
| 00006227543
00006227543c0000000000000003
c0000000000000003 |
| 814.36
814.36 |
| 0.00
0.00 |
| 3.114047
3.114047 |
| 800.21
800.21 |
| 1.00
1.00 |
| 6.609432
6.609432 |
|
|
| 00006227543
00006227543c0000000000000004
c0000000000000004 |
| 288.44
288.44 |
| 10.00
10.00 |
| 12.567651
12.567651 |
| 279.32
279.32 |
| 30.00
30.00 |
| 35.062746
35.062746 |
|
+
+------------------------------+----------+----------+-----------+--------------+--------------+--------------+
------------------------------+----------+----------+-----------+--------------+--------------+--------------+
4
4 rows
rows in
in set
set (
(2.0747
2.0747 sec
sec)
)
Copyright @ 2022 Oracle and/or its affiliates.
57
Get the Query Execution Plan
Let's have a look at the EXPLAIN plan (format=tree):
EXPLAIN
EXPLAIN:
: -
->
> Nested
Nested loop
loop inner
inner join
join (
(cost
cost=
=1348953.36
1348953.36 rows
rows=
=0
0)
)
-
->
> Filter:
Filter: (
(a
a.
.device_id
device_id is
is not
not null
null)
) (
(cost
cost=
=155455.11
155455.11.
..58090
.58090.86
.86 rows
rows=
=516341
516341)
)
-
->
> Table
Table scan
scan on
on a
a (
(cost
cost=
=0.01
0.01.
..6456
.6456.76
.76 rows
rows=
=516341
516341)
)
-
->
> Materialize
Materialize (
(cost
cost=
=155455.31
155455.31.
..161912
.161912.06
.06 rows
rows=
=516341
516341)
)
-
->
> Group
Group aggregate:
aggregate: max
max(
(temperature_history
temperature_history.
.`
`value
value`
`)
),
, min
min(
(temperature_history
temperature_history.
.`
`value
value`
`)
),
,
avg
avg(
(temperature_history
temperature_history.
.`
`value
value`
`)
) (
(cost
cost=
=103821.20
103821.20 rows
rows=
=516341
516341)
)
-
->
> Index
Index scan
scan on
on temperature_history
temperature_history using
using device_id_idx
device_id_idx (
(cost
cost=
=52187.10
52187.10 rows
rows=
=516341
516341)
)
-
->
> Index
Index lookup
lookup on
on b
b using
using <
<auto_key0
auto_key0>
> (
(device_id
device_id=
=a
a.
.device_id
device_id)
)
-
->
> Materialize
Materialize (
(cost
cost=
=0.00
0.00.
..0
.0.00
.00 rows
rows=
=0
0)
)
-
->
> Table
Table scan
scan on
on <
<temporary
temporary>
>
-
->
> Aggregate
Aggregate using
using temporary
temporary table
table
-
->
> Table
Table scan
scan on
on humidity_history
humidity_history (
(cost
cost=
=52191.40
52191.40 rows
rows=
=516384
516384)
)
Copyright @ 2022 Oracle and/or its affiliates.
58
Analyzing the collected data (2)
SQL
SQL >
> select
select *
* from
from (
(
select
select date
date(
(time_stamp
time_stamp)
) as
as `
`day
day`
`,
, device_id
device_id,
, count
count(
(*
*)
) as
as `
`tot
tot`
`,
,
max
max(
(value
value)
) as
as `
`max hum
max hum`
`,
, min
min(
(value
value)
) as
as `
`min hum
min hum`
`,
, avg
avg(
(value
value)
) as
as `
`avg hum
avg hum`
`
from
from humidity_history
humidity_history group
group by
by device_id
device_id,
, day
day)
) a
a
natural
natural join
join (
(
select
select date
date(
(time_stamp
time_stamp)
) as
as `
`day
day`
`,
, device_id
device_id,
, count
count(
(*
*)
) as
as `
`tot
tot`
`,
,
max
max(
(value
value)
) as
as `
`max temp
max temp`
`,
, min
min(
(value
value)
) as
as `
`min temp
min temp`
`,
, avg
avg(
(value
value)
) as
as `
`avg temp
avg temp`
`
from
from temperature_history
temperature_history group
group by
by device_id
device_id,
, day
day)
) b
b order
order by
by day
day,
, device_id
device_id;
;
+
+------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+
------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+
|
| day
day |
| device_id
device_id |
| tot
tot |
| max hum
max hum |
| min hum
min hum |
| avg hum
avg hum |
| max
max temp
temp |
| min
min temp
temp |
| avg
avg temp
temp |
|
+
+------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+
------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+
|
| 2022
2022-
-03
03-
-09
09 |
| 00006227543
00006227543c0000000000000002
c0000000000000002 |
| 14534
14534 |
| 65.00
65.00 |
| 55.00
55.00 |
| 60.009273
60.009273 |
| 29.99
29.99 |
| 20.00
20.00 |
| 22.597118
22.597118 |
|
|
| 2022
2022-
-03
03-
-09
09 |
| 00006227543
00006227543c0000000000000003
c0000000000000003 |
| 31605
31605 |
| 800.21
800.21 |
| 1.00
1.00 |
| 8.570861
8.570861 |
| 814.36
814.36 |
| 0.00
0.00 |
| 5.079733
5.079733 |
|
|
| 2022
2022-
-03
03-
-09
09 |
| 00006227543
00006227543c0000000000000004
c0000000000000004 |
| 31284
31284 |
| 279.32
279.32 |
| 30.00
30.00 |
| 35.294440
35.294440 |
| 288.44
288.44 |
| 10.00
10.00 |
| 12.797445
12.797445 |
|
|
| 2022
2022-
-03
03-
-10
10 |
| 00006227543
00006227543c0000000000000001
c0000000000000001 |
| 114906
114906 |
| 50.00
50.00 |
| 40.00
40.00 |
| 45.001613
45.001613 |
| 14.00
14.00 |
| 9.00
9.00 |
| 11.499796
11.499796 |
|
|
| 2022
2022-
-03
03-
-10
10 |
| 00006227543
00006227543c0000000000000002
c0000000000000002 |
| 100913
100913 |
| 65.00
65.00 |
| 55.00
55.00 |
| 59.999105
59.999105 |
| 25.00
25.00 |
| 20.00
20.00 |
| 22.501319
22.501319 |
|
|
| 2022
2022-
-03
03-
-10
10 |
| 00006227543
00006227543c0000000000000003
c0000000000000003 |
| 101465
101465 |
| 11.00
11.00 |
| 1.00
1.00 |
| 5.998472
5.998472 |
| 5.00
5.00 |
| 0.00
0.00 |
| 2.501763
2.501763 |
|
|
| 2022
2022-
-03
03-
-10
10 |
| 00006227543
00006227543c0000000000000004
c0000000000000004 |
| 101044
101044 |
| 40.00
40.00 |
| 30.00
30.00 |
| 34.991012
34.991012 |
| 15.00
15.00 |
| 10.00
10.00 |
| 12.496505
12.496505 |
|
+
+------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+
------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+
7
7 rows
rows in
in set
set (
(1.2717
1.2717 sec
sec)
)
Copyright @ 2022 Oracle and/or its affiliates.
59
Get the Query Execution Plan (2)
EXPLAIN
EXPLAIN:
: -
->
> Sort: a
Sort: a.
.`
`day
day`
`,
, a
a.
.device_id
device_id
-
->
> Stream results
Stream results (
(cost
cost=
=1374880.15
1374880.15 rows
rows=
=0
0)
)
-
->
> Nested
Nested loop
loop inner
inner join
join (
(cost
cost=
=1374880.15
1374880.15 rows
rows=
=0
0)
)
-
->
> Filter:
Filter: (
((
(b
b.
.`
`day
day`
` is
is not
not null
null)
) and
and (
(b
b.
.device_id
device_id is
is not
not null
null)
))
) (
(cost
cost=
=0.11
0.11.
..59207
.59207.65
.65 rows
rows=
=526268
526268)
)
-
->
> Table
Table scan
scan on
on b
b (
(cost
cost=
=2.50
2.50.
..2
.2.50
.50 rows
rows=
=0
0)
)
-
->
> Materialize
Materialize (
(cost
cost=
=2.50
2.50.
..2
.2.50
.50 rows
rows=
=0
0)
)
-
->
> Table
Table scan
scan on
on <
<temporary
temporary>
>
-
->
> Aggregate
Aggregate using
using temporary
temporary table
table
-
->
> Table
Table scan
scan on
on temperature_history
temperature_history (
(cost
cost=
=53179.80
53179.80 rows
rows=
=526268
526268)
)
-
->
> Index
Index lookup
lookup on
on a
a using
using <
<auto_key0
auto_key0>
> (
(day
day=
=b
b.
.`
`day
day`
`,
, device_id
device_id=
=b
b.
.device_id
device_id,
, tot
tot=
=b
b.
.tot
tot)
)
-
->
> Materialize
Materialize (
(cost
cost=
=0.00
0.00.
..0
.0.00
.00 rows
rows=
=0
0)
)
-
->
> Table
Table scan
scan on
on <
<temporary
temporary>
>
-
->
> Aggregate
Aggregate using
using temporary
temporary table
table
-
->
> Table
Table scan
scan on
on humidity_history
humidity_history (
(cost
cost=
=53184.10
53184.10 rows
rows=
=526311
526311)
)
Copyright @ 2022 Oracle and/or its affiliates.
60
Enable HeatWave
Let's boost MySQL's performance with HeatWave !
We have two options to enable HeatWave:
. Editing the Stack (if we used OCI Resoure Manager)
. Using MySQL Database Service's console
Copyright @ 2022 Oracle and/or its affiliates.
61
Enable HeatWave - with Stack
Copyright @ 2022 Oracle and/or its affiliates.
62
Enable HeatWave - with Stack (2)
Copyright @ 2022 Oracle and/or its affiliates.
63
Enable HeatWave - with Stack (3)
Copyright @ 2022 Oracle and/or its affiliates.
64
Enable HeatWave - with MDS Console
Copyright @ 2022 Oracle and/or its affiliates.
65
Enable HeatWave - with MDS Console (2)
Copyright @ 2022 Oracle and/or its affiliates.
66
Enable HeatWave - with MDS Console (3)
Copyright @ 2022 Oracle and/or its affiliates.
67
Enable HeatWave - with MDS Console (4)
Copyright @ 2022 Oracle and/or its affiliates.
68
SQL
SQL >
> show
show global
global status
status like
like 'rapid_%er%_status'
'rapid_%er%_status';
;
+
+----------------------+--------+
----------------------+--------+
|
| Variable_name
Variable_name |
| Value
Value |
|
+
+----------------------+--------+
----------------------+--------+
|
| rapid_cluster_status
rapid_cluster_status |
| ON
ON |
|
|
| rapid_service_status
rapid_service_status |
| ONLINE
ONLINE |
|
+
+----------------------+--------+
----------------------+--------+
HeatWave Ready
Copyright @ 2022 Oracle and/or its affiliates.
69
Load Data to HeatWave
We now use the load command printed during the Estimate Node Count step:
SQL
SQL >
> CALL
CALL sys
sys.
.heatwave_load
heatwave_load(
(JSON_ARRAY
JSON_ARRAY(
('piday'
'piday')
),
, NULL
NULL)
);
;
Copyright @ 2022 Oracle and/or its affiliates.
70
Load Data to HeatWave (2)
This operation returns a report:
.
..
..
.
+
+-------------------------------------------------------------------------------+
-------------------------------------------------------------------------------+
|
| LOAD
LOAD SUMMARY
SUMMARY |
|
+
+-------------------------------------------------------------------------------+
-------------------------------------------------------------------------------+
|
| |
|
|
| SCHEMA
SCHEMA TABLES
TABLES TABLES
TABLES COLUMNS
COLUMNS LOAD
LOAD |
|
|
| NAME LOADED FAILED LOADED DURATION
NAME LOADED FAILED LOADED DURATION |
|
|
| ------ ------ ------ ------- -------- |
------ ------ ------ ------- -------- |
|
| `
`piday
piday`
` 3
3 0
0 12
12 1.84
1.84 s
s |
|
|
| |
|
+
+-------------------------------------------------------------------------------+
-------------------------------------------------------------------------------+
6
6 rows
rows in
in set
set (
(1.9237
1.9237 sec
sec)
)
Copyright @ 2022 Oracle and/or its affiliates.
71
... and now ?
SQL
SQL >
> select
select *
* from
from (
(select
select device_id
device_id,
, max
max(
(value
value)
) as
as `
`max temp
max temp`
`,
, min
min(
(value
value)
) as
as `
`min temp
min temp`
`,
,
avg
avg(
(value
value)
) as
as `
`avg temp
avg temp`
` from
from temperature_history
temperature_history group
group by
by device_id
device_id)
) a
a
natural
natural join
join (
(select
select device_id
device_id,
, max
max(
(value
value)
) as
as `
`max humidity
max humidity`
`,
, min
min(
(value
value)
) as
as `
`min humidity
min humidity`
`,
,
avg
avg(
(value
value)
) as
as `
`avg humidity
avg humidity`
` from
from humidity_history
humidity_history group
group by
by device_id
device_id)
) b
b ;
;
+
+------------------------------+----------+----------+-----------+--------------+--------------+--------------+
------------------------------+----------+----------+-----------+--------------+--------------+--------------+
|
| device_id
device_id |
| max
max temp
temp |
| min
min temp
temp |
| avg
avg temp
temp |
| max humidity
max humidity |
| min humidity
min humidity |
| avg humidity
avg humidity |
|
+
+------------------------------+----------+----------+-----------+--------------+--------------+--------------+
------------------------------+----------+----------+-----------+--------------+--------------+--------------+
|
| 00006227543
00006227543c0000000000000003
c0000000000000003 |
| 814.36
814.36 |
| 0.00
0.00 |
| 3.114047
3.114047 |
| 800.21
800.21 |
| 1.00
1.00 |
| 6.609431
6.609431 |
|
|
| 00006227543
00006227543c0000000000000001
c0000000000000001 |
| 142.94
142.94 |
| 9.00
9.00 |
| 11.708011
11.708011 |
| 169.86
169.86 |
| 40.00
40.00 |
| 45.203256
45.203256 |
|
|
| 00006227543
00006227543c0000000000000002
c0000000000000002 |
| 29.99
29.99 |
| 20.00
20.00 |
| 22.513379
22.513379 |
| 65.00
65.00 |
| 55.00
55.00 |
| 60.000384
60.000384 |
|
|
| 00006227543
00006227543c0000000000000004
c0000000000000004 |
| 288.44
288.44 |
| 10.00
10.00 |
| 12.567650
12.567650 |
| 279.32
279.32 |
| 30.00
30.00 |
| 35.062746
35.062746 |
|
+
+------------------------------+----------+----------+-----------+--------------+--------------+--------------+
------------------------------+----------+----------+-----------+--------------+--------------+--------------+
4
4 rows
rows in
in set
set (
(0.1049
0.1049 sec
sec)
)
Copyright @ 2022 Oracle and/or its affiliates.
72
... and now ?
SQL
SQL >
> select
select *
* from
from (
(select
select device_id
device_id,
, max
max(
(value
value)
) as
as `
`max temp
max temp`
`,
, min
min(
(value
value)
) as
as `
`min temp
min temp`
`,
,
avg
avg(
(value
value)
) as
as `
`avg temp
avg temp`
` from
from temperature_history
temperature_history group
group by
by device_id
device_id)
) a
a
natural
natural join
join (
(select
select device_id
device_id,
, max
max(
(value
value)
) as
as `
`max humidity
max humidity`
`,
, min
min(
(value
value)
) as
as `
`min humidity
min humidity`
`,
,
avg
avg(
(value
value)
) as
as `
`avg humidity
avg humidity`
` from
from humidity_history
humidity_history group
group by
by device_id
device_id)
) b
b ;
;
+
+------------------------------+----------+----------+-----------+--------------+--------------+--------------+
------------------------------+----------+----------+-----------+--------------+--------------+--------------+
|
| device_id
device_id |
| max
max temp
temp |
| min
min temp
temp |
| avg
avg temp
temp |
| max humidity
max humidity |
| min humidity
min humidity |
| avg humidity
avg humidity |
|
+
+------------------------------+----------+----------+-----------+--------------+--------------+--------------+
------------------------------+----------+----------+-----------+--------------+--------------+--------------+
|
| 00006227543
00006227543c0000000000000003
c0000000000000003 |
| 814.36
814.36 |
| 0.00
0.00 |
| 3.114047
3.114047 |
| 800.21
800.21 |
| 1.00
1.00 |
| 6.609431
6.609431 |
|
|
| 00006227543
00006227543c0000000000000001
c0000000000000001 |
| 142.94
142.94 |
| 9.00
9.00 |
| 11.708011
11.708011 |
| 169.86
169.86 |
| 40.00
40.00 |
| 45.203256
45.203256 |
|
|
| 00006227543
00006227543c0000000000000002
c0000000000000002 |
| 29.99
29.99 |
| 20.00
20.00 |
| 22.513379
22.513379 |
| 65.00
65.00 |
| 55.00
55.00 |
| 60.000384
60.000384 |
|
|
| 00006227543
00006227543c0000000000000004
c0000000000000004 |
| 288.44
288.44 |
| 10.00
10.00 |
| 12.567650
12.567650 |
| 279.32
279.32 |
| 30.00
30.00 |
| 35.062746
35.062746 |
|
+
+------------------------------+----------+----------+-----------+--------------+--------------+--------------+
------------------------------+----------+----------+-----------+--------------+--------------+--------------+
4
4 rows
rows in
in set
set (
(0.1049
0.1049 sec
sec)
)
from 2.0747 sec to 0.1049 sec !!
20x faster !
Copyright @ 2022 Oracle and/or its affiliates.
72
the second example:
SQL
SQL >
> select
select *
* from
from (
(
select
select date
date(
(time_stamp
time_stamp)
) as
as `
`day
day`
`,
, device_id
device_id,
, count
count(
(*
*)
) as
as `
`tot
tot`
`,
,
max
max(
(value
value)
) as
as `
`max hum
max hum`
`,
, min
min(
(value
value)
) as
as `
`min hum
min hum`
`,
, avg
avg(
(value
value)
) as
as `
`avg hum
avg hum`
`
from
from humidity_history
humidity_history group
group by
by device_id
device_id,
, day
day)
) a
a
natural
natural join
join (
(
select
select date
date(
(time_stamp
time_stamp)
) as
as `
`day
day`
`,
, device_id
device_id,
, count
count(
(*
*)
) as
as `
`tot
tot`
`,
,
max
max(
(value
value)
) as
as `
`max temp
max temp`
`,
, min
min(
(value
value)
) as
as `
`min temp
min temp`
`,
, avg
avg(
(value
value)
) as
as `
`avg temp
avg temp`
`
from
from temperature_history
temperature_history group
group by
by device_id
device_id,
, day
day)
) b
b order
order by
by day
day,
, device_id
device_id;
;
+
+------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+
------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+
|
| day
day |
| device_id
device_id |
| tot
tot |
| max hum
max hum |
| min hum
min hum |
| avg hum
avg hum |
| max
max temp
temp |
| min
min temp
temp |
| avg
avg temp
temp |
|
+
+------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+
------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+
|
| 2022
2022-
-03
03-
-09
09 |
| 00006227543
00006227543c0000000000000002
c0000000000000002 |
| 14534
14534 |
| 65.00
65.00 |
| 55.00
55.00 |
| 60.009272
60.009272 |
| 29.99
29.99 |
| 20.00
20.00 |
| 22.597117
22.597117 |
|
|
| 2022
2022-
-03
03-
-09
09 |
| 00006227543
00006227543c0000000000000003
c0000000000000003 |
| 31605
31605 |
| 800.21
800.21 |
| 1.00
1.00 |
| 8.570860
8.570860 |
| 814.36
814.36 |
| 0.00
0.00 |
| 5.079732
5.079732 |
|
|
| 2022
2022-
-03
03-
-09
09 |
| 00006227543
00006227543c0000000000000004
c0000000000000004 |
| 31284
31284 |
| 279.32
279.32 |
| 30.00
30.00 |
| 35.294440
35.294440 |
| 288.44
288.44 |
| 10.00
10.00 |
| 12.797445
12.797445 |
|
|
| 2022
2022-
-03
03-
-10
10 |
| 00006227543
00006227543c0000000000000001
c0000000000000001 |
| 115609
115609 |
| 50.00
50.00 |
| 40.00
40.00 |
| 45.001736
45.001736 |
| 14.00
14.00 |
| 9.00
9.00 |
| 11.499157
11.499157 |
|
|
| 2022
2022-
-03
03-
-10
10 |
| 00006227543
00006227543c0000000000000002
c0000000000000002 |
| 100913
100913 |
| 65.00
65.00 |
| 55.00
55.00 |
| 59.999104
59.999104 |
| 25.00
25.00 |
| 20.00
20.00 |
| 22.501318
22.501318 |
|
|
| 2022
2022-
-03
03-
-10
10 |
| 00006227543
00006227543c0000000000000003
c0000000000000003 |
| 101465
101465 |
| 11.00
11.00 |
| 1.00
1.00 |
| 5.998472
5.998472 |
| 5.00
5.00 |
| 0.00
0.00 |
| 2.501762
2.501762 |
|
|
| 2022
2022-
-03
03-
-10
10 |
| 00006227543
00006227543c0000000000000004
c0000000000000004 |
| 101044
101044 |
| 40.00
40.00 |
| 30.00
30.00 |
| 34.991011
34.991011 |
| 15.00
15.00 |
| 10.00
10.00 |
| 12.496504
12.496504 |
|
+
+------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+
------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+
7
7 rows
rows in
in set
set (
(0.1267
0.1267 sec
sec)
)
Copyright @ 2022 Oracle and/or its affiliates.
73
More Data : more di erence !
Now let's use again the second example with more data (7 days):
Without HeatWave:
90
90 rows
rows in
in set
set (
(5
5 min
min 3.3237
3.3237 sec
sec)
)
Copyright @ 2022 Oracle and/or its affiliates.
74
More Data : more di erence !
Now let's use again the second example with more data (7 days):
Without HeatWave:
90
90 rows
rows in
in set
set (
(5
5 min
min 3.3237
3.3237 sec
sec)
)
With HeatWave:
90
90 rows
rows in
in set
set (
(0.8620
0.8620 sec
sec)
)
from 363.3237 sec to 0.8620 sec ! 421x faster !!
Copyright @ 2022 Oracle and/or its affiliates.
74
More Data : more di erence !
And this is with 5GB to parse:
SQL
SQL>
> select
select format_bytes
format_bytes(
(sum
sum(
(data_length
data_length)
))
) DATA
DATA,
,
format_bytes
format_bytes(
(sum
sum(
(index_length
index_length)
))
) INDEXES
INDEXES,
,
format_bytes
format_bytes(
(sum
sum(
(data_length
data_length +
+ index_length
index_length)
))
) 'TOTAL SIZE'
'TOTAL SIZE'
from
from information_schema
information_schema.
.TABLES
TABLES order
order by
by data_length
data_length +
+ index_length
index_length;
;
+
+----------+----------+------------+
----------+----------+------------+
|
| DATA
DATA |
| INDEXES
INDEXES |
| TOTAL SIZE
TOTAL SIZE |
|
+
+----------+----------+------------+
----------+----------+------------+
|
| 4.23
4.23 GiB
GiB |
| 1.37
1.37 GiB
GiB |
| 5.60
5.60 GiB
GiB |
|
+
+----------+----------+------------+
----------+----------+------------+
Copyright @ 2022 Oracle and/or its affiliates.
75
Without HeatWave:
44
44 rows
rows in
in set
set (
(10
10 min
min 14.1022
14.1022 sec
sec)
)
With HeatWave:
45
45 rows
rows in
in set
set (
(1.6051
1.6051 sec
sec)
)
Let's double the data:
+
+----------+----------+------------+
----------+----------+------------+
|
| DATA
DATA |
| INDEXES
INDEXES |
| TOTAL SIZE
TOTAL SIZE |
|
+
+----------+----------+------------+
----------+----------+------------+
|
| 8.66
8.66 GiB
GiB |
| 2.93
2.93 GiB
GiB |
| 11.59
11.59 GiB
GiB |
|
+
+----------+----------+------------+
----------+----------+------------+
69M ROWS
Copyright @ 2022 Oracle and/or its affiliates.
76
MySQL & HeatWave for your IoT Projects
Copyright @ 2022 Oracle and/or its affiliates.
77
MySQL & HeatWave
When having to deal with large amount of data for Analytics, this is the traditional
architecture:
Copyright @ 2022 Oracle and/or its affiliates.
78
MySQL & HeatWave - no more ETL required
Single MySQL database for OLTP & Analytics applications
All existing applications work without any changes
Extreme performance
Copyright @ 2022 Oracle and/or its affiliates.
79
MySQL & HeatWave - one solution !
Copyright @ 2022 Oracle and/or its affiliates.
80
Using HeatWave ?
SQL
SQL>
> show
show global
global status
status like
like 'rapid_query_offload_count'
'rapid_query_offload_count';
;
+
+---------------------------+-------+
---------------------------+-------+
|
| Variable_name
Variable_name |
| Value
Value |
|
+
+---------------------------+-------+
---------------------------+-------+
|
| rapid_query_offload_count
rapid_query_offload_count |
| 17
17 |
|
+
+---------------------------+-------+
---------------------------+-------+
The EXPLAIN command for a query will have the following value for Extra when using
HeatWave:
Using secondary engine RAPID
Using secondary engine RAPID
Copyright @ 2022 Oracle and/or its affiliates.
81
More with Autopilot Machine Learning
HeatWave includes several Autopilot processes, the following ones are avaible from the
SQL prompt when HeatWave is enabled:
Autopilot Encoding: Determines the optimal representation of columns loaded into
HeatWave by analyzing HeatWave query history, which improves query performance
and minimizes the required cluster size.
Autopilot Placement: Recommends how tables should be partitioned in memory to
achieve the best query performance, and estimates the expected performance
improvement
More Info: h ps://dev.mysql.com/doc/heatwave/en/heatwave-autopilot.html
Copyright @ 2022 Oracle and/or its affiliates.
82
More with Autopilot Machine Learning (2)
Autopilot Encoding:
CALL
CALL sys
sys.
.heatwave_advisor
heatwave_advisor(
(JSON_OBJECT
JSON_OBJECT(
("auto_enc"
"auto_enc",
,JSON_OBJECT
JSON_OBJECT(
("mode"
"mode",
, "recommend"
"recommend")
))
))
);
;
Autopilot Placement:
CALL
CALL sys
sys.
.heatwave_advisor
heatwave_advisor(
(JSON_OBJECT
JSON_OBJECT(
("target_schema"
"target_schema",
, JSON_ARRAY
JSON_ARRAY(
("piday"
"piday")
))
))
);
;
Copyright @ 2022 Oracle and/or its affiliates.
83
More with Autopilot Machine Learning (2)
Autopilot Encoding:
CALL
CALL sys
sys.
.heatwave_advisor
heatwave_advisor(
(JSON_OBJECT
JSON_OBJECT(
("auto_enc"
"auto_enc",
,JSON_OBJECT
JSON_OBJECT(
("mode"
"mode",
, "recommend"
"recommend")
))
))
);
;
Autopilot Placement:
CALL
CALL sys
sys.
.heatwave_advisor
heatwave_advisor(
(JSON_OBJECT
JSON_OBJECT(
("target_schema"
"target_schema",
, JSON_ARRAY
JSON_ARRAY(
("piday"
"piday")
))
))
);
;
Copyright @ 2022 Oracle and/or its affiliates.
83
HeatWave and Oracle Analytics Cloud
fast realtime analytics
Copyright @ 2022 Oracle and/or its affiliates.
84
Comprehensive cloud-native analytics
platform
Data visualization, data preparation,
data quality and data Flows
ML and AI embedded throughout
Natural language processing and
generation
Self upgrading, self patching, self
securing
Oracle Analytics Cloud
Complete Analytics Platform for Business Users, Developers and IT
Copyright @ 2022 Oracle and/or its affiliates.
85
Oracle Analytics Platform
Delivering at every stage of the analytics journey
Copyright @ 2022 Oracle and/or its affiliates.
86
For Data Connectivity, OAC supports…
Copyright @ 2022 Oracle and/or its affiliates.
87
From Multiple Native Connectors including
MySQL !
Creating a new connection to our MySQL
database instance:
Using Oracle Analytics Cloud with MySQL HeatWave
Copyright @ 2022 Oracle and/or its affiliates.
88
Using Oracle Analytics Cloud with MySQL HeatWave
Copyright @ 2022 Oracle and/or its affiliates.
89
For Data Modeling, OAC supports...
Copyright @ 2022 Oracle and/or its affiliates.
90
Now we can create our dataset:
Using Oracle Analytics Cloud with MySQL HeatWave
Copyright @ 2022 Oracle and/or its affiliates.
91
We search and select our connection
(piday):
Using Oracle Analytics Cloud with MySQL HeatWave
Copyright @ 2022 Oracle and/or its affiliates.
92
Using Oracle Analytics Cloud with MySQL HeatWave
Copyright @ 2022 Oracle and/or its affiliates.
93
Using Oracle Analytics Cloud with MySQL HeatWave
Copyright @ 2022 Oracle and/or its affiliates.
94
Using Oracle Analytics Cloud with MySQL HeatWave
We join using device_id eld:
Copyright @ 2022 Oracle and/or its affiliates.
95
Using Oracle Analytics Cloud with MySQL HeatWave
Copyright @ 2022 Oracle and/or its affiliates.
96
Using Oracle Analytics Cloud with MySQL HeatWave
Don't forget to specify that we want live data !
Copyright @ 2022 Oracle and/or its affiliates.
97
Using Oracle Analytics Cloud with MySQL HeatWave
Retrieving data from a JSON document in a collection.
Let's return the device_id as VARCHAR and its short_name using VIRTUAL COLUMNS:
SQL
SQL>
> alter
alter table
table devices
devices add
add device_id
device_id varchar
varchar(
(32
32)
)
generated always
generated always as
as (
(doc
doc-
->>
>>'$._id'
'$._id')
)
SQL
SQL>
> alter
alter table
table devices
devices add
add short_name
short_name varchar
varchar(
(20
20)
)
generated always
generated always as
as (
(doc
doc-
->>
>>'$.short_name'
'$.short_name')
);
;
Copyright @ 2022 Oracle and/or its affiliates.
98
Using Oracle Analytics Cloud with MySQL HeatWave
We can now retrieved them (and index them if needed) without having to use the special
JSON notation:
SQL
SQL>
> select
select device_id
device_id,
, short_name
short_name from
from devices
devices;
;
+
+------------------------------+------------+
------------------------------+------------+
|
| device_id
device_id |
| short_name
short_name |
|
+
+------------------------------+------------+
------------------------------+------------+
|
| 00006227543
00006227543c0000000000000001
c0000000000000001 |
| lefredPi
lefredPi |
|
|
| 00006227543
00006227543c0000000000000002
c0000000000000002 |
| fake01
fake01 |
|
|
| 00006227543
00006227543c0000000000000003
c0000000000000003 |
| fake02
fake02 |
|
|
| 00006227543
00006227543c0000000000000004
c0000000000000004 |
| fake03
fake03 |
|
+
+------------------------------+------------+
------------------------------+------------+
4
4 rows
rows in
in set
set (
(0.0284
0.0284 sec
sec)
)
Copyright @ 2022 Oracle and/or its affiliates.
99
Using Oracle Analytics Cloud with MySQL HeatWave
Copyright @ 2022 Oracle and/or its affiliates.
100
Using Oracle Analytics Cloud with MySQL HeatWave
Copyright @ 2022 Oracle and/or its affiliates.
101
Using Oracle Analytics Cloud with MySQL HeatWave
Copyright @ 2022 Oracle and/or its affiliates.
102
Using Oracle Analytics Cloud with MySQL HeatWave
Copyright @ 2022 Oracle and/or its affiliates.
103
For Data Preparation, OAC supports...
Copyright @ 2022 Oracle and/or its affiliates.
104
For Data Exploration, OAC supports...
Copyright @ 2022 Oracle and/or its affiliates.
105
For Data Visualization, OAC supports...
Copyright @ 2022 Oracle and/or its affiliates.
106
For Data Visualization, OAC supports... (2)
As a developer you could even check the performance parameters of your visualizations:
Copyright @ 2022 Oracle and/or its affiliates.
107
For Advances Analytics, OCA supports...
Copyright @ 2022 Oracle and/or its affiliates.
108
For Citizen Data Science, OAC supports...
Copyright @ 2022 Oracle and/or its affiliates.
109
For Collaboration, OAC Supports...
Copyright @ 2022 Oracle and/or its affiliates.
110
Using Oracle Analytics Cloud with MySQL HeatWave
Easy creation of real-time dashboard of all the data collected by the Raspberry Pi
Copyright @ 2022 Oracle and/or its affiliates.
111
Summary
our journey from IoT device to HeatWave and Analyitcs
Copyright @ 2022 Oracle and/or its affiliates.
112
Summary of our journey
Copyright @ 2022 Oracle and/or its affiliates.
113
Summary of our journey
We started from a simple Raspberry Pi
Copyright @ 2022 Oracle and/or its affiliates.
113
Summary of our journey
We started from a simple Raspberry Pi
We collected a lot of data
Copyright @ 2022 Oracle and/or its affiliates.
113
Summary of our journey
We started from a simple Raspberry Pi
We collected a lot of data
We ran queries super fast and were ready for Analitycs without any ETL service
Copyright @ 2022 Oracle and/or its affiliates.
113
Summary of our journey
We started from a simple Raspberry Pi
We collected a lot of data
We ran queries super fast and were ready for Analitycs without any ETL service
We used the limitless OAC capabilities to process, vizualize and forecast the data
Copyright @ 2022 Oracle and/or its affiliates.
113
Summary of our journey
We started from a simple Raspberry Pi
We collected a lot of data
We ran queries super fast and were ready for Analitycs without any ETL service
We used the limitless OAC capabilities to process, vizualize and forecast the data
and all this thanks to MySQL HeatWave !
Copyright @ 2022 Oracle and/or its affiliates.
113
Want more
Swag ?
Download a free trial
and get bonus swag on top of the Pi Day swag kit!
Copyright @ 2022 Oracle and/or its affiliates.
114
Once your email is whitelisted, go to bit.ly/piday-freetrial and click the Sign Up bu on
Copyright @ 2022 Oracle and/or its affiliates.
115
Click Verify my email bu on
Enter your Country/Territory, First Name, Last Name, and Email
Check the box if you are a human and complete the Captcha authentication
Copyright @ 2022 Oracle and/or its affiliates.
116
Click the Verify Email bu on
You will be presented with an o er for $500 in free credits, click the Select O er bu on
Go to the email account that was used to register for this event and look for the Oracle
Cloud email asking to verify the email address and create your Oracle account.
Copyright @ 2022 Oracle and/or its affiliates.
117
Enter required elds under Account
information
Read the Terms of Use and click the
Continue bu on
Copyright @ 2022 Oracle and/or its affiliates.
118
Enter your Address and Phone Number
Click the Continue bu on
Read the terms and conditions and
acknowledge the Agreement.
Click the Start my free trial bu on
Copyright @ 2022 Oracle and/or its affiliates.
119
Your Oracle Cloud Infrastructure (OCI) tenancy is now being provisioned.
Copyright @ 2022 Oracle and/or its affiliates.
120
Welcome to your Oracle Cloud Infrastructure (OCI) tenancy
Copyright @ 2022 Oracle and/or its affiliates.
121
Oracle Cloud Free Tier
bit.ly/piday-freetrial
Copyright @ 2022 Oracle and/or its affiliates.
122
Share our event!
#piday
#odevrel
#mysql
Join our slack channels!
bit.ly/odevrel-slack
bit.ly/mysql-slack
Copyright @ 2022 Oracle and/or its affiliates.
123
www.oracle.com/events/run-workloads-your-way-on-oci/
Copyright @ 2022 Oracle and/or its affiliates.
124
h ps://bit.ly/Pi-Quiz-2022
Test your Pi knowledge. ¶'s the limit.
Copyright @ 2022 Oracle and/or its affiliates.
125
Questions ?
Copyright @ 2022 Oracle and/or its affiliates.
126
Resources
h ps://github.com/lefred/oci-iot-mds
h ps://github.com/lefred/oracle-piday-2022
h ps://dev.mysql.com/doc/heatwave/en/
h ps://www.mysql.com/cloud/
h ps://www.oracle.com/in/business-analytics/data-visualization/examples.html
h ps://www.oracle.com/in/business-analytics
Copyright @ 2022 Oracle and/or its affiliates.
127
Resources (2)
Try a Live Lab: MySQL Database Service powered by HeatWave and Oracle Analytics Cloud:
h ps://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/workshop-a endee-2?
p210_workshop_id=870&p210_type=1&session=2731606019312
Copyright @ 2022 Oracle and/or its affiliates.
128

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesMySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
 
MySQL InnoDB Cluster / ReplicaSet - Making Provisioning & Troubleshooting as ...
MySQL InnoDB Cluster / ReplicaSet - Making Provisioning & Troubleshooting as ...MySQL InnoDB Cluster / ReplicaSet - Making Provisioning & Troubleshooting as ...
MySQL InnoDB Cluster / ReplicaSet - Making Provisioning & Troubleshooting as ...
 
Percona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL ArchitecturesPercona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL Architectures
 
PostgreSQL 15の新機能を徹底解説
PostgreSQL 15の新機能を徹底解説PostgreSQL 15の新機能を徹底解説
PostgreSQL 15の新機能を徹底解説
 
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
 
Oracle Data Guard による高可用性
Oracle Data Guard による高可用性Oracle Data Guard による高可用性
Oracle Data Guard による高可用性
 
DataOpsbarcelona 2019: Deep dive into MySQL Group Replication... the magic e...
DataOpsbarcelona 2019:  Deep dive into MySQL Group Replication... the magic e...DataOpsbarcelona 2019:  Deep dive into MySQL Group Replication... the magic e...
DataOpsbarcelona 2019: Deep dive into MySQL Group Replication... the magic e...
 
MySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & OperationsMySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & Operations
 
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera ) Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
 
Percona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio CodePercona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio Code
 
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdfMySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
 
Percona Live 2022 - The Evolution of a MySQL Database System
Percona Live 2022 - The Evolution of a MySQL Database SystemPercona Live 2022 - The Evolution of a MySQL Database System
Percona Live 2022 - The Evolution of a MySQL Database System
 
State of the Dolphin - May 2022
State of the Dolphin - May 2022State of the Dolphin - May 2022
State of the Dolphin - May 2022
 
Apache Spark on Kubernetes入門(Open Source Conference 2021 Online Hiroshima 発表資料)
Apache Spark on Kubernetes入門(Open Source Conference 2021 Online Hiroshima 発表資料)Apache Spark on Kubernetes入門(Open Source Conference 2021 Online Hiroshima 発表資料)
Apache Spark on Kubernetes入門(Open Source Conference 2021 Online Hiroshima 発表資料)
 
Rancher/Kubernetes入門ハンズオン資料~第2回さくらとコンテナの夕べ #さくらの夕べ 番外編
 Rancher/Kubernetes入門ハンズオン資料~第2回さくらとコンテナの夕べ #さくらの夕べ 番外編 Rancher/Kubernetes入門ハンズオン資料~第2回さくらとコンテナの夕べ #さくらの夕べ 番外編
Rancher/Kubernetes入門ハンズオン資料~第2回さくらとコンテナの夕べ #さくらの夕べ 番外編
 
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group ReplicationPercona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
 
監査ログをもっと身近に!〜統合監査のすすめ〜
監査ログをもっと身近に!〜統合監査のすすめ〜監査ログをもっと身近に!〜統合監査のすすめ〜
監査ログをもっと身近に!〜統合監査のすすめ〜
 
PostgreSQLのfull_page_writesについて(第24回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQLのfull_page_writesについて(第24回PostgreSQLアンカンファレンス@オンライン 発表資料)PostgreSQLのfull_page_writesについて(第24回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQLのfull_page_writesについて(第24回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
S13 Oracle Database を Microsoft Azure 上で運用する為に~基本事項とベストプラクティス
S13 Oracle Database を Microsoft Azure 上で運用する為に~基本事項とベストプラクティスS13 Oracle Database を Microsoft Azure 上で運用する為に~基本事項とベストプラクティス
S13 Oracle Database を Microsoft Azure 上で運用する為に~基本事項とベストプラクティス
 
え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理
え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理
え、まって。その並列分散処理、Kafkaのしくみでもできるの? Apache Kafkaの機能を利用した大規模ストリームデータの並列分散処理
 

Ähnlich wie Pi Day 2022 - from IoT to MySQL HeatWave Database Service

Streaming Data Into Your Lakehouse With Frank Munz | Current 2022
Streaming Data Into Your Lakehouse With Frank Munz | Current 2022Streaming Data Into Your Lakehouse With Frank Munz | Current 2022
Streaming Data Into Your Lakehouse With Frank Munz | Current 2022
HostedbyConfluent
 

Ähnlich wie Pi Day 2022 - from IoT to MySQL HeatWave Database Service (20)

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
 
MySQL Tech Café #8: MySQL 8.0 for Python Developers
MySQL Tech Café #8: MySQL 8.0 for Python DevelopersMySQL Tech Café #8: MySQL 8.0 for Python Developers
MySQL Tech Café #8: MySQL 8.0 for Python Developers
 
the State of the Dolphin - October 2020
the State of the Dolphin - October 2020the State of the Dolphin - October 2020
the State of the Dolphin - October 2020
 
Oracle Database Migration to Oracle Cloud Infrastructure
Oracle Database Migration to Oracle Cloud InfrastructureOracle Database Migration to Oracle Cloud Infrastructure
Oracle Database Migration to Oracle Cloud Infrastructure
 
MySQL Database Service Webinar: Upgrading from on-premise MySQL to MDS
MySQL Database Service Webinar: Upgrading from on-premise MySQL to MDSMySQL Database Service Webinar: Upgrading from on-premise MySQL to MDS
MySQL Database Service Webinar: Upgrading from on-premise MySQL to MDS
 
Oracle Cloud Infrastructure Data Science 概要資料(20200406)
Oracle Cloud Infrastructure Data Science 概要資料(20200406)Oracle Cloud Infrastructure Data Science 概要資料(20200406)
Oracle Cloud Infrastructure Data Science 概要資料(20200406)
 
MySQL Database Service Webinar: Installing Drupal in oci with mds
MySQL Database Service Webinar: Installing Drupal in oci with mdsMySQL Database Service Webinar: Installing Drupal in oci with mds
MySQL Database Service Webinar: Installing Drupal in oci with mds
 
Master Real-Time Streams With Neo4j and Apache Kafka
Master Real-Time Streams With Neo4j and Apache KafkaMaster Real-Time Streams With Neo4j and Apache Kafka
Master Real-Time Streams With Neo4j and Apache Kafka
 
MySQL Cluster 8.0 tutorial
MySQL Cluster 8.0 tutorialMySQL Cluster 8.0 tutorial
MySQL Cluster 8.0 tutorial
 
Data relay introduction to big data clusters
Data relay introduction to big data clustersData relay introduction to big data clusters
Data relay introduction to big data clusters
 
Oracle Database 最新情報(Oracle Cloudウェビナーシリーズ: 2020年6月25日)
Oracle Database 最新情報(Oracle Cloudウェビナーシリーズ: 2020年6月25日)Oracle Database 最新情報(Oracle Cloudウェビナーシリーズ: 2020年6月25日)
Oracle Database 最新情報(Oracle Cloudウェビナーシリーズ: 2020年6月25日)
 
State of the Dolphin 2020 - 25th Anniversary of MySQL with 8.0.20
State of the Dolphin 2020 - 25th Anniversary of MySQL with 8.0.20State of the Dolphin 2020 - 25th Anniversary of MySQL with 8.0.20
State of the Dolphin 2020 - 25th Anniversary of MySQL with 8.0.20
 
Oracle Cloud Infrastructure:2020年6月度サービス・アップデート
Oracle Cloud Infrastructure:2020年6月度サービス・アップデートOracle Cloud Infrastructure:2020年6月度サービス・アップデート
Oracle Cloud Infrastructure:2020年6月度サービス・アップデート
 
Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0
 
Streaming Data Into Your Lakehouse With Frank Munz | Current 2022
Streaming Data Into Your Lakehouse With Frank Munz | Current 2022Streaming Data Into Your Lakehouse With Frank Munz | Current 2022
Streaming Data Into Your Lakehouse With Frank Munz | Current 2022
 
SQL Server 2019 Big Data Cluster
SQL Server 2019 Big Data ClusterSQL Server 2019 Big Data Cluster
SQL Server 2019 Big Data Cluster
 
Neo4j: The path to success with Graph Database and Graph Data Science
Neo4j: The path to success with Graph Database and Graph Data ScienceNeo4j: The path to success with Graph Database and Graph Data Science
Neo4j: The path to success with Graph Database and Graph Data Science
 
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
 
AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...
AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...
AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...
 
002 Introducing Neo4j 5 for Administrators - NODES2022 AMERICAS Beginner 2 - ...
002 Introducing Neo4j 5 for Administrators - NODES2022 AMERICAS Beginner 2 - ...002 Introducing Neo4j 5 for Administrators - NODES2022 AMERICAS Beginner 2 - ...
002 Introducing Neo4j 5 for Administrators - NODES2022 AMERICAS Beginner 2 - ...
 

Mehr von Frederic Descamps

Mehr von Frederic Descamps (17)

MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
 
RivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and HistogramsRivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and Histograms
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and Histograms
 
Confoo 2022 - le cycle d'une instance MySQL
Confoo 2022  - le cycle d'une instance MySQLConfoo 2022  - le cycle d'une instance MySQL
Confoo 2022 - le cycle d'une instance MySQL
 
Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0
 
State of The Dolphin - May 2021
State of The Dolphin - May 2021State of The Dolphin - May 2021
State of The Dolphin - May 2021
 
MySQL Shell for DBAs
MySQL Shell for DBAsMySQL Shell for DBAs
MySQL Shell for DBAs
 
Deploying Magento on OCI with MDS
Deploying Magento on OCI with MDSDeploying Magento on OCI with MDS
Deploying Magento on OCI with MDS
 
MySQL Router REST API
MySQL Router REST APIMySQL Router REST API
MySQL Router REST API
 
From single MySQL instance to High Availability: the journey to MySQL InnoDB ...
From single MySQL instance to High Availability: the journey to MySQL InnoDB ...From single MySQL instance to High Availability: the journey to MySQL InnoDB ...
From single MySQL instance to High Availability: the journey to MySQL InnoDB ...
 
Cloud native - Why to use MySQL 8.0 and how to use it on oci with MDS
Cloud native -  Why to use MySQL 8.0 and how to use it on oci with MDSCloud native -  Why to use MySQL 8.0 and how to use it on oci with MDS
Cloud native - Why to use MySQL 8.0 and how to use it on oci with MDS
 
MySQL 8.0 Document Store - Discovery of a New World
MySQL 8.0 Document Store - Discovery of a New WorldMySQL 8.0 Document Store - Discovery of a New World
MySQL 8.0 Document Store - Discovery of a New World
 
Oracle Developer Live: Deploying MySQL InnoDB Cluster on OCI with Terraform
Oracle Developer Live: Deploying MySQL InnoDB Cluster on OCI with TerraformOracle Developer Live: Deploying MySQL InnoDB Cluster on OCI with Terraform
Oracle Developer Live: Deploying MySQL InnoDB Cluster on OCI with Terraform
 
MySQL Database Service Webinar - Installing WordPress in OCI with MDS
MySQL Database Service Webinar - Installing WordPress in OCI with MDSMySQL Database Service Webinar - Installing WordPress in OCI with MDS
MySQL Database Service Webinar - Installing WordPress in OCI with MDS
 
MySQL Day Virtual: Best Practices Tips - Upgrading to MySQL 8.0
MySQL Day Virtual: Best Practices Tips - Upgrading to MySQL 8.0MySQL Day Virtual: Best Practices Tips - Upgrading to MySQL 8.0
MySQL Day Virtual: Best Practices Tips - Upgrading to MySQL 8.0
 
OpenExpo Virtual Experience 2020: MySQL 8.0 Document Store - Discovery of a n...
OpenExpo Virtual Experience 2020: MySQL 8.0 Document Store - Discovery of a n...OpenExpo Virtual Experience 2020: MySQL 8.0 Document Store - Discovery of a n...
OpenExpo Virtual Experience 2020: MySQL 8.0 Document Store - Discovery of a n...
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

Pi Day 2022 - from IoT to MySQL HeatWave Database Service

  • 1. Frédéric Descamps Community Manager MySQL From IOT to MySQL HeatWave Database Service in OCI Oracle Pi Day - March 14th 2022
  • 2. Who am I ? about.me/lefred Copyright @ 2022 Oracle and/or its affiliates. 2
  • 3. @lefred MySQL Evangelist using MySQL since version 3.21 devops believer living in born at PiDay ! h ps://lefred.be   Frédéric Descamps Copyright @ 2022 Oracle and/or its affiliates. 3
  • 4. @lefred MySQL Evangelist using MySQL since version 3.21 devops believer living in born at PiDay ! h ps://lefred.be   Frédéric Descamps Copyright @ 2022 Oracle and/or its affiliates. 3
  • 5. IoT the Internet of Things Copyright @ 2022 Oracle and/or its affiliates. 4
  • 6. IoT - the Internet of Things The Internet of Things describes the network of physical objects—“things”—that are embedded with sensors, software, and other technologies for the purpose of connecting and exchanging data with other devices and systems over the internet. These devices range from ordinary household objects to sophisticated industrial tools. With more than 7 billion connected IoT devices today, experts are expecting this number to grow to 22 billion by 2025. Copyright @ 2022 Oracle and/or its affiliates. 5
  • 7. MySQL the most popular Open Source Relational Database Management System Copyright @ 2022 Oracle and/or its affiliates. 6
  • 8. MySQL HeatWave MySQL is the most popular Open Source Database and it's developed by Oracle. MySQL is a relational database management system (RDMBS) but also a NoSQL Document Store. Copyright @ 2022 Oracle and/or its affiliates. 7
  • 9. MySQL HeatWave MySQL is the most popular Open Source Database and it's developed by Oracle. MySQL is a relational database management system (RDMBS) but also a NoSQL Document Store. MySQL is also available in Oracle Cloud Inftrastructure (OCI) as a managed service. HeatWave is a massively, high performance, in-memory query accelerator for OCI MySQL Database Service that accelerates MySQL performance by orders of magnitude for analytics and mixed workload. Copyright @ 2022 Oracle and/or its affiliates. 7
  • 10. Raspberry Pi hardware & software Copyright @ 2022 Oracle and/or its affiliates. 8
  • 11. Hardware A Raspberry Pi Model B: Copyright @ 2022 Oracle and/or its affiliates. 9
  • 12. Hardware A DHT22 sensor providing mesure for temperature and humidity: Copyright @ 2022 Oracle and/or its affiliates. 10
  • 13. Hardware This is the assembly schema: Copyright @ 2022 Oracle and/or its affiliates. 11
  • 14. Software On the Raspberry the following packages are required: Python pip mysql-connector-python (from pip) Adafruit_Python_DHT (from pip) Copyright @ 2022 Oracle and/or its affiliates. 12
  • 15. Software On the Raspberry the following packages are required: Python pip mysql-connector-python (from pip) Adafruit_Python_DHT (from pip) We will also create our own program and a systemd script to manage it (start/stop/status): metrics_to_MySQL.py piday_metrics@.service Copyright @ 2022 Oracle and/or its affiliates. 12
  • 16. Architecture Deploy our Database in OCI Copyright @ 2022 Oracle and/or its affiliates. 13
  • 17. OCI Architecture - simpli ed Copyright @ 2022 Oracle and/or its affiliates. 14
  • 18. Deploy in OCI Once you have an Oracle Cloud account, you can just use the link on the next slide to deploy the required architecture using a Oracle Resource Manager Stack (Terraform). This will create all the necessary resources: A VCN The Public and Private Subnets An Internet Gateway The Security Lists A compute instance with MySQL Router installed and con gured A MySQL Database Service Instance Copyright @ 2022 Oracle and/or its affiliates. 15
  • 19. Deploy in OCI - Stack h ps://github.com/lefred/oci-iot-mds Copyright @ 2022 Oracle and/or its affiliates. 16
  • 20. Deploy in OCI - Stack (2) Copyright @ 2022 Oracle and/or its affiliates. 17
  • 21. Deploy in OCI - Stack (3) Copyright @ 2022 Oracle and/or its affiliates. 18
  • 22. Deploy in OCI - Stack (4) Copyright @ 2022 Oracle and/or its affiliates. 19
  • 23. Deploy in OCI - Stack (5) Copyright @ 2022 Oracle and/or its affiliates. 20
  • 24. Deploy in OCI - Stack (6) Copyright @ 2022 Oracle and/or its affiliates. 21
  • 25. Deploy in OCI - Stack (7) Copyright @ 2022 Oracle and/or its affiliates. 22
  • 26. Deploy in OCI - Stack (8) Copyright @ 2022 Oracle and/or its affiliates. 23
  • 27. Deploy in OCI - Stack (9) Copyright @ 2022 Oracle and/or its affiliates. 24
  • 28. Deploy in OCI - Created Resources Copyright @ 2022 Oracle and/or its affiliates. 25
  • 29. Deploy in OCI - Created Resources (2) Copyright @ 2022 Oracle and/or its affiliates. 26
  • 30. Database Design Schema, tables, collections, ... how to store the data? Copyright @ 2022 Oracle and/or its affiliates. 27
  • 31. MySQL 8.0 With MySQL 8.0, you can mix relational tables and JSON Documents. Copyright @ 2022 Oracle and/or its affiliates. 28
  • 32. MySQL 8.0 With MySQL 8.0, you can mix relational tables and JSON Documents. SQL + NoSQL = MySQL Document Store Copyright @ 2022 Oracle and/or its affiliates. 28
  • 33. Built on the MySQL JSON Data type and Proven MySQL Server Technology Provides a schema exible JSON Document Store No SQL required No need to de ne all possible a ributes, tables, etc. Uses new X DevAPI (available on premise and in OCI only !) Can leverage generated column to extract JSON values into materialized columns that can be indexed for fast SQL searches. Document can be ~1GB It's a column in a row of a table It cannot exceed max_allowed_packet Allows use of modern programming styles No more embedded strings of SQL in your code Easy to read Also works with relational Tables Proven MySQL Technology Copyright @ 2022 Oracle and/or its affiliates. 29
  • 35. Design - explanations For realtime (current) information, we use a collection of JSON documents where each document represents the state of a device with the lastest values it collected. For historical data generally used for analytics, we use relational tables that we will use later with HeatWave if we need to improve the performance. Copyright @ 2022 Oracle and/or its affiliates. 31
  • 36. Design - connection to the MySQL Instance We use port 6448 (X Protocol) on the Public IP of the Compute Instance where MySQL Router is deployed. Copyright @ 2022 Oracle and/or its affiliates. 32
  • 37. Design - schema and collection creation Copyright @ 2022 Oracle and/or its affiliates. 33
  • 38. Design - relational tables creation Copyright @ 2022 Oracle and/or its affiliates. 34
  • 39. At some point, dealing with historical data like archiving, deleting old records can become a heavy operation. HeatWave has been designed to deal with a huge amount of data but on MySQL, partitioning is a solution to deal with these operations. Design - relational tables creation Copyright @ 2022 Oracle and/or its affiliates. 35
  • 40. Design - relational tables creation: partitioning SQL SQL> > alter alter table table humidity_history humidity_history add add day_date day_date date date as as ( (date date( (time_stamp time_stamp) )) ) stored stored, , drop drop primary primary key key, , add add primary primary key key ( (id id, , day_date day_date) ); ; SQL SQL> > alter alter table table humidity_history humidity_history partition partition by by range range columns columns( (day_date day_date) ) ( ( partition partition p0_before2022 p0_before2022 values values less than less than( ('2022-01-01' '2022-01-01') ), , partition partition p2022_01 p2022_01 values values less than less than( ('2022-02-01' '2022-02-01') ), , partition partition p2022_02 p2022_02 values values less than less than( ('2022-03-01' '2022-03-01') ), , partition partition p2022_03 p2022_03 values values less than less than( ('2022-04-01' '2022-04-01') ), , partition partition p2022_04 p2022_04 values values less than less than( ('2022-05-01' '2022-05-01') ), , partition partition p2022_05 p2022_05 values values less than less than( ('2022-06-01' '2022-06-01') ), , . .. .. . partition partition p2023_12 p2023_12 values values less than less than( ('2024-01-01' '2024-01-01') ), , partition partition p9_future p9_future values values less than less than( (maxvalue maxvalue) )) ); ; see h ps://dev.mysql.com/doc/refman/8.0/en/partitioning-management-range-list.html Copyright @ 2022 Oracle and/or its affiliates. 36
  • 41. Dedicated User MySQL user creation Copyright @ 2022 Oracle and/or its affiliates. 37
  • 42. MySQL Dedicated User for IoT It's a best practice that every applications use their own user to access MySQL. In our case we will create one for all our devices. We create a user with the required priveleges to write data from our Rasbperry Pi: SQL SQL> > create create user user piday identified piday identified with with 'mysql_native_password' 'mysql_native_password' by by 'Fred140376#' 'Fred140376#'; ; SQL SQL> > grant grant select select, , insert insert, , update update on on piday piday. .* * to to piday piday; ; Copyright @ 2022 Oracle and/or its affiliates. 38
  • 43. Collecting Data from Raspberry Pi to MySQL Copyright @ 2022 Oracle and/or its affiliates. 39
  • 44. We need Adafruit_DHT module to read the sensor: import import Adafruit_DHT Adafruit_DHT sensor sensor= =Adafruit_DHT Adafruit_DHT. .DHT22 DHT22 gpio gpio= =4 4 humidity humidity, , temperature temperature = = Adafruit_DHT Adafruit_DHT. .read_retry read_retry( (sensor sensor, , gpio gpio) ) Reading from the Sensor I am using Python on the Raspberry Pi. Copyright @ 2022 Oracle and/or its affiliates. 40
  • 45. Connection to MySQL Of course all the connectors maintained by Oracle MySQL support the X Dev API Copyright @ 2022 Oracle and/or its affiliates. 41
  • 46. Connection to MySQL - Python import import mysqlx mysqlx connect_args connect_args = = { { 'host' 'host': : '130.61.38.177' '130.61.38.177', , 'port' 'port': : 6448 6448, , 'user' 'user': : 'piday' 'piday', , 'password' 'password': : 'Fred140376#' 'Fred140376#', , 'ssl-mode' 'ssl-mode': : 'DISABLED' 'DISABLED', , } }; ; session session = = mysqlx mysqlx. .get_session get_session( (** **connect_args connect_args) ) Copyright @ 2022 Oracle and/or its affiliates. 42
  • 47. The code : /opt/PiDayMySQL/metrics_to_MySQL.py import import sys sys import import time time import import urllib urllib. .request request from from datetime datetime import import datetime datetime import import Adafruit_DHT Adafruit_DHT import import mysqlx mysqlx rasbpy_id rasbpy_id = = "1" "1" if if len len( (sys sys. .argv argv) ) > > 1 1: : rasbpy_id rasbpy_id = = str str( (sys sys. .argv argv[ [1 1] ]) ) sensor sensor = = Adafruit_DHT Adafruit_DHT. .DHT22 DHT22 gpio gpio = = 4 4 Copyright @ 2022 Oracle and/or its affiliates. 43
  • 48. The code : /opt/PiDayMySQL/metrics_to_MySQL.py (2) connect_args connect_args = = { { 'host' 'host': : '130.61.46.6' '130.61.46.6', , 'port' 'port': : 6448 6448, , 'user' 'user': : 'piday' 'piday', , 'password' 'password': : 'Fred140376#' 'Fred140376#', , 'ssl-mode' 'ssl-mode': : 'DISABLED' 'DISABLED', , 'schema' 'schema': : 'piday' 'piday' } }; ; Copyright @ 2022 Oracle and/or its affiliates. 44
  • 49. The code : /opt/PiDayMySQL/metrics_to_MySQL.py (3) def def connect connect( () ): : global global external_ip external_ip global global session session global global schema schema global global tbl_temperature_history tbl_temperature_history, , tbl_humidity_history tbl_humidity_history, , tbl_publicip_history tbl_publicip_history global global col_devices col_devices external_ip external_ip = = urllib urllib. .request request. .urlopen urlopen( ( 'https://api.ipify.org' 'https://api.ipify.org') ). .read read( () ). .decode decode( ('utf8' 'utf8') ) session session = = mysqlx mysqlx. .get_session get_session( (** **connect_args connect_args) ) schema schema = = session session. .get_schema get_schema( ('piday' 'piday') ) tbl_temperature_history tbl_temperature_history = = schema schema. .get_table get_table( ('temperature_history' 'temperature_history') ) tbl_humidity_history tbl_humidity_history = = schema schema. .get_table get_table( ('humidity_history' 'humidity_history') ) tbl_publicip_history tbl_publicip_history = = schema schema. .get_table get_table( ('publicip_history' 'publicip_history') ) col_devices col_devices = = schema schema. .get_collection get_collection( ('devices' 'devices') ) connect connect( () ) Copyright @ 2022 Oracle and/or its affiliates. 45
  • 50. The code : /opt/PiDayMySQL/metrics_to_MySQL.py (4) while while( (True True) ): : if if not not session session. .is_open is_open( () ): : connect connect( () ) humidity humidity, , temperature temperature = = Adafruit_DHT Adafruit_DHT. .read_retry read_retry( (sensor sensor, , gpio gpio) ) if if humidity humidity is is not not None None and and temperature temperature is is not not None None: : # Find the device and its last ip # Find the device and its last ip res res = = col_devices col_devices. .find find( ("_id='{}'" "_id='{}'". .format format( (rasbpy_id rasbpy_id) )) ). .fields fields( ( '_id' '_id', , 'publicip' 'publicip') ). .execute execute( () ) device device = = res res. .fetch_one fetch_one( () ) if if device device: : old_public_ip old_public_ip = = device device[ ['publicip' 'publicip'] ] else else: : print print( ("device with _id: {} not found !" "device with _id: {} not found !". .format format( (rasbpy_id rasbpy_id) )) ) print print( ("sleeping 1 min..." "sleeping 1 min...") ) time time. .sleep sleep( (60 60) ) continue continue Copyright @ 2022 Oracle and/or its affiliates. 46
  • 51. The code : /opt/PiDayMySQL/metrics_to_MySQL.py (5) patch_json patch_json = = { {} } humidity_s humidity_s = = "{0:0.1f}%" "{0:0.1f}%". .format format( (humidity humidity) ) temperature_s temperature_s = = "{0:0.1f}C" "{0:0.1f}C". .format format( (temperature temperature) ) patch_json patch_json[ ['humidity' 'humidity'] ] = = humidity_s humidity_s patch_json patch_json[ ['temperature' 'temperature'] ] = = temperature_s temperature_s patch_json patch_json[ ['publicip' 'publicip'] ] = = external_ip external_ip patch_json patch_json[ ['last_update' 'last_update'] ] = = datetime datetime. .now now( () ). .strftime strftime( ( "%Y-%m-%d %H:%M:%S" "%Y-%m-%d %H:%M:%S") ) print print( ('Temp={} Humidity={}' 'Temp={} Humidity={}'. .format format( (temperature_s temperature_s, , humidity_s humidity_s) )) ) col_devices col_devices. .modify modify( ("_id='{}'" "_id='{}'". .format format( (rasbpy_id rasbpy_id) ) ) ). .patch patch( (patch_json patch_json) ). .execute execute( () ) if if old_public_ip old_public_ip != != external_ip external_ip: : tbl_publicip_history tbl_publicip_history. .insert insert( ([ ['device_id' 'device_id', , 'ip_address' 'ip_address'] ]) ). .values values( ( rasbpy_id rasbpy_id, , external_ip external_ip) ). .execute execute( () ) Copyright @ 2022 Oracle and/or its affiliates. 47
  • 52. The code : /opt/PiDayMySQL/metrics_to_MySQL.py (6) tbl_temperature_history tbl_temperature_history. .insert insert( ([ ['time_stamp' 'time_stamp', , 'device_id' 'device_id', , 'value' 'value'] ]) ). .values values( ( datetime datetime. .now now( () ). .strftime strftime( ("%Y-%m-%d %H:%M:%S" "%Y-%m-%d %H:%M:%S") ), , rasbpy_id rasbpy_id, , temperature temperature) ). .execute execute( () ) tbl_humidity_history tbl_humidity_history. .insert insert( ([ ['time_stamp' 'time_stamp', , 'device_id' 'device_id', , 'value' 'value'] ]) ). .values values( ( datetime datetime. .now now( () ). .strftime strftime( ("%Y-%m-%d %H:%M:%S" "%Y-%m-%d %H:%M:%S") ), , rasbpy_id rasbpy_id, , humidity humidity) ). .execute execute( () ) else else: : print print( ('Failed to get reading. Try again!' 'Failed to get reading. Try again!') ) time time. .sleep sleep( (1 1) ) Copyright @ 2022 Oracle and/or its affiliates. 48
  • 53. Systemd script /etc/systemd/system/piday_metrics@.service [Unit] Description=Sending DHT22 metrics from Raspberry Pi to MySQL Database Service After=network.target [Service] Type=simple User=root Restart=on-failure ExecStart=/usr/bin/python /opt/PiDayMySQL/metrics_to_MySQL.py %s [Install] WantedBy=multi-user.target Copyright @ 2022 Oracle and/or its affiliates. 49
  • 54. Testing running our script Copyright @ 2022 Oracle and/or its affiliates. 50
  • 55. Start the service on the Raspberry Pi [ [raspberry ~ raspberry ~] ]$ $ sudo sudo systemctl start piday_metrics@00006227543c0000000000000001 systemctl start piday_metrics@00006227543c0000000000000001 Copyright @ 2022 Oracle and/or its affiliates. 51
  • 56. Start the service on the Raspberry Pi [ [raspberry ~ raspberry ~] ]$ $ sudo sudo systemctl start piday_metrics@00006227543c0000000000000001 systemctl start piday_metrics@00006227543c0000000000000001 Copyright @ 2022 Oracle and/or its affiliates. 51
  • 57. Checking the data Copyright @ 2022 Oracle and/or its affiliates. 52
  • 58. Checking the data without any single line of SQL ;-) Copyright @ 2022 Oracle and/or its affiliates. 52
  • 59. Improvements using MQTT Broker Copyright @ 2022 Oracle and/or its affiliates. 53
  • 60. OCI Architectures - improved (1) Copyright @ 2022 Oracle and/or its affiliates. 54
  • 61. OCI Architectures - improved (2) Copyright @ 2022 Oracle and/or its affiliates. 55
  • 62. HeatWave MySQL on Steroid Copyright @ 2022 Oracle and/or its affiliates. 56
  • 63. Analyzing the collected data Let's get some statistics on the metrics we collected so far: SQL SQL > > select select * * from from ( (select select device_id device_id, , max max( (value value) ) as as ` `max temp max temp` `, , min min( (value value) ) as as ` `min temp min temp` `, , avg avg( (value value) ) as as ` `avg temp avg temp` ` from from temperature_history temperature_history group group by by device_id device_id) ) a a natural natural join join ( (select select device_id device_id, , max max( (value value) ) as as ` `max humidity max humidity` `, , min min( (value value) ) as as ` `min humidity min humidity` `, , avg avg( (value value) ) as as ` `avg humidity avg humidity` ` from from humidity_history humidity_history group group by by device_id device_id) ) b b ; ; + +------------------------------+----------+----------+-----------+--------------+--------------+--------------+ ------------------------------+----------+----------+-----------+--------------+--------------+--------------+ | | device_id device_id | | max max temp temp | | min min temp temp | | avg avg temp temp | | max humidity max humidity | | min humidity min humidity | | avg humidity avg humidity | | + +------------------------------+----------+----------+-----------+--------------+--------------+--------------+ ------------------------------+----------+----------+-----------+--------------+--------------+--------------+ | | 00006227543 00006227543c0000000000000001 c0000000000000001 | | 142.94 142.94 | | 9.00 9.00 | | 11.711163 11.711163 | | 169.86 169.86 | | 40.00 40.00 | | 45.206324 45.206324 | | | | 00006227543 00006227543c0000000000000002 c0000000000000002 | | 29.99 29.99 | | 20.00 20.00 | | 22.513379 22.513379 | | 65.00 65.00 | | 55.00 55.00 | | 60.000385 60.000385 | | | | 00006227543 00006227543c0000000000000003 c0000000000000003 | | 814.36 814.36 | | 0.00 0.00 | | 3.114047 3.114047 | | 800.21 800.21 | | 1.00 1.00 | | 6.609432 6.609432 | | | | 00006227543 00006227543c0000000000000004 c0000000000000004 | | 288.44 288.44 | | 10.00 10.00 | | 12.567651 12.567651 | | 279.32 279.32 | | 30.00 30.00 | | 35.062746 35.062746 | | + +------------------------------+----------+----------+-----------+--------------+--------------+--------------+ ------------------------------+----------+----------+-----------+--------------+--------------+--------------+ 4 4 rows rows in in set set ( (2.0747 2.0747 sec sec) ) Copyright @ 2022 Oracle and/or its affiliates. 57
  • 64. Get the Query Execution Plan Let's have a look at the EXPLAIN plan (format=tree): EXPLAIN EXPLAIN: : - -> > Nested Nested loop loop inner inner join join ( (cost cost= =1348953.36 1348953.36 rows rows= =0 0) ) - -> > Filter: Filter: ( (a a. .device_id device_id is is not not null null) ) ( (cost cost= =155455.11 155455.11. ..58090 .58090.86 .86 rows rows= =516341 516341) ) - -> > Table Table scan scan on on a a ( (cost cost= =0.01 0.01. ..6456 .6456.76 .76 rows rows= =516341 516341) ) - -> > Materialize Materialize ( (cost cost= =155455.31 155455.31. ..161912 .161912.06 .06 rows rows= =516341 516341) ) - -> > Group Group aggregate: aggregate: max max( (temperature_history temperature_history. .` `value value` `) ), , min min( (temperature_history temperature_history. .` `value value` `) ), , avg avg( (temperature_history temperature_history. .` `value value` `) ) ( (cost cost= =103821.20 103821.20 rows rows= =516341 516341) ) - -> > Index Index scan scan on on temperature_history temperature_history using using device_id_idx device_id_idx ( (cost cost= =52187.10 52187.10 rows rows= =516341 516341) ) - -> > Index Index lookup lookup on on b b using using < <auto_key0 auto_key0> > ( (device_id device_id= =a a. .device_id device_id) ) - -> > Materialize Materialize ( (cost cost= =0.00 0.00. ..0 .0.00 .00 rows rows= =0 0) ) - -> > Table Table scan scan on on < <temporary temporary> > - -> > Aggregate Aggregate using using temporary temporary table table - -> > Table Table scan scan on on humidity_history humidity_history ( (cost cost= =52191.40 52191.40 rows rows= =516384 516384) ) Copyright @ 2022 Oracle and/or its affiliates. 58
  • 65. Analyzing the collected data (2) SQL SQL > > select select * * from from ( ( select select date date( (time_stamp time_stamp) ) as as ` `day day` `, , device_id device_id, , count count( (* *) ) as as ` `tot tot` `, , max max( (value value) ) as as ` `max hum max hum` `, , min min( (value value) ) as as ` `min hum min hum` `, , avg avg( (value value) ) as as ` `avg hum avg hum` ` from from humidity_history humidity_history group group by by device_id device_id, , day day) ) a a natural natural join join ( ( select select date date( (time_stamp time_stamp) ) as as ` `day day` `, , device_id device_id, , count count( (* *) ) as as ` `tot tot` `, , max max( (value value) ) as as ` `max temp max temp` `, , min min( (value value) ) as as ` `min temp min temp` `, , avg avg( (value value) ) as as ` `avg temp avg temp` ` from from temperature_history temperature_history group group by by device_id device_id, , day day) ) b b order order by by day day, , device_id device_id; ; + +------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+ ------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+ | | day day | | device_id device_id | | tot tot | | max hum max hum | | min hum min hum | | avg hum avg hum | | max max temp temp | | min min temp temp | | avg avg temp temp | | + +------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+ ------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+ | | 2022 2022- -03 03- -09 09 | | 00006227543 00006227543c0000000000000002 c0000000000000002 | | 14534 14534 | | 65.00 65.00 | | 55.00 55.00 | | 60.009273 60.009273 | | 29.99 29.99 | | 20.00 20.00 | | 22.597118 22.597118 | | | | 2022 2022- -03 03- -09 09 | | 00006227543 00006227543c0000000000000003 c0000000000000003 | | 31605 31605 | | 800.21 800.21 | | 1.00 1.00 | | 8.570861 8.570861 | | 814.36 814.36 | | 0.00 0.00 | | 5.079733 5.079733 | | | | 2022 2022- -03 03- -09 09 | | 00006227543 00006227543c0000000000000004 c0000000000000004 | | 31284 31284 | | 279.32 279.32 | | 30.00 30.00 | | 35.294440 35.294440 | | 288.44 288.44 | | 10.00 10.00 | | 12.797445 12.797445 | | | | 2022 2022- -03 03- -10 10 | | 00006227543 00006227543c0000000000000001 c0000000000000001 | | 114906 114906 | | 50.00 50.00 | | 40.00 40.00 | | 45.001613 45.001613 | | 14.00 14.00 | | 9.00 9.00 | | 11.499796 11.499796 | | | | 2022 2022- -03 03- -10 10 | | 00006227543 00006227543c0000000000000002 c0000000000000002 | | 100913 100913 | | 65.00 65.00 | | 55.00 55.00 | | 59.999105 59.999105 | | 25.00 25.00 | | 20.00 20.00 | | 22.501319 22.501319 | | | | 2022 2022- -03 03- -10 10 | | 00006227543 00006227543c0000000000000003 c0000000000000003 | | 101465 101465 | | 11.00 11.00 | | 1.00 1.00 | | 5.998472 5.998472 | | 5.00 5.00 | | 0.00 0.00 | | 2.501763 2.501763 | | | | 2022 2022- -03 03- -10 10 | | 00006227543 00006227543c0000000000000004 c0000000000000004 | | 101044 101044 | | 40.00 40.00 | | 30.00 30.00 | | 34.991012 34.991012 | | 15.00 15.00 | | 10.00 10.00 | | 12.496505 12.496505 | | + +------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+ ------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+ 7 7 rows rows in in set set ( (1.2717 1.2717 sec sec) ) Copyright @ 2022 Oracle and/or its affiliates. 59
  • 66. Get the Query Execution Plan (2) EXPLAIN EXPLAIN: : - -> > Sort: a Sort: a. .` `day day` `, , a a. .device_id device_id - -> > Stream results Stream results ( (cost cost= =1374880.15 1374880.15 rows rows= =0 0) ) - -> > Nested Nested loop loop inner inner join join ( (cost cost= =1374880.15 1374880.15 rows rows= =0 0) ) - -> > Filter: Filter: ( (( (b b. .` `day day` ` is is not not null null) ) and and ( (b b. .device_id device_id is is not not null null) )) ) ( (cost cost= =0.11 0.11. ..59207 .59207.65 .65 rows rows= =526268 526268) ) - -> > Table Table scan scan on on b b ( (cost cost= =2.50 2.50. ..2 .2.50 .50 rows rows= =0 0) ) - -> > Materialize Materialize ( (cost cost= =2.50 2.50. ..2 .2.50 .50 rows rows= =0 0) ) - -> > Table Table scan scan on on < <temporary temporary> > - -> > Aggregate Aggregate using using temporary temporary table table - -> > Table Table scan scan on on temperature_history temperature_history ( (cost cost= =53179.80 53179.80 rows rows= =526268 526268) ) - -> > Index Index lookup lookup on on a a using using < <auto_key0 auto_key0> > ( (day day= =b b. .` `day day` `, , device_id device_id= =b b. .device_id device_id, , tot tot= =b b. .tot tot) ) - -> > Materialize Materialize ( (cost cost= =0.00 0.00. ..0 .0.00 .00 rows rows= =0 0) ) - -> > Table Table scan scan on on < <temporary temporary> > - -> > Aggregate Aggregate using using temporary temporary table table - -> > Table Table scan scan on on humidity_history humidity_history ( (cost cost= =53184.10 53184.10 rows rows= =526311 526311) ) Copyright @ 2022 Oracle and/or its affiliates. 60
  • 67. Enable HeatWave Let's boost MySQL's performance with HeatWave ! We have two options to enable HeatWave: . Editing the Stack (if we used OCI Resoure Manager) . Using MySQL Database Service's console Copyright @ 2022 Oracle and/or its affiliates. 61
  • 68. Enable HeatWave - with Stack Copyright @ 2022 Oracle and/or its affiliates. 62
  • 69. Enable HeatWave - with Stack (2) Copyright @ 2022 Oracle and/or its affiliates. 63
  • 70. Enable HeatWave - with Stack (3) Copyright @ 2022 Oracle and/or its affiliates. 64
  • 71. Enable HeatWave - with MDS Console Copyright @ 2022 Oracle and/or its affiliates. 65
  • 72. Enable HeatWave - with MDS Console (2) Copyright @ 2022 Oracle and/or its affiliates. 66
  • 73. Enable HeatWave - with MDS Console (3) Copyright @ 2022 Oracle and/or its affiliates. 67
  • 74. Enable HeatWave - with MDS Console (4) Copyright @ 2022 Oracle and/or its affiliates. 68
  • 75. SQL SQL > > show show global global status status like like 'rapid_%er%_status' 'rapid_%er%_status'; ; + +----------------------+--------+ ----------------------+--------+ | | Variable_name Variable_name | | Value Value | | + +----------------------+--------+ ----------------------+--------+ | | rapid_cluster_status rapid_cluster_status | | ON ON | | | | rapid_service_status rapid_service_status | | ONLINE ONLINE | | + +----------------------+--------+ ----------------------+--------+ HeatWave Ready Copyright @ 2022 Oracle and/or its affiliates. 69
  • 76. Load Data to HeatWave We now use the load command printed during the Estimate Node Count step: SQL SQL > > CALL CALL sys sys. .heatwave_load heatwave_load( (JSON_ARRAY JSON_ARRAY( ('piday' 'piday') ), , NULL NULL) ); ; Copyright @ 2022 Oracle and/or its affiliates. 70
  • 77. Load Data to HeatWave (2) This operation returns a report: . .. .. . + +-------------------------------------------------------------------------------+ -------------------------------------------------------------------------------+ | | LOAD LOAD SUMMARY SUMMARY | | + +-------------------------------------------------------------------------------+ -------------------------------------------------------------------------------+ | | | | | | SCHEMA SCHEMA TABLES TABLES TABLES TABLES COLUMNS COLUMNS LOAD LOAD | | | | NAME LOADED FAILED LOADED DURATION NAME LOADED FAILED LOADED DURATION | | | | ------ ------ ------ ------- -------- | ------ ------ ------ ------- -------- | | | ` `piday piday` ` 3 3 0 0 12 12 1.84 1.84 s s | | | | | | + +-------------------------------------------------------------------------------+ -------------------------------------------------------------------------------+ 6 6 rows rows in in set set ( (1.9237 1.9237 sec sec) ) Copyright @ 2022 Oracle and/or its affiliates. 71
  • 78. ... and now ? SQL SQL > > select select * * from from ( (select select device_id device_id, , max max( (value value) ) as as ` `max temp max temp` `, , min min( (value value) ) as as ` `min temp min temp` `, , avg avg( (value value) ) as as ` `avg temp avg temp` ` from from temperature_history temperature_history group group by by device_id device_id) ) a a natural natural join join ( (select select device_id device_id, , max max( (value value) ) as as ` `max humidity max humidity` `, , min min( (value value) ) as as ` `min humidity min humidity` `, , avg avg( (value value) ) as as ` `avg humidity avg humidity` ` from from humidity_history humidity_history group group by by device_id device_id) ) b b ; ; + +------------------------------+----------+----------+-----------+--------------+--------------+--------------+ ------------------------------+----------+----------+-----------+--------------+--------------+--------------+ | | device_id device_id | | max max temp temp | | min min temp temp | | avg avg temp temp | | max humidity max humidity | | min humidity min humidity | | avg humidity avg humidity | | + +------------------------------+----------+----------+-----------+--------------+--------------+--------------+ ------------------------------+----------+----------+-----------+--------------+--------------+--------------+ | | 00006227543 00006227543c0000000000000003 c0000000000000003 | | 814.36 814.36 | | 0.00 0.00 | | 3.114047 3.114047 | | 800.21 800.21 | | 1.00 1.00 | | 6.609431 6.609431 | | | | 00006227543 00006227543c0000000000000001 c0000000000000001 | | 142.94 142.94 | | 9.00 9.00 | | 11.708011 11.708011 | | 169.86 169.86 | | 40.00 40.00 | | 45.203256 45.203256 | | | | 00006227543 00006227543c0000000000000002 c0000000000000002 | | 29.99 29.99 | | 20.00 20.00 | | 22.513379 22.513379 | | 65.00 65.00 | | 55.00 55.00 | | 60.000384 60.000384 | | | | 00006227543 00006227543c0000000000000004 c0000000000000004 | | 288.44 288.44 | | 10.00 10.00 | | 12.567650 12.567650 | | 279.32 279.32 | | 30.00 30.00 | | 35.062746 35.062746 | | + +------------------------------+----------+----------+-----------+--------------+--------------+--------------+ ------------------------------+----------+----------+-----------+--------------+--------------+--------------+ 4 4 rows rows in in set set ( (0.1049 0.1049 sec sec) ) Copyright @ 2022 Oracle and/or its affiliates. 72
  • 79. ... and now ? SQL SQL > > select select * * from from ( (select select device_id device_id, , max max( (value value) ) as as ` `max temp max temp` `, , min min( (value value) ) as as ` `min temp min temp` `, , avg avg( (value value) ) as as ` `avg temp avg temp` ` from from temperature_history temperature_history group group by by device_id device_id) ) a a natural natural join join ( (select select device_id device_id, , max max( (value value) ) as as ` `max humidity max humidity` `, , min min( (value value) ) as as ` `min humidity min humidity` `, , avg avg( (value value) ) as as ` `avg humidity avg humidity` ` from from humidity_history humidity_history group group by by device_id device_id) ) b b ; ; + +------------------------------+----------+----------+-----------+--------------+--------------+--------------+ ------------------------------+----------+----------+-----------+--------------+--------------+--------------+ | | device_id device_id | | max max temp temp | | min min temp temp | | avg avg temp temp | | max humidity max humidity | | min humidity min humidity | | avg humidity avg humidity | | + +------------------------------+----------+----------+-----------+--------------+--------------+--------------+ ------------------------------+----------+----------+-----------+--------------+--------------+--------------+ | | 00006227543 00006227543c0000000000000003 c0000000000000003 | | 814.36 814.36 | | 0.00 0.00 | | 3.114047 3.114047 | | 800.21 800.21 | | 1.00 1.00 | | 6.609431 6.609431 | | | | 00006227543 00006227543c0000000000000001 c0000000000000001 | | 142.94 142.94 | | 9.00 9.00 | | 11.708011 11.708011 | | 169.86 169.86 | | 40.00 40.00 | | 45.203256 45.203256 | | | | 00006227543 00006227543c0000000000000002 c0000000000000002 | | 29.99 29.99 | | 20.00 20.00 | | 22.513379 22.513379 | | 65.00 65.00 | | 55.00 55.00 | | 60.000384 60.000384 | | | | 00006227543 00006227543c0000000000000004 c0000000000000004 | | 288.44 288.44 | | 10.00 10.00 | | 12.567650 12.567650 | | 279.32 279.32 | | 30.00 30.00 | | 35.062746 35.062746 | | + +------------------------------+----------+----------+-----------+--------------+--------------+--------------+ ------------------------------+----------+----------+-----------+--------------+--------------+--------------+ 4 4 rows rows in in set set ( (0.1049 0.1049 sec sec) ) from 2.0747 sec to 0.1049 sec !! 20x faster ! Copyright @ 2022 Oracle and/or its affiliates. 72
  • 80. the second example: SQL SQL > > select select * * from from ( ( select select date date( (time_stamp time_stamp) ) as as ` `day day` `, , device_id device_id, , count count( (* *) ) as as ` `tot tot` `, , max max( (value value) ) as as ` `max hum max hum` `, , min min( (value value) ) as as ` `min hum min hum` `, , avg avg( (value value) ) as as ` `avg hum avg hum` ` from from humidity_history humidity_history group group by by device_id device_id, , day day) ) a a natural natural join join ( ( select select date date( (time_stamp time_stamp) ) as as ` `day day` `, , device_id device_id, , count count( (* *) ) as as ` `tot tot` `, , max max( (value value) ) as as ` `max temp max temp` `, , min min( (value value) ) as as ` `min temp min temp` `, , avg avg( (value value) ) as as ` `avg temp avg temp` ` from from temperature_history temperature_history group group by by device_id device_id, , day day) ) b b order order by by day day, , device_id device_id; ; + +------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+ ------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+ | | day day | | device_id device_id | | tot tot | | max hum max hum | | min hum min hum | | avg hum avg hum | | max max temp temp | | min min temp temp | | avg avg temp temp | | + +------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+ ------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+ | | 2022 2022- -03 03- -09 09 | | 00006227543 00006227543c0000000000000002 c0000000000000002 | | 14534 14534 | | 65.00 65.00 | | 55.00 55.00 | | 60.009272 60.009272 | | 29.99 29.99 | | 20.00 20.00 | | 22.597117 22.597117 | | | | 2022 2022- -03 03- -09 09 | | 00006227543 00006227543c0000000000000003 c0000000000000003 | | 31605 31605 | | 800.21 800.21 | | 1.00 1.00 | | 8.570860 8.570860 | | 814.36 814.36 | | 0.00 0.00 | | 5.079732 5.079732 | | | | 2022 2022- -03 03- -09 09 | | 00006227543 00006227543c0000000000000004 c0000000000000004 | | 31284 31284 | | 279.32 279.32 | | 30.00 30.00 | | 35.294440 35.294440 | | 288.44 288.44 | | 10.00 10.00 | | 12.797445 12.797445 | | | | 2022 2022- -03 03- -10 10 | | 00006227543 00006227543c0000000000000001 c0000000000000001 | | 115609 115609 | | 50.00 50.00 | | 40.00 40.00 | | 45.001736 45.001736 | | 14.00 14.00 | | 9.00 9.00 | | 11.499157 11.499157 | | | | 2022 2022- -03 03- -10 10 | | 00006227543 00006227543c0000000000000002 c0000000000000002 | | 100913 100913 | | 65.00 65.00 | | 55.00 55.00 | | 59.999104 59.999104 | | 25.00 25.00 | | 20.00 20.00 | | 22.501318 22.501318 | | | | 2022 2022- -03 03- -10 10 | | 00006227543 00006227543c0000000000000003 c0000000000000003 | | 101465 101465 | | 11.00 11.00 | | 1.00 1.00 | | 5.998472 5.998472 | | 5.00 5.00 | | 0.00 0.00 | | 2.501762 2.501762 | | | | 2022 2022- -03 03- -10 10 | | 00006227543 00006227543c0000000000000004 c0000000000000004 | | 101044 101044 | | 40.00 40.00 | | 30.00 30.00 | | 34.991011 34.991011 | | 15.00 15.00 | | 10.00 10.00 | | 12.496504 12.496504 | | + +------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+ ------------+------------------------------+--------+---------+---------+-----------+----------+----------+-----------+ 7 7 rows rows in in set set ( (0.1267 0.1267 sec sec) ) Copyright @ 2022 Oracle and/or its affiliates. 73
  • 81. More Data : more di erence ! Now let's use again the second example with more data (7 days): Without HeatWave: 90 90 rows rows in in set set ( (5 5 min min 3.3237 3.3237 sec sec) ) Copyright @ 2022 Oracle and/or its affiliates. 74
  • 82. More Data : more di erence ! Now let's use again the second example with more data (7 days): Without HeatWave: 90 90 rows rows in in set set ( (5 5 min min 3.3237 3.3237 sec sec) ) With HeatWave: 90 90 rows rows in in set set ( (0.8620 0.8620 sec sec) ) from 363.3237 sec to 0.8620 sec ! 421x faster !! Copyright @ 2022 Oracle and/or its affiliates. 74
  • 83. More Data : more di erence ! And this is with 5GB to parse: SQL SQL> > select select format_bytes format_bytes( (sum sum( (data_length data_length) )) ) DATA DATA, , format_bytes format_bytes( (sum sum( (index_length index_length) )) ) INDEXES INDEXES, , format_bytes format_bytes( (sum sum( (data_length data_length + + index_length index_length) )) ) 'TOTAL SIZE' 'TOTAL SIZE' from from information_schema information_schema. .TABLES TABLES order order by by data_length data_length + + index_length index_length; ; + +----------+----------+------------+ ----------+----------+------------+ | | DATA DATA | | INDEXES INDEXES | | TOTAL SIZE TOTAL SIZE | | + +----------+----------+------------+ ----------+----------+------------+ | | 4.23 4.23 GiB GiB | | 1.37 1.37 GiB GiB | | 5.60 5.60 GiB GiB | | + +----------+----------+------------+ ----------+----------+------------+ Copyright @ 2022 Oracle and/or its affiliates. 75
  • 84. Without HeatWave: 44 44 rows rows in in set set ( (10 10 min min 14.1022 14.1022 sec sec) ) With HeatWave: 45 45 rows rows in in set set ( (1.6051 1.6051 sec sec) ) Let's double the data: + +----------+----------+------------+ ----------+----------+------------+ | | DATA DATA | | INDEXES INDEXES | | TOTAL SIZE TOTAL SIZE | | + +----------+----------+------------+ ----------+----------+------------+ | | 8.66 8.66 GiB GiB | | 2.93 2.93 GiB GiB | | 11.59 11.59 GiB GiB | | + +----------+----------+------------+ ----------+----------+------------+ 69M ROWS Copyright @ 2022 Oracle and/or its affiliates. 76
  • 85. MySQL & HeatWave for your IoT Projects Copyright @ 2022 Oracle and/or its affiliates. 77
  • 86. MySQL & HeatWave When having to deal with large amount of data for Analytics, this is the traditional architecture: Copyright @ 2022 Oracle and/or its affiliates. 78
  • 87. MySQL & HeatWave - no more ETL required Single MySQL database for OLTP & Analytics applications All existing applications work without any changes Extreme performance Copyright @ 2022 Oracle and/or its affiliates. 79
  • 88. MySQL & HeatWave - one solution ! Copyright @ 2022 Oracle and/or its affiliates. 80
  • 89. Using HeatWave ? SQL SQL> > show show global global status status like like 'rapid_query_offload_count' 'rapid_query_offload_count'; ; + +---------------------------+-------+ ---------------------------+-------+ | | Variable_name Variable_name | | Value Value | | + +---------------------------+-------+ ---------------------------+-------+ | | rapid_query_offload_count rapid_query_offload_count | | 17 17 | | + +---------------------------+-------+ ---------------------------+-------+ The EXPLAIN command for a query will have the following value for Extra when using HeatWave: Using secondary engine RAPID Using secondary engine RAPID Copyright @ 2022 Oracle and/or its affiliates. 81
  • 90. More with Autopilot Machine Learning HeatWave includes several Autopilot processes, the following ones are avaible from the SQL prompt when HeatWave is enabled: Autopilot Encoding: Determines the optimal representation of columns loaded into HeatWave by analyzing HeatWave query history, which improves query performance and minimizes the required cluster size. Autopilot Placement: Recommends how tables should be partitioned in memory to achieve the best query performance, and estimates the expected performance improvement More Info: h ps://dev.mysql.com/doc/heatwave/en/heatwave-autopilot.html Copyright @ 2022 Oracle and/or its affiliates. 82
  • 91. More with Autopilot Machine Learning (2) Autopilot Encoding: CALL CALL sys sys. .heatwave_advisor heatwave_advisor( (JSON_OBJECT JSON_OBJECT( ("auto_enc" "auto_enc", ,JSON_OBJECT JSON_OBJECT( ("mode" "mode", , "recommend" "recommend") )) )) ); ; Autopilot Placement: CALL CALL sys sys. .heatwave_advisor heatwave_advisor( (JSON_OBJECT JSON_OBJECT( ("target_schema" "target_schema", , JSON_ARRAY JSON_ARRAY( ("piday" "piday") )) )) ); ; Copyright @ 2022 Oracle and/or its affiliates. 83
  • 92. More with Autopilot Machine Learning (2) Autopilot Encoding: CALL CALL sys sys. .heatwave_advisor heatwave_advisor( (JSON_OBJECT JSON_OBJECT( ("auto_enc" "auto_enc", ,JSON_OBJECT JSON_OBJECT( ("mode" "mode", , "recommend" "recommend") )) )) ); ; Autopilot Placement: CALL CALL sys sys. .heatwave_advisor heatwave_advisor( (JSON_OBJECT JSON_OBJECT( ("target_schema" "target_schema", , JSON_ARRAY JSON_ARRAY( ("piday" "piday") )) )) ); ; Copyright @ 2022 Oracle and/or its affiliates. 83
  • 93. HeatWave and Oracle Analytics Cloud fast realtime analytics Copyright @ 2022 Oracle and/or its affiliates. 84
  • 94. Comprehensive cloud-native analytics platform Data visualization, data preparation, data quality and data Flows ML and AI embedded throughout Natural language processing and generation Self upgrading, self patching, self securing Oracle Analytics Cloud Complete Analytics Platform for Business Users, Developers and IT Copyright @ 2022 Oracle and/or its affiliates. 85
  • 95. Oracle Analytics Platform Delivering at every stage of the analytics journey Copyright @ 2022 Oracle and/or its affiliates. 86
  • 96. For Data Connectivity, OAC supports… Copyright @ 2022 Oracle and/or its affiliates. 87
  • 97. From Multiple Native Connectors including MySQL ! Creating a new connection to our MySQL database instance: Using Oracle Analytics Cloud with MySQL HeatWave Copyright @ 2022 Oracle and/or its affiliates. 88
  • 98. Using Oracle Analytics Cloud with MySQL HeatWave Copyright @ 2022 Oracle and/or its affiliates. 89
  • 99. For Data Modeling, OAC supports... Copyright @ 2022 Oracle and/or its affiliates. 90
  • 100. Now we can create our dataset: Using Oracle Analytics Cloud with MySQL HeatWave Copyright @ 2022 Oracle and/or its affiliates. 91
  • 101. We search and select our connection (piday): Using Oracle Analytics Cloud with MySQL HeatWave Copyright @ 2022 Oracle and/or its affiliates. 92
  • 102. Using Oracle Analytics Cloud with MySQL HeatWave Copyright @ 2022 Oracle and/or its affiliates. 93
  • 103. Using Oracle Analytics Cloud with MySQL HeatWave Copyright @ 2022 Oracle and/or its affiliates. 94
  • 104. Using Oracle Analytics Cloud with MySQL HeatWave We join using device_id eld: Copyright @ 2022 Oracle and/or its affiliates. 95
  • 105. Using Oracle Analytics Cloud with MySQL HeatWave Copyright @ 2022 Oracle and/or its affiliates. 96
  • 106. Using Oracle Analytics Cloud with MySQL HeatWave Don't forget to specify that we want live data ! Copyright @ 2022 Oracle and/or its affiliates. 97
  • 107. Using Oracle Analytics Cloud with MySQL HeatWave Retrieving data from a JSON document in a collection. Let's return the device_id as VARCHAR and its short_name using VIRTUAL COLUMNS: SQL SQL> > alter alter table table devices devices add add device_id device_id varchar varchar( (32 32) ) generated always generated always as as ( (doc doc- ->> >>'$._id' '$._id') ) SQL SQL> > alter alter table table devices devices add add short_name short_name varchar varchar( (20 20) ) generated always generated always as as ( (doc doc- ->> >>'$.short_name' '$.short_name') ); ; Copyright @ 2022 Oracle and/or its affiliates. 98
  • 108. Using Oracle Analytics Cloud with MySQL HeatWave We can now retrieved them (and index them if needed) without having to use the special JSON notation: SQL SQL> > select select device_id device_id, , short_name short_name from from devices devices; ; + +------------------------------+------------+ ------------------------------+------------+ | | device_id device_id | | short_name short_name | | + +------------------------------+------------+ ------------------------------+------------+ | | 00006227543 00006227543c0000000000000001 c0000000000000001 | | lefredPi lefredPi | | | | 00006227543 00006227543c0000000000000002 c0000000000000002 | | fake01 fake01 | | | | 00006227543 00006227543c0000000000000003 c0000000000000003 | | fake02 fake02 | | | | 00006227543 00006227543c0000000000000004 c0000000000000004 | | fake03 fake03 | | + +------------------------------+------------+ ------------------------------+------------+ 4 4 rows rows in in set set ( (0.0284 0.0284 sec sec) ) Copyright @ 2022 Oracle and/or its affiliates. 99
  • 109. Using Oracle Analytics Cloud with MySQL HeatWave Copyright @ 2022 Oracle and/or its affiliates. 100
  • 110. Using Oracle Analytics Cloud with MySQL HeatWave Copyright @ 2022 Oracle and/or its affiliates. 101
  • 111. Using Oracle Analytics Cloud with MySQL HeatWave Copyright @ 2022 Oracle and/or its affiliates. 102
  • 112. Using Oracle Analytics Cloud with MySQL HeatWave Copyright @ 2022 Oracle and/or its affiliates. 103
  • 113. For Data Preparation, OAC supports... Copyright @ 2022 Oracle and/or its affiliates. 104
  • 114. For Data Exploration, OAC supports... Copyright @ 2022 Oracle and/or its affiliates. 105
  • 115. For Data Visualization, OAC supports... Copyright @ 2022 Oracle and/or its affiliates. 106
  • 116. For Data Visualization, OAC supports... (2) As a developer you could even check the performance parameters of your visualizations: Copyright @ 2022 Oracle and/or its affiliates. 107
  • 117. For Advances Analytics, OCA supports... Copyright @ 2022 Oracle and/or its affiliates. 108
  • 118. For Citizen Data Science, OAC supports... Copyright @ 2022 Oracle and/or its affiliates. 109
  • 119. For Collaboration, OAC Supports... Copyright @ 2022 Oracle and/or its affiliates. 110
  • 120. Using Oracle Analytics Cloud with MySQL HeatWave Easy creation of real-time dashboard of all the data collected by the Raspberry Pi Copyright @ 2022 Oracle and/or its affiliates. 111
  • 121. Summary our journey from IoT device to HeatWave and Analyitcs Copyright @ 2022 Oracle and/or its affiliates. 112
  • 122. Summary of our journey Copyright @ 2022 Oracle and/or its affiliates. 113
  • 123. Summary of our journey We started from a simple Raspberry Pi Copyright @ 2022 Oracle and/or its affiliates. 113
  • 124. Summary of our journey We started from a simple Raspberry Pi We collected a lot of data Copyright @ 2022 Oracle and/or its affiliates. 113
  • 125. Summary of our journey We started from a simple Raspberry Pi We collected a lot of data We ran queries super fast and were ready for Analitycs without any ETL service Copyright @ 2022 Oracle and/or its affiliates. 113
  • 126. Summary of our journey We started from a simple Raspberry Pi We collected a lot of data We ran queries super fast and were ready for Analitycs without any ETL service We used the limitless OAC capabilities to process, vizualize and forecast the data Copyright @ 2022 Oracle and/or its affiliates. 113
  • 127. Summary of our journey We started from a simple Raspberry Pi We collected a lot of data We ran queries super fast and were ready for Analitycs without any ETL service We used the limitless OAC capabilities to process, vizualize and forecast the data and all this thanks to MySQL HeatWave ! Copyright @ 2022 Oracle and/or its affiliates. 113
  • 128. Want more Swag ? Download a free trial and get bonus swag on top of the Pi Day swag kit! Copyright @ 2022 Oracle and/or its affiliates. 114
  • 129. Once your email is whitelisted, go to bit.ly/piday-freetrial and click the Sign Up bu on Copyright @ 2022 Oracle and/or its affiliates. 115
  • 130. Click Verify my email bu on Enter your Country/Territory, First Name, Last Name, and Email Check the box if you are a human and complete the Captcha authentication Copyright @ 2022 Oracle and/or its affiliates. 116
  • 131. Click the Verify Email bu on You will be presented with an o er for $500 in free credits, click the Select O er bu on Go to the email account that was used to register for this event and look for the Oracle Cloud email asking to verify the email address and create your Oracle account. Copyright @ 2022 Oracle and/or its affiliates. 117
  • 132. Enter required elds under Account information Read the Terms of Use and click the Continue bu on Copyright @ 2022 Oracle and/or its affiliates. 118
  • 133. Enter your Address and Phone Number Click the Continue bu on Read the terms and conditions and acknowledge the Agreement. Click the Start my free trial bu on Copyright @ 2022 Oracle and/or its affiliates. 119
  • 134. Your Oracle Cloud Infrastructure (OCI) tenancy is now being provisioned. Copyright @ 2022 Oracle and/or its affiliates. 120
  • 135. Welcome to your Oracle Cloud Infrastructure (OCI) tenancy Copyright @ 2022 Oracle and/or its affiliates. 121
  • 136. Oracle Cloud Free Tier bit.ly/piday-freetrial Copyright @ 2022 Oracle and/or its affiliates. 122
  • 137. Share our event! #piday #odevrel #mysql Join our slack channels! bit.ly/odevrel-slack bit.ly/mysql-slack Copyright @ 2022 Oracle and/or its affiliates. 123
  • 139. h ps://bit.ly/Pi-Quiz-2022 Test your Pi knowledge. ¶'s the limit. Copyright @ 2022 Oracle and/or its affiliates. 125
  • 140. Questions ? Copyright @ 2022 Oracle and/or its affiliates. 126
  • 141. Resources h ps://github.com/lefred/oci-iot-mds h ps://github.com/lefred/oracle-piday-2022 h ps://dev.mysql.com/doc/heatwave/en/ h ps://www.mysql.com/cloud/ h ps://www.oracle.com/in/business-analytics/data-visualization/examples.html h ps://www.oracle.com/in/business-analytics Copyright @ 2022 Oracle and/or its affiliates. 127
  • 142. Resources (2) Try a Live Lab: MySQL Database Service powered by HeatWave and Oracle Analytics Cloud: h ps://apexapps.oracle.com/pls/apex/dbpm/r/livelabs/workshop-a endee-2? p210_workshop_id=870&p210_type=1&session=2731606019312 Copyright @ 2022 Oracle and/or its affiliates. 128