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 1ffm9t-0001Sv-6A for pgsql-general@arkaria.postgresql.org; Wed, 18 Jul 2018 13:06:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ffm9r-0004DU-J3 for pgsql-general@arkaria.postgresql.org; Wed, 18 Jul 2018 13:06:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ffm9q-0004DN-GV for pgsql-general@lists.postgresql.org; Wed, 18 Jul 2018 13:06:19 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ffm9m-0007D5-8G for pgsql-general@postgresql.org; Wed, 18 Jul 2018 13:06:17 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 910B1302; Wed, 18 Jul 2018 09:06:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 18 Jul 2018 09:06:10 -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=ggRk4WEUQ8jbMfrV2SsuvgZb7Ne9m bzW2ut65jnYVZA=; b=rlIlkMAcQkP18mdd9DZE4MB8kUB/SKDQiME57xM8G5nXh lKAmWVisbF7JsvGPlEjQLrKpv50fz4o2y2fVwioaJgKETvlec5ptiyhIQLaiGXNU InEAf4JZXKFR8NUS5JmmGUBIamWFDTeGFgsBJHo0h5CVhO02yA5dsIhkhhiNubC9 0m3MQa9zzPvKDoa7twVvjEbBvYw5jDjrwFJ+asSha4Goo0I3/sJ6olNFlFdsTTGo j/mmWlRSA9CDhBPXcNUVt/guW/NyR2wbAkchBrhB5blcu3eBSTkjO13I3TwXcHt1 tjLzlj9BY3crPV9xQab/vrdOWJkIaEk5DLVcnMxVQ== 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=ggRk4W EUQ8jbMfrV2SsuvgZb7Ne9mbzW2ut65jnYVZA=; b=tlkvE210nq8pOBI6/HTFwB PkgzjWQH4EOfXAio9VjA4+GnxywkY5TSTuASv+WKQJeqftioofDLDKfSOQy3WelN qanIjTl00uf69J/RHfjugoYHjrNSlyTu7WuStqBejEqQktwX8OzR7XHNGc5cot9/ /0dk0n09sk0NO1F43gQmQYQIJ7LPoVQUMviASsh66KT9xrnSnY2OR1dKKpkCjSmV 9YCfUTyQbbVnjHbU+MIkGC2oH2iKXvaZgdZu3BUuMxbeDL3b3F9unliJp3DOpNvg h0aJXjhWM72FusrYVz+xjefTxLgJflfJ0z4Mw5L0Zl0yNz2JFEYkmR+10rpDVpTw == 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 6BDDE10268; Wed, 18 Jul 2018 09:06:09 -0400 (EDT) Subject: Re: A bit confused about "pgsql_tmp" vs "temp tablespace" To: Thomas Kellerer , pgsql-general@postgresql.org References: From: Adrian Klaver Message-ID: <6b47cf26-1f2d-a076-194c-dbe6c34c3c6d@aklaver.com> Date: Wed, 18 Jul 2018 06:06:08 -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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 07/18/2018 12:53 AM, Thomas Kellerer wrote: > 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. > > Background: we are setting up a new server that has a regular (large) SSD and very fast NVMe SSD (which is too small to hold all tables). > So we would like to put anything that is "temporary" onto the NVMe drive. > > But I'm unsure if that is better done through a symlink for pgsql_tmp or a temp tablespace. > Currently no temporary tables are used (but that might change in the future), so only intermediate results (e.g. CTEs, sorting etc) would wind up there. > > > > > > > > > > -- Adrian Klaver adrian.klaver@aklaver.com