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 1nvdVA-0008GZ-38 for pgsql-admin@arkaria.postgresql.org; Mon, 30 May 2022 11:24:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nvdV8-0006KZ-4w for pgsql-admin@arkaria.postgresql.org; Mon, 30 May 2022 11:23:58 +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 1nvdV7-0006Hk-NY for pgsql-admin@lists.postgresql.org; Mon, 30 May 2022 11:23:57 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nvdV4-0003v1-GL for pgsql-admin@postgresql.org; Mon, 30 May 2022 11:23:56 +0000 Received: by mail-ed1-x52b.google.com with SMTP id n28so4285451edb.9 for ; Mon, 30 May 2022 04:23:53 -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:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=1KZMn6HkhPpztDv+rEBH0np1VhGvYt7vWrN5fJnON5Q=; b=wwG4PpTBjR8y9wFrDHc45tsxuZzS5WK7HDjiYizWC3aGzj+dPq5UxuoOmFwobUzW7i kVLkYh2xahOVXh/rfQ5le8apH4xaipszT10GImtGl+HQF0leTn5y9CqZ6Ex50zm2vujv zxHifzGBcHn69Fjuhp+MJfKaf3HSJ7llnMuU6UgDGCVbrifGJZcdK3mpVEYr/zLgteQk l6MIt/vcyX7ZceoPe9lbRJ5sWkEz7ErbZjFD0dK/pguqFsjEiTOWSgasfILRiuU0i9j5 JcyBDtMrXkKHE8el1t9ZqyelndnPhBF8bkULcWwYk+4A8AVRd7WzYGW+yK13A7vscux8 BwJw== 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:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=1KZMn6HkhPpztDv+rEBH0np1VhGvYt7vWrN5fJnON5Q=; b=ldYhrzAkZAi2vyjnzWFVGvqGLTBQIAgY6HKcA5irGyUHr3+YPnZ6QzZnktfTUw8nc3 Kc6RCz0WXLgViU2ebSf8+xEccDutYWraMdAVmXsrwoZFy/rozrydi62+ic8/froGSVOj OToofW7n3/nlT65e5O08PY6a3ihClFvf7b3+7DZnrLzjhbs8V/lelkHhVmtLyUvKMTsv QRWwh5p6oIvIF/ssMOf8rC9acfSl1pUji8q6LTPhKpu+yaFJovXPh8QM9prw8bWApJGq /7LAaDfLfEnv+zZehsXFTfbtXp+KI4YYLRLrK0i9x0cc1HiVwTcDB8aFPuT3mrgzSV9K pSkg== X-Gm-Message-State: AOAM532MO+OKQgm8jtj91EQJ846b27XHlslOirUHT/m6F3+eZNIGa5SA cBhsM+e0EWGx/0Ua5nqsCimC+g== X-Google-Smtp-Source: ABdhPJy5knKRtRxQwqehmN9NBWZGwFSpJv+9f4w4z6nu4tF9SVmjE3utizYTCsvLnWn8JbIKZEiZxA== X-Received: by 2002:a50:cd08:0:b0:426:1d9b:4b13 with SMTP id z8-20020a50cd08000000b004261d9b4b13mr57601110edi.360.1653909832614; Mon, 30 May 2022 04:23:52 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:9a01:3cb2:b65f:f0be:5d23]) by smtp.gmail.com with ESMTPSA id t9-20020a50c249000000b0042bd2012196sm6394802edf.85.2022.05.30.04.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 04:23:52 -0700 (PDT) Message-ID: <68bd3f240bc5792eb098418656445c3ebd0488c5.camel@cybertec.at> Subject: Re: how to calibrate the cost model parameters From: Laurenz Albe To: jian xu , "pgsql-admin@postgresql.org" Date: Mon, 30 May 2022 13:23:51 +0200 In-Reply-To: References: 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 Sun, 2022-05-29 at 15:29 +0000, jian xu wrote: > On my system, the estimated query cost has huge difference with the real query cost. > For example, a simple select query, the estimated query cost is 100X bigger than real cost, > I think I need to calibrate the cost model parameters below(I still use default value) > > #seq_page_cost = 1.0                                 # measured on an arbitrary scale > #random_page_cost = 4.0                         # same scale as above > #cpu_tuple_cost = 0.01                              # same scale as above > #cpu_index_tuple_cost = 0.005               # same scale as above > #cpu_operator_cost = 0.0025                   # same scale as above >   > I googled it, and only find some suggestions, for example set random_page_cost to 1 or 2 > for SSD, however, there is no doc about how to calibrate the cost model parameters to make > the estimated query cost close to the real query cost. That is as designed, see that "arbitrary scale" comment on "seq_page_cost". Sure, you could adjust all cost parameters so that 1 roughly corresponds to the number of milliseconds for the actual query, but there is little benefit in that. The numbers are only used to compare plans with each other. Moreover, settings like "enable_seqscan" and "enable_nestloop" can artificially distort the numbers. Yours, Laurenz Albe