View Source Oban.Plugins.Reindexer (Oban v2.14.0)
Periodically rebuild indexes to minimize database bloat.
Over time various Oban indexes may grow without VACUUM
cleaning them up properly. When this
happens, rebuilding the indexes will release bloat.
The plugin uses REINDEX
with the CONCURRENTLY
option to rebuild without taking any locks
that prevent concurrent inserts, updates, or deletes on the table.
Note: This plugin requires the CONCURRENT
option, which is only available in Postgres 12 and
above.
using-the-plugin
Using the Plugin
By default, the plugin will reindex once a day, at midnight UTC:
config :my_app, Oban,
plugins: [Oban.Plugins.Reindexer],
...
To run on a different schedule you can provide a cron expression. For example, you could use the
"@weekly"
shorthand to run once a week on Sunday:
config :my_app, Oban,
plugins: [{Oban.Plugins.Reindexer, schedule: "@weekly"}],
...
options
Options
:indexes
— a list of indexes to reindex on theoban_jobs
table. Defaults to only theoban_jobs_args_index
andoban_jobs_meta_index
.:schedule
— a cron expression that controls when to reindex. Defaults to"@midnight"
.:timeout
- time in milliseconds to wait for each query call to finish. Defaults to 15 seconds.:timezone
— which timezone to use when evaluating the schedule. To use a timezone other than the default of "Etc/UTC" you must have a timezone database like tz installed and configured.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Link to this section Types
@type option() :: Oban.Plugin.option() | {:schedule, binary()}
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.