I now have a table that has 604 000 row. I would like to drop 4000 random rows so my table will only contains 600 000 entries.
Would there be a quick way to do so ?
Thanks a lot.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In theory, this will be random and fast. In practise, it will be only fast:
This will be random but terribly slow, with 600K rows:
This won’t be truly random (as there are usually gaps in the ids) and it may not even delete exactly 4000 rows (but a few less when there are many gaps) but it’s probably faster than the previous.
An extra wrapping in a subquery is needed because the syntax for Delete from multiple tables does not allow
LIMIT:Explain output (of the subquery, from a 400K rows table):