mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-28 20:44:28 +02:00
graph/db+sqldb: find best default query cfg values for sqlite & postgres
This commit adds a BenchmarkFindOptimalSQLQueryConfig test in the graph/db package which runs ForEachNode and ForEachChannel queries against a local backend using various different values for the sql QueryConfig struct. This is done to determine good default values to use for the config options for sqlite vs postgres.
This commit is contained in:
@@ -15,6 +15,20 @@ const (
|
||||
// included in a batch query IN clause for Postgres. This was determined
|
||||
// using the TestSQLSliceQueries test.
|
||||
maxPostgresBatchSize = 65535
|
||||
|
||||
// defaultSQLitePageSize is the default page size for SQLite queries.
|
||||
defaultSQLitePageSize = 100
|
||||
|
||||
// defaultPostgresPageSize is the default page size for Postgres
|
||||
// queries.
|
||||
defaultPostgresPageSize = 10500
|
||||
|
||||
// defaultSQLiteBatchSize is the default batch size for SQLite queries.
|
||||
defaultSQLiteBatchSize = 250
|
||||
|
||||
// defaultPostgresBatchSize is the default batch size for Postgres
|
||||
// queries.
|
||||
defaultPostgresBatchSize = 5000
|
||||
)
|
||||
|
||||
// QueryConfig holds configuration values for SQL queries.
|
||||
@@ -66,6 +80,24 @@ func DefaultQueryConfig() *QueryConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultSQLiteConfig returns a default configuration for SQL queries to a
|
||||
// SQLite backend.
|
||||
func DefaultSQLiteConfig() *QueryConfig {
|
||||
return &QueryConfig{
|
||||
MaxBatchSize: defaultSQLiteBatchSize,
|
||||
MaxPageSize: defaultSQLitePageSize,
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultPostgresConfig returns a default configuration for SQL queries to a
|
||||
// Postgres backend.
|
||||
func DefaultPostgresConfig() *QueryConfig {
|
||||
return &QueryConfig{
|
||||
MaxBatchSize: defaultPostgresBatchSize,
|
||||
MaxPageSize: defaultPostgresPageSize,
|
||||
}
|
||||
}
|
||||
|
||||
// BatchQueryFunc represents a function that takes a batch of converted items
|
||||
// and returns results.
|
||||
type BatchQueryFunc[T any, R any] func(context.Context, []T) ([]R, error)
|
||||
|
Reference in New Issue
Block a user