Re: [GENERAL] partitioning / rules - strange behavior

2007-02-07 Thread Tomas Vondra
> I wouldn't call myself a novice, but yes - this surprised me a little. > Now it seems so natural ... I think there should be a clear explanation > / example in the docs about this - I've read the documentation on RULE > sytem several times and as far as I remember. ... and as far as I remember t

Re: [GENERAL] partitioning / rules - strange behavior

2007-02-07 Thread Tomas Vondra
>> But I don't understand why the nextval('sessions_id_seq') is evaluated >> multiple times? Even when I do > > RULE expand like macros, so every expression passed in is simply copied > to each place, leading to multiple evaluations. > > If you've played with the C preprocessor: that has the same

Re: [GENERAL] partitioning / rules - strange behavior

2007-02-07 Thread Martijn van Oosterhout
On Wed, Feb 07, 2007 at 08:09:57PM +0100, Tomas Vondra wrote: > But I don't understand why the nextval('sessions_id_seq') is evaluated > multiple times? Even when I do RULE expand like macros, so every expression passed in is simply copied to each place, leading to multiple evaluations. If you've

Re: [GENERAL] partitioning / rules - strange behavior

2007-02-07 Thread Tomas Vondra
> It's likely to be a problem because of multiple evaluations of volatile > expressions > in the rule rewrite systemshort example: > > CREATE TABLE sessions(id SERIAL PRIMARY KEY, value TEXT);^ > CREATE TABLE sessions_100(CHECK(id BETWEEN 1 AND 100), PRIMARY KEY(id)) > INHERITS(sessions);

Re: [GENERAL] partitioning / rules - strange behavior

2007-02-07 Thread Bernd Helmle
On Tue, 06 Feb 2007 21:28:49 +0100, Tomas Vondra <[EMAIL PROTECTED]> wrote: > > We're using sequence to generate the sessions(id) value, but that should > not be a problem - with the structure / rules everything works fine (the > current value in sessions_id_seq is about 870 so the values ar

Re: [GENERAL] partitioning / rules - strange behavior

2007-02-06 Thread Tomas Vondra
> If there´s only the insert_850 RULE then everything works as expected - > the > insert prints "INSERT 0 0", the row is inserted into the correct partition > which is sessions_850 - I can fetch it using either > > SELECT * FROM sessions WHERE id = currval('sessions_id_seq'); > > or dire

Re: [GENERAL] partitioning / rules - strange behavior

2007-02-05 Thread tv
> Suddenly stops working, or continues doing exactly what it did before? > I'm wondering if you are relying on a cached plan that doesn't include > the new rule. > > regards, tom lane > If there´s only the insert_850 RULE then everything works as expected - the insert pr

Re: [GENERAL] partitioning / rules - strange behavior

2007-02-04 Thread Tom Lane
Tomas Vondra <[EMAIL PROTECTED]> writes: > As I already said - it works until I create a rule for the next > partition (not used yet) - then is suddenly stops working. Suddenly stops working, or continues doing exactly what it did before? I'm wondering if you are relying on a cached plan that does

Re: [GENERAL] partitioning / rules - strange behavior

2007-02-04 Thread Tomas Vondra
> Looks to me as though you have forgottent the table inheritance part of the > table partitioning trick. Are you sure that sessions_90 inherit from > the sessions table? Does a direct count from the table referenced by the > rule return a non-zero count? In other words: > > SELECT count(*) FR

Re: [GENERAL] partitioning / rules - strange behavior

2007-02-04 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 > db=> INSERT INTO sessions(... non-pk columns ...) VALUES (... data ...); > INSERT 0 0 > db=> SELECT * FROM sessions WHERE id = currval('sessions_id_seq'); > (0 rows) > > which seems really strange to me. We're using sequence to generate the >

[GENERAL] partitioning / rules - strange behavior

2007-02-04 Thread Tomas Vondra
Hi, we're running PostgreSQL 8.1.4 and I've encountered some strange problems with partitioning / rules, and I really don't know how to fix it. We have a table 'sessions' partitioned along the 'id' column which is a primary key. Each partition holds at most 500.000 rows, i.e. partition 'sessions_