I am running Postgres version 10.01
psql -V
psql (PostgreSQL) 10.5
I have a table mytable with about 250 million rows - my objective is to create a new table newtable and copy about half of the mytable into newtable (SELECT * WHERE time > '2019-01-01 ), then to delete the records I copied from mytable
Of course, I want to keep all indices in mytable
What is the most efficient command to do this in psql ? TRUNCATE TABLE is efficient but will remove all rows. DELETE would probably take a lot of time and prevent inserts from happening (INSERTS are scheduled every 10 mins)
Any suggestions would be helpful
psql -Vprints the version of the command line utilitypsql. It's not the version of the Postgres server. That can reliably only obtained by runningselect version();DELETEwill not prevent inserts