public inbox for [email protected]  
help / color / mirror / Atom feed
From: Moreno Andreo <[email protected]>
To: [email protected]
Subject: Functions and Indexes
Date: Mon, 18 Nov 2024 15:37:57 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

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.







reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Functions and Indexes
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox