Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rmzGf-00Az2v-4x for pgsql-general@arkaria.postgresql.org; Wed, 20 Mar 2024 16:58:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rmzGd-006SO4-4w for pgsql-general@arkaria.postgresql.org; Wed, 20 Mar 2024 16:58:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rmzGc-006SNv-Qm for pgsql-general@lists.postgresql.org; Wed, 20 Mar 2024 16:58:19 +0000 Received: from smtp74.ord1d.emailsrvr.com ([184.106.54.74]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rmzGY-005Zwe-6h for pgsql-general@lists.postgresql.org; Wed, 20 Mar 2024 16:58:18 +0000 X-Auth-ID: xof@thebuild.com Received: by smtp18.relay.ord1d.emailsrvr.com (Authenticated sender: xof-AT-thebuild.com) with ESMTPSA id 08D04A0338; Wed, 20 Mar 2024 12:58:11 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: Dropping a temporary view? From: Christophe Pettus In-Reply-To: Date: Wed, 20 Mar 2024 09:57:11 -0700 Cc: Adrian Klaver , Erik Wienhold , "pgsql-generallists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: <5b2ebf67-df3b-4b94-8a27-74d20d28f014@aklaver.com> To: Celia McInnis X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Classification-ID: afa70c99-3bd1-444b-85ca-39071e5be444-1-1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Mar 20, 2024, at 09:51, Celia McInnis = wrote: >=20 > 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.=