Order of execution - Mailing list pgsql-performance

From luis.roberto@siscobra.com.br
Subject Order of execution
Date
Msg-id 1849398212.2153796.1619549557535.JavaMail.zimbra@siscobra.com.br
Whole thread Raw
Responses Re: Order of execution
List pgsql-performance
Hi!

My question is: is it possible to optimize function order execution?

Here's explanation:

I have a bunch of queries that have volatile quals, some more than one. For example:

SELECT *
  FROM clients
 WHERE some_func(client_id)
   AND some_other_func(client_id) 

Now, I know that having volatile function quals is not a good practice, but alas, it is what it is.

In this contrived example, some_func filters about 50% of clients, whereas some_other_func around 5%.

If PostgreSQL would execute them "serially", some_other_func would only run for 50% of the clients, cutting execution
time.What I've seen is that volatile functions execute always.
 

Is the reason this happen because the function can modify the result from the outer query?

Luis R. Weck 



pgsql-performance by date:

Previous
From: Marc Millas
Date:
Subject: Re: Does btrfs on Linux have a negative performance impact for PostgreSQL 13?
Next
From: Jean-Christophe Boggio
Date:
Subject: Re: Order of execution