> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hightouch.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PlanetScale

> Power internal tools, in-app experiences, and more

## Supported syncing

| Sync Type | Description | Supported Sync Modes |
| - | - | - |
| **Table** | Sync data from any source to a PlanetScale table | Upsert |

For more information about sync modes, refer to the [sync modes](https://docs.hightouch.com/syncs/types-and-modes.md#sync-modes) docs.

## Connect to PlanetScale

Go to the [**Destinations** overview page](https://app.hightouch.com/destinations?from=docs) and click the **Add destination** button. Select **PlanetScale** and click **Continue**.

Enter the following required fields into Hightouch:

* **Host**: The hostname or IP address of your PlanetScale server.
* **Port**: The port number of your PlanetScale server. The default is 3306, but yours may be different.
* **Database**: This specifies the database to use when Hightouch executes queries in Planetbase. This is different than the host, but your host address might contain your database name.
* **User**: This can be your personal PlanetScale login or a dedicated user for Hightouch.
* **Password**: The password for the user specified above.

## Sync configuration

Once you've set up your PlanetScale destination and have a [model](https://docs.hightouch.com/getting-started/concepts.md#models) to pull data from, you can set up your sync configuration to begin syncing data. Go to the [**Syncs** overview page](https://app.hightouch.com/syncs?from=docs) and click the **Add sync** button to begin. Then, select the relevant model and the PlanetScale destination you want to sync to.

### Select table

Select the existing table in PlanetScale you want to sync to.

### Record matching

You can match rows from your model to rows in PlanetScale on any column as long as it is a primary key or unique key.

You can see columns that fit this criteria as available options in records matching section.

![Sync configuration in the Hightouch UI](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/destinations/destination-planetscale-id-mapping.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=19aae36f53410822eaab2058428ad7e0)

If there are no fields in the dropdown, you must add a unique type column to your PlanetScale table. Then, click the refresh icon to access the newly created column.

### Field mapping

Select which model columns you want to sync to your PlanetScale table columns. Hightouch automatically pulls the columns from your table to make them available for you to map.

> [!TIP]
>
> When syncing to [binary](https://dev.mysql.com/doc/refman/8.0/en/binary-varbinary.html) destination fields, Hightouch assumes the model column values to be [base64](https://en.wikipedia.org/wiki/Base64) strings. If they aren't, you can use [template mapping](https://docs.hightouch.com/syncs/mapping-data.md#template-mapping) to [cast](https://docs.hightouch.com/models/data-types-casting.md#casting) them if needed.
>
> ![Base 64 template mapping](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/mapping-data/base-64-mapping.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=71ec8c496160ad1cc4762788993dacb6)

### Batch size

You can tune the number of rows Hightouch upserts per query based on your needs and database threshold. The default is 1000 rows per batch.

If you want to increase the sync's speed, you can increase the batch size. Keep in mind that PlanetScale fails the entire batch of rows if it detects any erroneous row. If you suspect that you will have many bad rows, don't use a high batch size. To avoid locks, ensure you account for your database's capacity when increasing the batch size.

### Delete behavior

When rows no longer shows up from your model's query results, you can configure the sync to **Do nothing** or **Delete** those rows from the PlanetScale.

| Behavior | Description |
| - | - |
| **Do nothing** | Keep the synced rows in the table in PlanetScale |
| **Delete** | Delete the synced rows from the table in PlanetScale |

## Tips and troubleshooting

To see the exact API requests and responses from each sync run, use the [live debugger](https://docs.hightouch.com/syncs/debugger.md). To get notified by Slack, PagerDuty, SMS, or email when a sync fails, set up [sync alerts](https://docs.hightouch.com/syncs/alerting.md). If you run into an issue this page doesn't cover, [contact support](#pylon-chat).
