Disclaimer: this is not for optimization, just out of curiosity.
I'm wondering if this:
SET search_path TO myscheme; -- obviously this is done once per connection
SELECT foo, bar FROM table1 WHERE [..clauses..]
is somehow faster / slower than
SELECT foo, bar FROM myscheme.table1 WHERE [..clauses..]
or if there are some other implications that could suggest specifying the schema (or not) in every query.
I've done some (really few) tests and I can't see any difference in terms of speed.
The second one is faster, but barely. SET
is extremely cheap.
Generally, a schema-qualified table name has the potential to be slightly faster, since the query to the system catalog can be more specific. But you won't be able to measure that. It's just irrelevant, performance-wise.
Setting the search_path
does have implications for security and convenience though. It is generally a good idea.
For instance, consider the advice in the manual on "Writing SECURITY DEFINER
Functions Safely".
Are you aware that there are many ways to set the search_path
?