Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I truncate the sales_flat_quote table in Magento database?

Tags:

mysql

magento

I'm working on a magento site which has a large amount of entries in the following tables:

Mysql grid from phpadmin

I have read some threads on this at: http://www.magentocommerce.com/boards/viewthread/67941/

I would like to know if i can safely delete some of the entries in these tables without foobaring the site up ! many thanks

like image 706
Ledgemonkey Avatar asked Feb 07 '12 07:02

Ledgemonkey


1 Answers

You can actually truncate the whole table - but you'll need to make sure you set the auto-increment ID back to what it was previously.

SET FOREIGN_KEY_CHECKS=0;
DELETE FROM `sales_flat_quote` WHERE updated_at < DATE_SUB(Now(),INTERVAL 60 DAY) 

However, it is much better to simple truncate records older than X days. Magento is supposed to do this automatically as part of its log cleaning - but I have never seen it working as expected (from 1.4 CE to 1.10 EE)

You can find a more thorough explanation here https://www.sonassi.com/blog/magento-kb/enourmous-magento-sales_flat_quote-tables

I would check out your other log tables too, as they'll likely be growing continually too, you can take the same approach with those, https://www.sonassi.com/blog/magento-kb/speed-up-magento-product-import-export-and-general-via-the-database

like image 58
Ben Lessani Avatar answered Oct 31 '22 14:10

Ben Lessani