From 43c73b9abfa244a63ba0d638627b7788714ae9e0 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Mon, 19 Mar 2018 13:31:05 -0400 Subject: [PATCH] fix slow sqlite query --- lbrynet/database/storage.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lbrynet/database/storage.py b/lbrynet/database/storage.py index 4dce4b477..a77a8dae8 100644 --- a/lbrynet/database/storage.py +++ b/lbrynet/database/storage.py @@ -423,12 +423,14 @@ class SQLiteStorage(object): if only_completed: lengths = transaction.execute( "select b.blob_hash, b.blob_length from blob b " - "inner join stream_blob s ON b.blob_hash=s.blob_hash and b.status='finished'" + "inner join stream_blob s ON b.blob_hash=s.blob_hash and b.status='finished' and s.stream_hash=?", + (stream_hash, ) ).fetchall() else: lengths = transaction.execute( "select b.blob_hash, b.blob_length from blob b " - "inner join stream_blob s ON b.blob_hash=s.blob_hash" + "inner join stream_blob s ON b.blob_hash=s.blob_hash and s.stream_hash=?", + (stream_hash, ) ).fetchall() blob_length_dict = {}