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 1r0D5D-004Bz6-3d for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Nov 2023 03:48:55 +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 1r0D5B-004D3u-5r for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Nov 2023 03:48:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r0D5A-004D0w-9m for pgsql-hackers@lists.postgresql.org; Tue, 07 Nov 2023 03:48:52 +0000 Received: from m12.mail.163.com ([220.181.12.215]) by makus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r0D54-004Kzu-HV for pgsql-hackers@lists.postgresql.org; Tue, 07 Nov 2023 03:48:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version: Content-Type; bh=sxOYbv44eYI78CQkg1Gl1kDHxR3uNEEY2SyZiSnCCJ0=; b=qYwRCj930yZRLaoHpLAXK0nw0mqmdFB4YHoF7AOHpeTcB0KugT0xhyBBqccnNj 5mNW5FJIAwlQKDzfRfPoR9jUJnnGq6VWUUTneDdU0TUBjbV/Jo2CkGlFUdOXzYHA 0IiTN2Ocn0vdbt2mndLhSafu3oK9qqRY0egWP1xNJcSsU= Received: from 66ed4ed24c7c (unknown [140.205.118.227]) by zwqz-smtp-mta-g4-2 (Coremail) with SMTP id _____wAHhhSPs0llHe0gCg--.28S3; Tue, 07 Nov 2023 11:48:32 +0800 (CST) References: <7mlamswjp81p.fsf@e18c07352.et15sqa> <7mla7cnmue6q.fsf@e18c07352.et15sqa> <7mla7cnh4rsy.fsf@e18c07352.et15sqa> User-agent: mu4e 1.10.7; emacs 29.1 From: zhihuifan1213@163.com To: jian he Cc: pgsql-hackers@lists.postgresql.org Subject: Re: UniqueKey v2 Date: Tue, 07 Nov 2023 11:44:42 +0800 In-reply-to: Message-ID: <87cywmmdf4.fsf@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID:_____wAHhhSPs0llHe0gCg--.28S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7XrWUZF4rGr4ftFW8ZryrZwb_yoWDuFc_ZF 98AwnxAw4xGry2yFZYyr43Cr1qqF4Uu3s0grWDGF15G3srAr4xG3ykG3s2vrnxG34vgF9a 9FyDAF4xA39F9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUbgTmDUUUUU== X-Originating-IP: [140.205.118.227] X-CM-SenderInfo: x2klx3xlid0iqsrtqiywtou0bp/xtbBzxYhU1aEAieowQAAs1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk jian he writes: > On Fri, Oct 20, 2023 at 4:33=E2=80=AFPM wrote: >> >> >> > i did some simple tests using text data type. >> > >> > it works with the primary key, not with unique indexes. >> > it does not work when the column is unique, not null. >> > >> > The following is my test. >> >> Can you simplify your test case please? I can't undertand what "doesn't >> work" mean here and for which case. FWIW, this feature has nothing with >> the real data, I don't think inserting any data is helpful unless I >> missed anything. > > Sorry for not explaining it very well. > "make distinct as no-op." > my understanding: it means: if fewer rows meet the criteria "columnX < > const_a;" , after analyze the table, it should use index only scan No, "mark distinct as no-op" means the distinct node can be discarded automatically since it is not needed any more. The simplest case would be "select distinct pk from t", where it should be same as "select pk from t". You can check the testcase for the more cases.=20 --=20 Best Regards Andy Fan