A self-managing workload repository infrastructure (or "AWR" for Automatic
workload repository) which is useful for a database server to collect and
manage useful system performance statistics. The AWR runs automatically
to collect performance data about the operation of the database system,
and stores the data that it captures into the database. The collection
process is done inside the database, and the collection process is highly
efficient as data is retrieved directly from the shared memory of the
database kernel. The data captured allows both system level and user
level analysis to be performed without unduly impacting system
performance, e.g., by eliminating or reducing the requirement to repeat
the workload in order to diagnose problems. The AWR is configured to
automatically capture snapshots of statistics data on a periodic basis as
well as purge stale data on a periodic basis. The captured performance
data includes one or more of the top N (e.g., 20 or 30) statistics for
activities involving a large set of objects, time-based statistics,
cumulative statistics, sampled data and metrics and other data types.