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 1h8nt7-0003U0-4V for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2019 15:21:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h8nt5-00045v-PK for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2019 15:21:15 +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 1h8nt5-00045n-Hb for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2019 15:21:15 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8nt2-0001t2-Gb for pgsql-hackers@postgresql.org; Tue, 26 Mar 2019 15:21:14 +0000 Received: by mail-wm1-x344.google.com with SMTP id z24so10134762wmi.5 for ; Tue, 26 Mar 2019 08:21:12 -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=i6C4vD3fzSqw67hKqtj9GkHhFjeGrJPI3ZAZorvdLoI=; b=YfxbVnPPFvZWpwxa6hbj4txM52vW+rw+Nmzkf57AaBRcbW0ofiNSjfxd9c0mzhJ/Qs pVS0AxX3O1TOiM+dpRaWt3JO6otAQ9AZ25NBe+aNs93CkmnTHPomGdFjA8B6HHJ6rei0 2/43Sm5OVbbQdzyxQhEDks3Zfy4OyUOdcR0Y1Wj8xF1sQDuqjumUpyFQSYCcYK7pfpuZ aOKumC4MxZTQL/4hndIxlXqE9Vt8V3/MGsUp02Yv5IFxOkZq9ANj39DgKNB39jjwv/WL zy6kSHVLQLxbM0vxUr/gUCxpUwvVsEyzpds8luF4lMSibBREXeI7jL2/n38klKiJG/a0 8dlQ== 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=i6C4vD3fzSqw67hKqtj9GkHhFjeGrJPI3ZAZorvdLoI=; b=pAZQ4ihxvtfcgupzPc8feFDHYlctfRNAK/Sp7tJzE3+GXQ4/19oEPsbEHFp1KZfya1 XhUlLeBD0pkH6+wbgxG5rddn8ooSNzGBghD5uzwQlDzzmO3q8qM9/DD9nS+rI7QAqtDR U0MVPatyVYcfBGKMbzxdxWxHgRMqn9DwnZf42PPVd3VI9+cLFga0M+JPXoon8kwnOaOr r59ZHmObk2SlPCMXILSyTsFzOfCSj5ks8pKXEx4FdXmbK6B8+6Vwo/0U01nG7Q3z1xJh xm4JxAuKhdmawKZ139BX71W9S1ygWhqmXta5dX1AkA5Ccl38AhgqHXArWk/i5cUv5jbd kS1A== X-Gm-Message-State: APjAAAXe9DWF8Jfl2d+vQxq5XLtnX/JN4xnwAPQ8gqNLRnAw04Z57krR NcQCR3teSOgS9D0vz+VwSYqbCw== X-Google-Smtp-Source: APXvYqxjTlJQHNodrSkYVCoD6AkbHVQKzuBkSxNNPcmyNJStTsmHTe8y0+gk96c7LVyPH8py9h49VQ== X-Received: by 2002:a1c:3845:: with SMTP id f66mr9826923wma.41.1553613671450; Tue, 26 Mar 2019 08:21:11 -0700 (PDT) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id e12sm21301538wrt.94.2019.03.26.08.21.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Mar 2019 08:21:10 -0700 (PDT) Date: Tue, 26 Mar 2019 16:21:08 +0100 From: Tomas Vondra To: Dean Rasheed Cc: David Rowley , Kyotaro HORIGUCHI , Alvaro Herrera , Michael Paquier , Andres Freund , Thomas Munro , Bruce Momjian , Mark Dilger , PostgreSQL Hackers Subject: Re: [HACKERS] PATCH: multivariate histograms and MCV lists Message-ID: <20190326152108.GB3088@development> References: <37ce47c5-e0cf-c6d3-6923-6b8cfd1cc6b1@2ndquadrant.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Mar 26, 2019 at 01:37:33PM +0000, Dean Rasheed wrote: >On Tue, 26 Mar 2019 at 11:59, Dean Rasheed wrote: >> >> On Mon, 25 Mar 2019 at 23:36, Tomas Vondra wrote: >> > >> > Attached is an updated patch... >> >> I just looked through the latest set of changes and I have a couple of >> additional review comments: >> > >I just spotted another issue while reading the code: > >It's possible to build an MCV list with more than >STATS_MCVLIST_MAX_ITEMS = 8192 items, which then causes an error when >the code tries to read it back in: > >create temp table foo(a int, b int); >insert into foo select x,x from generate_series(1,10000) g(x); >insert into foo select x,x from generate_series(1,10000) g(x); >alter table foo alter column a set statistics 10000; >alter table foo alter column b set statistics 10000; >create statistics s (mcv) on a,b from foo; >analyse foo; >select * from foo where a=1 and b=1; > >ERROR: invalid length (10000) item array in MCVList > >So this needs to be checked when building the MCV list. > >In fact, the stats targets for table columns can be as large as 10000 >(a hard-coded constant in tablecmds.c, which is pretty ugly, but >that's a different matter), so I think STATS_MCVLIST_MAX_ITEMS >probably ought to match that. > >There are also a couple of comments that refer to the 8k limit, which >would need updating, if you change it. > I think we can simply ditch this separate limit, and rely on the statistics target. The one issue with it is that if we ever allows the statistics target to we may end up overflowing uint16 (which is used in the serialized representation). But I think it's OK to just check that in an assert, or so. -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services