View Source Oban.Plugins.Reindexer (Oban v2.12.1)
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
:schedule
— a cron expression that controls when to reindex. Defaults to"@midnight"
.: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 tzdata 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
.