Interface PerformanceConfig

Performance configuration options provided by users.

All fields are optional; unspecified fields use tier defaults.

const db = await createDatabase({
performance: {
tier: 'balanced',
cacheTtlMs: 30000, // Override: longer cache
trackMetrics: true, // Override: enable metrics
}
});
interface PerformanceConfig {
    tier?: PerformanceTier;
    cacheEnabled?: boolean;
    cacheTtlMs?: number;
    cacheMaxEntries?: number;
    batchWrites?: boolean;
    batchFlushIntervalMs?: number;
    batchMaxSize?: number;
    validateSql?: boolean;
    trackMetrics?: boolean;
    slowQueryThresholdMs?: number;
    retryOnError?: boolean;
    maxRetries?: number;
    retryDelayMs?: number;
}

Properties

Performance tier preset.

'balanced'
cacheEnabled?: boolean

Enable query result caching.

When enabled, identical SELECT queries return cached results until the cache TTL expires or cache is invalidated.

  • Caching is per-adapter instance (not shared)
  • Cache is invalidated on any write operation to affected tables
  • Use accurate tier for systems where stale data is unacceptable
tier-dependent
cacheTtlMs?: number

Cache time-to-live in milliseconds.

After this duration, cached query results are considered stale and will be re-fetched on next access.

5000 for balanced tier
cacheMaxEntries?: number

Maximum number of cached query results.

When exceeded, least-recently-used entries are evicted.

1000 for balanced tier
batchWrites?: boolean

Enable write batching.

When enabled, write operations (INSERT, UPDATE, DELETE) are collected and executed in batches to reduce I/O operations.

  • Recommended for mobile/browser environments
  • Not recommended for systems requiring immediate consistency
  • Batch is flushed on batchFlushIntervalMs or batchMaxSize
false for balanced tier, true for efficient tier
batchFlushIntervalMs?: number

Batch flush interval in milliseconds.

Accumulated writes are flushed after this interval.

100 for balanced tier
batchMaxSize?: number

Maximum batch size before auto-flush.

When batch reaches this size, it is immediately flushed regardless of the flush interval.

50 for balanced tier
validateSql?: boolean

Validate SQL statements before execution.

Performs basic syntax and injection checks.

true for balanced tier
trackMetrics?: boolean

Track performance metrics.

When enabled, the adapter tracks:

  • Total queries/mutations/transactions
  • Average query duration
  • Error counts
  • Uptime

Retrieve metrics via adapter.getMetrics().

true for balanced tier
slowQueryThresholdMs?: number

Slow query logging threshold in milliseconds.

Queries exceeding this duration are logged at warn level.

100 for balanced tier
retryOnError?: boolean

Retry operations on transient errors.

Transient errors include network timeouts, connection resets, and deadlocks.

true for balanced tier
maxRetries?: number

Maximum retry attempts.

3 for balanced tier
retryDelayMs?: number

Delay between retry attempts in milliseconds.

Uses exponential backoff: delay * 2^attempt.

100 for balanced tier