But you realize that the time it took to run the query is NOT the same as
the CPU time, right? A heavy table with 100,000,000 rows may use only a
tiny percentage of CPU but take a minute to return, while your I/O
subsystem thrashes away dmaing the data into memory where it gets copied
to output in 30 milliseconds of CPU time.
Look for iostat to analyze your I/O load, which is often the greater load
factor for a db server than CPU use.
On Wed, 18 Dec 2002, Jessica Blank wrote:
> Thanky thanky. That might work.
>
> Still, I'd rather just have a way I could get a plain old figure.
>
> E.g.:
>
> DELETE FROM V$CPUUSE;
> (DO THE QUERIES IN QUESTION HERE)
> SELECT NANOSECONDS_USED FROM V$CPUUSE;
>
> On Wed, 18 Dec 2002, Joe Conway wrote:
>
> > Jessica Blank wrote:
> > > I wish to find a way to measure the CPU time used by any given query (or
> > > set of queries).
> > >
> > > I could not find any information on how to do this...
> > >
> > > Is there some secret internal table (like the V$ virtual tables in Oracle)
> > > that contains this info?
> >
> > Well, I don't know of anything specific to CPU usage, but for monitoring your
> > server see Monitoring Database Activity in the manual:
> > http://www.us.postgresql.org/users-lounge/docs/7.3/postgres/monitoring.html
> >
> > Also, one of the best and most commonly used tools for optimizing individual
> > queries is EXPLAIN ANALYZE; see:
> > http://www.us.postgresql.org/users-lounge/docs/7.3/postgres/sql-explain.html
> >
> > HTH,
> >
> > Joe
> >
>
>