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 1job2L-000436-IH for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jun 2020 23:12:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1job2J-0007ma-IZ for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jun 2020 23:12:03 +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 1job2I-0007mT-Pl for pgsql-hackers@lists.postgresql.org; Thu, 25 Jun 2020 23:12:02 +0000 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1job2G-0004Mz-AQ for pgsql-hackers@postgresql.org; Thu, 25 Jun 2020 23:12:01 +0000 Received: by mail-ej1-x641.google.com with SMTP id ga4so7541443ejb.11 for ; Thu, 25 Jun 2020 16:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=88Nt5Vb+1LCY2W1+YFK6Q60Nnk5Ic/VhczLkVb59HI4=; b=dAVepIyMzp5zUc0RiCGNXM6wenKVf/oCGeCRn1wpCaftSw5hLrcPwoMvYz9OGdm+So yth0/hvkb11O1dAOGzUUo6Rcs/SwbTf4GS+qo32382dYqQZZjMHgSinDYzRD0YcfaScL j+1npPD86oZd+mj2W8ymTo4US4vJgfVwuxOFGK3lu4LbsnZvk4+eVwf11GYowXkDvMHT vkQmeti+mnWtG3S6ICD4QLL5Ybge47DYLYCgRjQAVfdaYn5HgrlbUIZMAboPurLS0Mpa mvgPsjQ2icB4mXjRFOExmKbY9JaJq0BSivFcuXOXI81wbkdwXnibwKAIO7+Jt1kmZ9Zl oZjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=88Nt5Vb+1LCY2W1+YFK6Q60Nnk5Ic/VhczLkVb59HI4=; b=avUk+b6NdI4HSa5XiwPzJI9NmbwD0ptWoKofe5JLY8rtB7CrRQBXCxRcLRx0S5MNen G7tbmQWLNLwL9Oxn+DW4xVuVEXfjETnIEELHihyYDkmnPs2Y6AkjVfaikbjyjdjHFWss FmzwHtoTjJNpU+zmfaXEblW69MQ4c3RYxv/oER0qS4uQmCdYHi0PgiV7Hj0zjngGrMKw 4NUW8EXcH8Mz4p72C2YS/5q7CqCIv9Y93Lp6w4/30K9Q9LM0JB8N/h8sv7SV0/QvNI68 CeMJfSkI98WqYJEm4pmx3mAcQZzs1/iX1skx1q8AOFdm/YsqfD4nj9DVgVnRHeRxvFbw I2cA== X-Gm-Message-State: AOAM532iUsZ2hjJ4A/Qb2lu3Dru6nQ8y0Y5yXNIf1XI2dfS45SOAH75I nwWJEhmniiKocB4sJA4urQucIA== X-Google-Smtp-Source: ABdhPJxGFKgMteKPiBfQB846YD2DJ+eCgdsIhzPxM73+Dr4MAE3SAWe/6INMiSdr9SvuX919MmzWkg== X-Received: by 2002:a17:906:af62:: with SMTP id os2mr99874ejb.345.1593126719000; Thu, 25 Jun 2020 16:11:59 -0700 (PDT) Received: from localhost (ip-86-49-253-141.net.upcbroadband.cz. [86.49.253.141]) by smtp.gmail.com with ESMTPSA id p13sm19874363edi.74.2020.06.25.16.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 16:11:57 -0700 (PDT) Date: Fri, 26 Jun 2020 01:11:54 +0200 From: Tomas Vondra To: Jeff Davis Cc: Bruce Momjian , Tom Lane , Justin Pryzby , David Rowley , Robert Haas , Melanie Plageman , pgsql-hackers@postgresql.org Subject: Re: Default setting for enable_hashagg_disk Message-ID: <20200625231154.uknvrnqwmahv6rtu@development> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Jun 25, 2020 at 02:28:02PM -0700, Jeff Davis wrote: >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. > The important bit here is that while the logical writes are random, those are effectively combined in page cache and the physical writes are pretty sequential. So I think the cost model is fairly reasonable. Note: Judging by iosnoop stats shared in the thread linked by Jeff. >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 > > regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services