Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oO86M-0006sx-Lj for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Aug 2022 01:44:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oO86K-0006wU-Ev for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Aug 2022 01:44:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oO86J-0006wK-Hl for pgsql-hackers@lists.postgresql.org; Wed, 17 Aug 2022 01:44:08 +0000 Received: from mail-177131.yeah.net ([123.58.177.131]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oO86C-00080B-AD for pgsql-hackers@postgresql.org; Wed, 17 Aug 2022 01:44:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yeah.net; s=s110527; h=Message-ID:Date:MIME-Version:From:Subject; bh=0CnW/ mBcUDsbYLgChNxSx4TyHqZ9WmyyQ+cFH8MKp90=; b=gSgko81Ut65xAK1qCRcEK +vV6D9LTIMEcQth2+Oe28SAJYpIad6AuGL1E0pa8Fk/aDIS2C3B8T7H1uKrkHAK5 7HcaQHmoQ9JRWlRIeCINLuNWO16mMMhcnK9Oo7TOr4HVXJ47XQZhJ8K9IVtraLfd b339cY6F0/MamdnxSW+wi0= Received: from [192.168.1.100] (unknown [221.196.108.142]) by smtp1 (Coremail) with SMTP id ClUQrACnrz_aR_xi7e1XAA--.53643S2; Wed, 17 Aug 2022 09:43:55 +0800 (CST) Content-Type: multipart/mixed; boundary="------------qo3oSwLACao9gezDBToOF76V" Message-ID: Date: Wed, 17 Aug 2022 09:43:54 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 From: Quan Zongliang Subject: Bug: When user-defined AM is used, the index path cannot be selected correctly To: pgsql-hackers Content-Language: en-US X-CM-TRANSID: ClUQrACnrz_aR_xi7e1XAA--.53643S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ww4kCryDuF4ftF47XFy3twb_yoW8JFW3pr 13tr1xGr48GryxXryUXr1Utr1UJrn3AF1UJr17JF4rAw1UCryUXF1UGr1kJ34UJryUtr1j yF1UJr1Utr1UJw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jLWrJUUUUU= X-Originating-IP: [221.196.108.142] X-CM-SenderInfo: htxd06xrqjzxxdqjq5hhdkh0dhw/1tbiBRtgJFsVAiy1wgAAsN List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------qo3oSwLACao9gezDBToOF76V Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, 1. When using extended PGroonga CREATE EXTENSION pgroonga; CREATE TABLE memos ( id boolean, content varchar ); CREATE INDEX idxA ON memos USING pgroonga (id); 2. Disable bitmapscan and seqscan: SET enable_seqscan=off; SET enable_indexscan=on; SET enable_bitmapscan=off; 3. Neither ID = 'f' nor id= 't' can use the index correctly. postgres=# explain select * from memos where id='f'; QUERY PLAN -------------------------------------------------------------------------- Seq Scan on memos (cost=10000000000.00..10000000001.06 rows=3 width=33) Filter: (NOT id) (2 rows) postgres=# explain select * from memos where id='t'; QUERY PLAN -------------------------------------------------------------------------- Seq Scan on memos (cost=10000000000.00..10000000001.06 rows=3 width=33) Filter: id (2 rows) postgres=# explain select * from memos where id>='t'; QUERY PLAN ------------------------------------------------------------------- Index Scan using idxa on memos (cost=0.00..4.01 rows=2 width=33) Index Cond: (id >= true) (2 rows) The reason is that these expressions are converted to BoolExpr and Var. match_clause_to_indexcol does not use them to check boolean-index. patch attached. -- Quan Zongliang Beijing Vastdata --------------qo3oSwLACao9gezDBToOF76V Content-Type: text/plain; charset=UTF-8; name="indxpath.patch" Content-Disposition: attachment; filename="indxpath.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL29wdGltaXplci9wYXRoL2luZHhwYXRoLmMgYi9z cmMvYmFja2VuZC9vcHRpbWl6ZXIvcGF0aC9pbmR4cGF0aC5jCmluZGV4IDdkMTc2ZTdiMDAu LjMxMjI5Y2UxNmMgMTAwNjQ0Ci0tLSBhL3NyYy9iYWNrZW5kL29wdGltaXplci9wYXRoL2lu ZHhwYXRoLmMKKysrIGIvc3JjL2JhY2tlbmQvb3B0aW1pemVyL3BhdGgvaW5keHBhdGguYwpA QCAtMjI5NSw3ICsyMjk1LDcgQEAgbWF0Y2hfY2xhdXNlX3RvX2luZGV4Y29sKFBsYW5uZXJJ bmZvICpyb290LAogCiAJLyogRmlyc3QgY2hlY2sgZm9yIGJvb2xlYW4taW5kZXggY2FzZXMu ICovCiAJb3BmYW1pbHkgPSBpbmRleC0+b3BmYW1pbHlbaW5kZXhjb2xdOwotCWlmIChJc0Jv b2xlYW5PcGZhbWlseShvcGZhbWlseSkpCisJaWYgKElzQm9vbGVhbk9wZmFtaWx5KG9wZmFt aWx5KSB8fCBJc0EoY2xhdXNlLCBCb29sRXhwcikgfHwgSXNBKGNsYXVzZSwgVmFyKSkKIAl7 CiAJCWljbGF1c2UgPSBtYXRjaF9ib29sZWFuX2luZGV4X2NsYXVzZShyb290LCByaW5mbywg aW5kZXhjb2wsIGluZGV4KTsKIAkJaWYgKGljbGF1c2UpCg== --------------qo3oSwLACao9gezDBToOF76V--