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 1tD2tF-00FQ1G-M5 for pgsql-general@arkaria.postgresql.org; Mon, 18 Nov 2024 14:38: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 1tD2tC-005ISV-NF for pgsql-general@arkaria.postgresql.org; Mon, 18 Nov 2024 14:38:07 +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 1tD2tC-005ISM-9Z for pgsql-general@lists.postgresql.org; Mon, 18 Nov 2024 14:38:06 +0000 Received: from mail.evolu-s.it ([77.81.232.174]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tD2t5-002Wzn-Ap for pgsql-general@lists.postgresql.org; Mon, 18 Nov 2024 14:38:05 +0000 dkim-signature: v=1; a=rsa-sha256; d=evolu-s.it; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From:Subject:Date:Message-ID:To:MIME-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References; bh=bTBlE3VfOODafUFEqdsdER2hfj41wAmEyEH42vb22cY=; b=Ari328tsYW5K6OqM4ylVhkHFYjkODo1z+UXPIrL13Q4VHC9vL7jDFXkzeSqKcTwqddtNGHZnI1pUK7PwUXfT+DbCjO3H7eGE4lcsnNp/mT9yJUk61es9glHrJKr6kzRpHNKfC/8vKYRqKyjjTjlCWTgr1K2+yH3NGvVPsUs7F7w= Received: from [192.168.1.103] (res-129401d.ppp.twt.it [83.217.179.105]) by mail.evolu-s.it with ESMTPSA (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128) ; Mon, 18 Nov 2024 15:37:57 +0100 Message-ID: <8dfd0bd5-87e5-4de7-9f60-8a680a32bc11@evolu-s.it> Date: Mon, 18 Nov 2024 15:37:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Functions and Indexes Content-Language: en-US, it References: <2e36a2fe-b30f-46a5-937f-3b7d94e75cb6@evolu-s.it> To: pgsql-general@lists.postgresql.org From: Moreno Andreo In-Reply-To: <2e36a2fe-b30f-46a5-937f-3b7d94e75cb6@evolu-s.it> X-Forwarded-Message-Id: <2e36a2fe-b30f-46a5-937f-3b7d94e75cb6@evolu-s.it> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi folks, I'm creating indexes for some tables, and I came across a doubt. If a column appears in the WHERE clause (and so it should be placed in index), in case it is "processed" in a function (see below), is it possible to insert this function to further narrow down things? Common index: SELECT foo1, foo2 FROM bar WHERE foo1 = 2 CREATE index bar1_idx ON bar USING btree(foo1); What about if query becomes SELECT foo1, foo2 FROM bar WHERE (POSITION(foo1 IN 'blah blah') >0) Second question: I 've seen contrasting opinions about putting JOIN parameters (ON a.field1 = b.field2) in an index and I'd like to know your thoughts. Thanks, Moreno.