perseas / Pyrseas

Provides utilities for Postgres database schema versioning.
https://perseas.github.io/
BSD 3-Clause "New" or "Revised" License
395 stars 67 forks source link

Omit deepcopy for constraints and tables #255

Closed pwmarcz closed 1 year ago

pwmarcz commented 1 year ago

It looks like invoking deepcopy on all fields for constraints and tables takes a significant amount of time, since we end up copying nested objects that we don't care about in the final result.

Instead, we can copy only the dictionaries that we're going to modify, and then deepcopy the final result (which is going to be much smaller).

The difference is drastic: on my database (250+ tables), this speeds up dbtoyaml from 70 seconds to 1.2 seconds, with the same final YAML generated.