> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/tposs/6.19/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/tposs/6.19/configuration/mysql-database.md).

# Database server requirements and settings

TPOSS may work with the following versions of these databases:

- MariaDB 10.3 to 10.5
- MySQL 5.7, including the latest 5.7.33

> [!NOTE]
> MySQL 8 is supported in the context of compatibility, but performance issues with insert operations may occur.

TPOSS is compatible to run with the MariaDB Galera cluster and MySQL NDB cluster, and it does not have any specific limitations according to the [MySQL NDB](https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster-limitations-syntax.html) and [MariaDB Galera cluster](https://mariadb.com/docs/galera-cluster/galera-management/mariadb-galera-cluster-known-limitations) documentation.

To operate on MySQL, TPOSS must have a database created. Create a UTF-8 encoded database named `tposs` and a user with **all** permissions for this database:

```sql
CREATE DATABASE tposs CHARACTER SET UTF8 COLLATE utf8_bin;
```

## Tables partitioning

If TPOSS is configured to have the [CDR table partitioned](https://docs.cennso.com/components/tposs/6.19/configuration/charging.md#charging-data-records-configuration), enable the [MySQL event scheduler](https://dev.mysql.com/doc/refman/8.0/en/event-scheduler.html):

```sql
SET GLOBAL event_scheduler = ON;
```

If there is more than one MySQL instance used in the deployment, disable the events on the secondary MySQL instances:

```sql
ALTER EVENT drop_partitions DISABLE ON SLAVE;
ALTER EVENT reorganize_partitions DISABLE ON SLAVE;
```

## Connection pooling

The size of a connection pool configured in the database must match the expectation of the applications. For example, a database connected to two TPOSS instances with a configured pool size of 100 must be able to handle at least 200 connections. You can check the possible number of connections using the `max_connections` MySQL variable:

```sql
SHOW VARIABLES LIKE "max_connections";
```

It is worth to set `max_connections` to a value higher than the pool size of all TPOSS instances to have a separate access through the standard MySQL client to the database.

> [!NOTE]
> To execute each query, TPOSS uses [prepared statements](https://dev.mysql.com/doc/refman/8.0/en/sql-prepared-statements.html). The default limit of the maximum number of the prepared statements might not be suitable for production. It is worth to set `max_prepared_stmt_count` to `50000`.
