Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t498v-00Gc8J-IF for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Oct 2024 01:29:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t498t-00ALuG-Bq for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Oct 2024 01:29:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t498t-00ALu8-1g for pgsql-hackers@lists.postgresql.org; Fri, 25 Oct 2024 01:29:31 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t498q-002pT2-98 for pgsql-hackers@postgresql.org; Fri, 25 Oct 2024 01:29:30 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-539f7606199so1952509e87.0 for ; Thu, 24 Oct 2024 18:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729819767; x=1730424567; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=77291bVN7l4HvmJ0BgI9mW4M0EKuyv2gJRk15qlvJ7w=; b=N2l+cjdp7SMaSkkoxs1cTNhLuXb0A6Y0uyS9afUFMIu+Gv857qG1DK44DK+Vh/WTvX Z1VVuH9HCYaWF6gUr+DoFlCJRDwqqJ6QSH/f78DaQZU1v7pMQyVRw4rs+YmDphlR3N/e kKinnaXq8L/ili94Favwa14CtgmDvsUrHpZmcV09xp+f2EYc6clc+soXvoQN9jK0QDQ1 ByJgCdMqAJrzHoDoZXkE8YmkQg4iA90dfOZCBbWHkQYtGGZHGYo1fO+dENokar+d9H5g Ze1eR1KJCI1f0DOK/eZx4pO2yWI83xzw5uTLGH40dD36sETgXJwnHyovu9gocdBRchSZ ySHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729819767; x=1730424567; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=77291bVN7l4HvmJ0BgI9mW4M0EKuyv2gJRk15qlvJ7w=; b=iWaW/DveNOgoWsEMEbMn6ZNpSJWGDOA1hUkK0zgBATo+PYkdNH4z/SdeFaxn+5aVBV 0iC0iH4/F0FW5y6Il8/IOJMJrrNvXm0G0cKv7JnLGgJ8Sf293j+YJAzF4eTNPQRfe4V3 Yz8rrclnwlvQt/GWjPJsAfbYtwvj/3tB+bHPTS5wRkP+DDDlXVD30xbuPILyw/N2DKPK 1B3WAK1HPsmBzIPmIoK0RycQ70oTVqcyva1OHgN8FUj3nXRuL5X4z9H6MyjMXSjdi+DV LP8dqCLoSJjzwGIz8c7g4ucZ/iDh6aSXSxYEuGe8jkiVgiAcorQvSykJAyvf6K3oPgke nPPQ== X-Forwarded-Encrypted: i=1; AJvYcCV/cDRgKs410HqzEoiwGk8ijUnn+9h3SldFNyotHN8Gumo4y//eHIa3R4V6E8ZKh1YUFhvaTa4p5vtJtvFd@postgresql.org X-Gm-Message-State: AOJu0YxGWK6lhKJVoo7SEOJ5TmCvXyUpOqbxYyuZhJS/X9+JVtmdQga+ JBR8BY5jz9waX0c/g72XBYzED7iIXZittjfsEYeXoHyXxDdEPZvX/icJ79WxI2bEZC++kbbcpVR S04UyXKMUcUCdVw06dUqWNFdqJhI= X-Google-Smtp-Source: AGHT+IGgu5Vss51/U5ebIHeCwJCsJwsd5PFpMaKA8Qyn0VaBdSgWIWTNZmdTKlKFk5byvKH4H7mdoFZUBNz79Pvvrrg= X-Received: by 2002:a05:6512:3c8a:b0:52f:ca2b:1d33 with SMTP id 2adb3069b0e04-53b1a30bd95mr4467235e87.20.1729819766856; Thu, 24 Oct 2024 18:29:26 -0700 (PDT) MIME-Version: 1.0 References: <877caxaxt6.fsf@wibble.ilmari.org> In-Reply-To: From: David Rowley Date: Fri, 25 Oct 2024 14:29:14 +1300 Message-ID: Subject: Re: Changing the default random_page_cost value To: Greg Sabino Mullane Cc: =?UTF-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= , pgsql-hackers , Bruce Momjian Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 25 Oct 2024 at 13:14, Greg Sabino Mullane wrot= e: > > On Mon, Oct 14, 2024 at 10:20=E2=80=AFPM David Rowley wrote: >> >> Yeah, I think any effort to change the default value for this setting wo= uld require some analysis to prove that the newly proposed default >> is a more suitable setting than the current default. I mean, why 1.2 and= not 1.1 or 1.3? Where's the evidence that 1.2 is the best value >> for this? > > As I said, I was just throwing that 1.2 number out there. It felt right, = although perhaps a tad high (which seems right as we keep things very conse= rvative). I agree we should make a best effort to have an accurate, defenda= ble default. We all know (I hope) that 4.0 is wrong for SSDs. I don't think we're going to find the correct new value for this setting by throwing randomly chosen numbers at each other on an email thread. Unfortunately, someone is going to have to do some work to figure out what the number should be, and then hopefully someone else can verify that work to check that person is correct. I'm not trying to be smart or funny here, but I just am failing to comprehend why you think you offering a number without any information about how you selected that number to set as the new default random_page_cost would be acceptable. Are you expecting someone else to go and do the work to prove that your selected number is the correct one? It's been 4 weeks since your first email and nobody has done that yet, so maybe you might need to consider other ways to achieve your goal. >> I don't think just providing evidence that random read times are closer = to sequential read times on SSDs are closer than they are with >> HDDs is going to be enough. > > ... >> >> It would be nice to have this as a script so that other people could eas= ily run it on their hardware to ensure that random_page_cost we >> choose as the new default is representative of the average hardware. > > > Heh, this is starting to feel like belling the cat (see https://fablesofa= esop.com/belling-the-cat.html) I don't see the similarity. Changing the default random_page_cost requires analysis to find what the new default should be. The execution of the actual change in default is dead simple. With belling the cat, it seems like the execution is the hard part and nobody is debating the idea itself. > Remember this is still just a default, and we should encourage people to = tweak it themselves based on their own workloads. I just want people to sta= rt in the right neighborhood. I'll see about working on some more research = / generating a script, but help from others is more than welcome. You might be mistakenly thinking that the best random_page_cost is an exact ratio of how much slower a random seek and read is from a sequential read. There are unfortunately many other factors to consider. The correct setting is going to be the one where the chosen plan uses the scan method that's the fastest and knowing the answer to that is going to take some benchmarks on PostgreSQL. Our cost model simply just isn't perfect enough for you to assume that I/O is the only factor that changes between an Index Scan and a Seq Scan. I'd say it's not overly difficult to come up with test cases that go to prove the value you select is "correct". I've done this before for CPU-related costs. I think with I/O the main difference will be that your tests should be much larger, and doing that will mean getting the results takes much more time. Here's a link to some analysis I did to help solve a problem relating to partition-wise aggregates [1]. Maybe you can use a similar method to determine random_page_cost. David [1] https://www.postgresql.org/message-id/CAKJS1f9UXdk6ZYyqbJnjFO9a9hyHKGW7= B%3DZRh-rxy9qxfPA5Gw%40mail.gmail.com