Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0oXl-0004pG-Tq for pgsql-general@arkaria.postgresql.org; Fri, 14 Sep 2018 13:53:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g0oXh-0003a1-QF for pgsql-general@arkaria.postgresql.org; Fri, 14 Sep 2018 13:53:53 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0oXh-0003Zp-9n for pgsql-general@lists.postgresql.org; Fri, 14 Sep 2018 13:53:53 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0oXZ-0002DD-VJ for pgsql-general@postgresql.org; Fri, 14 Sep 2018 13:53:51 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 075F924BEA; Fri, 14 Sep 2018 09:53:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 14 Sep 2018 09:53:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=MLdCL9McdHiFRxS9oymwH62LU8CZ3 uzAu7skMUBuBdI=; b=JspQ1pPAdBdYu+2CDIDxWYplOmNVYF9+MDQDeXq/7EILE Kytv6bJlzKr/FUFIMC7Sijw+VrS+s7dZZDc0pSbdApxuUZ6iyKdZVnTUaA4bmsnf F51dq7+TxEykRo920LF28onxa9YnAkZ2MXTBPHI6xB1X/XOkFYP+1iNVu82Yh4NW lzCgqblpAcGz/ANSnZNkqKYCBvg7fC/dRPkZFhZzCDgXMXM9JX9VsyV39F2fZKWJ BZ402ipRXGRQqXclWWeL/wRaEybiNZ53qoE0UvvBXnbrWlis8h6KsirsuLI9x0io OYe3yiJD65mr3MyOXv++Mj14p5lDDIXboFEr8kR8Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=MLdCL9 McdHiFRxS9oymwH62LU8CZ3uzAu7skMUBuBdI=; b=QoAGZHa5FT8xqmKbDpEwZ8 nBEyzn8MKL0Jr7Imwrj9sIzRusrSTLPA0ZPC6ct3Ga+/NPpU/b0voFqib9ZOV2ld aDxWyUmEwf3/+VYnspaGTgUhN98rYomrXm27euI17yZKkCxenQyaoywP3T13m+zr 8S9F8nxoXknQNvgh32xw8wsKVYQpzIHlzz3pfeTKb9o1SkO/8hrbw3pfzog2f3y1 aG0f6alZaDrxkKNKI7aOD4/EW/6azs29PrP7iqqh/GqYwLFNa4q5vey+RRVT8jon TXJjaP9ssMnYa+Uw9qREiX0OmwC4yQgiJ2vGj3NIlTuVx7gsnt4k7X603ougHRwg == X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 8DEBDE47B5; Fri, 14 Sep 2018 09:53:43 -0400 (EDT) Subject: Re: [External] RE: Estimate time without running the query To: Neto pr , david.g.johnston@gmail.com Cc: vjain@opentable.com, johnescm@hotmail.com, PostgreSQL General References: <9777232F-131E-46BF-AF0C-3B2242A99645@opentable.com> From: Adrian Klaver Message-ID: <1ddc4fab-c89c-4c4e-c252-8f1179d51dcc@aklaver.com> Date: Fri, 14 Sep 2018 06:53:42 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 9/13/18 4:55 PM, Neto pr wrote: > > > Em qui, 13 de set de 2018 às 19:53, David G. Johnston > > escreveu: > > On Thu, Sep 13, 2018 at 3:30 PM, Neto pr >wrote: > > The problem is that using the explain analyze I have to > wait for the query to execute. > I would like to estimate the time without having to wait for the > query execution. > Does anyone know how to estimate the time without waiting for > the query to be executed? > > > On the machine in question you have to experiment to obtain data to > construct a formula to convert cost to time.  Then when using the > function remember that lots of things can play into individual > executions taking more time (and sometimes less too I suspect) such > as locks, caching, physical data locality. > > It seems more useful to log actual execution times and look for > trends.  If you are writing a query odds are it needs to be run > regardless of how efficient it may be - or used in a relative > comparison to an alternate query. > > > Okay, David, but does not it have some SQL statement that returns a time > estimate, without having to execute the query? To get close to a true time you need to run the actual query. An analogy based on running 10K under the following conditions: 1) Cool day, flat course. 2) Hot day, up a 10% grade. You can reasonably predict that 1) will yield a faster time then 2), however you will not know the actual times until you run them. > > David J. > -- Adrian Klaver adrian.klaver@aklaver.com