Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcVHY-0001v2-3b for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Aug 2016 10:19:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bcVHX-0004HU-Mi for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Aug 2016 10:19:39 +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 1bcVHX-0004HK-CQ for pgsql-bugs@postgresql.org; Wed, 24 Aug 2016 10:19:39 +0000 Received: from mail.windfish.net ([23.253.200.25]) by magus.postgresql.org with esmtps (TLS1.1:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bcVHT-0002hR-D0 for pgsql-bugs@postgresql.org; Wed, 24 Aug 2016 10:19:38 +0000 Received: by mail.windfish.net (Postfix, from userid 33) id E90E27697E; Wed, 24 Aug 2016 06:19:32 -0400 (EDT) To: Michael Paquier 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="=_80e13fbc24635aa3d67bf65321c4abdb" Date: Wed, 24 Aug 2016 06:19:32 -0400 From: Rick Otten Cc: PostgreSQL mailing lists In-Reply-To: References: <20160818190623.1529.12440@wrigleys.postgresql.org> Message-ID: <763fbff79441cfde6dc68b0ad2877c21@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 --=_80e13fbc24635aa3d67bf65321c4abdb Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Refreshing materialized views can definitely create temporary objects. They even get logged when I turn on logging of temporary objects. On 2016-08-24 03:47, Michael Paquier wrote: > On Fri, Aug 19, 2016 at 4:06 AM, wrote: > >> I've recently observed that if while refreshing a materialized view, temp space is required, it will not use the default temp_tablespaces defined in postgresql.conf. Instead it uses the tablespace where the materialized view lives. If this can't be easily changed to use the default temp tablespaces, it would be good if the documentation were updated to alert materialized view users to this caveat. Refreshing a materialized view may use as much temporary space, or more, than its current size. For example, I have a 100G materialized view. Refreshing it uses almost 300G additional disk while the refresh is running. > > Per the docs: > https://www.postgresql.org/docs/9.6/static/runtime-config-client.html [1] > This variable specifies tablespaces in which to create temporary > objects (temp tables and indexes on temp tables) when a CREATE command > does not explicitly specify a tablespace. Temporary files for purposes > such as sorting large data sets are also created in these tablespaces. > > And as far as I know, there is no concept of temporary object for > matviews, so the documentation is correct IMO, and the behavior you > are seeing expected. Links: ------ [1] https://www.postgresql.org/docs/9.6/static/runtime-config-client.html --=_80e13fbc24635aa3d67bf65321c4abdb Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8

Refreshing materialized views can definitely create temporary objects. &= nbsp;They even get logged when I turn on logging of temporary objects.

 

On 2016-08-24 03:47, Michael Paquier wrote:

On Fri, Aug 19, 2016 at 4:06 AM,  <rotten@windfish.net> wrote:
I've recently observed that if while refreshing a= materialized view, temp space is required, it will not use the default tem= p_tablespaces defined in postgresql.conf. Instead it uses the tablespace wh= ere the materialized view lives. If this can't be easily changed to use the= default temp tablespaces, it would be good if the documentation were updat= ed to alert materialized view users to this caveat. Refreshing a materializ= ed view may use as much temporary space, or more, than its current size. Fo= r example, I have a 100G materialized view. Refreshing it uses almost 300G = additional disk while the refresh is running.
Per the docs:
https://www.postgresql.org/docs/9.6/static/runtime-config-client=
=2Ehtml
This variable specifies tablespaces in which to create temporary
objects (temp tables and indexes on temp tables) when a CREATE command
does not explicitly specify a tablespace. Temporary files for purposes
such as sorting large data sets are also created in these tablespaces.

And as far as I know, there is no concept of temporary object for
matviews, so the documentation is correct IMO, and the behavior you
are seeing expected.

 

--=_80e13fbc24635aa3d67bf65321c4abdb--