Re: clear a mysql table

From: Date: Sun, 26 Oct 2008 23:43:10 +0000
Subject: Re: clear a mysql table
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-282459@lists.php.net to get a copy of this message
Ronald Wiplinger (Lists) wrote:
I need to clear a table (cache) from a database based on the database size. Our web site uses cached pages. Our webhost only allow us 100 MB storage. Usually the database is just 10 MB, but when a search engine crawls our calendar, then the storage is quickly 108 MB. The system reports then mathematically correct: Space left on database -8MB !!! I plan therefore a web page, which is triggered by cron every hour and will just clear the table. Can I use just: mysql_query("DELETE FROM cash") or die(mysql_error());
If you really want to delete all rows, use truncate cash; otherwise the db deletes the entries row by row - which will be slow, and also it has to update all indexes on the tables as it is doing it. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#282459) next »