Re: [HACKERS] RAM-only temporary tables

2008-11-21 Thread Kevin Grittner
Sorry for the late response; I was on vacation. >>> Heikki Linnakangas <[EMAIL PROTECTED]> wrote: > Kevin, what was your original scenario like that led you to investigate > this? We noticed a performance degradation in application code which, within a database transaction, looped through lar

Re: [HACKERS] RAM-only temporary tables

2008-11-11 Thread Heikki Linnakangas
Tom Lane wrote: Heikki Linnakangas <[EMAIL PROTECTED]> writes: Tom Lane wrote: Heikki, would it be reasonable to fix things so that a nonexistent FSM fork is semantically the same as an empty one, and not create FSM until there's actually something to put in it? Possibly, but I'd like to unde

Re: [HACKERS] RAM-only temporary tables

2008-11-11 Thread Heikki Linnakangas
Alvaro Herrera wrote: Heikki Linnakangas wrote: oprofile does suggest that more time is spent in the kernel in CVS HEAD. CVS HEAD: 3738713.9383 no-vmlinux postgres (no symbols) 8.3: 27264 9.3254 no-vmlinux postgres (

Re: [HACKERS] RAM-only temporary tables

2008-11-11 Thread Heikki Linnakangas
Tom Lane wrote: Heikki Linnakangas <[EMAIL PROTECTED]> writes: What's happening is that there is simply so many temporary tables in pg_class that when the new backend tries to clear them with RemoveTempRelations, it runs out of lock space. What happened to the original owner of the tables? I

Re: [HACKERS] RAM-only temporary tables

2008-11-11 Thread Alvaro Herrera
Heikki Linnakangas wrote: > oprofile does suggest that more time is spent in the kernel in CVS HEAD. > CVS HEAD: > > 3738713.9383 no-vmlinux postgres (no > symbols) > 8.3: > > 27264 9.3254 no-vmlinux postgres (no > symbol

Re: [HACKERS] RAM-only temporary tables

2008-11-11 Thread Tom Lane
Heikki Linnakangas <[EMAIL PROTECTED]> writes: > What's happening is that there is simply so many temporary tables in > pg_class that when the new backend tries to clear them with > RemoveTempRelations, it runs out of lock space. What happened to the original owner of the tables? It must have h

Re: [HACKERS] RAM-only temporary tables

2008-11-11 Thread Heikki Linnakangas
Heikki Linnakangas wrote: Tom Lane wrote: Try several thousand temp tables within one transaction. I ran into an interesting problem while doing that. I created a SQL script with 1 CREATE TEMPORARY TABLE statements. After testing with that a few times, I got this: WARNING: out of shar

Re: [HACKERS] RAM-only temporary tables

2008-11-11 Thread Heikki Linnakangas
Tom Lane wrote: Heikki Linnakangas <[EMAIL PROTECTED]> writes: Tom Lane wrote: Heikki, would it be reasonable to fix things so that a nonexistent FSM fork is semantically the same as an empty one, and not create FSM until there's actually something to put in it? Possibly, but I'd like to unde

Re: [HACKERS] RAM-only temporary tables

2008-11-11 Thread Heikki Linnakangas
Heikki Linnakangas wrote: I tried running this: CREATE TEMPORARY TABLE footemp (id int4); DROP TABLE footemp; with pgbench -f, but can't see any meaningful difference between 8.3 and CVS HEAD. Both can do about 300 tpm, or 700-800 with fsync=off. There probably is a measurable difference ther

Re: [HACKERS] RAM-only temporary tables

2008-11-11 Thread Tom Lane
Heikki Linnakangas <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Heikki, would it be reasonable to fix things so that a nonexistent FSM >> fork is semantically the same as an empty one, and not create FSM until >> there's actually something to put in it? > Possibly, but I'd like to understand w

Re: [HACKERS] RAM-only temporary tables

2008-11-11 Thread Heikki Linnakangas
Tom Lane wrote: "Kevin Grittner" <[EMAIL PROTECTED]> writes: That would make the file creation and unlink just under half the load. Worst possible case :-( ... means that we wouldn't get much improvement without addressing both aspects. It strikes me however that this does put some urgency in

Re: [HACKERS] RAM-only temporary tables

2008-11-06 Thread Alvaro Herrera
Kevin Grittner wrote: > Note that the 150 disk writes were for the CREATE and the DROP. Does > that mean that we'd actually shave 84 of 150 writes? Hmm, you'd shave more than 42 but not 84, because index entries are not deleted until a later vacuum. (I'd say about 56 -- 42 plus the 14 heap dele

Re: [HACKERS] RAM-only temporary tables

2008-11-06 Thread Tom Lane
"Kevin Grittner" <[EMAIL PROTECTED]> writes: > That would make the file creation and unlink just under half the load. Worst possible case :-( ... means that we wouldn't get much improvement without addressing both aspects. It strikes me however that this does put some urgency into the question of

Re: [HACKERS] RAM-only temporary tables

2008-11-06 Thread Kevin Grittner
>>> Tom Lane <[EMAIL PROTECTED]> wrote: > it's difficult to tell how much > physical I/O results from the create or unlink syscalls. It might be > interesting to make a test program that just creates 4000 files We use xfs with noatime for our databases. In a fresh subdirectory of such a mount

Re: [HACKERS] RAM-only temporary tables

2008-11-06 Thread Alvaro Herrera
Tom Lane wrote: > One place that I've always wanted to look at was suppressing the > creation of a btree metapage until there's some useful data in the > table. We managed to avoid creating a root page until there's data, > but at the time avoiding the metapage seemed too invasive. (Admittedly,

Re: [HACKERS] RAM-only temporary tables

2008-11-06 Thread Tom Lane
"Kevin Grittner" <[EMAIL PROTECTED]> writes: > Tom Lane <[EMAIL PROTECTED]> wrote: >> I think a large fraction of the writes you're measuring are coming from >> the file create/unlink operations. It would certainly be important to >> identify where the bulk of the cost *really* is before we start

Re: [HACKERS] RAM-only temporary tables

2008-11-06 Thread Kevin Grittner
>>> Tom Lane <[EMAIL PROTECTED]> wrote: > I think a large fraction of the writes you're measuring are coming from > the file create/unlink operations. It would certainly be important to > identify where the bulk of the cost *really* is before we start > expending effort on a solution. Any ideas

Re: [HACKERS] RAM-only temporary tables

2008-11-06 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Right -- I don't expect we can make use of such an idea readily. Not > creating unnecessary pg_attribute entries for system columns is probably > a lot easier to do. I seem to recall having proposed that in the past, and getting shot down on the basis

Re: [HACKERS] RAM-only temporary tables

2008-11-06 Thread Alvaro Herrera
Kevin Grittner wrote: > It sounds like you were counting the 8kB pages pushed from the > PostgreSQL cache to the OS cache, and I was counting the 1kB blocks > pushed from the OS cache to the RAID controller cache. By watching > vmstat results after pushing this to a more-or-less steady state, I >

Re: [HACKERS] RAM-only temporary tables

2008-11-06 Thread Tom Lane
"Kevin Grittner" <[EMAIL PROTECTED]> writes: > Note that the 150 disk writes were for the CREATE and the DROP. Does > that mean that we'd actually shave 84 of 150 writes? It really shouldn't be the case that each system catalog tuple insertion generates a separate write --- especially not for mul

Re: [HACKERS] RAM-only temporary tables

2008-11-06 Thread Kevin Grittner
>>> Alvaro Herrera <[EMAIL PROTECTED]> wrote: > Kevin Grittner wrote: > >> Note that the 150 disk writes were for the CREATE and the DROP. Does >> that mean that we'd actually shave 84 of 150 writes? > > Hmm, you'd shave more than 42 but not 84, because index entries are not > deleted until a l

Re: [HACKERS] RAM-only temporary tables

2008-11-06 Thread Kevin Grittner
>>> Alvaro Herrera <[EMAIL PROTECTED]> wrote: > Kevin Grittner wrote: >> An idea for a possible enhancement to PostgreSQL: allow creation of a >> temporary table without generating any disk I/O. (Creating and >> dropping a three-column temporary table within a database transaction >> currently ge

Re: [HACKERS] RAM-only temporary tables

2008-11-05 Thread Alvaro Herrera
Kevin Grittner wrote: > An idea for a possible enhancement to PostgreSQL: allow creation of a > temporary table without generating any disk I/O. (Creating and > dropping a three-column temporary table within a database transaction > currently generates about 150 disk writes). Most of these are ca

Re: [HACKERS] RAM-only temporary tables

2008-11-05 Thread Matthew T. O'Connor
Kevin Grittner wrote: An idea for a possible enhancement to PostgreSQL: allow creation of a temporary table without generating any disk I/O. (Creating and dropping a three-column temporary table within a database transaction currently generates about 150 disk writes). If some circumstances don

Re: [HACKERS] RAM-only temporary tables

2008-11-05 Thread Alex Hunsaker
On Wed, Nov 5, 2008 at 16:00, Kevin Grittner <[EMAIL PROTECTED]> wrote: > An idea for a possible enhancement to PostgreSQL: allow creation of a > temporary table without generating any disk I/O. (Creating and > dropping a three-column temporary table within a database transaction > currently gener

[HACKERS] RAM-only temporary tables

2008-11-05 Thread Kevin Grittner
An idea for a possible enhancement to PostgreSQL: allow creation of a temporary table without generating any disk I/O. (Creating and dropping a three-column temporary table within a database transaction currently generates about 150 disk writes). If some circumstances don't make it feasible to a