1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

feat(storage): add limit parameter to ClearRemovedEntriesContent

Without the limit, this query is going to hangs forever on large
databases with millions of entries.
This commit is contained in:
Frédéric Guillot 2025-08-17 17:30:33 -07:00
parent 905d652511
commit 5403ca09f6
2 changed files with 13 additions and 6 deletions

View file

@ -297,7 +297,7 @@ func (s *Storage) DeleteRemovedEntriesEnclosures() (int64, error) {
}
// ClearRemovedEntriesContent clears the content fields of entries marked as "removed", keeping only their metadata.
func (s *Storage) ClearRemovedEntriesContent() (int64, error) {
func (s *Storage) ClearRemovedEntriesContent(limit int) (int64, error) {
query := `
UPDATE
entries
@ -305,12 +305,19 @@ func (s *Storage) ClearRemovedEntriesContent() (int64, error) {
title='',
content=NULL,
url='',
author=NULL
WHERE
status=$1 AND content IS NOT NULL
author=NULL,
comments_url=NULL,
document_vectors=NULL
WHERE id IN (
SELECT id
FROM entries
WHERE status = $1 AND content IS NOT NULL
ORDER BY id ASC
LIMIT $2
)
`
result, err := s.db.Exec(query, model.EntryStatusRemoved)
result, err := s.db.Exec(query, model.EntryStatusRemoved, limit)
if err != nil {
return 0, fmt.Errorf(`store: unable to clear content from removed entries: %v`, err)
}