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 1ffn97-0004zf-3O for pgsql-general@arkaria.postgresql.org; Wed, 18 Jul 2018 14:09:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ffn95-0005rc-1Y for pgsql-general@arkaria.postgresql.org; Wed, 18 Jul 2018 14:09:35 +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 1ffn93-0005r9-7t for pgsql-general@lists.postgresql.org; Wed, 18 Jul 2018 14:09:34 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ffn90-0006db-4l for pgsql-general@lists.postgresql.org; Wed, 18 Jul 2018 14:09:31 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 91725436; Wed, 18 Jul 2018 10:09:28 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 18 Jul 2018 10:09:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=cHICoEFU1djaol2tGU6pLrwZkfxdj LRP+VBBxNmUiYQ=; b=H9sJ+l15VJ2uH/nh8bL225XyqGVpO5r0f+bXPeNN/Sfgp XxxusH0O/n53YTrolQST9YsSv4j5rnEVdpDgonOylo9mdJDdBV64dtmtlwFreSq7 /bw9r06Y1WXlqvPABO9pvGmE6OKlNkhDpTe108Xo4jumOpSNbNyojYNtknkqoWz6 1qUAcYfTVqYPrur22wsDrKsCon3/TWlL4Amvv019DZZLjdZKxZ25OZhsu4zOHaoT Qrw93l2UWM4FwKrrpdVtYd0YoqTDppeNyiFK5PJTqFmW1ZPTLdJRu8EZYupaVF4u 6M+IA7pP9EROEAs4KORA1KQ7GhZAAZqBcYekv39iw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=cHICoE FU1djaol2tGU6pLrwZkfxdjLRP+VBBxNmUiYQ=; b=jlJxaE9iCg4Px0GgUDREzN 3UfhG8Bh7nV5+UDUa3IjklW12l0j310zu0bjNwXc9cbdvK7PpPVFqHwS+Yk7xBIl mTOTldZcbpt9pw7LBV5yhxg8Ri7VRN6aPDD8rNGAujXVrMzeES1prSHuvkNSiqOf F/u/jjoZmSX5iX6veDS/SnMpk3XgOreTBDT/alBOYhHgO/rff179B2M6refw00xG cN4GvWIVhLCimJCz+d0ntjK1bYznJYuhZ86cIAqDb80W0kg4dAzzFUGUR3I0kYN3 jn0GPxDv2IbtTZpqbn11bhaZbz4Ja6UhA3qvLnEXS7hkT5draYB02j3/yk5W0C2Q == X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.134.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 7BDB110268; Wed, 18 Jul 2018 10:09:27 -0400 (EDT) Subject: Re: A bit confused about "pgsql_tmp" vs "temp tablespace" To: Thomas Kellerer , pgsql-general@lists.postgresql.org References: <6b47cf26-1f2d-a076-194c-dbe6c34c3c6d@aklaver.com> <9bcde31d-e9c2-c391-746f-913c0403a6e4@gmx.net> From: Adrian Klaver Message-ID: <4cccee55-0106-76e9-feb3-69c0bbca6f2e@aklaver.com> Date: Wed, 18 Jul 2018 07:09:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <9bcde31d-e9c2-c391-746f-913c0403a6e4@gmx.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 07/18/2018 06:57 AM, Thomas Kellerer wrote: > 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? Yes, all setting temp_tablespace from '' to some_tablespace(s) does is redirect the creation of unspecified temp files from the db default_namespace/pgsql_tmp to the named some_tablespace(s)/pgsql_tmp. To verify this create a tablespace and add it to temp_tablespace and then do temp operations and look at the_tablespace/pgsql_tmp/. > > > > > -- Adrian Klaver adrian.klaver@aklaver.com