fix blockchain sync query performance issue
This commit is contained in:
parent
953b8dab76
commit
f532a1fbcd
2 changed files with 11 additions and 5 deletions
|
@ -598,7 +598,7 @@ class Config(CLIConfig):
|
|||
('reflector.lbry.com', 5566)
|
||||
])
|
||||
full_nodes = Servers("Full blockchain nodes", [
|
||||
('sdk.lbry.tech', 50001),
|
||||
('sdk.lbry.tech', 5278),
|
||||
('spv12.lbry.com', 50001),
|
||||
('spv13.lbry.com', 50001),
|
||||
('spv14.lbry.com', 50001),
|
||||
|
|
|
@ -2,7 +2,7 @@ import logging
|
|||
from datetime import date
|
||||
from typing import Tuple, List, Optional, Union
|
||||
|
||||
from sqlalchemy import union, func, text, between, distinct, case, false
|
||||
from sqlalchemy import union, func, text, between, distinct, case, false, not_, exists
|
||||
from sqlalchemy.future import select, Select
|
||||
|
||||
from lbry.constants import INVALIDATED_SIGNATURE_GRACE_PERIOD
|
||||
|
@ -60,11 +60,17 @@ def where_unspent_txos(
|
|||
if blocks is not None:
|
||||
condition &= between(TXO.c.height, *blocks)
|
||||
if missing_in_supports_table:
|
||||
condition &= TXO.c.txo_hash.notin_(select(Support.c.txo_hash))
|
||||
condition &= not_(
|
||||
exists(select(1).where(Support.c.txo_hash == TXO.c.txo_hash))
|
||||
)
|
||||
elif missing_or_stale_in_claims_table:
|
||||
condition &= TXO.c.txo_hash.notin_(select(Claim.c.txo_hash))
|
||||
condition &= not_(
|
||||
exists(select(1).where(Claim.c.txo_hash == TXO.c.txo_hash))
|
||||
)
|
||||
elif missing_in_claims_table:
|
||||
condition &= TXO.c.claim_hash.notin_(select(Claim.c.claim_hash))
|
||||
condition &= not_(
|
||||
exists(select(1).where(Claim.c.claim_hash == TXO.c.claim_hash))
|
||||
)
|
||||
return condition
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue