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 1nvveG-0003rE-Rc for pgsql-admin@arkaria.postgresql.org; Tue, 31 May 2022 06:46:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nvveE-0002PE-BX for pgsql-admin@arkaria.postgresql.org; Tue, 31 May 2022 06:46:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nvveD-0002P3-Sg for pgsql-admin@lists.postgresql.org; Tue, 31 May 2022 06:46:34 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nvveB-0005Dp-Fj for pgsql-admin@postgresql.org; Tue, 31 May 2022 06:46:33 +0000 Received: by mail-ed1-x532.google.com with SMTP id h11so16162818eda.8 for ; Mon, 30 May 2022 23:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=iJv+Cz+SrI+NVOqjlb1mkxRi/zOUc3XF4WFhMWGvTyI=; b=2aD8kucVIpHfJDm9MEyolftndOlnzLeEC3vGf5Y43ooPQYwcfzz0aJpnpDwHDHZ0yV QY+s/HLvjshHNM4q5W9aG3rh4Zl76vHhCwpYtQdb4b1bELZp1+ltFg2AOucpzO3HtaOa 1c8kdKk+8ajF37JOOAlXuEiYzZmICDIxWMC55HZPYIoMH5HPqo9T/e/2GaX9TFN0hjYn vtM09XUNVMIUnfdbQr57LJP5MfHqMIimmb4/Q29ExO5PhKhzp/UDMK/Au2DMzKBIrXm0 HCWEBIf8WGrKWQo8xC5Iw5Xrx2pvRMgM3OTUfrVPrjFJlKk2ie7mAIJkOuyzm+So8R2N pRog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=iJv+Cz+SrI+NVOqjlb1mkxRi/zOUc3XF4WFhMWGvTyI=; b=rBwh/U4FjTOUZaY9GHDjRHTdBW/Y5bth1iXeTNZCeIej1SyXEmGBJHfvH6s0e/GGMy DMR0TVY/p+oo1aC6OCxe9xf1Jfdcbv+qDD8P55lCO2pvLIfH/w+ucByuw+BBr+6tlGvb Y0s4T34e+6OhZ/oVTqfR3qi7t9ubcZZHhFfiubR+cpNK5+ND2uXCKf87ed7SdSoNnqdG y5ogLkLqMu9TYWzbtGD2wpYdGdnllxEtWi8y2AUjzkhxlff93iocp4tqfzFq5TODTB/+ QDBXGLiKBYOt49fbBGZpFZ8B77PbzJmWRiciBar6U33ul6w41eHmCIAwlnFk6gZr0Zp2 rdhw== X-Gm-Message-State: AOAM53161BdH3yS2XFx5EjKp79a45MkvckyKjmkvEymPLWV4SlvHJb2E /KujQclRsUd5IKyjHVRuIx5Jpg== X-Google-Smtp-Source: ABdhPJwZz2nYd7pKua80eneyyRTkbnJPnSJiCSM6TgH5emedWd/wAwWAXrSzg/PPTG3X8mmnbFcoIQ== X-Received: by 2002:a05:6402:1f03:b0:42b:38ed:a9ff with SMTP id b3-20020a0564021f0300b0042b38eda9ffmr40671191edb.218.1653979590244; Mon, 30 May 2022 23:46:30 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:8496:47b0:e18d:1f9a:4c26]) by smtp.gmail.com with ESMTPSA id d21-20020a170906641500b006febce7081esm4708425ejm.177.2022.05.30.23.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 23:46:29 -0700 (PDT) Message-ID: <1ec517a25fd893f783e3bd4606eccf036b0c6696.camel@cybertec.at> Subject: Re: how to calibrate the cost model parameters From: Laurenz Albe To: Jeff Janes , jian xu Cc: "pgsql-admin@postgresql.org" Date: Tue, 31 May 2022 08:46:29 +0200 In-Reply-To: References: <68bd3f240bc5792eb098418656445c3ebd0488c5.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2022-05-30 at 17:12 -0400, Jeff Janes wrote: > On Mon, May 30, 2022 at 3:40 PM jian xu wrote: > > Thanks Laurenz.  It is ok that these values are "arbitrary scale", but we still need > > to calibrate them to get the correct"arbitrary scale". For example if seq_page_cost > > is 1 and cpu_tuple_cost is 0.01, how to verify the io seq cost is 100 times slower than cpu access cost? > > "enable_seqscan" and "enable_nestloop" can work in some cases, but it doesn’t work with any cases. > > Does anyone have experience to  calibrate the cost model parameters to get the correct value? Thanks > > I put a lot of time into it, and I think you will find that there is no consistent way to do so. > For cpu_tuple_cost, for example, are the hint bits already set?  Do they need to get set? > Are the clog pages still in memory?  Is there contention on the lock used to determine if a given > transaction is still running?  How many columns does the table have? How many of them need to be > accessed for the current case, and how far left and right are they in the table and are they toasted? > > For seq reads, how much contention is there for the buffer mapping partition lock?  What is the > throughput of your IO system?  How many other seq reads will be occuring at the same time? Etc. > > For any change you intend to make, do you have a good enough load generator and test system set > up so you can test that it doesn't make something else worse? +1 I think that the values of those parameters are more set by experience and tradition than by measurable physical evidence. In a way, it just happens to work (mostly). For example, who says that on a spinning disk, random I/O is four times as slow as sequential I/O? Very likely, you have to factor in that part of the I/O requests are satisfied from the kernel page cache. Yours, Laurenz Albe