java - 批量删除大量数据的一个疑问
巴扎黑
巴扎黑 2017-04-18 09:42:41
0
4
376

有一张同步表,这里面每条信息都有一个图片路径,这张表每天产生50万条数据,到了第二天凌晨需要删除这50万条数据,以及这50万条数据对应的图片文件。

我的想法是:

  • 在一个循环中进行前100条当天数据的分页查询,一旦查询有数据,就进入循环

  • 然后将每次分页查询出来的内容进行遍历,获取图片路径,然后进行图片文件的删除,并将刚才分页查询出来的数据从数据库里删掉

不知道大家有没有更好的办法,能更快速的进行删除

谢谢

巴扎黑
巴扎黑

reply all(4)
刘奇

Add a field by date, and the pictures are divided into categories by date. One directory is deleted every day.

伊谢尔伦

Are you starting to engage in technology after retirement?

PHPzhong

Why are the pictures to be deleted together not in a specific path?

洪涛

Create a table by day and a picture directory by day

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!