-
Notifications
You must be signed in to change notification settings - Fork 7
Performance
=== Reusing objects ===
Most of the API functions (like add_condition(...)
or get_condition(...)
) can accept model objects as
parameters:
run = db.get_run(1) ct = db.get_condition_type("my_value") db.add_condition(run, ct, 10)
When you do db.add_condition(1, "my_value", 10)
condition type and run are queried inside a function. If you do several actions with one object, like adding many conditions for one run or adding one condition to many runs, reusing the object could boost performance up to 30% each.
=== Auto commit value addition===
Performance study shows, that approximately 50% of the time spent in add_condition(...)
is used to commit changes to DB.
To speed up conditions addition add_condition(...)
function has '''auto_commit''' optional argument.
By default it is '''True''', changes are committed to DB, if ''add_condition'' call is successful.
Setting ''auto_commit''='''False''' allows to defer commit, changes are pending in SQLAlchemy cache and can be committed
manually later.
''auto_commit''='''False''' purposes are:
- Make a lot of changes and commit them at one time gaining performance
- Rollback changes
To commit changes, having db = RCDBProvider(...)
you should call db.session.commit()
self.db.add_condition(1, ct, 10, auto_commit=False)
val = self.db.get_condition(1, ct) self.assertEqual(val.value, 10)
self.db.session.commit()
self.db.add_condition(1, ct, 20, None, True, False) self.db.add_condition(1, ct, 30, None, True, False)
val = self.db.get_condition(1, ct) self.assertEqual(val.value, 30)
self.db.session.rollback() val = self.db.get_condition(1, ct) self.assertEqual(val.value, 10)
The example is available in tests:
$RCDB_HOME/python/tests/test_conditions.py
(!) note at the same time, that more complex scenarios with not committed objects haven't been tested.
Getting started & basic usage:
- Installation
- Select values tutorial (python)
- Query syntax
- Add data (python)
- CLI Basics
RCDB Explained:
- Connection
- DB and APIs structure
- SQL examples
- Creating condition types
- Adding condition values
- Saving files
- SQLAlchemy
- Logging
- Performance
Command line tools:
DAQ: