Recently I have received a data dump in csv format that I am trying to import in my PSQL database. The dump consists of 8 csv file each of size 7GB.
I have found that using the Copy command on one file is incredibly slow if the indexes are defined on the table. I have 2 indexes, one on 3 fields and one on 2. Whereas copy on table with no index takes roughly 2 minutes. I was wondering, what is the best practice to copy and index big data files from CSV, for now, copying then reindexing seems like my best options. Is there any best practice for that. Why is copy incredibly slow when indexing data?