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
?