more indexes

This commit is contained in:
Lex Berezhny 2020-07-13 14:29:38 -04:00
parent af4138ff51
commit 8fd92cb649
3 changed files with 18 additions and 15 deletions

View file

@ -175,7 +175,7 @@ def claims_update(blocks: Tuple[int, int], p: ProgressContext):
for row in cursor:
txo, extra = row_to_claim_for_saving(row)
loader.update_claim(txo, **extra)
if len(loader.update_claims) >= 500:
if len(loader.update_claims) >= 25:
p.add(loader.flush(Claim))
p.add(loader.flush(Claim))

View file

@ -394,7 +394,7 @@ class Advanced(Basic):
label = d.get('label', name[-11:])
self.get_or_create_bar(
f"{name}#{d['id']}", label, d['units'], d['total'],
name.split('.')[-1] not in ('insert', 'update')
name.split('.')[-1] not in ('insert', 'update', 'file')
)
else:
if d['done'][0] != -1:

View file

@ -203,17 +203,6 @@ Claim = Table(
)
def pg_add_claim_constraints_and_indexes(execute):
execute(text("ALTER TABLE claim ADD PRIMARY KEY (claim_hash);"))
# finding claims that aren't updated with latest TXO
execute(text("CREATE INDEX claim_txo_hash ON claim (txo_hash);"))
# used to calculate content in a channel
execute(text("""
CREATE INDEX signed_content ON claim (channel_hash)
INCLUDE (amount) WHERE is_signature_valid;
"""))
Tag = Table(
'tag', metadata,
Column('claim_hash', LargeBinary),
@ -221,6 +210,20 @@ Tag = Table(
)
def pg_add_claim_constraints_and_indexes(execute):
execute(text("ALTER TABLE claim ADD PRIMARY KEY (claim_hash);"))
execute(text("ALTER TABLE tag ADD PRIMARY KEY (claim_hash, tag);"))
# take over updates are base on normalized name
execute(text("CREATE INDEX claim_normalized ON claim (normalized);"))
# finding claims that aren't updated with latest TXO
execute(text("CREATE UNIQUE INDEX claim_txo_hash ON claim (txo_hash);"))
# used to calculate content in a channel
execute(text("""
CREATE INDEX signed_content ON claim (channel_hash)
INCLUDE (amount) WHERE is_signature_valid;
"""))
Support = Table(
'support', metadata,