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 1rJJFj-00CdSz-LA for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Dec 2023 20:14:43 +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 1rJJFi-00BwpF-AF for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Dec 2023 20:14:42 +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 1rJJFi-00Bwp7-0F for pgsql-hackers@lists.postgresql.org; Fri, 29 Dec 2023 20:14:42 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rJJFe-00EWPc-Uz for pgsql-hackers@lists.postgresql.org; Fri, 29 Dec 2023 20:14:40 +0000 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-553ba2f0c8fso8244355a12.1 for ; Fri, 29 Dec 2023 12:14:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1703880876; x=1704485676; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=b++z4NWkFj5QQwWQIcFC+khqDnMUepLG9ELz+AHG+JU=; b=aUQVuWaRmuMSLWhb8b1xzoFFUAjjQUKLRjb5FzomUyf3noDoaW40lFKiWHUhpPyL/L kGfvGPs8P2fq1oN0QHc6qjb0TlKtp1hR5JMJz/ZIiWJlQsUOLCOIEB/XuIlGxbqBlONU VR7Yzs72R8yrSAO1OwLRJOMBH2iIw6RYLaglliEaEn4mfs/nHjli0g2X8ELkI/92iW7N OBbfGlfolG0AQ2xaUaskxBvTA4dK1mbVq7vltsz1Bzx2DttiPrt1uSzgIJbeXnJ1y7n8 I337yS6vaxPDBmQEVbwEEvy0KOmvE7YM7o7isxFwM3OlL+WPqks6CvT85qy9S2vQb9co FICg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703880876; x=1704485676; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=b++z4NWkFj5QQwWQIcFC+khqDnMUepLG9ELz+AHG+JU=; b=M9AZh3c1ZXbby7MtTBqnMFJivjeXEXBpcP8R3ad5pALQBcUx5Kcs8+fLFz8RvbZftr PTHi4RnEzfgRhzMXxvhbCm8LunwpC6/9ZsED2HybbhowhLhpPfIRtzrfiSktNLwo/cpl DX9v/j2T7cpi5Actvm502aob0GKYUlZ+7uDQpUGtJspA0sHfurKPsi+aGGmzzJvIodHX KRIcbA5DLZ92umh8FR4uBf8L6JQXhmn5/CgREUMy9+NB3RhKkSpltIeuUKU+/TH+CRLn QZhK0yNga+PgDU+r7dO9DIT6+6FsqsX2NY6KSXPvDUTr1dqRq9+SvGuP2njrkm0ZVlFD lJWg== X-Gm-Message-State: AOJu0YxG6h26lOHw/BXmZQLe6ZBA2OIkC7ogepUA+JkzA2Zigc9lERUX YBADRA/K78MDE8EqvnxhiQXZR2y2URmc X-Google-Smtp-Source: AGHT+IEJnelmpEccqcP4sEeeuo5CTNwy9tmqL+MYS7padmQw8+HneDlKD5ch7C4sXdl2qhehuK/DBA== X-Received: by 2002:a17:907:710f:b0:a27:9365:ef68 with SMTP id zr15-20020a170907710f00b00a279365ef68mr229617ejb.127.1703880876382; Fri, 29 Dec 2023 12:14:36 -0800 (PST) Received: from [10.137.0.17] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id l13-20020a1709066b8d00b00a26887307besm8662504ejr.180.2023.12.29.12.14.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Dec 2023 12:14:36 -0800 (PST) Message-ID: <42d78931-9e7d-ac5e-da68-5440c726e985@enterprisedb.com> Date: Fri, 29 Dec 2023 21:14:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: Statistics Import and Export To: Corey Huinker Cc: Ashutosh Bapat , pgsql-hackers@lists.postgresql.org References: <76596388-6fe6-0baf-351d-734458a46d76@enterprisedb.com> Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/29/23 17:27, Corey Huinker wrote: > But maybe it's enough to just do what you did - if we get an MCELEM > slot, can it ever contain anything else than array of elements of the > attribute array type? I'd bet that'd cause all sorts of issues, no? > > > Thanks for the explanation of why it wasn't working for me. Knowing that > the case of MCELEM + is-array-type is the only case where we'd need to > do that puts me at ease. > But I didn't claim MCELEM is the only slot where this might be an issue. I merely asked if a MCELEM slot can ever contain an array with element type different from the "original" attribute. After thinking about this a bit more, and doing a couple experiments with a trivial custom data type, I think this is true: 1) MCELEM slots for "real" array types are OK I don't think we allow "real" arrays created by users directly, all arrays are created implicitly by the system. Those types always have array_typanalyze, which guarantees MCELEM has the correct element type. I haven't found a way to either inject my custom array type or alter the typanalyze to some custom function. So I think this is OK. 2) I'm not sure we can extend this regular data types / other slots For example, I think I can implement a data type with custom typanalyze function (and custom compute_stats function) that fills slots with some other / strange stuff. For example I might build MCV with hashes of the original data, a CountMin sketch, or something like that. Yes, I don't think people do that often, but as long as the type also implements custom selectivity functions for the operators, I think this would work. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company