Re: Performance Improvement by reducing WAL for Update Operation

Heikki Linnakangas <hlinnakangas@vmware.com>

From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Andres Freund <andres@2ndquadrant.com>, Robert Haas <robertmhaas@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>, Mike Blackwell <mike.blackwell@rrd.com>, Bruce Momjian <bruce@momjian.us>, Peter Geoghegan <pg@heroku.com>, Claudio Freire <klaussfreire@gmail.com>
Date: 2014-03-03T14:27:05Z
Lists: pgsql-hackers

Attachments

On 02/16/2014 01:51 PM, Amit Kapila wrote:
> On Wed, Feb 5, 2014 at 5:29 PM, Heikki Linnakangas
> <hlinnakangas@vmware.com>  wrote:
>> >I'm pretty sure the overhead of that would be negligible, so we could always
>> >enable it. There are certainly a lot of scenarios where prefix/suffix
>> >detection alone wouldn't help, but so what.
>> >
>> >Attached is a quick patch for that, if you want to test it.
> I have updated the patch to correct few problems, addressed review comments
> by Andres and done some optimizations to improve CPU overhead for worst
> case.

Thanks. I have to agree with Robert though that using the pglz encoding 
when we're just checking for a common prefix/suffix is a pretty crappy 
way of going about it [1].

As the patch stands, it includes the NULL bitmap when checking for a 
common prefix. That's probably not a good idea, because it defeats the 
prefix detection in a the common case that you update a field from NULL 
to not-NULL or vice versa.

Attached is a rewritten version, which does the prefix/suffix tests 
directly in heapam.c, and adds the prefix/suffix lengths directly as 
fields in the WAL record. If you could take one more look at this 
version, to check if I've missed anything.

This ought to be tested with the new logical decoding stuff as it 
modified the WAL update record format which the logical decoding stuff 
also relies, but I don't know anything about that.

[1] 
http://www.postgresql.org/message-id/CA+TgmoZSTdQdKU7DHcLjChvMBrh1_YFOUSE+fuxESEVnc4jEgg@mail.gmail.com

- Heikki

Commits

  1. Flush stderr and stdout in isolation tester.