Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 95C7164FD24 for ; Sun, 19 Oct 2008 05:56:05 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 00455-05 for ; Sun, 19 Oct 2008 05:56:01 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from cronos.madness.at (madness.at [217.196.146.217]) by postgresql.org (Postfix) with ESMTP id D84D164FCC0 for ; Sun, 19 Oct 2008 05:56:01 -0300 (ADT) Received: from host64-34-static.107-82-b.business.telecomitalia.it ([82.107.34.64] helo=[192.168.1.32]) by cronos.madness.at with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1KrU4o-0008FA-6I; Sun, 19 Oct 2008 10:55:56 +0200 Message-ID: <48FAF616.4040005@kaltenbrunner.cc> Date: Sun, 19 Oct 2008 10:55:50 +0200 From: Stefan Kaltenbrunner User-Agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: tarcizioab@c3sl.ufpr.br CC: pgsql-performance@postgresql.org Subject: Re: Explain Analyze - Total runtime very differentes References: <50397.200.140.234.93.1224357249.squirrel@webmail.inf.ufpr.br> In-Reply-To: <50397.200.140.234.93.1224357249.squirrel@webmail.inf.ufpr.br> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200810/102 X-Sequence-Number: 31683 tarcizioab@c3sl.ufpr.br wrote: > Hello friends ... > > I'm evaluating the performance of algorithms for optimization of queries. > I am comparing results between the algorithm of Dynamic Programming and an > implementation of Kruskal's algorithm. When submitting a query that makes > reference to only 2 tables of my base, logically the same "Query Plan" is > shown. But the "Total runtime" displayed by the command "Explain-Analyze" > presents a variation of time very high: > > Dynamic Programming Total runtime: 1204.220 ms > > Kruskal Total runtime: 3744.879 ms > > No change of data (insert, delete, update) in the tables was made during > the tests. The same query was submitted several times (with Kruskal and > Dynamic Programming algorithms) and the variation of results persists. > > The "explain analyze" only reports the time to run *execute* the query. > With the same "Query Plan", does not understand why this variation occurs. > > In annex the Query Plans sure it it not something as simple as a caching effect - ie you run the slow variant first and pg and/or the OS buffered data and the repeated execution just got a benefit from that ? Try running all variations a few dozend times both in cached and uncached state and you should see the difference getting leveled out. Stefan