Skip to content

Commit

Permalink
database: Update Cayley to fix slow deletions
Browse files Browse the repository at this point in the history
subject, predicate, object and labels are not indexed, thus, using a where clause on these fields for the DELETE statement does a full-table scan. Using *_hash columns instead will use the indexes.
  • Loading branch information
Quentin-M committed Nov 18, 2015
1 parent ac0e68e commit cfa960d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions database/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ func Lock(name string, duration time.Duration, owner string) (bool, time.Time) {

// Unlock unlocks a lock specified by its name if I own it
func Unlock(name, owner string) {
pruneLocks()

unlocked := 0
it, _ := cayley.StartPath(store, name).Has("locked", "locked").Has("locked_by", owner).Save("locked_until", "locked_until").BuildIterator().Optimize()
defer it.Close()
Expand Down Expand Up @@ -133,7 +131,7 @@ func pruneLocks() {
tt, _ := strconv.ParseInt(t, 10, 64)

if now.Unix() > tt {
log.Debugf("Lock %s owned by %s has expired.", n, o)
log.Debugf("lock %s owned by %s has expired.", n, o)

tr := cayley.NewTransaction()
tr.RemoveQuad(cayley.Quad(n, "locked", "locked", ""))
Expand All @@ -142,7 +140,9 @@ func pruneLocks() {
err := store.ApplyTransaction(tr)
if err != nil {
log.Errorf("failed transaction (pruneLocks): %s", err)
continue
}
log.Debugf("lock %s has been successfully pruned.", n)
}
}
if it.Err() != nil {
Expand Down
4 changes: 2 additions & 2 deletions vendor/github.com/google/cayley/graph/sql/quadstore.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cfa960d

Please sign in to comment.