diff --git a/postgrestq/task_queue.py b/postgrestq/task_queue.py index cb16761..f6deb17 100644 --- a/postgrestq/task_queue.py +++ b/postgrestq/task_queue.py @@ -98,6 +98,14 @@ def _create_queue_table(self) -> None: )""" ).format(sql.Identifier(self._table_name)) ) + cur.execute( + sql.SQL( + """CREATE INDEX IF NOT EXISTS + task_queue_can_start_at_idx + ON {} (can_start_at) + """ + ).format(sql.Identifier(self._table_name)) + ) def __len__(self) -> int: """