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 1rMQlF-004YSf-5x for pgsql-hackers@arkaria.postgresql.org; Sun, 07 Jan 2024 10:52:09 +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 1rMQlD-00FGaK-Jk for pgsql-hackers@arkaria.postgresql.org; Sun, 07 Jan 2024 10:52:07 +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 1rMQlD-00FGaC-9T for pgsql-hackers@lists.postgresql.org; Sun, 07 Jan 2024 10:52:07 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rMQl5-000ImS-8u for pgsql-hackers@postgresql.org; Sun, 07 Jan 2024 10:52:05 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40e45a3ee03so1972075e9.3 for ; Sun, 07 Jan 2024 02:51:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1704624717; x=1705229517; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=HQRLqqCG4rYXH8loMRTSPc2VuOnR1kUKYt246Tu2eGY=; b=kKk0t8iq+5F4f7naARsmlJ8q2EG1KDXKMITBG+yXzPnuCEmb8ESpj+y+AL5C3rSLkC iGzjISyFUdpWdjCrFkjNr03l/qn/ygiuKmaCQr1/50tiKzQ7igeA5PSJIdsJeq7Apz4e CKhWHY+VAOlalDdX048idW+ObPVRBKW3OUUqTV5jCcZkHXBPhOlDWKDeW8OAC6ECKWyk EDFmloQy9aBVeFzecGCeKCGK2aP6vNUQplguIU+UDBmmlYJ1GzTNfqj//xys37ZR4C6b wvNCxKyTVennlOxohcstZZmKQWdDZlBT/t1g1TSuZkT4LVhPVSzrHEQXHU+jq2QnnvWG YZpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704624717; x=1705229517; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HQRLqqCG4rYXH8loMRTSPc2VuOnR1kUKYt246Tu2eGY=; b=JauSaFz54nGYQr2f1aXj55iSq5axxEmesQFQ5Y9w/V1vP0n6ePX4mDPi58lHlaiNSl f0V1wogEzMoF8cf3ajxcOoOYl51YtN5tgSMm77DRVhH3khJ6QwMpUKpZaPlFZsC1bZdh n/14g4SevGSNegdkFwiH+zUF7Ktb3gjkWLizQ6MjVxBwBYXXXkPyRoLVYXBofZVhmqty x7YISlJKEW2wcWxrh3HbNwIOTfqK8Oqeo5zNuf85lzZu+EqAnZ0J2+pZDCMx7vervcHp tRC06ySSVPnnLgf6KN0Zy6EEdfXT4mSkx7bJbUIMApMwLWL46jKvJMbS6GoLFFPad4RN nyhw== X-Gm-Message-State: AOJu0YztYYtwqXJ5NcGJTYaRYP1Y57domE2AJIXuu4QHylErku3WHnXj sB1G35zirFh9q76IreQ49Z8FRskv1KQf X-Google-Smtp-Source: AGHT+IHF7q1SaSlEKZfgZJxTYdmriRI6FdU8KIaVTwDuwUeari6lts8yOu5pbMGHIQdPLwc8zyRYhw== X-Received: by 2002:a05:600c:1e05:b0:40e:4694:8b71 with SMTP id ay5-20020a05600c1e0500b0040e46948b71mr131347wmb.117.1704624717146; Sun, 07 Jan 2024 02:51:57 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id l8-20020a05600c1d0800b0040d6e07a147sm7317618wms.23.2024.01.07.02.51.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jan 2024 02:51:56 -0800 (PST) Message-ID: <31d8c6d6-717c-45ae-a8f7-9947eb5e3401@enterprisedb.com> Date: Sun, 7 Jan 2024 11:51:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Multidimensional Histograms Content-Language: en-US To: Andrei Lepikhov Cc: pgsql-hackers@postgresql.org, Alexander Cheshev References: <6e92450c-8136-11d4-8f6e-501c693af5c8@enterprisedb.com> <62435ae5-15f3-4485-a8e5-4f50d3bc8c8b@postgrespro.ru> From: Tomas Vondra In-Reply-To: <62435ae5-15f3-4485-a8e5-4f50d3bc8c8b@postgrespro.ru> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/7/24 11:22, Andrei Lepikhov wrote: > On 7/1/2024 06:54, Tomas Vondra wrote: >> It's an interesting are for experiments, no doubt about it. And if you >> choose to explore it, that's fine. But it's better to be aware it may >> not end with a commit. >> For the multi-dimensional case, I propose we first try to experiment >> with the various algorithms, and figure out what works etc. Maybe >> implementing them in python or something would be easier than C. > > Curiously, trying to utilize extended statistics for some problematic > cases, I am experimenting with auto-generating such statistics by > definition of indexes [1]. Doing that, I wanted to add some hand-made > statistics like a multidimensional histogram or just a histogram which > could help to perform estimation over a set of columns/expressions. > I realized that current hooks get_relation_stats_hook and > get_index_stats_hook are insufficient if I want to perform an estimation > over a set of ANDed quals on different columns. > In your opinion, is it possible to add a hook into the extended > statistics to allow for an extension to propose alternative estimation? > > [1] https://github.com/danolivo/pg_index_stats > No idea, I haven't thought about that very much. Presumably the existing hooks are insufficient because they're per-attnum? I guess it would make sense to have a hook for all the attnums of the relation, but I'm not sure it'd be enough to introduce a new extended statistics kind ... regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company