Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bceTs-0001Dd-O2 for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Aug 2016 20:09:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bceTs-000532-75 for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Aug 2016 20:09:00 +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.84_2) (envelope-from ) id 1bceTD-0004KO-Qs for pgsql-bugs@postgresql.org; Wed, 24 Aug 2016 20:08:19 +0000 Received: from mail.windfish.net ([2001:4801:7824:104:ca47:84ed:ff10:50ea]) by magus.postgresql.org with esmtps (TLS1.1:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bceT6-0006Kg-A5 for pgsql-bugs@postgresql.org; Wed, 24 Aug 2016 20:08:19 +0000 Received: by mail.windfish.net (Postfix, from userid 33) id B73007697B; Wed, 24 Aug 2016 16:08:09 -0400 (EDT) To: Andrew Gierth Subject: Re: BUG #14290: materialized view refresh doesn't use =?UTF-8?Q?temp=5Ftablespace?= X-PHP-Originating-Script: 33:rcube.php MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_ec96c2eb33050de1181ed5f731deb2c7" Date: Wed, 24 Aug 2016 16:08:09 -0400 From: Rick Otten Cc: pgsql-bugs@postgresql.org In-Reply-To: <87shtu9ewv.fsf@news-spur.riddles.org.uk> References: <20160818190623.1529.12440@wrigleys.postgresql.org> <87shtu9ewv.fsf@news-spur.riddles.org.uk> Message-ID: <0042eb8ad3f665b06c06b5948ca02399@www.windfish.net> X-Sender: rotten@windfish.net User-Agent: Roundcube Webmail/1.0.3 X-Pg-Spam-Score: -2.1 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --=_ec96c2eb33050de1181ed5f731deb2c7 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Is t1 also the tablespace for your materialized view? (It isn't clear from what you've posted below.) In my environment my default tablespace for the database is different than the temp_tablespace. On 2016-08-24 14:58, Andrew Gierth wrote: > "rotten" == rotten writes: rotten> I've recently observed that if while refreshing a materialized rotten> view, temp space is required, it will not use the default rotten> temp_tablespaces defined in postgresql.conf. Instead it uses rotten> the tablespace where the materialized view lives. rotten> This surprised me the other day when my production database ran rotten> out of disk space. I was able to confirm the behavior in my rotten> development environment. rotten> To reproduce: rotten> 1) Set up a temp tablespace. rotten> 2) Configure temp_tablespaces in postgrsql.conf to use that tablespace. rotten> 3) Turn on logging of tablespace names. rotten> 4) Reduce work_mem (so that temp space is more likely to be required). rotten> 5) Bounce the DB, or reload the postgresql.conf rotten> 6) Refresh a fairly large materialized view. rotten> 7) Observe in the logs where the temp tablespace was created. I can't reproduce this. postgres=# show server_version; server_version ---------------- 9.5.4 postgres=# create materialized view mvx1 as select * from generate_series(1,100000); SELECT 100000 postgres=# set temp_tablespaces = 't1'; SET postgres=# set log_temp_files = 0; SET postgres=# set work_mem = '64kB'; SET postgres=# refresh materialized view mvx1; LOG: temporary file: path "pg_tblspc/18002/PG_9.5_201510051/pgsql_tmp/pgsql_tmp91239.1", size 1400000 STATEMENT: refresh materialized view mvx1; REFRESH MATERIALIZED VIEW (this clearly shows that the temp file created by the FunctionScan of generate_series is located in tablespace oid 18002, which happens to be t1) --=_ec96c2eb33050de1181ed5f731deb2c7 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8

Is t1 also the tablespace for your materialized view?  (It isn't cl= ear from what you've posted below.)

In my environment my default tablespace for the database is different th= an the temp_tablespace.

 

On 2016-08-24 14:58, Andrew Gierth wrote:

"rotten" =3D=3D rotten <rotten@windfish.net> writes:
 rotten> I've recently observed that if while refreshing a material=
ized
 rotten> view, temp space is required, it will not use the default
 rotten> temp_tablespaces defined in postgresql.conf.  Instead it uses
 rotten> the tablespace where the materialized view lives.

 rotten> This surprised me the other day when my production database ran
 rotten> out of disk space.  I was able to confirm the behavior in my
 rotten> development environment.

 rotten> To reproduce:
 rotten> 1) Set up a temp tablespace.
 rotten> 2) Configure temp_tablespaces in postgrsql.conf to use that tab=
lespace.
 rotten> 3) Turn on logging of tablespace names.
 rotten> 4) Reduce work_mem (so that temp space is more likely to be req=
uired).
 rotten> 5) Bounce the DB, or reload the postgresql.conf
 rotten> 6) Refresh a fairly large materialized view.
 rotten> 7) Observe in the logs where the temp tablespace was created.

I can't reproduce this.

postgres=3D# show server_version;
 server_version=20
----------------
 9.5.4

postgres=3D# create materialized view mvx1 as select * from generate_series=
(1,100000);
SELECT 100000
postgres=3D# set temp_tablespaces =3D 't1';
SET
postgres=3D# set log_temp_files =3D 0;
SET
postgres=3D# set work_mem =3D '64kB';
SET

postgres=3D# refresh materialized view mvx1;
LOG:  temporary file: path "pg_tblspc/18002/PG_9.5_201510051/pgsql_tmp/pgsq=
l_tmp91239.1", size 1400000
STATEMENT:  refresh materialized view mvx1;
REFRESH MATERIALIZED VIEW

(this clearly shows that the temp file created by the FunctionScan of
generate_series is located in tablespace oid 18002, which happens to be
t1)

 

--=_ec96c2eb33050de1181ed5f731deb2c7--