pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Julie Nishimura <juliezain@hotmail.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: default_tablespace in 8.3 postgresql
Date: Wed, 15 May 2019 13:35:44 -0700
Message-ID: <bbefdb39-12fc-c7de-4b28-15a428607a86@aklaver.com> (raw)
In-Reply-To: <BYAPR08MB50141ABB3D3816BDA9D0F583AC090@BYAPR08MB5014.namprd08.prod.outlook.com>
References: <BYAPR08MB50140E0F61E51CAB861B9DEAAC090@BYAPR08MB5014.namprd08.prod.outlook.com>
	<b2823aab-d8f7-e145-2065-aba20bb7a23b@aklaver.com>
	<BYAPR08MB50141ABB3D3816BDA9D0F583AC090@BYAPR08MB5014.namprd08.prod.outlook.com>

On 5/15/19 1:01 PM, Julie Nishimura wrote:
> Adrian, thanks for your reply.
> This is very interesting behavior...
> Those databases have been created long time ago, only some tables in 
> them were created today.
> So, make it more clear: lets say we have 5 user databases, 5 tables in 
> each db, + template0, template1, . I have modified 3 user databases and 
> template1 to use new tablespace. However, since I have modified 
> template1 (and most likely, those databases were copied from it in the 
> past), it changed default_parameter for them as well. Interesting...

I don't have an instance of 8.3 around so I can't test the above. On my 
11 instance I could not get the template1 to change tablespaces.

Can you confirm that template1 actually is set to 'vol4'?

I am with David I am not sure that even if it was changed that it would 
affect objects created in the past.

Using tablepaces is one of those actions where explicit is better then 
implicit. Whenever possible use the TABLESPACE clause to the object 
CREATE/ALTER command to be certain of where the object is going.


> 
> Thanks
> 
> 
> 
> ------------------------------------------------------------------------
> *From:* Adrian Klaver <adrian.klaver@aklaver.com>
> *Sent:* Wednesday, May 15, 2019 12:47 PM
> *To:* Julie Nishimura; pgsql-general@lists.postgresql.org; pgsql-general
> *Subject:* Re: default_tablespace in 8.3 postgresql
> On 5/15/19 12:39 PM, Julie Nishimura wrote:
>> Hello, I have created new tablespace on a new drive yesterday and 
>> modified some of existing databases to use this tablespace as default, 
>> like this:
>> ALTER DATABASE xxx
>> SET default_tablespace = 'vol4';
>> 
>> So, this command did not physically move any existing tables/indices on 
>> the database xxx, but all new objects are currently being created on 
>> this tablespace (this was expected).
>> 
>> Please note, I also altered "template1" database to use new volume, to 
>> ensure all new databases will be created there by default.
>> 
>> ALTER DATABASE template1
>> SET default_tablespace = 'vol4';
>> 
>> However, I have not yet modified postgresql.conf, and our settings for 
>> default_tablespace and temp_tablespaces still set to use "vol3", because 
>> I was planning to leave some of databases out of vol4 (newer 
>> tablespace), since I did NOT altered their default_tablespace, and it 
>> was previously set to vol3.
>> 
>> Today, checking which tables were created where, I noticed, that all new 
>> tables, including tables from those databases which I did not alter to 
>> use new volume as default_tablespace, have been created on new volume 4. 
>> If I select from pg_database, I can see all my user databases have 
>> default_tablespace as vol4 (newer tablespace), even though I did not 
>> modify it. So, my question is, could altering "template1" database 
>> change default tablespace for all existing databases on a server???
> 
> https://www.postgresql.org/docs/8.3/manage-ag-tablespaces.html
> 
> "If a database is created without specifying a tablespace for it, it
> uses the same tablespace as the template database it is copied from."
> 
>> 
>> PS. I could not make a mistake altering all, since I scripted my 
>> commands before, eliminating some of databases, and I do not see it in 
>> my script. Any thoughts?
>> 
>> Thank you
>> 
> 
> 
> -- 
> Adrian Klaver
> adrian.klaver@aklaver.com


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (21+ messages)  latest in thread

Message-ID: <bbefdb39-12fc-c7de-4b28-15a428607a86@aklaver.com>
Permalink:  ../bbefdb39-12fc-c7de-4b28-15a428607a86@aklaver.com/
Also on:    postgresql.org/message-id/bbefdb39-12fc-c7de-4b28-15a428607a86@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, juliezain@hotmail.com
  Subject: Re: default_tablespace in 8.3 postgresql
  In-Reply-To: <bbefdb39-12fc-c7de-4b28-15a428607a86@aklaver.com>
  References: <BYAPR08MB50140E0F61E51CAB861B9DEAAC090@BYAPR08MB5014.namprd08.prod.outlook.com> <b2823aab-d8f7-e145-2065-aba20bb7a23b@aklaver.com> <BYAPR08MB50141ABB3D3816BDA9D0F583AC090@BYAPR08MB5014.namprd08.prod.outlook.com> <bbefdb39-12fc-c7de-4b28-15a428607a86@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox