pg.ddx.io pgsql-performance@postgresql.org mailing list archivehelp / color / mirror / Atom feed
How can retrieve total query run-time with out using explain 2+ messages / 2 participants [nested] [flat]
* How can retrieve total query run-time with out using explain @ 2011-07-03 04:13 Radhya sahal <rad_cs_2006@yahoo.com> 2011-07-03 06:09 ` Re: How can retrieve total query run-time with out using explain Craig Ringer <craig@postnewspapers.com.au> 0 siblings, 1 reply; 2+ messages in thread From: Radhya sahal @ 2011-07-03 04:13 UTC (permalink / raw) To: pgsql-performance Dear all, How can retrieve total query run-time when i run any query with out using explain for example when i run any query such as select * from tablel1; Total query runtime: 443 ms. i want a function can return "runtime: 443 ms" with out using explain i want this command to call it from java source code can any one help me??? . ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: How can retrieve total query run-time with out using explain 2011-07-03 04:13 How can retrieve total query run-time with out using explain Radhya sahal <rad_cs_2006@yahoo.com> @ 2011-07-03 06:09 ` Craig Ringer <craig@postnewspapers.com.au> 0 siblings, 0 replies; 2+ messages in thread From: Craig Ringer @ 2011-07-03 06:09 UTC (permalink / raw) To: Radhya sahal <rad_cs_2006@yahoo.com>; +Cc: pgsql-performance On 3/07/2011 12:13 PM, Radhya sahal wrote: > Dear all, > How can retrieve total query run-time when i run any query with out > using explain EXPLAIN doesn't tell you the query runtime. EXPLAIN ANALYZE does, but it doesn't return the query results, returning plan and timing information instead. > for example when i run any query such as > select * from tablel1; > Total query runtime: 443 ms. in psql, use: \timing on > i want a function can return "runtime: 443 ms" with out using explain > i want this command to call it from java source code Record the system time before you run the query using System.currentTimeMillis() or System.nanoTime(). Record the system time after you run the query. Subtract and convert the difference to a java.util.Date so you can format it prettily for display, or just print the difference in milliseconds. If you want more flexible date/time handling, see JodaTime. This gives you the time the query took including how long it took to retrieve the initial resultset. If you want the time the query took to execute on the server, not counting fetch time, this may not be what you want. I don't know how to get query execution time *not* counting resultset retrieval time from the client. Anyone know if it's even possible? -- Craig Ringer ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2011-07-03 06:09 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2011-07-03 04:13 How can retrieve total query run-time with out using explain Radhya sahal <rad_cs_2006@yahoo.com> 2011-07-03 06:09 ` Craig Ringer <craig@postnewspapers.com.au>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox