DBMS like MySQL and hsqldb (the only two I know that can keep and
process tables on the heap) have a CREATE DATABASE case in which the
'database' is specified to reside in memory, that is RAM. For some
data handling cases for which persistence is not important, this is
all you need.

 These types of DBs are very fast and convenient for temporary and
transient 'tables' you don't really need or care to persist, like
session tables for web based applications and temporary tables usually
built in subqueries that might be OK for the next request.

 Some hacks I could think about is running "SELECT * " on the needed
table at the start of the DB engine and periodically and -hope- the
operative system keeps it in the cache, but I have the gut feeling,
having such a feature in the DBMS itslef should be faster.

 After RTFM and googling for this piece of info, I think PostgreSQL
has no such a feature.

 Why not? 

 . Isn't RAM cheap enough nowadays? RAM is indeed so cheap that you
could design diskless combinations of OS + firewall + web servers
entirely running off RAM. Anything needing persistence you will send
to the backend DB then

 . Granted, coding a small Data Structure with the exact functionality
you need will do exactly this "keeping the table's data on the heap".
But why doing this if this is what DBMS have been designed for in the
first place? And also, each custom coded DB functionality will have to
be maintaned.

 Is there any way or at least elegant hack to do this?

 I don't see a technically convincing explanation to what could be a
design decision, could you explain to me the rationale behind it, if
any?

6 Jun 2004 11:02:34 -0700
lbrtchx@hotmail.com (Albretch)
CREATE DATABASE on the heap with PostgreSQL?
Albretch wrote:

>  After RTFM and googling for this piece of info, I think PostgreSQL
> has no such a feature.
> 
>  Why not? 
> 
>  . Isn't RAM cheap enough nowadays? RAM is indeed so cheap that you
> could design diskless combinations of OS + firewall + web servers
> entirely running off RAM. Anything needing persistence you will send
> to the backend DB then
>  . Granted, coding a small Data Structure with the exact functionality
> you need will do exactly this "keeping the table's data on the heap".
> But why doing this if this is what DBMS have been designed for in the
> first place? And also, each custom coded DB functionality will have to
> be maintaned.
> 
>  Is there any way or at least elegant hack to do this?
> 
>  I don't see a technically convincing explanation to what could be a
> design decision, could you explain to me the rationale behind it, if
> any?


If you access a table more frequently then other and you have enough
RAM your OS will mantain that table on RAM, don't you think ?
BTW if you trust on your UPS I'm sure you are able to create a RAM
disk and place that table in RAM.


Regards
Gaetano Mendola





Sun, 06 Jun 2004 20:43:44 +0200
Gaetano Mendola <mendola@bigfoot.com>
Re: CREATE DATABASE on the heap with PostgreSQL?
May Users  forcely assign a table / database / cluster storage in RAM 
purely ?

or a in-directly-way , like  making a RAM-Disk-Device and assign this 
device as a  postgreSQL cluster?

I think this feature will push a lot High-Performance usage ,
any suggestion ?

jihuang

Gaetano Mendola wrote:

> Albretch wrote:
>
>>  After RTFM and googling for this piece of info, I think PostgreSQL
>> has no such a feature.
>>
>>  Why not?
>>  . Isn't RAM cheap enough nowadays? RAM is indeed so cheap that you
>> could design diskless combinations of OS + firewall + web servers
>> entirely running off RAM. Anything needing persistence you will send
>> to the backend DB then
>>  . Granted, coding a small Data Structure with the exact functionality
>> you need will do exactly this "keeping the table's data on the heap".
>> But why doing this if this is what DBMS have been designed for in the
>> first place? And also, each custom coded DB functionality will have to
>> be maintaned.
>>
>>  Is there any way or at least elegant hack to do this?
>>
>>  I don't see a technically convincing explanation to what could be a
>> design decision, could you explain to me the rationale behind it, if
>> any?
>
>
>
> If you access a table more frequently then other and you have enough
> RAM your OS will mantain that table on RAM, don't you think ?
> BTW if you trust on your UPS I'm sure you are able to create a RAM
> disk and place that table in RAM.
>
>
> Regards
> Gaetano Mendola
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend



Mon, 07 Jun 2004 12:22:05 +0800
jihuang <jihuang@iis.sinica.edu.tw>
Re: [HACKERS] CREATE DATABASE on the heap with PostgreSQL?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jihuang wrote:

| May Users  forcely assign a table / database / cluster storage in RAM
| purely ?

NO.

| or a in-directly-way , like  making a RAM-Disk-Device and assign this
| device as a  postgreSQL cluster?

YES.


| I think this feature will push a lot High-Performance usage ,
| any suggestion ?


I don't think you'll obtain this performance increase. You can write your own
script that before postgres start:

