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 1hfC8D-0001NE-Dx for pgsql-hackers@arkaria.postgresql.org; Sun, 23 Jun 2019 23:42:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hfC89-0001pj-Nf for pgsql-hackers@arkaria.postgresql.org; Sun, 23 Jun 2019 23:42:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hfC89-0001pc-4t for pgsql-hackers@lists.postgresql.org; Sun, 23 Jun 2019 23:42:41 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hfC84-0006o1-Oa for pgsql-hackers@lists.postgresql.org; Sun, 23 Jun 2019 23:42:39 +0000 Received: by mail-wm1-x331.google.com with SMTP id c66so11045719wmf.0 for ; Sun, 23 Jun 2019 16:42:36 -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=UHzv6QZ0QgAYzhJyskJPnnoJhd8d8srU5jErdAzZL14=; b=WDYDMREndiL2UwbDXd40RfJ3gK046kQyIXidcdzs+G6RL6IbGM1B8a39dEYIjnD4/Y Zwoo/bYNeshhg7YUvvnwHkGSncjFpQDE4PLyWNHH2FjGDN+0L0OfLURuWmR2ckOMHOtc eFYPmT8Y8GXhyCS2c2tXu6g+FG6FuvodPTa5nrhMyVyiI+luSNS8h33RzvKQGQicLG+i 4pwPmHC076sti/Z5KQURRXHdNva59q0rWepu9SPgyagEr9frZHW1hji01BTl/AOITZat Ni5jZ/2P0LgiVccIbJEYR8xU7UooBNlEx8SsJakhGIp1nAnRP+sfI2dGVk4URO076Pvq 2KXw== 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=UHzv6QZ0QgAYzhJyskJPnnoJhd8d8srU5jErdAzZL14=; b=Z7gnhVMRkaxdR+5V0sL4AuV0t2F2wNLcoc716X1/sRsqIXnnHlYKKN77qoFVTNPCCL nvwy50qb9ZhSssJWV+PM3Md8wweVa80gPTln47UXh0yU05eUoJ9JOqC3saPjf0vur8Hj Pc0KsGpmPx6JsweARA6S8sWVwj5gRTwo9Rus0Jd7kpJ6jNJhmN+8AM5COwu+H2jpqZjs 94O4XgBco90YkrSMNE7CxhH4QnC3KL74EtoXF89AidcIy7rXUJguXJf+8L70CUvbRVKT U7wXhyvTpzPJNjNvjyqlkY3avnRw6lw6+0YcEMpH0sroDZs7/tPPtyydsPmB9ZdjkFLF aWIQ== X-Gm-Message-State: APjAAAWDLiq9Sw09qysYDo0aByeloZ4Rz0ohrxgvML6g8nsN7F5B9P1j R8lgLVboGhDiCtp90v0ctP9osg== X-Google-Smtp-Source: APXvYqzsAvvTuKG+K6WiVWmL8BE1sdJXFxWLwkNXZxETdvBFWC3eReMAYUobSg6SaBoHYsKQp1M3TQ== X-Received: by 2002:a7b:c766:: with SMTP id x6mr13236492wmk.40.1561333353878; Sun, 23 Jun 2019 16:42:33 -0700 (PDT) Received: from localhost (ip-86-49-253-160.net.upcbroadband.cz. [86.49.253.160]) by smtp.gmail.com with ESMTPSA id 72sm11678087wrk.22.2019.06.23.16.42.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 16:42:33 -0700 (PDT) Date: Mon, 24 Jun 2019 01:42:32 +0200 From: Tomas Vondra To: Dean Rasheed Cc: PostgreSQL Hackers Subject: Re: Choosing values for multivariate MCV lists Message-ID: <20190623234232.xkydftfd7uxexelo@development> References: <20190618205920.qtlzcu73whfpfqne@development> <20190620223548.p22wj7uejbrhkglf@development> <20190622141052.5csokbp3sx577mub@development> <20190623202319.4lcqsi5zc53hktda@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190623202319.4lcqsi5zc53hktda@development> User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services