Imporve performance at content relation time
During sync for some content, like Modulemd and Packages, relations are created.
Currently an attempt to create a relation happens for every content in that relation and regardless if it exists or not, if content is saved to the DB or is still in memory only.
To reduce DB requests, the suggestion is to inspect relations (declarative content for both content units is available) and try to create a relation if it doesn't exist.
- check that both objects are saved in the DB, if it's not the case, there is no need even to try to create a relation.
- check if the relation already exists
Updated by dalley about 3 years ago
We should use this when possible: https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.bulk_update
I don't know that we can, due to the way our content objects are structured.
If we cannot -- transactions usually help performance.