From 38b80d96eaa4aa57a95d02ae4ffd1d5833c7c7e7 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Thu, 4 Apr 2024 21:19:02 -0700 Subject: storage: change GetReadTime() function to use entries_feed_id_hash_key index --- internal/storage/entry.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'internal/storage/entry.go') diff --git a/internal/storage/entry.go b/internal/storage/entry.go index 867338f7..f22a424b 100644 --- a/internal/storage/entry.go +++ b/internal/storage/entry.go @@ -231,24 +231,21 @@ func (s *Storage) IsNewEntry(feedID int64, entryHash string) bool { return !result } -// GetReadTime fetches the read time of an entry based on its hash, and the feed id and user id from the feed. -// It's intended to be used on entries objects created by parsing a feed as they don't contain much information. -// The feed param helps to scope the search to a specific user and feed in order to avoid hash clashes. -func (s *Storage) GetReadTime(entry *model.Entry, feed *model.Feed) int { +func (s *Storage) GetReadTime(feedID int64, entryHash string) int { var result int + + // Note: This query uses entries_feed_id_hash_key index s.db.QueryRow( `SELECT reading_time FROM entries WHERE - user_id=$1 AND - feed_id=$2 AND - hash=$3 + feed_id=$1 AND + hash=$2 `, - feed.UserID, - feed.ID, - entry.Hash, + feedID, + entryHash, ).Scan(&result) return result } -- cgit v1.2.3