To drop an index with psycopg2 takes effect before or after commit?

Viewed 525

I'm doing a python script to insert several data into a postgresql database.

Following the postgresql documentation in order to speed up the load process my script has this sort of structure

  • Connect to the database and create a cursor
  • Drop all the indexes
  • Load all the data using the 'copy' command
  • Recreate back all the indexes
  • Commit and close of the cursor and connection (only commit in the whole script)

So my question is: Is dropping the indexes before the commit, taking any effect in terms of speeding up the loading, or not ?

1 Answers
Related