Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make owncloudsql leverage existing filecache index #2075

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: make owncloudsql leverage existing filecache index

When listing folders the SQL query now uses an existing index on the filecache table.

https://github.com/cs3org/reva/pull/2075
8 changes: 5 additions & 3 deletions pkg/storage/fs/owncloudsql/filecache/filecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,17 @@ func (c *Cache) List(storage interface{}, p string) ([]*File, error) {
return nil, err
}

rows, err := c.db.Query(`
var rows *sql.Rows
phash := fmt.Sprintf("%x", md5.Sum([]byte(strings.Trim(p, "/"))))
rows, err = c.db.Query(`
SELECT
fc.fileid, fc.storage, fc.path, fc.parent, fc.permissions, fc.mimetype, fc.mimepart,
mt.mimetype, fc.size, fc.mtime, fc.storage_mtime, fc.encrypted, fc.unencrypted_size,
fc.name, fc.etag, fc.checksum
FROM oc_filecache fc
LEFT JOIN oc_mimetypes mt ON fc.mimetype = mt.id
WHERE path != '' AND path LIKE ? AND PATH NOT LIKE ? AND storage = ?
`, p+"%", p+"%/%", storageID)
WHERE storage = ? AND parent = (SELECT fileid FROM oc_filecache WHERE storage = ? AND path_hash=?) AND name IS NOT NULL
`, storageID, storageID, phash)
if err != nil {
return nil, err
}
Expand Down