vacuum analyze public.blocks after cleanup

This commit is contained in:
Ian Norden 2020-03-26 04:25:00 -05:00
parent f4a20de5ae
commit 657abbb7ec
2 changed files with 33 additions and 7 deletions

View File

@ -86,7 +86,9 @@ func (c *Cleaner) vacuumAnalyze(t shared.DataType) error {
if err := c.vacuumTxInputs(); err != nil { if err := c.vacuumTxInputs(); err != nil {
return err return err
} }
return c.vacuumTxOutputs() if err := c.vacuumTxOutputs(); err != nil {
return err
}
case shared.Transactions: case shared.Transactions:
if err := c.vacuumTxs(); err != nil { if err := c.vacuumTxs(); err != nil {
return err return err
@ -94,10 +96,13 @@ func (c *Cleaner) vacuumAnalyze(t shared.DataType) error {
if err := c.vacuumTxInputs(); err != nil { if err := c.vacuumTxInputs(); err != nil {
return err return err
} }
return c.vacuumTxOutputs() if err := c.vacuumTxOutputs(); err != nil {
return err
}
default: default:
return fmt.Errorf("btc cleaner unrecognized type: %s", t.String()) return fmt.Errorf("btc cleaner unrecognized type: %s", t.String())
} }
return c.vacuumIPLDs()
} }
func (c *Cleaner) vacuumHeaders() error { func (c *Cleaner) vacuumHeaders() error {
@ -120,6 +125,11 @@ func (c *Cleaner) vacuumTxOutputs() error {
return err return err
} }
func (c *Cleaner) vacuumIPLDs() error {
_, err := c.db.Exec(`VACUUM ANALYZE public.blocks`)
return err
}
func (c *Cleaner) cleanFull(tx *sqlx.Tx, rng [2]uint64) error { func (c *Cleaner) cleanFull(tx *sqlx.Tx, rng [2]uint64) error {
if err := c.cleanTransactionIPLDs(tx, rng); err != nil { if err := c.cleanTransactionIPLDs(tx, rng); err != nil {
return err return err

View File

@ -105,14 +105,20 @@ func (c *Cleaner) vacuumAnalyze(t shared.DataType) error {
case shared.Full, shared.Headers: case shared.Full, shared.Headers:
return c.vacuumFull() return c.vacuumFull()
case shared.Uncles: case shared.Uncles:
return c.vacuumUncles() if err := c.vacuumUncles(); err != nil {
return err
}
case shared.Transactions: case shared.Transactions:
if err := c.vacuumTxs(); err != nil { if err := c.vacuumTxs(); err != nil {
return err return err
} }
return c.vacuumRcts() if err := c.vacuumRcts(); err != nil {
return err
}
case shared.Receipts: case shared.Receipts:
return c.vacuumRcts() if err := c.vacuumRcts(); err != nil {
return err
}
case shared.State: case shared.State:
if err := c.vacuumState(); err != nil { if err := c.vacuumState(); err != nil {
return err return err
@ -120,12 +126,17 @@ func (c *Cleaner) vacuumAnalyze(t shared.DataType) error {
if err := c.vacuumAccounts(); err != nil { if err := c.vacuumAccounts(); err != nil {
return err return err
} }
return c.vacuumStorage() if err := c.vacuumStorage(); err != nil {
return err
}
case shared.Storage: case shared.Storage:
return c.vacuumStorage() if err := c.vacuumStorage(); err != nil {
return err
}
default: default:
return fmt.Errorf("eth cleaner unrecognized type: %s", t.String()) return fmt.Errorf("eth cleaner unrecognized type: %s", t.String())
} }
return c.vacuumIPLDs()
} }
func (c *Cleaner) vacuumFull() error { func (c *Cleaner) vacuumFull() error {
@ -185,6 +196,11 @@ func (c *Cleaner) vacuumStorage() error {
return err return err
} }
func (c *Cleaner) vacuumIPLDs() error {
_, err := c.db.Exec(`VACUUM ANALYZE public.blocks`)
return err
}
func (c *Cleaner) cleanFull(tx *sqlx.Tx, rng [2]uint64) error { func (c *Cleaner) cleanFull(tx *sqlx.Tx, rng [2]uint64) error {
if err := c.cleanStorageIPLDs(tx, rng); err != nil { if err := c.cleanStorageIPLDs(tx, rng); err != nil {
return err return err