Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hfhb1-0005ST-UB for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Jun 2019 09:18:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hfhaz-0004yT-KX for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Jun 2019 09:18:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hfhaz-0004yM-75 for pgsql-hackers@lists.postgresql.org; Tue, 25 Jun 2019 09:18:33 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hfhar-000602-9z for pgsql-hackers@lists.postgresql.org; Tue, 25 Jun 2019 09:18:32 +0000 Received: by mail-wm1-x342.google.com with SMTP id u8so2154533wmm.1 for ; Tue, 25 Jun 2019 02:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=y9cBdjBZucLIbslUXD4kRD75/K55TgT5NNmTM3gSfb0=; b=W0MGa7n/kuWHMsgnWcrNmkS/QeE5AAUhRrqSb5FqX87gdzmj5Xokez5tBpIDbNZQr4 lV6EHoiXzZADpjruxZX0357hH72/hdFYGo1gYZP47w1TsSCYpXY+kgbL4WBsKoVAEskE 3Yl91jvp8uji08HU6s/V1woLLStL/WQDmPnzY5g4M2gHOL2DfhazYECaKDMRzfUdBZCS ErmWtfcKsRLIsM6OZJhKGXKob1PogrKVK4OtewZ3+1E77/qu9bCpJTaydx5j8VE4xh4k Ufi10zFO35jlaTK/WXhsffOX9VrWy7gt0kT2OkuPy+JR1H0b9U/UWPsAVaOnEYjHnsv/ xFqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=y9cBdjBZucLIbslUXD4kRD75/K55TgT5NNmTM3gSfb0=; b=sAsJVRW0koAWEj0QWdQ+YE7CXjj9gn0ZAiimqzmsJhpFc5XD/XIq5yXazDEPoznKlt Uw3OELj4eBvP3AH7X604OwwAOy/6kWmFMt/qWgT6mPHRY/nLmmYsEcFVM/mfPl3xcARQ NlZEeBU85hOm8hUYSHCbhXPYcW4K4t4m51NNoN7aDP6hETyQ4TCTadL4WE5Ni2dNfDA9 UzWcFTZjGtFhdIepyLu6ycp793n3zmZeS4lVxuNI80NHvuX/8MK9cvyxqq+hDqJgshxo XaO2NVw3ZYygfJ57BdIRwTiGMrlr3DOFwETE9vtt3QjWAs7LhZNkakjOsQXZtqWN+gyy 5Y8Q== X-Gm-Message-State: APjAAAVN1Gpnn9UPC8QeuR8Tl/SqZKboPpnOPMLtWvjdrYopfg8SU+Ce vQSQ5FloNS4SpyLPo7cm+ETHow== X-Google-Smtp-Source: APXvYqw4sX78Nibiq1v+GkgMlOi6eZ2cPOYANdX/ZKdhUDhTYKu/cHd2bex+Z7jWB5gY9fziu9ATaA== X-Received: by 2002:a1c:2c41:: with SMTP id s62mr19125599wms.8.1561454303762; Tue, 25 Jun 2019 02:18:23 -0700 (PDT) Received: from localhost (ip-86-49-253-160.net.upcbroadband.cz. [86.49.253.160]) by smtp.gmail.com with ESMTPSA id t12sm14347345wrw.53.2019.06.25.02.18.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 02:18:20 -0700 (PDT) Date: Tue, 25 Jun 2019 11:18:19 +0200 From: Tomas Vondra To: Dean Rasheed Cc: PostgreSQL Hackers Subject: Re: Choosing values for multivariate MCV lists Message-ID: <20190625091819.uslpopydrkqm3sdf@development> References: <20190618205920.qtlzcu73whfpfqne@development> <20190620223548.p22wj7uejbrhkglf@development> <20190622141052.5csokbp3sx577mub@development> <20190623202319.4lcqsi5zc53hktda@development> <20190623234232.xkydftfd7uxexelo@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Jun 24, 2019 at 02:54:01PM +0100, Dean Rasheed wrote: >On Mon, 24 Jun 2019 at 00:42, Tomas Vondra wrote: >> >> On Sun, Jun 23, 2019 at 10:23:19PM +0200, Tomas Vondra wrote: >> >On Sun, Jun 23, 2019 at 08:48:26PM +0100, Dean Rasheed wrote: >> >>On Sat, 22 Jun 2019 at 15:10, Tomas Vondra wrote: >> >>>One annoying thing I noticed is that the base_frequency tends to end up >> >>>being 0, most likely due to getting too small. It's a bit strange, though, >> >>>because with statistic target set to 10k the smallest frequency for a >> >>>single column is 1/3e6, so for 2 columns it'd be ~1/9e12 (which I think is >> >>>something the float8 can represent). >> >>> >> >> >> >>Yeah, it should be impossible for the base frequency to underflow to >> >>0. However, it looks like the problem is with mcv_list_items()'s use >> >>of %f to convert to text, which is pretty ugly. >> >> >> > >> >Yeah, I realized that too, eventually. One way to fix that would be >> >adding %.15f to the sprintf() call, but that just adds ugliness. It's >> >probably time to rewrite the function to build the tuple from datums, >> >instead of relying on BuildTupleFromCStrings. >> > >> >> OK, attached is a patch doing this. It's pretty simple, and it does >> resolve the issue with frequency precision. >> >> There's one issue with the signature, though - currently the function >> returns null flags as bool array, but values are returned as simple >> text value (formatted in array-like way, but still just a text). >> >> In the attached patch I've reworked both to proper arrays, but obviously >> that'd require a CATVERSION bump - and there's not much apetite for that >> past beta2, I suppose. So I'll just undo this bit. >> > >Hmm, I didn't spot that the old code was using a single text value >rather than a text array. That's clearly broken, especially since it >wasn't even necessarily constructing a valid textual representation of >an array (e.g., if an individual value's textual representation >included the array markers "{" or "}"). > >IMO fixing this to return a text array is worth doing, even though it >means a catversion bump. > Yeah :-( It used to be just a "debugging" function, but now that we're using it e.g. in pg_stats_ext definition, we need to be more careful about the output. Presumably we could keep the text output and make sure it's escaped properly etc. We could even build an array internally and then run it through an output function. That'd not require catversion bump. I'll cleanup the patch changing the function signature. If others think the catversion bump would be too significant annoyance at this point, I will switch back to the text output (with proper formatting). Opinions? regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services