Loading...


Related Products


Date Published: February 6, 2025

Truncating a large database table

Issue

One or more tables in your database are too large and need to be reduced in size. For information on assessing your disk space usage see About disk storage in Cloud Platform.

Resolution

Before attempting to reduce the size of any database, it is important that you make a backup as is best practice. Please take a look at our Backing up your Drupal database documentation. 

After you have backed up the database, you could use the following command to connect to your database, replacing [site-uri] with the base URL to the website you want to connect to:

drush sqlc --uri=[site_URL]

Important

Make sure to include the URI flag (especially if you have a multisite application) to ensure that you are connecting to the correct database. For example:
drush sqlc --uri=www.acquia.com

Now that you have a backup, are connected to the correct DB and know which table needs to be truncated (table_name), run the following command:

TRUNCATE TABLE table_name;

For example, if the table you needed to truncate was cache_container.idb, you would run this command

TRUNCATE TABLE cache_container;

For more information on truncating a table, please see Managing Large Cache Render tables in Drupal 8, which outlines how to truncate the cache_render table in particular, for Drupal 8.

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Back to Section navigation
Back to Site navigation