Should I delete index before bulk-loading data with COPY?
2
votes
1
answer
402
views
My pet project has one table which is totally rewritten once a day. This project uses a PostgreSQL database. I decided to use
COPY
to insert data from 4 CSV files (about 3 million rows).
At the same time there are maybe some queries to that table from clients. This table has a composite index. I use COPY
in a transaction.
- Should the index be deleted before COPY and then recreated?
- Or index recreated automatically after new data inserted?
- Maybe there is better solution than I have chosen?
Queries need the index.
I don't understand whether the index will be rebuilt automatically or whether it will need to be rebuilt manually. If manually, then maybe delete it first and then create it after copy. But I see that in my case I can't delete the index because there are concurent queries.
Asked by Rash-77
(21 rep)
May 10, 2024, 10:35 AM
Last activity: May 11, 2024, 09:14 AM
Last activity: May 11, 2024, 09:14 AM