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 1u4U5J-002gTb-Hp for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Apr 2025 00:23:29 +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 1u4U5H-005ISd-Hf for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Apr 2025 00:23:28 +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 1u4U5H-005ISS-4K for pgsql-hackers@lists.postgresql.org; Tue, 15 Apr 2025 00:23:28 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u4U5E-0007Kd-2F for pgsql-hackers@lists.postgresql.org; Tue, 15 Apr 2025 00:23:27 +0000 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-30c2d427194so45917841fa.0 for ; Mon, 14 Apr 2025 17:23:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744676604; x=1745281404; darn=lists.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=jlxUUjD+slMC/H07ivqn0cgi+FACX47ACog8/WUbEUc=; b=OtxVZTOxRSfyGeN5MQbZutaeNBij5SC0RzEc2QCER5tufo2gXFZhXmKXFhJMVANXQw VUQOnR1FX86Vxdi3GaS59SadCVwef+Cd/5otjIiyoz6dJJKtcdkry84g9cVq1v1AVUJQ OWG5ffLmnKAldkAxRtOUs4RhgwMdQq1DQMhyoV+rcROPz9YrfZpkAz6s9epVbqQlC3nk NhfJAGl7eG46asIlFI2u+f1rPdiXp00cPKJu+6slptqpuCyCBNHVKfgqvMaROsDSfQc4 zdh65yq40scpCoOIZVAY58+v4Y5j8290g8kwO9W5QqYnjcpd2oJOymvZswUEXSSQoR6M jm9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744676604; x=1745281404; 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=jlxUUjD+slMC/H07ivqn0cgi+FACX47ACog8/WUbEUc=; b=dEKSl7pSOe4rz8ZU0dAGlM1Qa2ykMD1ClNmSuarMtniQIyOnkuHc7H/nfFpG+UckES r1oiHO8j9lY3FfqrpUtFJg37wZmwdZrN7VhpUsZwFi9n2CTIwVvZzm8zUMOlg6rd9ARQ h7BMS3rQFoqmNezjY8p4BRvzDqrp47wSJKG+Ef1o4+rGPYJfv6dnx1DsxYW3zxCgL7FD FlOWwPixN+1gjSgD1qbig2SdqMbLYjEXjR2o+NTghsUozad0et7jFpa1SpClq1NS1b5h 67gPqLapk7qCVPs49LP9h0JhaSm1afjezcqzqgywiGfwwP9GVYy9tfyrMZAk+O8tAMy5 gTpQ== X-Forwarded-Encrypted: i=1; AJvYcCXxCR/xzg1sbTFkUz4NGkt+XNKuMqtl1zc3NAcHjNvun8bgef5pRKTd5AoYKrwWpYmT0TGzhxIZtLXv2MUR@lists.postgresql.org X-Gm-Message-State: AOJu0Yy3a5CKLlSr/dJRiXNgURC3gZ0QjQZO1CP3auKPFvR2PdeL/Iqa bzvfZ+LQbMDiHIjLAQVQW8ep4HMc6dDi8MGqeW6g3dgwXqWTdjSl/DEqGkyz/qyetVu/UULZPiZ p7tCVvOdLvivuyYSAl8FLqC2VQ6M= X-Gm-Gg: ASbGncskdGOVHoShow8VNej1yDNgZtAYAB8MJkZvSARzwvWsSTQZSCF8i9mQj2fEi3X 9hOmayfEeRMO6g+Z4+KdFDTFOCpX2/yAT6nYmTYE62kgjeEjsO09dyu0SvdwppJuEJiM5GZKiMx CJDKYkiZDyoLpsN2Jz8FS5Pvj1D7IemNu8XuroaTlK+aaWgQ8hAO+lP+hb X-Google-Smtp-Source: AGHT+IFiQM3HSRfEOfpx5lh6pzNpO2E/A7oMGe+lPiIYCk6jGRkF3q18dr0FhQ4jOf50DNhhgX6f517cm2nm62sImew= X-Received: by 2002:a2e:b88d:0:b0:30b:f775:baf5 with SMTP id 38308e7fff4ca-3104951e934mr43578371fa.0.1744676603697; Mon, 14 Apr 2025 17:23:23 -0700 (PDT) MIME-Version: 1.0 References: <11c709e1-9b17-4c00-9ead-93609a09b9db@gmail.com> <1161645.1742854534@sss.pgh.pa.us> <1164845.1742856354@sss.pgh.pa.us> <3ba16aa7-3cb2-4289-b773-522ae2f03a77@tantorlabs.com> <81ef0f5a-b6a1-4417-ae3a-2bae9b8d419e@gmail.com> <67b5c84a-dedd-4103-af7e-0117046102fe@tantorlabs.com> <580fe72c-85be-45a8-9e00-6b5417690557@tantorlabs.com> <3ea66a50-e4b0-4f20-ae0c-4d9cbaf81cfb@tantorlabs.com> In-Reply-To: <3ea66a50-e4b0-4f20-ae0c-4d9cbaf81cfb@tantorlabs.com> From: David Rowley Date: Tue, 15 Apr 2025 12:23:11 +1200 X-Gm-Features: ATxdqUHKDBN7FGBVbR7qWDGPY_YbBikne4Xbv2rNlXBpFZ763HF8M_TAGm1FayI Message-ID: Subject: Re: Add estimated hit ratio to Memoize in EXPLAIN to explain cost adjustment To: Ilia Evdokimov Cc: Robert Haas , Tom Lane , Lukas Fittl , Daniel Gustafsson , PostgreSQL Hackers , Nikolay Samokhvalov , Andrei Lepikhov 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 Tue, 15 Apr 2025 at 11:14, Ilia Evdokimov wrote: > On 14.04.2025 23:53, David Rowley wrote: > If we can't get consensus for everything people want to add at once > then maybe the patch could be broken into two, with 0001 being pretty > much the v4 patch and then have 0002 add the Estimated Hit Ratio. > Having the physical patches and being able to try it out or view the > regression test changes might lower the bar on people chipping in with > their views. > > > Agreed - I=E2=80=99ll split the patch into two: one adds Estimated Capaci= ty and Estimated Distinct Keys, and the second adds Estimated Hit Ratio. I= =E2=80=99ll also add regression test differences to make it easier to evalu= ate the usefulness of each part. Thanks for the patches. I'm just looking for ways to allow us to group all three of these together for the TEXT format type. I see the BUFFERS are displayed quite compactly, e.g. "Buffers: shared hit=3D17 read=3D4". show_wal_usage() does something similar and so does show_modifytable_info() for MERGE. Maybe we could compress the text output a bit with: "Estimates: capacity=3DN distinct keys=3DN hit ratio=3DN.N%" If we get it that compact, maybe lookups could fit in there too, i.e.: "Estimates: capacity=3DN distinct keys=3DN lookups=3DN hit ratio=3DN.N%" I'd also like to vote that you modify explain.c and multiply the hit_ratio by 100 and use "%" as the unit in ExplainPropertyFloat(). Just looking at the raw number of "1.00" in the expected output, it isn't obvious if the planner expects every lookup to be a cache hit or just 1% of them. Also, to get something commitable, you'll also need to modify explain_memoize() at the top of memoize.sql and add handling to mask out the value of these new properties. These are not going to be anywhere near stable enough across platforms to have these shown in the expected output files. David