Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8D229B5DD52 for ; Tue, 25 Oct 2011 12:06:16 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 83802-01-4 for ; Tue, 25 Oct 2011 15:06:10 +0000 (UTC) Received: from news.hub.org (news.hub.org [200.46.204.72]) by mail.postgresql.org (Postfix) with ESMTP id A7B78B5DD47 for ; Tue, 25 Oct 2011 12:06:10 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id p9PF6Anx035117 for ; Tue, 25 Oct 2011 12:06:10 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id p9PEqB17022341 for pgsql-sql@postgresql.org; Tue, 25 Oct 2011 11:52:11 -0300 (ADT) (envelope-from news) From: alan X-Newsgroups: pgsql.sql Subject: how to use explain analyze Date: Tue, 25 Oct 2011 07:12:17 -0700 (PDT) Organization: http://groups.google.com Lines: 27 Message-ID: <7be7d91b-c054-41c6-8a7c-08e77d29625e@v2g2000yqf.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Complaints-To: groups-abuse@google.com Complaints-To: groups-abuse@google.com Injection-Info: v2g2000yqf.googlegroups.com; posting-host=198.182.37.200; posting-account=96UIwAoAAAARNv37wOIskbKVHaDu53iB User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HNKUARELSC X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1,gzip(gfe) To: pgsql-sql@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.393 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RP_MATCHES_RCVD=-0.504, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201110/78 X-Sequence-Number: 35962 I'm new to postgres and was wondering how to use EXPLAIN ANALYZE .... Can I use the output from ANALYZE EXPLAIN to estimate or predict the actual time it would take for a given query to return? I ask because I'm writing a typical web app that allows the user to build and submit a query to my DB. Since I don't know how "simple" or "complex" the user- generated queries will be I thought it might be possible to use the ANALYZE EXPLAIN output to make a "guestimation" about the expected return time of the query. I'd like to use this in my web-app to determine whether to run the query in real-time (user waits for results) or queue up the query (and notify the user once the query is finished). E.g.: if (the Total runtime" reported by explain analyze is > n ms) { tell the user that his request was submitted for processing, and notify the user once resuilts are available } else { run the query and wait for the results in real time. } Thanks, Alan