From my webinar "A first look at MariaDB 11.x features
and ideas on how to use them", from November 2023. I talked about the features introduced in MariaDB versions 11.0 to 11.3, not yet production-ready. For some features, I provided ideas about how they can be used.
3. ● Not yet released
● In MariaDB, databases and schemas are the same thing
○ SCHEMA, SCHEMAS are synonyms for DATABASE,
DATABASES
● Both are similar to what other DBMSs call schemas:
namespaces, soft containers
Catalogs
4. ● Both are similar to what other DBMSs call schemas:
namespaces, soft containers
● They also use different directories
● But the same connection can query multiple schemas and
join tables in different schemas
Catalogs
5. ● Catalogs are similar to other DBMSs databases
● They provide isolation
● MDEV-31542
Catalogs
6. ● Development databases are usually on the developers
laptops
● This has drawbacks, but having a DB in the cloud for each
developer would cost too much
● But with Catalogs, we can setup a Catalog for each
developers, for a reasonable cost
Catalogs for development databases
8. ● Ideally, each microservice should run on a separate set of
servers, with Galera Cluster and/or replication
○ and a load balancer and monitoring and backups and …
● For microservices with a very low workload, this is too
expensive
● So, put them into the same servers / clusters, but at least use
Catalogs to provide more isolation
Catalogs for small microservices
11. ● Since 11.2 most ALTER TABLEs are not locking
● Unless we specify different LOCK!=NONE or
ALGORITHM!=COPY clauses
● MDEV-26137
ALTER TABLE ONLINE
12. ● Internally, it works similarly to gh-ost or
pt-online-schema-change:
○ A new table is created, with the required structure
○ The old table is still used
○ The new table is kept in sync with the old
○ Data are copied without locks
○ The tables are switched
ALTER TABLE ONLINE
14. ● Change buffer was removed in 10.11,
but it was already disabled by default
● Fragmentation was removed in 11.1
InnoDB: cleanups
15. ● After tables are dropped or many data are deleted, InnoDB
system tablespace will shrink are restart
MDEV-14795
● It's possible to shrink InnoDB temporary tablespace on
restart in this way:
SET innodb_truncate_temporary_tablespace_now = 1;
MDEV-28699
Note: local temporary tables now appear in
information_schema.TABLES
ALTER TABLE ONLINE
17. Since MariaDB 11.3:
● SSL is now configured automatically
○ If a certificate exists it will be used
○ Otherwise a self-signed certificate is generated
● The client requires the server to use SSL by default
● Optionally, the client can verify server's certificate
SSL
18. ● A self-signed certificate can be used to established encrypted
connections
● But it's not validated by a trusted Certification Authority
● This exposes you to man-in-the-middle attacks
● But for non-public server, a self-signed certificate is often
considered enough
SSL
20. ● New function KDF() returns good keys for AES_ENCRYPT()
● It uses OpenSSL EVP_KDF_derive()
SET @str = 'my secret';
SET @key = KDF('foo', 'bar', 'infa', 'hkdf');
SELECT HEX(
AES_ENCRYPT(@secret, '@key,
'0123456789abcdef',
'aes-256-cbc')
);
AES
21. ● The key and the initialisation vector are necessary to decrypt
a string
● Storing them in the same database as the encrypted string is
a security risk
AES
23. ● 11.x comes with big changes for the optimizer cost model
● This is a massive change, and would deserve a separate
webinar
Optimiser
24. ● There are also cases when previously indexes couldn't be
used, but now can (some of these are in 10.11 as well):
○ WHERE DATE(col) = ?
○ WHERE YEAR(col) = ?
○ WHERE UPPER(col) = ?
○ WHERE utf8mb3_column = 'utf8mb4 string'
Optimiser
25. ● Previously, subqueries were poorly optimised
DELETE
FROM user
WHERE id IN (SELECT id FROM user WHERE age < 18);
DELETEs and UPDATEs with subqueries
26. ● information_schema.PROCESSLIST now has
ROWS_EXAMINED and SENT_ROWS columns
● This allows us to:
○ Check if a long query is returning many rows or is just a
poorly optimised query
○ Or monitor the processlist to find non-optimised queries,
prioritising those with a low sent / examined ratio
Processlist
28. ● SET GLOBAL redirect_url = '...';
● Support from clients is needed
Redirection
29. Use cases:
● Dismiss a replica, inform clients to use another replica
instead
● Put replicas in maintenance
● Rolling upgrade
But you should use a proxy. So, a better use case is:
● Inform a proxies in advance that a replica shouldn't be used
Redirection
30. These options now are also variables:
● binlog_do_db
● binlog_ignore_db
● binlog_row_event_max_size
Redirection
32. ● Validate JSON against JSON Schema, 2020 draft:
JSON_SCHEMA_VALID(schema, json);
● The schema is passed as a parameter
● In very simple cases, you can do this in a CHECK clause
● For more complex cases, store schema/schemas in a table
and use a chron
JSON_SCHEMA_VALID()
33. FORMAT_PICO_TIME(picoseconds)
Returns a human-readable string from picoseconds (10−12
)
Example: '2us' (microseconds)
ps - picoseconds
ns - nanoseconds
us - microseconds
ms - milliseconds
s - seconds
min - minutes
h - hours
d - days
FORMAT_PICO_TIME()
34. ● JSON_OBJECT_FILTER_KEYS(obj, array_keys)
Returns an object with only the keys that are in the array
● JSON_OBJECT_TO_ARRAY(obj)
Transforms an object into an array in the form:
[ ["key1", "value1"], … ]
● JSON_ARRAY_INTERSECT(array1, array2)
Returns the intersection of 2 arrays
MDEV-26182
More JSON functions
35. ● INET4 can now be cast into INET6
● This means that we can use queries like:
WHERE inet4_column = 'inet6 value'
IP types