Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jerch committed Aug 4, 2022
1 parent 202b815 commit d009b4c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fast_update/copy.py
Expand Up @@ -906,10 +906,12 @@ def copy_update(
c.execute(f'CREATE TEMPORARY TABLE "{temp}" ({create_columns(column_def)})')
copy_from(c, temp, objs, attnames, colnames, get, encs,
encoding or CONNECTION_ENCODINGS[c.connection.encoding])
# micro optimization (~6x speedup in ./manage.py perf for 10 instances):
# for small changesets ANALYZE is much more expensive than a sequential scan
# of the temp table, tipping point is 150+-80 records (higher for less fields)
# --> enable ANALYZE for >100 only (assuming rather big records for copy_update)
# optimization (~6x speedup in ./manage.py perf for 10 instances):
# for small changesets ANALYZE is much more expensive than
# a sequential scan of the temp table
# tipping point is 150+-80 records (higher for less fields)
# --> enable ANALYZE for >100 only (assuming rather big records
# for copy_update)
if len(objs) > 100:
c.execute(f'ANALYZE "{temp}" ({pk_field.column})')
c.execute(update_sql(model._meta.db_table, temp, pk_field.column, fields))
Expand Down

0 comments on commit d009b4c

Please sign in to comment.