Thread: Trying to profile a function, but weird stuff happens

Trying to profile a function, but weird stuff happens

From
Ericson Smith
Date:
Hi,

I'm trying to figure out how long my function is taking to run, but it
keeps returning identical start and stop times. Here's a segment...

    seg := date_part(''second'', now())::float;

    FOR rec IN SELECT qcounter FROM tlogs_queue LOOP
      blah, blah, blah
    END LOOP;

    secs := date_part(''second'', now())::float;

    RAISE NOTICE ''Start %'', seg;
    RAISE NOTICE ''End   %'', secs;

seg and secs are the exact same number. Any pointers would be much
appreciated.

- Ericson Smith
eric@did-it.com
http://www.did-it.com

--
Ericson Smith <eric@did-it.com>
--
Ericson Smith <eric@did-it.com>


Re: Trying to profile a function, but weird stuff happens

From
Tom Lane
Date:
Ericson Smith <eric@did-it.com> writes:
> I'm trying to figure out how long my function is taking to run, but it
> keeps returning identical start and stop times.

now() doesn't advance inside a transaction.  See timeofday().

            regards, tom lane