Is it better to create an index before filling a table with data, or after the data is in place?
问题 I have a table of about 100M rows that I am going to copy to alter, adding an index. I'm not so concerned with the time it takes to create the new table, but will the created index be more efficient if I alter the table before inserting any data or insert the data first and then add the index? 回答1: Creating index after data insert is more efficient way (it even often recomended to drop index before batch import and after import recreate it). Syntetic example (PostgreSQL 9.1, slow development