1) Create the RAM disk
2) Copy the table in memory
3) Create the link between the old location to the new one


and after stop postgres:


1) copy the table from RAM to DISK





Regards
Gaetano Mendola





-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAxDC07UpzwH2SGd4RAm3KAJ9HFgvTSqXSGCh3Xx2n6+Mfqb7AcQCgzWht
CeFGnUTQrD9AWOTvwdkVr0A=
=evpH
-----END PGP SIGNATURE-----


Mon, 07 Jun 2004 11:09:09 +0200
Gaetano Mendola <mendola@bigfoot.com>
Re: [HACKERS] CREATE DATABASE on the heap with PostgreSQL?
Gaetano Mendola <mendola@bigfoot.com> wrote in message news:<40C365E0.6090905@bigfoot.com>...
> If you access a table more frequently then other and you have enough
> RAM your OS will mantain that table on RAM, don't you think ?
> BTW if you trust on your UPS I'm sure you are able to create a RAM
> disk and place that table in RAM.
> 
> 
> Regards
> Gaetano Mendola

 RAMdisks still need a hard disk drive to operate. I am talking here
about entirely diskless configurations.

 Well, maybe as I suspected there is no technical explanation why this
design decision has been made.

 When I have more time I will run a bechmark to check to which extent
it does make a difference. I mean running the application from RAM and
letting the DBMS know about it instead of letting the OS figure it
out.

7 Jun 2004 03:34:58 -0700
lbrtchx@hotmail.com (Albretch)
Re: CREATE DATABASE on the heap with PostgreSQL?
Hi,

The original poster seemed not to care too much about whether the data 
in this database is persistent. Under that assumption, I wonder if it's 
possible to do the following:

1- start postmaster
2 - create database on RAM disk (will be easy once tablespaces are there)
3 - work with this database
4 - postmaster shuts down / reboot server
5 - start postmaster
6 - create database ...

The question is whether 5/6 will work, as the database will have entries 
in the system catalogs, and since the data of the database has 
disappeared. I.e. postmaster will probably complain mightly on startup.

Perhaps it's possible to first start postmaster in single user mode to 
clean up the system catalogs?

Maarten

Mon, 07 Jun 2004 19:04:03 +0400
Maarten Boekhold <boekhold@emirates.net.ae>
Re: [HACKERS] CREATE DATABASE on the heap with PostgreSQL?
Maarten Boekhold <boekhold@emirates.net.ae> writes:
> The original poster seemed not to care too much about whether the data 
> in this database is persistent. Under that assumption, I wonder if it's 
> possible to do the following:

> 1- start postmaster
> 2 - create database on RAM disk (will be easy once tablespaces are there)
> 3 - work with this database
> 4 - postmaster shuts down / reboot server
> 5 - start postmaster
> 6 - create database ...

> The question is whether 5/6 will work, as the database will have entries 
> in the system catalogs, and since the data of the database has 
> disappeared. I.e. postmaster will probably complain mightly on startup.

You'd probably have to do a manual "DELETE FROM pg_database" to get rid
of the row, but as of right now I don't think there'd be any other
cleanup needed.  The tablespace patch might complicate the picture though.

			regards, tom lane

Mon, 07 Jun 2004 11:50:40 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] CREATE DATABASE on the heap with PostgreSQL? 
Albretch wrote:

>Gaetano Mendola <mendola@bigfoot.com> wrote in message news:<40C365E0.6090905@bigfoot.com>...
>  
>
>>If you access a table more frequently then other and you have enough
>>RAM your OS will mantain that table on RAM, don't you think ?
>>BTW if you trust on your UPS I'm sure you are able to create a RAM
>>disk and place that table in RAM.
>>
>>
>>Regards
>>Gaetano Mendola
>>    
>>
>
> RAMdisks still need a hard disk drive to operate. I am talking here
>about entirely diskless configurations.
>  
>
I asked this question not long after 7.4 debuted.  In general the basic 
answer I got was:

1)  Especially with 7.5 and the ARC, small tables which can be stored 
entirely in RAM and are frequently used will end up being fully cached 
there anyway.  Presumably, complex updates would still cause I/O 
bottlenecks, but read performance should not be any different than for a 
RAM-based table.

2)  Given the upcoming release of ARC, there is no real reason to 
consider having a table reside only in memory (doing so may impact the 
performance of other tables in the database as well).

3)  HEAP tables are not planned.  PostgreSQL is focused on data 
integrity and reliability, and this is a can of worms regarding these 
topics which is best left untouched.

Best Wishes,
Chris Travers
Metatron Technology Consulting

Mon, 07 Jun 2004 17:44:39 -0700
Chris Travers <chris@travelamericas.com>
Re: CREATE DATABASE on the heap with PostgreSQL?