pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedTemporary tablespaces on a RAM disk
15+ messages / 7 participants
[nested] [flat]
* Temporary tablespaces on a RAM disk
@ 2020-03-17 09:49 Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
0 siblings, 3 replies; 15+ messages in thread
From: Daniel Westermann (DWE) @ 2020-03-17 09:49 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Hi,
is someone using temporary tablespaces on a RAM disk ? Any experiences with that?
I did some quick tests and checked the archives but could not find any information that either confirmed it is a bad idea nor the opposite.
Thanks in advance
Daniel
^ permalink raw reply [nested|flat] 15+ messages in thread
* RE: Temporary tablespaces on a RAM disk
@ 2020-03-17 17:05 Kevin Brannen <KBrannen@efji.com>
parent: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2 siblings, 1 reply; 15+ messages in thread
From: Kevin Brannen @ 2020-03-17 17:05 UTC (permalink / raw)
To: pgsql-general
Daniel Westermann wrote:
> is someone using temporary tablespaces on a RAM disk ? Any experiences with that?
> I did some quick tests and checked the archives but could not find any information that either confirmed it is a bad idea nor the opposite.
Well, we point our "stats_temp_directory" to a tmpfs partition, which is probably fairly common (or so I'd guess).
But a full tablespace with tables and everything? That sounds pretty risky for anything other than a place to store
data for transformation or summary of data that could be recreated by restarting a process if the server goes down
in the middle.
I think you'd be better off explaining what your goal is and then people could give you better comments.
HTH,
Kevin
.
This e-mail transmission, and any documents, files or previous e-mail messages attached to it, may contain confidential information. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are hereby notified that any disclosure, distribution, review, copy or use of any of the information contained in or attached to this message is STRICTLY PROHIBITED. If you have received this transmission in error, please immediately notify us by reply e-mail, and destroy the original transmission and its attachments without reading them or saving them to disk. Thank you.
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-17 17:19 David G. Johnston <david.g.johnston@gmail.com>
parent: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2 siblings, 2 replies; 15+ messages in thread
From: David G. Johnston @ 2020-03-17 17:19 UTC (permalink / raw)
To: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Tue, Mar 17, 2020 at 2:49 AM Daniel Westermann (DWE) <
daniel.westermann@dbi-services.com> wrote:
> is someone using temporary tablespaces on a RAM disk ? Any experiences
> with that?
> I did some quick tests and checked the archives but could not find any
> information that either confirmed it is a bad idea nor the opposite.
>
There is a nice big bold warning callout in the documentation that covers
this explicitly.
https://www.postgresql.org/docs/12/manage-ag-tablespaces.html
David J.
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-17 17:59 Ron <ronljohnsonjr@gmail.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
1 sibling, 1 reply; 15+ messages in thread
From: Ron @ 2020-03-17 17:59 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 3/17/20 12:19 PM, David G. Johnston wrote:
> On Tue, Mar 17, 2020 at 2:49 AM Daniel Westermann (DWE)
> <daniel.westermann@dbi-services.com
> <mailto:daniel.westermann@dbi-services.com>> wrote:
>
> is someone using temporary tablespaces on a RAM disk ? Any experiences
> with that?
> I did some quick tests and checked the archives but could not find any
> information that either confirmed it is a bad idea nor the opposite.
>
>
> There is a nice big bold warning callout in the documentation that covers
> this explicitly.
>
> https://www.postgresql.org/docs/12/manage-ag-tablespaces.html
Warning
Placing a tablespace on a temporary file system like a RAM disk risks the
reliability of the entire cluster.
But aren't temporary files removed when you restart Postgres? (I'm assuming
that temp_tablespaces is treated "the same" as data/pgsql_tmp. Is that a
false assumption?)
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-17 19:22 Tom Lane <tgl@sss.pgh.pa.us>
parent: Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 15+ messages in thread
From: Tom Lane @ 2020-03-17 19:22 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
Ron <ronljohnsonjr@gmail.com> writes:
> On 3/17/20 12:19 PM, David G. Johnston wrote:
>> There is a nice big bold warning callout in the documentation that covers
>> this explicitly.
>> https://www.postgresql.org/docs/12/manage-ag-tablespaces.html
>>> Warning
>>> Placing a tablespace on a temporary file system like a RAM disk risks the
>>> reliability of the entire cluster.
> But aren't temporary files removed when you restart Postgres? (I'm assuming
> that temp_tablespaces is treated "the same" as data/pgsql_tmp. Is that a
> false assumption?)
I think the main issue is that there's no mechanism preventing you from
putting regular (non-temp) tables into the "temporary" tablespace.
If you do, crash recovery will get very unhappy when it tries to replay
updates for those tables and they're not there.
There are probably additional issues having to do with the tablespace
directory(s) disappearing. That, you could maybe finesse by having the
postmaster start script re-create any missing directories.
All in all, I wouldn't try it without careful pre-testing of what happens
after the RAM disk gets wiped.
People have asked about this before, so maybe it'd be an idea to make
an explicit concept of a temp tablespace that only accepts temp tables,
and do whatever is needful to make that robust. But I've not heard of
any work towards that.
regards, tom lane
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-17 19:26 Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
1 sibling, 0 replies; 15+ messages in thread
From: Daniel Westermann (DWE) @ 2020-03-17 19:26 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Tue, Mar 17, 2020 at 2:49 AM Daniel Westermann (DWE) <daniel.westermann@dbi-services.com<mailto:daniel.westermann@dbi-services.com>> wrote:
is someone using temporary tablespaces on a RAM disk ? Any experiences with that?
I did some quick tests and checked the archives but could not find any information that either confirmed it is a bad idea nor the opposite.
>There is a nice big bold warning callout in the documentation that covers this explicitly.
>
>https://www.postgresql.org/docs/12/manage-ag-tablespaces.html<https://www.postgresql.org/docs/12/...;
I know, I am talking about temp_tablespaces only, so temporary objects like temporary tables, sorts, .etc.
Regards
Daniel
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-17 19:28 Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
parent: Kevin Brannen <KBrannen@efji.com>
0 siblings, 0 replies; 15+ messages in thread
From: Daniel Westermann (DWE) @ 2020-03-17 19:28 UTC (permalink / raw)
To: Kevin Brannen <KBrannen@efji.com>; pgsql-general
Daniel Westermann wrote:
> is someone using temporary tablespaces on a RAM disk ? Any experiences with that?
> I did some quick tests and checked the archives but could not find any information that either confirmed it is a bad idea nor the opposite.
>Well, we point our "stats_temp_directory" to a tmpfs partition, which is probably fairly common (or so I'd guess).
>But a full tablespace with tables and everything? That sounds pretty risky for anything other than a place to store
>data for transformation or summary of data that could be recreated by restarting a process if the server goes down
>in the middle.
>I think you'd be better off explaining what your goal is and then people could give you better comments.
Thank you for the hint with stats_temp_directory. I am only talking about temp_tablespaces which are supposed for temporary objects only. It is pretty clear not to use that for persistent objects, I know.
Regards
Daniel
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-17 19:33 Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 15+ messages in thread
From: Daniel Westermann (DWE) @ 2020-03-17 19:33 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Ron <ronljohnsonjr@gmail.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Ron <ronljohnsonjr@gmail.com> writes:
> On 3/17/20 12:19 PM, David G. Johnston wrote:
>> There is a nice big bold warning callout in the documentation that covers
>> this explicitly.
>> https://www.postgresql.org/docs/12/manage-ag-tablespaces.html
>>> Warning
>>> Placing a tablespace on a temporary file system like a RAM disk risks the
>>> reliability of the entire cluster.
> But aren't temporary files removed when you restart Postgres? (I'm assuming
> that temp_tablespaces is treated "the same" as data/pgsql_tmp. Is that a
> false assumption?)
>I think the main issue is that there's no mechanism preventing you from
>putting regular (non-temp) tables into the "temporary" tablespace.
>If you do, crash recovery will get very unhappy when it tries to replay
>updates for those tables and they're not there.
Yes, that works and this is why I asked for temp_tablespaces which are supposed to hold temporary objects only, I believe.
>There are probably additional issues having to do with the tablespace
>directory(s) disappearing. That, you could maybe finesse by having the
>postmaster start script re-create any missing directories.
Yes, but the server will start even if the tmpfs is gone, you just need to recreate it, which also can be handled with /etc/fstab for booting.
>All in all, I wouldn't try it without careful pre-testing of what happens
>after the RAM disk gets wiped.
Sure.
>People have asked about this before, so maybe it'd be an idea to make
>an explicit concept of a temp tablespace that only accepts temp tables,
>and do whatever is needful to make that robust. But I've not heard of
>any work towards that.
That's what I thought temp_tablespaces are for ( plus sorts, temporary files getting created by materialized views ... )
Regards
Daniel
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-17 19:41 Tom Lane <tgl@sss.pgh.pa.us>
parent: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
0 siblings, 1 reply; 15+ messages in thread
From: Tom Lane @ 2020-03-17 19:41 UTC (permalink / raw)
To: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>; +Cc: Ron <ronljohnsonjr@gmail.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
"Daniel Westermann (DWE)" <daniel.westermann@dbi-services.com> writes:
>> People have asked about this before, so maybe it'd be an idea to make
>> an explicit concept of a temp tablespace that only accepts temp tables,
>> and do whatever is needful to make that robust. But I've not heard of
>> any work towards that.
> That's what I thought temp_tablespaces are for ( plus sorts, temporary files getting created by materialized views ... )
No ... temp_tablespaces says it's okay to use any of the listed
tablespaces to keep temporary working files in, but it doesn't
say that those tablespaces can *only* be used for that.
The whole business of temp tables (as opposed to those invisible-to-SQL
working files) in such a tablespace is a separate issue, too. I think
that the server would mostly survive having temp-table files disappear
during reboot, but it's not an officially supported or tested scenario.
regards, tom lane
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-17 19:50 Laurenz Albe <laurenz.albe@cybertec.at>
parent: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2 siblings, 1 reply; 15+ messages in thread
From: Laurenz Albe @ 2020-03-17 19:50 UTC (permalink / raw)
To: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Tue, 2020-03-17 at 09:49 +0000, Daniel Westermann (DWE) wrote:
> is someone using temporary tablespaces on a RAM disk ? Any experiences with that?
> I did some quick tests and checked the archives but could not find any information that either confirmed it is a bad idea nor the opposite.
Taking a step back, wouldn't it be better to increase "work_mem"
and "temp_buffers" and set "temp_file_limit", so that temporary
files are avoided whenever possible and temporary tables are cached?
Then essentially you are using the same memory for the same purposes,
but in a supported fashion.
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-17 19:51 Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 15+ messages in thread
From: Daniel Westermann (DWE) @ 2020-03-17 19:51 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Ron <ronljohnsonjr@gmail.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
>"Daniel Westermann (DWE)" <daniel.westermann@dbi-services.com> writes:
>>> People have asked about this before, so maybe it'd be an idea to make
>>> an explicit concept of a temp tablespace that only accepts temp tables,
>>> and do whatever is needful to make that robust. But I've not heard of
>>> any work towards that.
>> That's what I thought temp_tablespaces are for ( plus sorts, temporary files getting created by materialized views ... )
>No ... temp_tablespaces says it's okay to use any of the listed
>tablespaces to keep temporary working files in, but it doesn't
>say that those tablespaces can *only* be used for that.
Ok, understood. For me, at least, it sounds weird to put anything other than real temporary stuff in there.
>The whole business of temp tables (as opposed to those invisible-to-SQL
>working files) in such a tablespace is a separate issue, too. I think
>that the server would mostly survive having temp-table files disappear
>during reboot, but it's not an officially supported or tested scenario.
Thank you, that is what I wanted to know. I works for all the cases I tested, but it is not officially supported.
Regards
Daniel
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-17 19:57 Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
parent: Laurenz Albe <laurenz.albe@cybertec.at>
0 siblings, 1 reply; 15+ messages in thread
From: Daniel Westermann (DWE) @ 2020-03-17 19:57 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Hi Laurenz,
>From: Laurenz Albe <laurenz.albe@cybertec.at>
>Sent: Tuesday, March 17, 2020 20:50
>To: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
>Subject: Re: Temporary tablespaces on a RAM disk
>On Tue, 2020-03-17 at 09:49 +0000, Daniel Westermann (DWE) wrote:
>> is someone using temporary tablespaces on a RAM disk ? Any experiences with that?
>> I did some quick tests and checked the archives but could not find any information that either confirmed it is a bad idea nor the opposite.
>Taking a step back, wouldn't it be better to increase "work_mem"
>and "temp_buffers" and set "temp_file_limit", so that temporary
>files are avoided whenever possible and temporary tables are cached?
I don't think you can avoid that for all cases, especially when working with large data sets. That was one of the reasons for my initial question.
>Then essentially you are using the same memory for the same purposes,
>but in a supported fashion.
Agreed.
Regards
Daniel
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-17 21:05 Laurenz Albe <laurenz.albe@cybertec.at>
parent: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
0 siblings, 1 reply; 15+ messages in thread
From: Laurenz Albe @ 2020-03-17 21:05 UTC (permalink / raw)
To: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Tue, 2020-03-17 at 19:57 +0000, Daniel Westermann (DWE) wrote:
> >> is someone using temporary tablespaces on a RAM disk ? Any experiences with that?
> >> I did some quick tests and checked the archives but could not find any
> >> information that either confirmed it is a bad idea nor the opposite.
>
> >Taking a step back, wouldn't it be better to increase "work_mem"
> >and "temp_buffers" and set "temp_file_limit", so that temporary
> >files are avoided whenever possible and temporary tables are cached?
>
> I don't think you can avoid that for all cases, especially when working
> with large data sets. That was one of the reasons for my initial question.
But with your proposed setup, any query that needs more temp space
than your RAM disk has will fail. I don't think that is good for large
data sets.
Setting "work_mem" and "temp_buffers" high, you can use all the RAM
you have, and if it still is not enough, it spills to disk rather than die.
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-17 22:05 Jerry Sievers <gsievers19@comcast.net>
parent: Laurenz Albe <laurenz.albe@cybertec.at>
0 siblings, 1 reply; 15+ messages in thread
From: Jerry Sievers @ 2020-03-17 22:05 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; +Cc: Daniel Westermann \(DWE\) <daniel.westermann@dbi-services.com>; pgsql-general\@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Laurenz Albe <laurenz.albe@cybertec.at> writes:
> On Tue, 2020-03-17 at 19:57 +0000, Daniel Westermann (DWE) wrote:
>
>> >> is someone using temporary tablespaces on a RAM disk ? Any experiences with that?
>> >> I did some quick tests and checked the archives but could not find any
>> >> information that either confirmed it is a bad idea nor the opposite.
>>
>> >Taking a step back, wouldn't it be better to increase "work_mem"
>> >and "temp_buffers" and set "temp_file_limit", so that temporary
>> >files are avoided whenever possible and temporary tables are cached?
>>
>> I don't think you can avoid that for all cases, especially when working
>> with large data sets. That was one of the reasons for my initial question.
>
> But with your proposed setup, any query that needs more temp space
> than your RAM disk has will fail. I don't think that is good for large
> data sets.
Perhaps not, but disk filling on the same volume as WAL is also a
serious problem in case the process that eventually took the storage to
100% and got an ENoSpace was the WAL write :-)
Er, but any standard 1-tablespace configuration is at risk of that,
generally.
FWIW
>
> Setting "work_mem" and "temp_buffers" high, you can use all the RAM
> you have, and if it still is not enough, it spills to disk rather than die.
>
> Yours,
> Laurenz Albe
>
>
>
>
--
Jerry Sievers
Postgres DBA/Development Consulting
e: postgres.consulting@comcast.net
^ permalink raw reply [nested|flat] 15+ messages in thread
* Re: Temporary tablespaces on a RAM disk
@ 2020-03-18 07:17 Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
parent: Jerry Sievers <gsievers19@comcast.net>
0 siblings, 0 replies; 15+ messages in thread
From: Daniel Westermann (DWE) @ 2020-03-18 07:17 UTC (permalink / raw)
To: Jerry Sievers <gsievers19@comcast.net>; Laurenz Albe <laurenz.albe@cybertec.at>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
>Laurenz Albe <laurenz.albe@cybertec.at> writes:
>> On Tue, 2020-03-17 at 19:57 +0000, Daniel Westermann (DWE) wrote:
>>
>>> >> is someone using temporary tablespaces on a RAM disk ? Any experiences with that?
>>> >> I did some quick tests and checked the archives but could not find any
>>> >> information that either confirmed it is a bad idea nor the opposite.
>>>
>>> >Taking a step back, wouldn't it be better to increase "work_mem"
>>> >and "temp_buffers" and set "temp_file_limit", so that temporary
>>> >files are avoided whenever possible and temporary tables are cached?
>>>
>>> I don't think you can avoid that for all cases, especially when working
>>> with large data sets. That was one of the reasons for my initial question.
>>
>> But with your proposed setup, any query that needs more temp space
>> than your RAM disk has will fail. I don't think that is good for large
>> data sets.
>Perhaps not, but disk filling on the same volume as WAL is also a
>serious problem in case the process that eventually took the storage to
>100% and got an ENoSpace was the WAL write :-)
>Er, but any standard 1-tablespace configuration is at risk of that,
>generally.
Thank you all for your input.
Regards
Daniel
^ permalink raw reply [nested|flat] 15+ messages in thread
end of thread, other threads:[~2020-03-18 07:17 UTC | newest]
Thread overview: 15+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-17 09:49 Temporary tablespaces on a RAM disk Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-03-17 17:05 ` Kevin Brannen <KBrannen@efji.com>
2020-03-17 19:28 ` Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-03-17 17:19 ` David G. Johnston <david.g.johnston@gmail.com>
2020-03-17 17:59 ` Ron <ronljohnsonjr@gmail.com>
2020-03-17 19:22 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-03-17 19:33 ` Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-03-17 19:41 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-03-17 19:51 ` Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-03-17 19:26 ` Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-03-17 19:50 ` Laurenz Albe <laurenz.albe@cybertec.at>
2020-03-17 19:57 ` Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-03-17 21:05 ` Laurenz Albe <laurenz.albe@cybertec.at>
2020-03-17 22:05 ` Jerry Sievers <gsievers19@comcast.net>
2020-03-18 07:17 ` Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
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