Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1joZPr-0001G6-TZ for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jun 2020 21:28:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1joZPq-0001AJ-E5 for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jun 2020 21:28:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1joZPq-00018c-0l for pgsql-hackers@lists.postgresql.org; Thu, 25 Jun 2020 21:28:14 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1joZPj-0003TT-BJ for pgsql-hackers@postgresql.org; Thu, 25 Jun 2020 21:28:12 +0000 Received: by mail-pl1-x62f.google.com with SMTP id g17so3359738plq.12 for ; Thu, 25 Jun 2020 14:28:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=+FIGIBBCLZZKtrEvMXytZoz6aBXlfAq6AkJej95Nj/Y=; b=FkQzOCI6wzCkGT5Fn+x0XgS/XRa55AeT21KgBzyHimDZAl/6VQupXVC4kSGr67kHgF OFozLL6yNvtEFF+08QdsKc163evywX4ISkDv/pa8x1DoBXun2GIH9wx3ir9crag1bN2D O9oq/F5aBAsNtVD6NUEBUHQ2u25KONSd8wdBi4aEYS4XBSdBYddjXgHg5+J5kldwhebe GfTfguFpNSFs+7qCTZLoFcidiF1/WouwWg4uI/uL0lpwUBYiProohQLbbFGPJhJglfeA dTx5zMfVJpdt/gslQ5CDjfZLzpzK1YGHvxDJsHUdQd+g/0sTTMJZSPh76cO/tsPzy+V9 5jnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=+FIGIBBCLZZKtrEvMXytZoz6aBXlfAq6AkJej95Nj/Y=; b=Gs7FjsU2b4HUcgXl2jCKkfBE28pzWiyHtYD7PnOVB+1pXXWV2wyXAB5oUzfYF+xraS XOC24qZ4XSec4lNCFfqr4uI7Sa1rJzmmiVVRb9dXPapnZQvAmgaBHuYWyZ/tSIwT1WeG MrYhn1xiX67Ecoi0JNEzU8pc1M6/z+SrGE0L1Jnx08vNB8uysCjG9BTP6jnp+Pj+69ud rFRD6YLmUGTmRqmDIrxteoNFqr1GYgRcJzxY3uPuyj/qKx/eylt2wDwGzlA73Hevgncc FTIkr7Afoorgv/F7TEK6c36ycwZ7EY2/icx2hvcX0FH9WkauUSW3x76KsKknR/gGvnWn vfWA== X-Gm-Message-State: AOAM532bc7hsuMeDNieW0kdS6IGcJrQWPvhjNexDsVZD20soN3+zkFRY q/R5HBzTIVTuIjWQeYZoTM5Blw== X-Google-Smtp-Source: ABdhPJzVAsWIMUuG+d5z04cNspi1tGMokw6YovoZumyL0jl0Tynw/5L9X9voaxtPoueEE9XaP6M4Hw== X-Received: by 2002:a17:90a:319:: with SMTP id 25mr3496587pje.77.1593120485823; Thu, 25 Jun 2020 14:28:05 -0700 (PDT) Received: from jdavis.lan (c-73-231-146-4.hsd1.ca.comcast.net. [73.231.146.4]) by smtp.gmail.com with ESMTPSA id m16sm6102051pfd.101.2020.06.25.14.28.03 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jun 2020 14:28:04 -0700 (PDT) Message-ID: Subject: Re: Default setting for enable_hashagg_disk From: Jeff Davis To: Bruce Momjian Cc: Tom Lane , Justin Pryzby , David Rowley , Robert Haas , Melanie Plageman , Tomas Vondra , pgsql-hackers@postgresql.org Date: Thu, 25 Jun 2020 14:28:02 -0700 In-Reply-To: <20200625195607.GA16766@momjian.us> References: <129c8f1739957589584d9525e1d8782eae3f412f.camel@j-davis.com> <20200624090628.GA19640@momjian.us> <20200624123843.GX4107@telsasoft.com> <2214502.1593019796@sss.pgh.pa.us> <20200625192442.GD12486@momjian.us> <20200625195607.GA16766@momjian.us> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, 2020-06-25 at 15:56 -0400, Bruce Momjian wrote: > It is my understanding that spill of sorts is mostly read > sequentially, > while hash reads are random. Is that right? Is that not being > costed > properly? I don't think there's a major problem with the cost model, but it could probably use some tweaking. Hash writes are random. The hash reads should be mostly sequential (for large partitions it will be 128-block extents, or 1MB). The cost model assumes 50% sequential and 50% random. Sorts are written sequentially and read randomly, but there's prefetching to keep the reads from being too random. The cost model assumes 75% sequential and 25% random. Overall, the IO pattern is better for Sort, but not dramatically so. Tomas Vondra did some nice analysis here: https://www.postgresql.org/message-id/20200525021045.dilgcsmgiu4l5jpa@development That resulted in getting the prealloc and projection patches in. Regards, Jeff Davis