more indexes
This commit is contained in:
parent
af4138ff51
commit
8fd92cb649
3 changed files with 18 additions and 15 deletions
|
@ -58,9 +58,9 @@ def staked_support_count_calc(other):
|
||||||
|
|
||||||
def make_label(action, blocks):
|
def make_label(action, blocks):
|
||||||
if blocks[0] == blocks[-1]:
|
if blocks[0] == blocks[-1]:
|
||||||
return f"{action}{blocks[0]:>6}"
|
return f"{action} {blocks[0]:>6}"
|
||||||
else:
|
else:
|
||||||
return f"{action}{blocks[0]:>6}-{blocks[-1]:>6}"
|
return f"{action} {blocks[0]:>6}-{blocks[-1]:>6}"
|
||||||
|
|
||||||
|
|
||||||
def select_claims_for_saving(
|
def select_claims_for_saving(
|
||||||
|
@ -175,7 +175,7 @@ def claims_update(blocks: Tuple[int, int], p: ProgressContext):
|
||||||
for row in cursor:
|
for row in cursor:
|
||||||
txo, extra = row_to_claim_for_saving(row)
|
txo, extra = row_to_claim_for_saving(row)
|
||||||
loader.update_claim(txo, **extra)
|
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))
|
||||||
p.add(loader.flush(Claim))
|
p.add(loader.flush(Claim))
|
||||||
|
|
||||||
|
|
|
@ -394,7 +394,7 @@ class Advanced(Basic):
|
||||||
label = d.get('label', name[-11:])
|
label = d.get('label', name[-11:])
|
||||||
self.get_or_create_bar(
|
self.get_or_create_bar(
|
||||||
f"{name}#{d['id']}", label, d['units'], d['total'],
|
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:
|
else:
|
||||||
if d['done'][0] != -1:
|
if d['done'][0] != -1:
|
||||||
|
|
|
@ -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 = Table(
|
||||||
'tag', metadata,
|
'tag', metadata,
|
||||||
Column('claim_hash', LargeBinary),
|
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 = Table(
|
||||||
'support', metadata,
|
'support', metadata,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue