X-Original-To: pgsql-sql@postgresql.org Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id D7E87474E44 for ; Fri, 21 Mar 2003 11:31:31 -0500 (EST) Received: (qmail 28226 invoked from network); 21 Mar 2003 16:32:34 -0000 Received: from ns1.trade-india.com (HELO www.trade-india.com) (66.234.10.14) by infocom-236-129-del.trade-india.com with SMTP; 21 Mar 2003 16:32:34 -0000 Received: (qmail 870 invoked by uid 99); 21 Mar 2003 16:32:11 -0000 Received: from 219.65.253.113 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Fri, 21 Mar 2003 22:02:11 +0530 (IST) Message-ID: <1114.219.65.253.113.1048264331.squirrel@mail.trade-india.com> Date: Fri, 21 Mar 2003 22:02:11 +0530 (IST) Subject: Re: explain From: To: X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Cc: X-Mailer: SquirrelMail (version 1.2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Archive-Number: 200303/503 X-Sequence-Number: 12542 Popeanga , Its basically possible to get the info programatically. see below is an example perl code that is getting the plan data: ############### file test.pl ################# #!/usr/bin/perl use DBI; $dbh = DBI->connect('dbi:Pg:dbname=rmallah' , '',''); $your_query_here= 'select * from test'; $rows = $dbh -> selectall_arrayref("EXPLAIN ANALYZE $your_query_here"); foreach (@$rows) { print "$_->[0]\n"; } $dbh -> disconnect(); ############################################# on running you get: [rmallah@subho rmallah]$ ./test.pl Seq Scan on test (cost=0.00..20.00 rows=1000 width=32) (actual time=0.02..0.05 rows=11 loops=1) Total runtime: 0.19 msec But be careful abt explain analyzing queries that potentially modify data. (read more on docs of EXPLAIN) we have to put the explain analyze in a transaction block which shud eventually be rollbacked. now that you have seen how to get lines of output from EXPLAIN using/hadling this data is upto you application. also note that the last like of EXPLAIN analyze carries the runtime. hope it helps Mallah. ----------------------------------------- Get your free web based email at trade-india.com. "India's Leading B2B eMarketplace.!" http://www.trade-india.com/