Databases
Each VIP Platform WordPress environment is supported by a unique database. Unique databases per-environment allows testing to be performed on non-production environments without impacting the production environment.
- Data syncs from a production environment to a non-production environment can be performed in the VIP Dashboard’s Data Sync panel or with the VIP-CLI command:
vip sync [options]
- Databases for production environments are backed up every hour, and databases for non-production environments are backed up daily. Database backups include all tables including custom tables and are available for download in the VIP Dashboard or with VIP-CLI.
- VIP uses Automattic’s HyperDB
db.php
drop-in. HyperDB is configured to send writes to an environment’s master database and sends reads to database replicas. No otherdb.php
drop-ins can be used on the platform. - The size of an environment’s database can be reviewed in the Insights & Metrics panel of the VIP Dashboard.
- The default setting for
DB_CHARSET
isutf8mb4
, andDB_COLLATE
is defined asutf8mb4_unicode_ci
. In order for a SQL file to successfully be imported to a VIP database, it must use supported collation and character sets.
Access
Direct access to an environment’s database is limited.
phpMyAdmin
Users with an Org admin role or an App admin role can access a read-only phpMyAdmin console with the VIP-CLI command vip db phpmyadmin
.
The vip db phpmyadmin
command opens a phpMyAdmin console for an environment’s database in the user’s default browser. The phpMyAdmin session will persist for 6 hours. To begin a new session run the vip db phpmyadmin
command again.
Note
For sites behind a reverse proxy configuration, all request paths that begin with [PROXIED_DOMAIN]/.wpvip/pma
must be configured to forward to VIP in order to access the phpMyAdmin console.
Refer to phpMyAdmin’s documentation for additional guidance on performing read-only actions in the console.
WP-CLI
Most WP-CLI wp db *
commands are disallowed on VIP. Queries that include DROP
, TRUNCATE
or CREATE
cannot be executed. wp db query
is allowed, but defaults to read-only. For write operations, wp db query
must be passed with --read-write
. As an alternative, a custom WP-CLI command could run a function that leverages $wpdb->query()
.
Database queries
Direct database queries in code should be avoided whenever possible. WordPress API functions for fetching and manipulating data should be used instead.
- Database queries that run for longer than 60 seconds are automatically terminated. This is a default platform setting that is subject to change, and is not customizable per application. A terminated query will appear in a Runtime Logs entry with the PHP message
MySQL server has gone away
. - Slow queries that should be optimized in order to improve database efficiency can be reviewed in the Health – Slow Query Logs panel in the VIP Dashboard.
- The efficiency of the queries made to the database by application code can be reviewed in the Insights & Metrics panel of the VIP Dashboard.
Custom tables
Use caution when adding custom tables to a VIP Platform environment’s database.
- To prevent unexpected issues, all tables should begin with the
$wpdb->prefix
table prefix.
- Use
dbDelta
as part of an upgrade routine to add/update the table. - Do a thorough analysis of the schema and indexes and validate against the queries being run to ensure they match up.
- Add caching to queries where it makes sense.
Last updated: May 15, 2024