gino
gino copied to clipboard
Optimize columns loading: lazy create row locator
Locator instance builds unnecessary query for each row when the model is loaded from a database, to my mind, it is better to create an instance of the locator/UpdateRequest lazily (only if some values are passed to the model)
Here are the results of the benchmarks for loading 20000 rows, from my previous PR
https://github.com/python-gino/gino/pull/786#issuecomment-865472758
before
CPU time: 0.55 s, Real time: 0.56 s
Single column loader
CPU time: 0.33 s, Real time: 0.33 s
Partial loader
CPU time: 0.45 s, Real time: 0.45 s
after
CPU time: 0.20 s, Real time: 0.20 s
Single column loader
CPU time: 0.04 s, Real time: 0.04 s
Partial loader
CPU time: 0.15 s, Real time: 0.15 s