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 1tmeOs-008RN2-NY for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Feb 2025 19:45:59 +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 1tmeOr-007DIp-GB for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Feb 2025 19:45:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tmeOr-007DII-2C for pgsql-hackers@lists.postgresql.org; Mon, 24 Feb 2025 19:45:57 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tmeOn-000X1w-2I for pgsql-hackers@lists.postgresql.org; Mon, 24 Feb 2025 19:45:55 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-220c2a87378so81285405ad.1 for ; Mon, 24 Feb 2025 11:45:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1740426354; x=1741031154; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=WlU32xzqL4kRWkVDDll+rSeeBOFaYbGYP+sEgJVqCrk=; b=bChblJZLRI80UEsQFgxHjnVfruUHsTTUV+cr8ilTsDrKrkMLL+IWr39O0H2V4/id00 tpXHVtfKz1G+HfNh50XS4o2xgSGqklc03aOT1TYRjb7UPQvyVAPajj3nk0WeLz/u3yvU mAABcShEwpjoPh9+KNMR9dwXY3mukv1xHvU0KA09uwEiY1vRPOfx6cni/7lsZrs4cqLn QCAIGIPY0RuQt1jBXSSMyR+RfksDBvYXdnkVGFna1obL+DD7ncKjk92fENw1GQXqGTaJ KUm2bpiRrcRN0ABsd84Y4oYSA70axAE34ymeZdco7t6hl5WREY6FXU698weZp/XZRRWE Z7fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740426354; x=1741031154; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=WlU32xzqL4kRWkVDDll+rSeeBOFaYbGYP+sEgJVqCrk=; b=sz0QAteNR1fqS4sg3AIE85gDaKzhw+qLx665kKu+NfktS3z91H45yoi+z2GnwhVLNx VvMZB+7sKahTI5Pa1nQbddaNvlYCC0PDkpxcv2K50qv5cTgUoutsS3OdqHZ4VqwA2QeW +QsUn2jfpBbSW5hvwPUzUNwSkCx6vPCdbAZBYkLfvM6x5DPyNCfn9qnvQTZnlaF0TDf2 WklViEgMeF2dUEBZsV6PRQJ4WrmAJqEngoFOhoFtfOYKVVg0ahkcBGWk3pffUKJaDRNY BAIUVpevZfbiHPxV4GSO08Pd1C6N96YhukM/7nWRLh12Ixj4h1duw5kooG+RM5QzIMdq rPaA== X-Forwarded-Encrypted: i=1; AJvYcCWYAp9UiUkhwv8863HpZOgEy+PhYY9nTZLSlvR+RHmDmOTlbRKZmNahkZPpHOcbF0fuGu5EeM+RtBmJMsCF@lists.postgresql.org X-Gm-Message-State: AOJu0Yy6PqDWPn4jOk/GXtvm5mxyMg/nezWQzA/eRAVPOkjmulTGt8Ys FxYrZc1S0FzGtbV22Cv4kl5VqL6CBziUKckE6ebek5MRDJ4slRcILNfNkEi+Ug== X-Gm-Gg: ASbGnctMNsgC/EywJyeheKieqOMspBgeQ5zoMqh4v7YXKd7GTm+xyX6YvUPnLxA2ZVg vnTK+ukEcD7UrUDQ3LVll4gLV5rzboCJHBmlaOzMQTPaEAd+QK+i+cDkz0IxibR8P5Jt16H65WG kIAGQgQ/ovtakekXGI6dqTav3aHb6pPmDD5Y0mjzWjSKUQWLOAc7zmAyNx2RxeFSvBKt1TAtfqr 5DkH1/djowLl51htgCVnDeXTqhjDsQKGqpBxYqQjP2CusE9AY4IOpSenSFNosDMIZzg2yNH8Gq4 N6XUcg1cUTkf5iqjiiaNAM2U0pLEzlTKkNrzZ3f1iihIKnAf33yIkY96C+tiSBf/ymcp X-Google-Smtp-Source: AGHT+IG8XFKz9RlDE4MTqeZ5V+o1YpO2+7Mpvj3DQx5hmHu2NgtMBvVlwGn6yd9Dio3dslI+5x0qoA== X-Received: by 2002:a17:902:d4d2:b0:21f:4b63:d5c3 with SMTP id d9443c01a7336-221a0edbfa5mr256200885ad.12.1740426353677; Mon, 24 Feb 2025 11:45:53 -0800 (PST) Received: from jeff-laptop.lan (c-76-102-242-158.hsd1.ca.comcast.net. [76.102.242.158]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fceb12e4casm6974103a91.48.2025.02.24.11.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2025 11:45:53 -0800 (PST) Message-ID: Subject: Re: Statistics Import and Export From: Jeff Davis To: Corey Huinker , Andres Freund Cc: Tom Lane , Michael Paquier , jian he , Nathan Bossart , Bruce Momjian , Matthias van de Meent , Magnus Hagander , Stephen Frost , Ashutosh Bapat , Peter Smith , PostgreSQL Hackers , alvherre@alvh.no-ip.org Date: Mon, 24 Feb 2025 11:45:51 -0800 In-Reply-To: References: <3670503.1740173078@sss.pgh.pa.us> <3728741.1740178078@sss.pgh.pa.us> <97b451228227c555be1a4f79c4a62ddec9a74f06.camel@j-davis.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2025-02-24 at 12:57 -0500, Corey Huinker wrote: > As I see it, the point is that we're getting an input that is a > string representation from the query, and the end-goal is to convey > that value with fidelity to the destination database, so there's > nothing we can do to get us closer to the string that we already > have. As Andres mentioned, for the float-to-string conversion, we're using what the backend does, so it doesn't seem like a problem. But you have a point in that float4in() does slightly more work than strtof() to handle platform differences about NaN/Inf. I'm not sure how much to weigh that concern, but I agree that there is non-zero cognitive overhead here. Should we solve that problem by moving some of that code to src/common src/port somewhere? > I don't have benchmark numbers beyond the instinct that > doing=C2=A0something takes more time than doing nothing. Granted, > "nothing" here means 96 bytes of memory and 3 strncpy()s, and > "something" is 24 bytes of memory, 2 atoi()s, 1 strtof() plus > whatever memory and processing we do back in converting back to > strings. To me, this argument is, at best, premature optimization. Even if there were a few cycles saved here somewhere, you'd need to compare that against the wasted memory. Using 2 int32s and a float4 is only 12 bytes (not 24) versus 96 for the strings. Anyone looking at the structure would be wondering (a) why we're using 32 bytes to store something where the natural representation is 4 bytes; and (b) whether that memory adds up to anything worth worrying about. I'm sure we could analyze that and write an explanatory comment, but that has non-zero cognitive overhead, as well. Regards, Jeff Davis