class optuna.storages.RDBStorage(url, engine_kwargs=None, skip_compatibility_check=False)[source]

Storage class for RDB backend.

Note that library users can instantiate this class, but the attributes provided by this class are not supposed to be directly accessed by them.


We create an RDBStorage instance with customized pool_size and max_overflow settings.

>>> import optuna
>>> def objective(trial):
>>>     ...
>>> storage = optuna.storages.RDBStorage(
>>>     url='postgresql://foo@localhost/db',
>>>     engine_kwargs={
>>>         'pool_size': 20,
>>>         'max_overflow': 0
>>>     }
>>> )
>>> study = optuna.create_study(storage=storage)
>>> study.optimize(objective)


If you use MySQL, pool_pre_ping will be set to True by default to prevent connection timeout. You can turn it off with engine_kwargs['pool_pre_ping']=False, but it is recommended to keep the setting if execution time of your objective function is longer than the wait_timeout of your MySQL configuration.