Merge "More efficient pruning of events"
This commit is contained in:
commit
dd2e69a794
|
@ -898,13 +898,16 @@ def _delete_event_rows(context, stack_id, limit):
|
||||||
# So we must manually supply the IN() values.
|
# So we must manually supply the IN() values.
|
||||||
# pgsql SHOULD work with the pure DELETE/JOIN below but that must be
|
# pgsql SHOULD work with the pure DELETE/JOIN below but that must be
|
||||||
# confirmed via integration tests.
|
# confirmed via integration tests.
|
||||||
query = _query_all_by_stack(context, stack_id)
|
|
||||||
session = context.session
|
session = context.session
|
||||||
ids = [r.id for r in query.order_by(
|
res = session.query(models.Event.id).filter_by(
|
||||||
models.Event.id).limit(limit).all()]
|
stack_id=stack_id).order_by(models.Event.id).limit(limit).all()
|
||||||
q = session.query(models.Event).filter(
|
if not res:
|
||||||
models.Event.id.in_(ids))
|
return 0
|
||||||
return q.delete(synchronize_session='fetch')
|
(max_id, ) = res[-1]
|
||||||
|
return session.query(models.Event).filter(
|
||||||
|
models.Event.id <= max_id).filter(
|
||||||
|
models.Event.stack_id == stack_id).delete(
|
||||||
|
synchronize_session=False)
|
||||||
|
|
||||||
|
|
||||||
def event_create(context, values):
|
def event_create(context, values):
|
||||||
|
|
Loading…
Reference in New Issue