X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 473B1476349 for ; Sat, 22 Mar 2003 01:13:36 -0500 (EST) Received: from ns.cnlo.ro (cnlo.ro [193.231.112.154]) by postgresql.org (Postfix) with ESMTP id 729DC475EE2 for ; Sat, 22 Mar 2003 01:13:33 -0500 (EST) Received: from cnlo.ro (marian.cnlo.ro [192.168.10.64]) by ns.cnlo.ro (8.12.8/8.12.5) with ESMTP id h2M6C1nJ019093; Sat, 22 Mar 2003 08:12:02 +0200 Message-ID: <3E7BFE7F.2010500@cnlo.ro> Date: Sat, 22 Mar 2003 08:11:11 +0200 From: Popeanga Marian User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 X-Accept-Language: en-us, en MIME-Version: 1.0 To: mallah@trade-india.com Cc: pgsql-sql@postgresql.org Subject: Re: explain References: <1114.219.65.253.113.1048264331.squirrel@mail.trade-india.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-RAVMilter-Version: 8.4.1(snapshot 20020919) (ns.cnlo.ro) X-Spam-Status: No, hits=-18.9 required=5.0 tests=EMAIL_ATTRIBUTION,REFERENCES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50-cvs X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50-cvs (1.172-2003-02-14-exp) X-Archive-Number: 200303/517 X-Sequence-Number: 12556 Mallah, Thanks for your info, I runned the query with explain yesterday and it didn't work for a user where i didn't had enough privileges i think !? Why db didn't say anythink ? I created a new user and a new table. Explain for this table worked just as you said and for any other querys. Is there any way to know if a user has wright privileges to explain a query ? mallah@trade-india.com wrote: >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/ > > > > -- Popeanga Marian DBA Oracle CNLO Romania