I have a table with 10 million records, which is the fastest way to delete and save the last 30 days.
I know that this can be done in the event planner, but I worry if it takes too long, it can lock the table for a long time.
It will be great if you can offer the best way.
Thank.
Sent, I would:
() 30 .
.
PARTITION BY LIST (TO_DAYS( date_field ))
1 , , :
ALTER TABLE tbl_name DROP PARTITION p#
http://dev.mysql.com/doc/refman/5.1/en/partitioning.html
, , , : merge, . partitioning, ( ) .
merge
,
: table - , newtable -
rename table table to temptable, newtable to table; drop temptable;
, . concurrency .
, , , sql temp delete. temp, , max_packet_size. MySQL 16 (16777216 ). temp max_packet_size. . , . , , .
Turn off your resource,, SELECT .. INTO OUTFILEoutput the parsing, delete the table, LOAD DATA LOCAL INFILE optimized_db.txt- it’s cheaper to recreate than UPDATE.
SELECT .. INTO OUTFILE
LOAD DATA LOCAL INFILE optimized_db.txt
Source: https://habr.com/ru/post/1766862/More articles:How to fix the Visual Studio 2008 redraw problem? - visual-studio-2008Django LEFT OUTER JOIN on two columns where one is not a foreign key - sqlPrint Specification Name - ruby-on-railsVery simple memory leak Ruby GServer - ruby | fooobar.comPass success_url to activate - pythonDynamic tables? - sqlDoes the link not work when positioning with a background image? - javascriptiOS - как обрабатывать изменения ориентации в пользовательских ячейках таблицы - iphoneMalicious destination detection? - securityRails3 and heroku image_path - ruby-on-rails-3All Articles