Situation
In our magento database we have three tables that are growing too big.
- sales_flat_quote_shipping_rate: 3045MB
- sales_flat_quote_address: 1688MB
- sales_flat_quote: 1897MB
That's more than 6GB of data.
I've found this article on how to truncate these tables. This article only speaks of the third table.
I'm not sure about the truncating, and I prefer to delete all data older than 60 days. The article speaks of 17 million records – we have 20! If I'm correct, deleting these records won't lock the table, and I'm currently testing this on a test installation. That seems to work, and it doesn't conflict too much with the site.
Questions
- I would like to know if I can use the same query for the other two tables as well?
- I'm wondering what these tables are for.
Best Answer
sales_flat_quote
and it's related tables use foreign key relations to delete on cascade so deletions in the primary table deletes all related entries automatically in the other tables.Once you get it down in size, you can easily modify the observer (obligatory make a module here) that's supposed to clean out expired quotes to include all quotes as is done in the first link with customized retention for abandoned cart recovery and retention of logged in customer quotes for a reasonable period so your customers don't get mad when their cart empties unexpectedly: Are unconverted quote records ever removed in Magento?
or use Fabrizio Branca's AOE Quote Cleaner
sales_flat_quote* tables contain shopping cart contents. This is known as a quote and is held until the customer decides to finish placing the order. For finished quotes that have been converted to Sales-Order, Magento automatically clears them with a cron job. The logic was never extended to include open quotes.