70eda67bc1
Before and after segments loop we are collecting stats about number of entries in segments and objects table. We are using number of segments to validate loop execution but currently we are not using number of objects anywhere. This change drops SQL query to count objects count as it's not use anywhere at the moment. Change-Id: I25ce77758870beb0daa5c0e21084a4c633a26f15
31 lines
826 B
Go
31 lines
826 B
Go
// Copyright (C) 2021 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package metabase
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// GetTableStats contains arguments necessary for getting table statistics.
|
|
type GetTableStats struct {
|
|
AsOfSystemInterval time.Duration
|
|
}
|
|
|
|
// TableStats contains information about the metabase status.
|
|
type TableStats struct {
|
|
SegmentCount int64
|
|
}
|
|
|
|
// GetTableStats gathers information about the metabase tables, currently only "segments" table.
|
|
func (db *DB) GetTableStats(ctx context.Context, opts GetTableStats) (result TableStats, err error) {
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
err = db.db.QueryRowContext(ctx, `SELECT count(*) FROM segments `+db.impl.AsOfSystemInterval(opts.AsOfSystemInterval)).Scan(&result.SegmentCount)
|
|
if err != nil {
|
|
return TableStats{}, err
|
|
}
|
|
return result, nil
|
|
}
|