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 1fF0VC-000781-Dg for pgsql-general@arkaria.postgresql.org; Sat, 05 May 2018 16:57:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fF0V8-00075B-9x for pgsql-general@arkaria.postgresql.org; Sat, 05 May 2018 16:57:38 +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 1fF0V6-0006sw-42 for pgsql-general@lists.postgresql.org; Sat, 05 May 2018 16:57:38 +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 1fF0V1-0003qz-4R for pgsql-general@postgresql.org; Sat, 05 May 2018 16:57:34 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 80B3421CF9; Sat, 5 May 2018 12:57:29 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 05 May 2018 12:57:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= 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=fm2; bh=3TB3RAwub6ASRwxgJspZ3cAui2dnC dIAFNJygtkFBHo=; b=LKDrkvO/+S6EHbgUpy5z/ImpomvNrjoM9ZaC5O60Zl4EB dZzWNCpPo6KjG/FWR9m7i1NMEG43O+/B330i9hop5Sg1lTINunNpaJL7plOCFWF2 10IkJqGBa3uUc3yr2V/FmDbXH84BLDcYEGNRBJaBqTzU9M8cx8uh7umVYL9PwW2w ezOlZOdw+FgwvHGBKtJVpH0zleZLq4O6jvMC+Y5UBdbnG+Nc4KH9+ZY3J+XwyaDP FAiSUKsaC7xz0iwaBwh+uppb9r/FDBRsztcPr/0UW2jPjUjjiFQaiQhv0W7A6AV6 YVd/SZMXxmHR/WjH/ukI7zyjPfS5SLyloWnmKe5VQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=fm2; bh=3TB3RA wub6ASRwxgJspZ3cAui2dnCdIAFNJygtkFBHo=; b=anhlhBP2R96Z+GUAeVAroG Hs9RHFqHlgBM08GGxigqKQC67jtn7WqqCVimlBW9W2rGihGVJC5wKMBID0NysBvH L+I4K+asPfF8dSztmQGpzMzfwMBYXTVH2c/JNzxlCdzESmMW8bp1VJ4OOTHw19M5 D1cWBIIh4zWY9eW2u2RqYDqf66kmuIm0bMIPvtKoMq1NXvDmjPfxjn5Ky4xWeYfS 13svitOLrBTukwU019zRm9G4uilEERYt4fJZmxS5QCU3sh5V9Qk5L9TywDrs9wKm Tut7jTJd5uvbILs982hlFKBaWUqYtFqduptk+xEhZPsiG+/T/NzimJaIp6wpP/MA == X-ME-Sender: Received: from [192.168.1.2] (unknown [71.212.135.74]) by mail.messagingengine.com (Postfix) with ESMTPA id E70CFE5094; Sat, 5 May 2018 12:57:28 -0400 (EDT) Subject: Re: comparison between 2 execution plans To: Neto pr , PostgreSQL General References: From: Adrian Klaver Message-ID: <793ad4e8-82cd-74e7-a4ff-b39d049b2568@aklaver.com> Date: Sat, 5 May 2018 09:57:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.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 05/05/2018 06:26 AM, Neto pr wrote: > Dear all > > Could you help me understand these two execution plans for the same > query (query 3 benchmark TPCH www.tpc.org/tpch > ), executed in two different environments of > Postgresql, as described below: > Execution Plan 1: > - https://explain.depesz.com/s/Ughh > - Postgresql version 10.1 (default) with index on l_shipdate (table > lineitem) > > Execution Plan 2: > - https://explain.depesz.com/s/7Zb7 > - Postgresql version 9.5 (version with source code changed by me) with It might help if you explained what 'version with source code changed by me' means? Also the schema for the table lineitem from both instances might help shed light. Any reason why the index changed between instances? > index on l_orderkey (table lineitem). > > Some doubts > - Difference between GroupAggregate and Finalize GroupAggregate > - because some algorithms show measurements on "Disk" and others on > "Memory" example: >      - External sort Disk: 52784kB >      - quicksort Memory: 47770kB > > Because one execution plan was much smaller than the other, considering > that the query is the same and the data are the same. > -------------------------------------------------- > select >     l_orderkey, >     sum(l_extendedprice * (1 - l_discount)) as revenue, >     o_orderdate, >     o_shippriority > from >     customer, >     orders, >     lineitem > where >     c_mktsegment = 'HOUSEHOLD' >     and c_custkey = o_custkey >     and l_orderkey = o_orderkey >     and o_orderdate < date '1995-03-21' >     and l_shipdate > date '1995-03-21' > group by >     l_orderkey, >     o_orderdate, >     o_shippriority > order by >     revenue desc, >     o_orderdate > -------------------------------------------------- > > best regards > Neto -- Adrian Klaver adrian.klaver@aklaver.com