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 1qGDXy-0007ly-Sr for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Jul 2023 07:00:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qGDXx-0001Sn-NE for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Jul 2023 07:00:29 +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 1qGDXx-0001Sd-Dl for pgsql-hackers@lists.postgresql.org; Mon, 03 Jul 2023 07:00:29 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qGDXq-001kvO-4x for pgsql-hackers@lists.postgresql.org; Mon, 03 Jul 2023 07:00:27 +0000 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-313e714342cso4777513f8f.0 for ; Mon, 03 Jul 2023 00:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1688367620; x=1690959620; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=reYngPI4M5MM6WeqI9uPpp3tFxCdpxb/sdyfQssXT7Q=; b=EcriXHUP3f35fhF1xEs8sC+lpStt+oo1GT6dAo3nErVJXT0FS92/U/rdTN9Lxzg7/q dSqdYvvPeVmecdF33fvG4lt6teFBUQERV4p6rYxnzfcsVrHafLLF3jxUEkon+RzUlrs8 IE59v4XKUtqQvjPxdBI6WBbuY4km/iOm5XrAfs+XUngNeDA71DFsprXFTDSZxY+2bi6d 5Q5hCMovLYXZJRHHTgSk548C859M9Yr/4nddRNcyMr32dLXBZlnGtyuoYYxADBIG5QK9 1dbkp+/QsZrHmhnAW0hl3NKimV02DN6KR5J9RW5S4Z2hiQi3EL97Cy5fXqneGEmedefv +38w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688367620; x=1690959620; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=reYngPI4M5MM6WeqI9uPpp3tFxCdpxb/sdyfQssXT7Q=; b=gZtDiy6FHH4BOc0YbWJeVS647K6wmtaF6mzRx6LI3iZGDs2BdkEfSJT9HVd/Lg1yfS 1Y91ZGQ0h2BD3JvFfSEeb32kZUoaQZckUA2r7U1jNZJcCs+mmyQbhuGrosS+2exhGwoi dBc1yoA9uM4sGQuYjUELHYVmB0ZL+33HqibG4xOVUYGzeXWQAiz+YtucGtRjxJcI+rYH M6LGgOfWZ3dlNp1NaAbmocIqWCQqC7mcK2UxWMzMGE0JKAieqyQT7V3RbWwYkiBX1IQ+ k9B3oJ+QiRC/TAo3uWyn57ui3PrMuIY9596twNYge5W3xIAbP8AMkIIlOoly9a3B0dXr /vZA== X-Gm-Message-State: ABy/qLZnPOWYZPcRGFg+jmWFAfZRUtGtRFLH4L7IGNhDEDawAw0fhxwY PAglT8JPl/PYaa4txFkGceKQxA== X-Google-Smtp-Source: APBJJlEW5/kCNmqut9LosyTtCIZzykPQriJ91lm2mqc7rSTIUelKYZ4e1qzIDSBQj2JvMso6wmqFlA== X-Received: by 2002:adf:e84c:0:b0:314:1d88:f072 with SMTP id d12-20020adfe84c000000b003141d88f072mr7927674wrn.25.1688367620611; Mon, 03 Jul 2023 00:00:20 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-228-220.bb.vodafone.cz. [86.49.228.220]) by smtp.gmail.com with ESMTPSA id c9-20020adfe749000000b0031416362e23sm10481786wrn.3.2023.07.03.00.00.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Jul 2023 00:00:20 -0700 (PDT) Message-ID: <10ed61c0-a078-9bdf-9ff4-dca92ffd5315@enterprisedb.com> Date: Mon, 3 Jul 2023 09:00:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: Should heapam_estimate_rel_size consider fillfactor? To: Peter Eisentraut , Corey Huinker Cc: PostgreSQL Hackers References: <63729d7a-cb1e-06af-a24e-27a8b93717ef@eisentraut.org> Content-Language: en-US From: Tomas Vondra In-Reply-To: <63729d7a-cb1e-06af-a24e-27a8b93717ef@eisentraut.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/3/23 08:46, Peter Eisentraut wrote: > On 14.06.23 20:41, Corey Huinker wrote: >>     So maybe we should make table_block_relation_estimate_size smarter to >>     also consider the fillfactor in the "no statistics" branch, per the >>     attached patch. >> >> >> I like this a lot. The reasoning is obvious, the fix is simple,it >> doesn't upset any make-check-world tests, and in order to get a >> performance regression we'd need a table whose fillfactor has been >> changed after the data was loaded but before an analyze happens, and >> that's a narrow enough case to accept. >> >> My only nitpick is to swap >> >>     (usable_bytes_per_page * fillfactor / 100) / tuple_width >> >> with >> >>     (usable_bytes_per_page * fillfactor) / (tuple_width * 100) >> >> >> as this will eliminate the extra remainder truncation, and it also >> gets the arguments "in order" algebraically. > > The fillfactor is in percent, so it makes sense to divide it by 100 > first before doing any further arithmetic with it.  I find your version > of this to be more puzzling without any explanation.  You could do > fillfactor/100.0 to avoid the integer division, but then, the comment > above that says "integer division is intentional here", without any > further explanation.  I think a bit more explanation of all the > subtleties here would be good in any case. > Yeah, I guess the formula should be doing (fillfactor / 100.0). The "integer division is intentional here" comment is unrelated to this change, it refers to the division by "tuple_width" (and yeah, it'd be nice to have it explain why it's intentional). regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company