Re: Functions and Indexes

2024-11-19 Thread Laurenz Albe
On Tue, 2024-11-19 at 14:30 +0100, Moreno Andreo wrote: > Inhttps://www.cybertec-postgresql.com/en/join-strategies-and-performance-in-postgresql/ >  you say >  "Note that for inner joins there is no distinction between the join > condition and the WHERE condition, but that doesn't hold for outer

Re: Functions and Indexes

2024-11-19 Thread Moreno Andreo
On 19/11/24 12:34, Laurenz Albe wrote: On Tue, 2024-11-19 at 11:53 +0100, Moreno Andreo wrote: What about if query becomes SELECT foo1, foo2 FROM bar WHERE (POSITION(foo1 IN 'blah blah') >0) You could create an index like     CREATE INDEX ON bar (position(foo1 IN 'blah blah')); Alternative

Re: Functions and Indexes

2024-11-19 Thread Laurenz Albe
On Tue, 2024-11-19 at 11:53 +0100, Moreno Andreo wrote: > > > What about if query becomes > > > SELECT foo1, foo2 FROM bar WHERE (POSITION(foo1 IN 'blah blah') >0) > > > > You could create an index like > > > >     CREATE INDEX ON bar (position(foo1 IN 'blah blah')); > > > > Alternatively, you co

Re: Functions and Indexes

2024-11-19 Thread Moreno Andreo
On 18/11/24 20:05, Laurenz Albe wrote: On Mon, 2024-11-18 at 15:37 +0100, Moreno Andreo wrote: 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),

Re: Functions and Indexes

2024-11-19 Thread Moreno Andreo
On 18/11/24 15:43, Gianni Ceccarelli wrote: On Mon, 18 Nov 2024 15:37:57 +0100 Moreno Andreo wrote: 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 do

Re: Functions and Indexes

2024-11-18 Thread Laurenz Albe
On Mon, 2024-11-18 at 15:37 +0100, Moreno Andreo wrote: > 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 fun

Re: Functions and Indexes

2024-11-18 Thread Gianni Ceccarelli
On Mon, 18 Nov 2024 15:37:57 +0100 Moreno Andreo wrote: > 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? You probably want to look at ht

Functions and Indexes

2024-11-18 Thread Moreno Andreo
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: SE