optimize definition of state_heights

In the same parentstateroot, the one with the smallest height should be selected
This commit is contained in:
Albert·Gou 2020-09-11 16:52:48 +08:00
parent 232cc320bd
commit 6e7de3c8d9

View File

@ -136,7 +136,8 @@ create unique index if not exists block_cid_uindex
on blocks (cid,height); on blocks (cid,height);
create materialized view if not exists state_heights create materialized view if not exists state_heights
as select distinct height, parentstateroot from blocks; as select b.parentstateroot, min(b.height) height
from blocks b group by b.parentstateroot;
create index if not exists state_heights_height_index create index if not exists state_heights_height_index
on state_heights (height); on state_heights (height);