MySQL 8.0.14 came with Lateral Derived Tables as a new
feature. But what is that and how do you use them?
Let's start what a derived table is. According to the
manual (link below) A derived table is an expression that
generates a table within the scope of a query FROM
clause. You are probably used to using a subquery
or JSON_TABLE where that query feeds data into another
query.
Derived Tables
Derived tables can return a scalar, column, row, or table. But
there are limits to their use.
A derived table cannot be a correlated subquery and a derived
table cannot contain references to other tables of the same
SELECT. And previous to MySQL 8.0.14, a derived table cannot
contain outer references.
Okay, so what is an 'outer reference'? The SQL-92 standard …
In Part I, we introduced a High Availability (HA) framework for MySQL hosting and discussed various components and their functionality. Now in Part II, we will discuss the details of MySQL semisynchronous replication and the related configuration settings that help us ensure redundancy and consistency of the data in our HA setup. Make sure to check back in for Part III where we will review various failure scenarios that could arise and the way the framework responds and recovers from these conditions.
What is MySQL Semisynchronous Replication?
Simply put, in a …
[Read more]Have you been experiencing slow MySQL startup times in GTID mode? We recently ran into this issue on one of our MySQL hosting deployments and set out to solve the problem. In this blog, we break down the issue that could be slowing down your MySQL restart times, how to debug for your deployment, and what you can do to decrease your start time and improve your understanding of GTID-based replication.
How We Found The Problem
We were investigating slow MySQL startup times on a low-end, disk-based MySQL 5.7.21 deployment which had GTID mode enabled. The system was part of a master-slave pair and was under a moderate write load. When restarting during a scheduled maintenance, we …
[Read more]In this three-part blog series, we will explain the details and functionality of a High Availability (HA) framework for MySQL hosting using MySQL semisynchronous replication and the Corosync plus Pacemaker stack. In Part I, we’ll walk you through the basics of High Availability, the components of an HA framework, and then introduce you to the HA framework for MySQL.
What is High Availability?
The availability of a computer system is the percentage of time its services are up during a period of time. It’s generally expressed as a series of 9′s. For example, the table below shows availability and the corresponding downtime measured over one year.
| Availability % | … |
JSON has proven to be a very import data format with immense
popularity. A good part of my time for the last two or so years
has been dedicated to this area and I even wrote a book on the subject. This is a
comparison of the implementations of handling JSON data in MySQL
and MariaDB. I had requests from the community and customers for
this evaluation.
JSON Data Types Are Not All Equal
MySQL added a JSON data type in version 5.7 and it has proven to
be very popular. MariaDB has JSON
support version 10.0.16 but is actually an alias to a
longtext data type so that statement based replication
from MySQL to MariaDB is possible.
MySQL stores JSON documents are …
In this blog post, we review some of the important aspects of configuring and managing SSL in MySQL hosting. These would include the default configuration, disabling SSL, and enabling and enforcing SSL on a MySQL server. Our observations are based on the community version of MySQL 5.7.21.
Default SSL Configuration in MySQL
By default, MySQL server always installs and enables SSL configuration. However, it is not enforced that clients connect using SSL. Clients can choose to connect with or without SSL as the server allows both types of connections. Let’s see how to verify this default behavior of MySQL server.
When SSL is installed and enabled on MySQL server by default, we will typically see the following:
- Presence of *.pem files in the MySQL data directory. These are the various client and server certificates and keys that are in …
Windowing functions are a critical tool for grouping rows of data
that are related to other rows. But they go far beyond the
regular aggregate functions found in MySQL 5.7 and earlier. In
MySQL 8 you do not have to collapse all the information down into
a single output row. Each row can retain its individual identity
but the server can analyze the data as a unit.
Statistics and Damned Lies Finding the total Population of
the District Texas from the world.city table
is simple.
SQL> select District, sum(Population)
from city where district = 'Texas';
+----------+-----------------+
| District | sum(Population) |
+----------+-----------------+
| Texas
| 9208281 |
+----------+-----------------+
1 row in set (0.0068 sec)
…
Both MongoDB and the MySQL Document Store are JSON document
stores. The syntax differences in the two products are very
interesting. This long will be a comparison of how commands
differ between these two products and may evolve into a 'cheat
sheet' if there is demand.
I found an excellent Mongo tutorial Getting Started With MongoDB that I use as a
framework to explore these two JSON document stores.
The DataI am using the primer-dataset.json file that
MongoDB has been using for years in their documentation,
classes, and examples. MySQL has created the world_x data
set based on the world database used for years in
documentation, classes and examples. The data set is a
collection of JSON documents filled with restaurants around
Manhattan.
…
Pretend you have a JSON array of data that looks roughly like the
following.
mysql> insert into x(y) values('["a","b","c","d"]');
Query OK, 1 row affected (0.10 sec)
You could get all the values from that array using
$[*]
mysql> select y->"$[*]" from x;
+----------------------+
| y->"$[*]" |
+----------------------+
| ["a", "b", "c", "d"] |
+----------------------+
1 row in set (0.00 sec)
Or the individual members of the array with an index that starts
with zero.
mysql> select y->"$[0]" from x;
+-----------+
| y->"$[0]" |
+-----------+
| "a" |
+-----------+
1 row in set (0.00 sec)
But what about the times you want the last item in the array and
really do not want to loop through all the items? How about using …
Semi-sync Replication is a plugin
available for mysql which allows you to create more durable
replication topologies. For instance you can ensure that in
the event of a master crash that at least one of your replicas
has all transaction currently written to the master so that when
you promote, you know you're not missing any data.
That's a huge simplification.
What's the downside? Write speed. If a transaction on
your master have to wait until a replica acknowledges it has that
transaction, then there is going to be some delay. Not only
that, but your network latency between the two points matters a
lot. If you want greater durability, the cost is
performance.
It's important to note that the master doesn't wait until the
replica actually runs the transaction on the …