8000 [pull] main from miniflux:main by pull[bot] · Pull Request #367 · suhaoGe/miniflux · GitHub
[go: up one dir, main page]

Skip to content
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
11 changes: 11 additions & 0 deletions internal/database/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1568,4 +1568,15 @@ var migrations = [...]func(tx *sql.Tx) error{
`)
return err
},
func(tx *sql.Tx) (err error) {
// Index the raw SHA-256 digest (32 bytes) instead of its hex text
// encoding (64 bytes) to roughly halve this index on disk. The
// ON CONFLICT clause in createEnclosure uses the same expression.
_, err = tx.Exec(`
DROP INDEX IF EXISTS enclosures_user_entry_url_unique_idx;
CREATE UNIQUE INDEX enclosures_user_entry_url_unique_idx
ON enclosures (user_id, entry_id, sha256(url::bytea));
`)
return err
},
}
2 changes: 1 addition & 1 deletion internal/storage/enclosure.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (s *Storage) createEnclosure(tx *sql.Tx, enclosure *model.Enclosure) error
(url, size, mime_type, entry_id, user_id, media_progression)
VALUES
($1, $2, $3, $4, $5, $6)
ON CONFLICT (user_id, entry_id, encode(sha256(url::bytea), 'hex')) DO NOTHING
ON CONFLICT (user_id, entry_id, sha256(url::bytea)) DO NOTHING
RETURNING
id
`
Expand Down
Loading
0