From a55cf2a8031dad7aa5edcddfe5814d6e5971b081 Mon Sep 17 00:00:00 2001 From: ElegantMonkey Date: Sun, 14 May 2017 18:24:41 -0300 Subject: [PATCH] Use NoCount version of GetTorrents The normal GetTorrents version always called COUNT(*) on the query, which consistently took around 300 ms. With the NoCount, the SELECT queries take 5-50 ms. --- service/torrent/metainfoFetcher/metainfoFetcher.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service/torrent/metainfoFetcher/metainfoFetcher.go b/service/torrent/metainfoFetcher/metainfoFetcher.go index 807bc381..179eca5f 100644 --- a/service/torrent/metainfoFetcher/metainfoFetcher.go +++ b/service/torrent/metainfoFetcher/metainfoFetcher.go @@ -196,9 +196,9 @@ func (fetcher *MetainfoFetcher) fillQueue() { } else { params = serviceBase.CreateWhereParams("((filesize IS NULL OR filesize = 0) OR (torrents.torrent_id NOT IN (SELECT files.torrent_id FROM files WHERE files.torrent_id = torrents.torrent_id))) AND date > ?", oldest) } - dbTorrents, count, err := torrentService.GetTorrents(params, fetcher.queueSize, 0) + dbTorrents, err := torrentService.GetTorrentsOrderByNoCount(¶ms, "", fetcher.queueSize, 0) - if count == 0 { + if len(dbTorrents) == 0 { log.Infof("No torrents for filesize update") return }