performance - How to tune this query when updating 4 million records in MySQL? -
i have query set date far far in future. table has 4 million records. , query straight forward. query took 3 min run.
update table set to_date = str_to_date('31-01-3000','%d-%m-%y') to_date null;
there's no index on column.
how can tune query or mysql itself? lot.
fastest solution not involving index (and in fact, fastest solution period), make column default '31-01-3000', means you'll never have update it. note initial alter may take quite few minutes, though, considering you're running on such large table.
alter table `table_name` change column `to_date` `to_date` date not null default '3000-01-31';
Comments
Post a Comment