From: Derek Downey Date: November 4 2011 4:54pm Subject: Re: Deleting Records in Big tables List-Archive: http://lists.mysql.com/mysql/226241 Message-Id: <0F1F2754-5BA1-4082-BE1F-7747CD5A2163@orange-pants.com> MIME-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Be careful deleting with limit. If you're replicating, you're not = guaranteed the same order of those you've deleted. Perhaps a better way to delete in smaller chunks is to increase the id = value: DELETE FROM my_big_table WHERE id> 5000; DELETE FROM my_big_table WHERE id> 4000; etc -- Derek On Nov 4, 2011, at 12:47 PM, Andy Wallace wrote: > I've had some luck in the past under similar restrictions deleting in > chunks: >=20 > delete from my_big_table where id > 2474 limit 1000 >=20 > But really, the best way is to buy some more disk space and use the > new table method >=20 > On 11/4/11 1:44 AM, Adarsh Sharma wrote: >> Thanks Anand, >>=20 >>=20 >> Ananda Kumar wrote: >>> Why dont you create a new table where id < 2474, rename the original = table to "_old" and the new table to actual table name. >> I need to delete rows from 5 tables each > 50 GB , & I don't have = sufficient space to store extra data. >> My application loads 2 GB data daily in my databases. >>>=20 >>> or >>> You need to write a stored proc to loop through rows and delete, = which will be faster. >>=20 >> Can U provide me a simple example of stored proc >>>=20 >>> Doing just a simple "delete" statement, for deleting huge data will = take ages. >>=20 >> Even the Create Index command on ID takes hours too complete. >>=20 >> I think there is no easiest way to delete that rows from mysql = tables. >>=20 >>=20 >>=20 >>=20 >>=20 >>>=20 >>> regards >>> anandkl >>>=20 >>> On Fri, Nov 4, 2011 at 12:52 PM, Adarsh Sharma = > wrote: >>>=20 >>>=20 >>> Dear all, >>>=20 >>> Today I need to delete some records in > 70 GB tables. >>> I have 4 tables in mysql database. >>>=20 >>> my delete command is :- >>>=20 >>> delete from metadata where id>2474; >>>=20 >>> but it takes hours to complete. >>>=20 >>> One of my table structure is as :- >>>=20 >>> CREATE TABLE `metadata` ( >>> `meta_id` bigint(20) NOT NULL AUTO_INCREMENT, >>> `id` bigint(20) DEFAULT NULL, >>> `url` varchar(800) DEFAULT NULL, >>> `meta_field` varchar(200) DEFAULT NULL, >>> `meta_value` varchar(2000) DEFAULT NULL, >>> `dt_stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, >>> PRIMARY KEY (`meta_id`) >>> ) ENGINE=3DInnoDB AUTO_INCREMENT=3D388780373 ; >>>=20 >>>=20 >>> Please let me know any quickest way to do this. >>> I tried to create indexes in these tables on id, but this too >>> takes time. >>>=20 >>>=20 >>>=20 >>> Thanks >>>=20 >>> -- MySQL General Mailing List >>> For list archives: http://lists.mysql.com/mysql >>> To unsubscribe: http://lists.mysql.com/mysql?unsub=3Danandkl@stripped= >>>=20 >>>=20 >>=20 >>=20 >=20 > --=20 > Andy Wallace > iHOUSEweb, Inc. > awallace@stripped > (866) 645-7700 ext 219 > -- > There are two ways to build software: > Make it so simple that there are obviously no bugs, > or make it so complex that there are no obvious bugs. >=20 > --=20 > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: = http://lists.mysql.com/mysql?unsub=3Dderek@stripped >=20