Created
October 13, 2017 14:20
-
-
Save dip00dip/680f4c384ba0a4ed120c1bd036b20391 to your computer and use it in GitHub Desktop.
delete_mass_records
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET temp_buffers = 1000MB -- or whatever you can spare temporarily | |
CREATE TEMP TABLE tmp AS | |
SELECT t.* | |
FROM tbl t | |
LEFT JOIN del_list d USING (id) | |
WHERE d.id IS NULL; -- copy surviving rows into temporary table | |
TRUNCATE tbl; -- empty table - truncate is very fast for big tables | |
INSERT INTO tbl | |
SELECT * FROM tmp; -- insert back surviving rows. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment