> On Mar 20, 2024, at 09:51, Celia McInnis <celia.mcin...@gmail.com> wrote:
>
> The view is being used in some web query software that multiple people will
> be accessing and the contents of the view depend on what the person is
> querying, so I think that temporary views or tables are a good idea.
There's nothing wrong with temporary views or tables, and the use-case you
describe is a reasonable one. The issue comes up when they have the same name
as a permanent view or table.
It's deterministic which one a query will use. All temporary objects are in
the pseudo-schema `pg_temp` (it's a "pseudo-schema" because it's an alias to
the current session's temporary schema, rather than a schema itself). By
default, pg_temp is absent from search_path, which is treated as if it were the
first entry, so temporary tables and views "mask" the permanent ones. However,
if that temporary object doesn't happen to exist, or if pg_temp is explicitly
moved to a different position in the search path, you could have some
surprising behavior.