Re: Measuring CPU time use? (Another stupid question)

Поиск
Список
Период
Сортировка
От Keehan Mallon
Тема Re: Measuring CPU time use? (Another stupid question)
Дата
Msg-id 20021218213747.9019.qmail@web11202.mail.yahoo.com
обсуждение исходный текст
Ответ на Re: Measuring CPU time use? (Another stupid question)  (Jessica Blank <jb@twu.net>)
Список pgsql-general
Jessica,

I'm not sure, but for what you are asking it seems like you could whip
up something in a quick and dirty shell script around some psql calls
called using time:

$ time psql -d template1 -c "$YOURSQL"

this should report the time taken to run $YOURSQL.

example:
$ time psql -d template1 -c "select * from pg_language;"

The possiblities seem endless from here.  You could do multiple
iterations counting averages, mins or maxs.

I understand this is external to postgres, but it sounds like it solves
your problem.

Keehan

--- Jessica Blank <jb@twu.net> wrote:
> I suppose I should rephrase.
>
> I am trying to figure out which of two competing ideas of mine is the
> more
> efficient.
>
> Right now, I am running it on a "slow" machine-- a G3/220 with 148MB
> of
> RAM, on OLD SCSI-1/2 hardware. Modern machines have much faster
> CPUs--
> they also have much faster disk tho.
>
> What is important is how long it takes to do a "typical" or "average"
>
> search. I am coding a full-text search system and had two ideas on
> how to
> do it (without implementing my own file-based database, using another
>
> person's, writing stuff in C, or other stuff far more complex than
> what
> the client is paying me for ;) )
>
> So I guess what I'm saying is that I don't care so much about CPU
> time, or
> I/O time, but *TOTAL* time. How long it takes from the instant the
> query
> hits Postgres to the instant I get my results back...
>
> So I need a way to run some 'typical' queries (common search terms
> for
> this system) and figure out which of my algorithms works better... :)
>
> On Wed, 18 Dec 2002, scott.marlowe wrote:
>
> > 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
> > > >
> > >
> > >
> >
>
> --
> J e s s i c a    L e a h    B l a n k
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

В списке pgsql-general по дате отправления:

Предыдущее
От: Larry Rosenman
Дата:
Сообщение: Re: trouble caused by change in 7.3 handling of '' in
Следующее
От: Justin Clift
Дата:
Сообщение: Re: Measuring CPU time use? (Another stupid question)