forked from LBRYCommunity/lbry-sdk
use LEFT JOIN instead of IN for faster get_block_range_without_filters()
This commit is contained in:
parent
d10a88c79b
commit
082a91dc15
1 changed files with 4 additions and 2 deletions
|
@ -251,8 +251,10 @@ def get_block_range_without_filters() -> Tuple[int, int]:
|
|||
func.coalesce(func.min(BlockTable.c.height), -1).label('start_height'),
|
||||
func.coalesce(func.max(BlockTable.c.height), -1).label('end_height'),
|
||||
)
|
||||
.select_from(BlockTable)
|
||||
.where(BlockTable.c.height.notin_(select(BlockFilter.c.height)))
|
||||
.select_from(
|
||||
BlockTable.join(BlockFilter, BlockTable.c.height == BlockFilter.c.height, isouter=True)
|
||||
)
|
||||
.where(BlockFilter.c.height == None)
|
||||
)
|
||||
result = context().fetchone(sql)
|
||||
return result['start_height'], result['end_height']
|
||||
|
|
Loading…
Reference in a new issue