<Header icon={<img src="/docs/logos/mysql.svg" className="w-9 h-9 inline" />}>MySQL</Header>

MySQL is a popular open source object-relational database system.

## Features

| Feature                                       | Supported |
|-----------------------------------------------|-----------|
| [Batch Mode](#batch-mode)                     | ✅         |
| [Stream Mode](#stream-mode)                   | ✅         |
| [Deduplication](#deduplication)               | ✅         |
| [Queries Optimization](#queries-optimization) | ✅         |

## Configuration

<DestinationConfiguration type="mysql" />

## Advanced: Implementation Details

This section describes how Jitsu implements various modes and features for Mysql.

### Batch Mode

<details>
<summary>Algorithm</summary>

```sql
-- Jitsu collects events batches in tmp file on file system.
BEGIN -- start transaction
INSERT into tmp_table -- load tmp file into tmp_table
INSERT into target_table select from tmp_table
COMMIT -- commit transaction
```
</details>

### Stream Mode

`INSERT INTO target_table (...) VALUES (..)`

### Deduplication

For batch mode the following algorithm is used:
<details>
<summary>Algorithm</summary>

```sql
-- Jitsu collects events batches in tmp file on file system.
-- Deduplicate rows in tmp file
BEGIN -- start transaction
INSERT into tmp_table ... ON DUPLICATE KEY UPDATE ... -- load tmp file into tmp_table
INSERT into target_table select from tmp_table ... ON DUPLICATE KEY UPDATE ...
COMMIT -- commit transaction
```
</details>

For stream mode:

`INSERT INTO target_table ... ON DUPLICATE KEY UPDATE ...`

### Queries Optimization

**Timestamp** connection setting is used to optimize SELECT queries.

Regular index is created on specified timestamp column.