Re: [SQL] Problem with large tuples. - Mailing list pgsql-sql

From Dirk Lutzebaeck
Subject Re: [SQL] Problem with large tuples.
Date
Msg-id 14472.32125.181522.797383@ampato.aeccom.com
Whole thread Raw
In response to Problem with large tuples.  (Patrik Kudo <kudo@partitur.se>)
List pgsql-sql
Patrik Kudo writes:> I've noticed that some of my tables with large text tuples have> problem when these exceed some
certainsize. I know about the> 8k tuplesize limit, but it seems the problem appears earlier> than that. This is what
I'vebeen able to recreate:> > CREATE TABLE sizetest (id int, txt text);> INSERT INTO sizetest (id, txt) VALUES (1,
'...');// ... = string of> 4000 chars> vacuum analyze; // <-- works nicely> INSERT INTO sizetest (id, txt) VALUES (2,
'...');// ... = string of> 4100 chars> vacuum analyze;> ERROR:  Tuple is too big: size 8152, max size 8140> > How come
theinsert works while the vacuum fails?
 

It's a bug. You need this patch against 6.5.3:

*** src/backend/commands/vacuum.c.orig    Wed Aug 25 08:01:45 1999
--- src/backend/commands/vacuum.c    Tue Jan  4 12:15:17 2000
***************
*** 2405,2414 ****                     stup = heap_formtuple(sd->rd_att, values, nulls);                      /*
----------------
!                      *    insert the tuple in the relation and get the tuple's oid.                      *
----------------                     */
 
!                     heap_insert(sd, stup);                     pfree(DatumGetPointer(values[3]));
pfree(DatumGetPointer(values[4]));                    pfree(stup);
 
--- 2405,2425 ----                     stup = heap_formtuple(sd->rd_att, values, nulls);                      /*
----------------
!                      *    Watch out for oversize tuple, which can happen if
!                      *    both of the saved data values are long.
!                      *    Our fallback strategy is just to not store the
!                      *    pg_statistic tuple at all in that case.  (We could
!                      *    replace the values by NULLs and still store the
!                      *    numeric stats, but presently selfuncs.c couldn't
!                      *    do anything useful with that case anyway.)                      * ----------------
           */
 
!                     if (MAXALIGN(stup->t_len) <= MaxTupleSize)
!                     {
!                         /* OK to store tuple */
!                         heap_insert(sd, stup);
!                     }
!                      pfree(DatumGetPointer(values[3]));                     pfree(DatumGetPointer(values[4]));
            pfree(stup);
 

After patching you should remove your statistics with
'DELETE FROM pg_statistic'; 

You might also need to patch vio.c. Get it from the latest snapshot...

Go back in the pgsql-bugs archive to read more about this problem. It
was discussed some weeks ago...

Dirk




pgsql-sql by date:

Previous
From: Patrik Kudo
Date:
Subject: Duplicate tuples with unique index
Next
From: Tom Lane
Date:
Subject: Re: [SQL] Duplicate tuples with unique index