List of tables to safely truncate in Magento?

List of tables to safely truncate in Magento?

July 7, 2026 · Illustrated author avatarBy Stefan Bogdanescu
List of tables to safely truncate in Magento?

Safely Truncating Tables in Magento: A Comprehensive Guide

When working with Magento, there are times when you might want to truncate certain database tables to free up space or reset data. However, it’s crucial to proceed with caution to avoid data loss or site functionality issues. This guide provides a list of tables that can be safely truncated while preserving your products and important data.

Tables That Can Be Safely Truncated

Here is an updated list of tables that you can typically truncate without harming your Magento store’s core functionality:

Sales Log Tables

  • log_customer: Logs customer activity
  • log_quote: Logs quote (shopping cart) activity
  • log_summary: Summarizes sales data for a given day
  • log_summary_type: Summarizes sales data by order status and day
  • log_url: Tracks URL access logs
  • log_url_info: Stores additional information about URLs accessed
  • log_visitor: Logs visitor activity
  • log_visitor_info: Stores additional information about visitors

These tables store log data that is useful for analytics but not essential to your site’s operation. Clearing them can help improve performance and reduce database size.

Index Tables (Depend on Flat Catalog)

  • Where # depends on the multistore configuration
  • catalog_product_flat_1 or catalog_product_flat_#

If you have enabled the flat catalog feature in your Magento setup, these tables store denormalized product data. Truncating them will clear the flat data and require a rebuild.

URL Rewrite Cache Table (Use with Caution)

  • core_url_rewrite

This table stores the rewrites for URLs on your site. However, it should be used with caution. If you have any custom URL rewrites in place, truncating this table will clear them. Always backup important rewrite data before proceeding.

Tables to Avoid Truncating

While Magento is designed to handle many types of operations, some tables contain critical data that should never be truncated:

Core Configuration Table

  • core_config_data

This table stores your site’s configuration settings, including payment methods, shipping options, and more. Clearing this data will reset all configuration values.

Product Tables (Never Truncate)

  • catalog_product_entity
  • Related tables like catalog_category_product, catalog_product_attribute_media_gallery, etc.

Truncating product-related tables will delete your products and associated data.

Best Practices for Safe Table truncation

Before proceeding with any database operations, always follow these best practices:

  1. Backup Your Database: Always create a database backup before making any changes. This ensures you can restore your site if anything goes wrong.

  2. Test on a Staging Environment: Never perform database operations directly on your live production site. Use a staging or development environment to test the process first.

  3. Use Safe SQL Commands: Instead of DELETE, use TRUNCATE TABLE for faster performance and reduced overhead.

  4. Reindex After Truncating Flat Tables: If you truncate any flat catalog tables, remember to reindex your site afterward using the command php bin/magento indexer:reindex.

Conclusion

Truncating certain Magento database tables can help improve site performance and reduce database size. However, it’s crucial to proceed with caution and understand the implications of each operation.

Always backup your data, test on a staging environment, and ensure you’re only targeting the safe tables listed in this guide. Remember, some tables like core_url_rewrite should be used with extreme caution to avoid losing important rewrite data.

For more advanced database operations and performance optimization techniques, consider exploring our comprehensive guide on Magento database management at LaravelCompany.com.

By following these best practices and targeting the correct tables, you can safely truncate your Magento database while preserving your products and critical data.

Checkout Catalog Indexing Database

Our network