Skip to content

Make the history purger query more efficient#1319

Merged
ssalinas merged 8 commits intomasterfrom
purger_query
Oct 24, 2016
Merged

Make the history purger query more efficient#1319
ssalinas merged 8 commits intomasterfrom
purger_query

Conversation

@ssalinas
Copy link
Copy Markdown
Contributor

@ssalinas ssalinas commented Oct 17, 2016

Currently the purger query can grow in an unbounded manner when in the mode to set bytes to '' rather than deleting, since the query just goes by updatedAt < x. This PR updates the taskHistory table to have an additional indexed purged column. This way we can limit our query to only tasks we have not already purged.

/cc @tpetr @darcatron

abstract Date getMinUpdatedAtWithLimitForRequest(@Bind("requestId") String requestId, @Bind("limit") Integer limit);

@SqlUpdate("UPDATE taskHistory SET bytes = '' WHERE requestId = :requestId AND updatedAt \\< :updatedAtBefore")
@SqlUpdate("UPDATE taskHistory SET bytes = '', purged = true WHERE requestId = :requestId AND purged = false AND updatedAt \\< :updatedAtBefore")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is true proper SQL here? wouldn't it be 1? (not 100% sure myself)

@ssalinas
Copy link
Copy Markdown
Contributor Author

Removed the update statement from the migration. When the purger first runs, the relevant rows will be updated and all subsequent runs of the purger will be faster

@ssalinas ssalinas modified the milestone: 0.12.0 Oct 18, 2016
@ssalinas ssalinas merged commit 64e0611 into master Oct 24, 2016
@ssalinas ssalinas deleted the purger_query branch October 24, 2016 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants