Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ffmxo-0004F5-8b for pgsql-general@arkaria.postgresql.org; Wed, 18 Jul 2018 13:57:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ffmxm-0000kM-OX for pgsql-general@arkaria.postgresql.org; Wed, 18 Jul 2018 13:57:54 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ffmxm-0000kF-DN for pgsql-general@lists.postgresql.org; Wed, 18 Jul 2018 13:57:54 +0000 Received: from mout.kundenserver.de ([212.227.17.10]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ffmxj-0006Ie-9h for pgsql-general@lists.postgresql.org; Wed, 18 Jul 2018 13:57:53 +0000 Received: from [10.8.0.146] ([185.40.248.10]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPSA (Nemesis) id 0MQew1-1fTNon0WWj-00U67D for ; Wed, 18 Jul 2018 15:57:48 +0200 Subject: Re: A bit confused about "pgsql_tmp" vs "temp tablespace" To: pgsql-general@lists.postgresql.org Newsgroups: gmane.comp.db.postgresql.general References: <6b47cf26-1f2d-a076-194c-dbe6c34c3c6d@aklaver.com> From: Thomas Kellerer Message-ID: <9bcde31d-e9c2-c391-746f-913c0403a6e4@gmx.net> Date: Wed, 18 Jul 2018 15:57:47 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: <6b47cf26-1f2d-a076-194c-dbe6c34c3c6d@aklaver.com> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:MCqAkCnVPho7v+B2oRacS62QlnmnL30R8mk0gf7pUruLOvMnNho 1gySEB7ZcjuE0ixScY84j/6C49/JFZeEnIzX9cuG10WLBSMB1GE05IA1K7VVEl4D+9ExDf1 LYuxJYHHSmJcOw2IrBUuno/BcWx+i9FE9BZPgGZoFjSA/Ecf4uQ7CUYCNMn903HZyw6y75e XtVnC9fVc+9AZU7FUDjGQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:yzwzbu4u2tc=:xc8ROB7HOcHJqSuXvfK0jD MeF1OYiWsmF6FqzYUve77igPrFWWvhrY/gFiHPv0HydZrMOfSKU14kaN5GU8JpOubCMvFZR4+ vUjArdZLjD5fcUWfg2JJ5a5aEyud+v+hn6SvXxmo7GUAD/cR+LMHDRx/r6xqZzYl1Daue6u0Q mQBxGk4R5mwuFISj1Qj+6TFOpSLTaHcfQ0UxCoiKBWUGJ+pfZo+t+iRLslVaHREjWa0OtxPCg pf1e9EbC6RfKzIXNRu/JnkzPl8MpRFXX8pMaoKTRbKqqEBehk17NaBjEo/A9jqhyAGErFBPdH q40Vhw68En1BvTaoWa3xdvaY4DXYco3msZJGiG1sKBOTOiGYxMvMtzCChtYHe7TOh+xJkst2M w2dbTuWw/bZX2STSw6MNvCi0dnfuqyPhZ9dbpaivOLZJbwyniDKvOk26EaStJOfQWT/LoWpVo TqKVdOVIhYiuWqJViO8C9HTLsulfi2ArB38kq1H8aIHBkRJ2+WWZNx0aY8+Mf9WBdtI2W++aW DcapNiKFscNjK5rXO3rHW+A67hrz2QK868zOVll3pK1i0Ev9g8bMUGJqD+o9T1efYdz2EQ7t0 37sCkyByAUoD55ml5bMIHkreeAFEi3m+k3O5bc37vhGQg8PVsIOzxwM1SJEIaELV85nefWeoM KPswiMFODV9XE2c2jo6ajPpEJ9KO1pCxl/gjWMkgfWPPByj86x7dWe8i3p5cT5RcdYk/3A848 mUziyc6BakDMABSi List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Adrian Klaver schrieb am 18.07.2018 um 15:06: >> In the chapter "Database File layout" the pgsql_tmp is explained as follows: >> >>     Temporary files (for operations such as sorting more data than can fit in memory) >>     are created within PGDATA/base/pgsql_tmp, or within a pgsql_tmp subdirectory of >>     a tablespace directory >> >> However the documentation for "temp_tablespaces" states: >> >>     Temporary files for purposes such as sorting large data sets are also created >>     in these tablespaces. >> >> >> How do these two things related to each other? >> >> Does this mean that if I do not explicitly create a dedicated "temp tablespace" then the pgsql_tmp subdirectory is used. >> But _if_ I do create a temp tablespace (by creating one, and adding it to temp_tablespaces) then the sorting is done *there*? > > Yes, for those objects that do not have a tablespace specified in their CREATE statement. > >> >> So far I thought that a temp tablespace is only used for temporary tables (and indexes on them) but that paragraph in the >> temp_tablespaces documentation seems to indicate otherwise. > > The Database File Layout section you quoted above says the same > thing. Basically setting temp_tablespaces just overrides where temp > objects and operation files are placed when a tablespace is not > specified in their creation. Thanks. I understand the relation between explicitly CREATEd objects and the temp tablespace(s). But what about the (temp) space needed for e.g. sorting, grouping or intermediate results from CTEs or derived tables? Is that also controlled through the temp_tablespaces?