Proposal for Null Bitmap Optimization(for Trailing NULLs)

Started by Gokulakannan Somasundaramabout 18 years ago22 messages
#1Gokulakannan Somasundaram
gokul007@gmail.com

Hi,
Currently we check for the existence of NULL values in the tuple and we
set the has_null flag. If the has_null flag is present, the tuple will be
storing a null bitmap. What i propose is

a) By modifying the functions, heap_form_tuple and heap_fill_tuple, we can
check whether all the nulls are trailing nulls. If all the nulls are
trailing nulls, then we will not set the has_null flag and we will not have
the null bitmap with the tuple.

b) While selecting the tuple, we will check whether the tuple offset equals
/ exceeds the length of the tuple and then mark the remaining attributes of
the tuple as null. To be exact, we need to modify the slot_deform_tuple in
order to achieve the same.

This may not give huge performance benefits, but as you may know, it will
help is reducing the disk footprint.

Expecting your comments..

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)

#2Gokulakannan Somasundaram
gokul007@gmail.com
In reply to: Gokulakannan Somasundaram (#1)
Re: Proposal for Null Bitmap Optimization(for Trailing NULLs)

We can also implement the same for index tuples.....

On Dec 17, 2007 1:10 PM, Gokulakannan Somasundaram <gokul007@gmail.com>
wrote:

Hi,
Currently we check for the existence of NULL values in the tuple and
we set the has_null flag. If the has_null flag is present, the tuple will be
storing a null bitmap. What i propose is

a) By modifying the functions, heap_form_tuple and heap_fill_tuple, we can
check whether all the nulls are trailing nulls. If all the nulls are
trailing nulls, then we will not set the has_null flag and we will not have
the null bitmap with the tuple.

b) While selecting the tuple, we will check whether the tuple offset
equals / exceeds the length of the tuple and then mark the remaining
attributes of the tuple as null. To be exact, we need to modify the
slot_deform_tuple in order to achieve the same.

This may not give huge performance benefits, but as you may know, it will
help is reducing the disk footprint.

Expecting your comments..

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)

#3Gregory Stark
stark@enterprisedb.com
In reply to: Gokulakannan Somasundaram (#1)
Re: Proposal for Null Bitmap Optimization(for Trailing NULLs)

"Gokulakannan Somasundaram" <gokul007@gmail.com> writes:

a) By modifying the functions, heap_form_tuple and heap_fill_tuple, we can
check whether all the nulls are trailing nulls. If all the nulls are
trailing nulls, then we will not set the has_null flag and we will not have
the null bitmap with the tuple.

I think that would work. The only question is whether it's worth bothering
since we would have to check it on every heap_form_tuple. But I suspect it
might be possible to do it pretty cheaply or perhaps even for free. The extra
complexity would be pretty localized so I don't think that's a big downside.

b) While selecting the tuple, we will check whether the tuple offset equals
/ exceeds the length of the tuple and then mark the remaining attributes of
the tuple as null. To be exact, we need to modify the slot_deform_tuple in
order to achieve the same.

Actually this already works. *_deform_tuple has to be able to deal with tables
to which people have added columns. In that case tuples inserted before the
columns were added will look just as you describe, with trailing columns
missing.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!

#4Simon Riggs
simon@2ndquadrant.com
In reply to: Gokulakannan Somasundaram (#1)
Re: Proposal for Null Bitmap Optimization(for Trailing NULLs)

On Mon, 2007-12-17 at 13:10 +0530, Gokulakannan Somasundaram wrote:

Currently we check for the existence of NULL values in the tuple
and we set the has_null flag. If the has_null flag is present, the
tuple will be storing a null bitmap. What i propose is

Will this work for ALTER TABLE when adding and dropping columns?

Another idea is to store the bitmap from the first nullable column.

Some of these ideas have been discussed before, so I would check the
archives thoroughly. Most everything has if you look closely enough.

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

#5Gokulakannan Somasundaram
gokul007@gmail.com
In reply to: Simon Riggs (#4)
Re: Proposal for Null Bitmap Optimization(for Trailing NULLs)

On Dec 17, 2007 3:28 PM, Simon Riggs <simon@2ndquadrant.com> wrote:

On Mon, 2007-12-17 at 13:10 +0530, Gokulakannan Somasundaram wrote:

Currently we check for the existence of NULL values in the tuple
and we set the has_null flag. If the has_null flag is present, the
tuple will be storing a null bitmap. What i propose is

Will this work for ALTER TABLE when adding and dropping columns?

When we drop columns, it is not at all an issue. When we add columns, by
default they have null values. If we want to set default, postgres allows it
only for new inserts. Can you think of any specific instance.

Another idea is to store the bitmap from the first nullable column.

This is a different idea. I like this. I will think about this also.

Some of these ideas have been discussed before, so I would check the
archives thoroughly. Most everything has if you look closely enough.

I have done a fair amount of search in the archives. But if you remember any
please notify me about it.

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)

#6Gokulakannan Somasundaram
gokul007@gmail.com
In reply to: Gregory Stark (#3)
Re: Proposal for Null Bitmap Optimization(for Trailing NULLs)

Thanks. I agree with you.

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)

#7Andrew Dunstan
andrew@dunslane.net
In reply to: Gregory Stark (#3)
Re: Proposal for Null Bitmap Optimization(for Trailing NULLs)

Gregory Stark wrote:

"Gokulakannan Somasundaram" <gokul007@gmail.com> writes:

a) By modifying the functions, heap_form_tuple and heap_fill_tuple, we can
check whether all the nulls are trailing nulls. If all the nulls are
trailing nulls, then we will not set the has_null flag and we will not have
the null bitmap with the tuple.

I think that would work. The only question is whether it's worth bothering
since we would have to check it on every heap_form_tuple.

This strikes me as such a corner case that it's likely not to be worth it.

If you really want to save space along these lines, one better place to
start might be mutable with column ordering - see
http://archives.postgresql.org/pgsql-hackers/2006-12/msg00983.php . That
would mean that we would be able to move nullable columns physically to
the tail which in turn might help this suggestion have more effect.

cheers

andrew

#8Simon Riggs
simon@2ndquadrant.com
In reply to: Andrew Dunstan (#7)
Re: Proposal for Null Bitmap Optimization(for Trailing NULLs)

On Mon, 2007-12-17 at 08:47 -0500, Andrew Dunstan wrote:

This strikes me as such a corner case that it's likely not to be worth it.

If you really want to save space along these lines, one better place to
start might be mutable with column ordering - see
http://archives.postgresql.org/pgsql-hackers/2006-12/msg00983.php . That
would mean that we would be able to move nullable columns physically to
the tail which in turn might help this suggestion have more effect.

Could be a good idea.

Currently on a 64-bit system we occupy 23 bytes for row header, so any
table with more than 8 columns will cause the null bitmap to overflow
and for us to use another 8 bytes.

OP's idea could avoid that in many cases, so the saving isn't 1 byte it
is fairly frequently going to be an 8 byte saving.

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

#9Gregory Stark
stark@enterprisedb.com
In reply to: Simon Riggs (#8)
Re: Proposal for Null Bitmap Optimization(for TrailingNULLs)

"Simon Riggs" <simon@2ndquadrant.com> writes:

On Mon, 2007-12-17 at 08:47 -0500, Andrew Dunstan wrote:

This strikes me as such a corner case that it's likely not to be worth it.

If you really want to save space along these lines, one better place to
start might be mutable with column ordering - see
http://archives.postgresql.org/pgsql-hackers/2006-12/msg00983.php . That
would mean that we would be able to move nullable columns physically to
the tail which in turn might help this suggestion have more effect.

That would only be one factor in deciding how to arrange columns but you have
to decide what order to store them when you're creating the table. You can't
move them around tuple by tuple. Only when rewriting the whole table would you
be able to move them around.

My first thought on how to arrange the columns would be:

fixed-size not nullable
fixed-size nullable
all variable-sized

With this additional tweak you would want to change that to:

fixed-size not nullable
fixed-size nullable
variable-size not nullable
variable-size nullable

I don't think you would want to store variable-sized not nullable columns
before fixed-sized nullable columns because in the cases where they're not
null you want to be able to use the cached offsets.

There could be some other factors to the decision when it comes to alignment
though. It might be worth putting a nullable column before a not null column
if it lets you fix the alignment and it's rarely actually null.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's PostGIS support!

In reply to: Gregory Stark (#9)
Re: Proposal for Null Bitmap Optimization(for TrailingNULLs)

Hi,
I made the fix and tested it today. It involved some 10-15 lines of code
change. I will mail it tomorrow. Feel free to give suggestions on making the
fix more maintainable.
I have followed Gregory's advice in the fix - Instead of changing the
slot_deform_tuple, i have reduced the number of attributes field of the
HeapTupleHeader(during insertion), so that the trailing nulls are treated
the same as newly added columns. Thanks Gregory.
Regarding arrangement of the columns, my take is to leave it to the user
on the arrangement of the columns. May be we can put some kind of tuning
hint somewhere in our document on the suggestions. I have made the above
statement, without thinking about other advantages, if any.

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)

In reply to: Gokulakannan Somasundaram (#10)
Re: Proposal for Null Bitmap Optimization(for TrailingNULLs)

Hi,
I have currently completed the following
a) If there are only trailing nulls in the heap, no null-bitmap gets stored
b) If there are trailing nulls in addition to nulls inbetween values in the
heap, then the trailing nulls are not added to the null-bitmap. I wouldn't
have done it, but it came almost free of cost
c) If there are only trailing nulls in the index, no null-bitmap gets stored

The index part gave some issues and i hope i have fixed it. i am still
testing it(feeling sleepy :)). So i will post the patch, as soon as i
complete testing.

Thanks,
Gokul.

On Dec 18, 2007 12:05 AM, Gokulakannan Somasundaram <gokul007@gmail.com>
wrote:

Hi,
I made the fix and tested it today. It involved some 10-15 lines of
code change. I will mail it tomorrow. Feel free to give suggestions on
making the fix more maintainable.
I have followed Gregory's advice in the fix - Instead of changing the
slot_deform_tuple, i have reduced the number of attributes field of the
HeapTupleHeader(during insertion), so that the trailing nulls are treated
the same as newly added columns. Thanks Gregory.
Regarding arrangement of the columns, my take is to leave it to the
user on the arrangement of the columns. May be we can put some kind of
tuning hint somewhere in our document on the suggestions. I have made the
above statement, without thinking about other advantages, if any.

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)

#12Tom Lane
tgl@sss.pgh.pa.us
In reply to: Gokulakannan Somasundaram (#11)
Re: Proposal for Null Bitmap Optimization(for TrailingNULLs)

"Gokulakannan Somasundaram" <gokul007@gmail.com> writes:

I have currently completed the following
a) If there are only trailing nulls in the heap, no null-bitmap gets stored
b) If there are trailing nulls in addition to nulls inbetween values in the
heap, then the trailing nulls are not added to the null-bitmap. I wouldn't
have done it, but it came almost free of cost
c) If there are only trailing nulls in the index, no null-bitmap gets stored

The index part gave some issues and i hope i have fixed it.

I doubt you have fixed it; I doubt it's *possible* to fix it without
significant rejiggering of IndexTuple representation. The problem is
that IndexTuple lacks a number-of-fields field, so there is no place
to indicate how many null bitmap bits you have actually stored.
I would suggest forgetting that part and submitting the part that
has some chance of getting accepted.

regards, tom lane

#13Gregory Stark
stark@enterprisedb.com
In reply to: Tom Lane (#12)
Re: Proposal for Null Bitmap Optimization(for TrailingNULLs)

"Tom Lane" <tgl@sss.pgh.pa.us> writes:

"Gokulakannan Somasundaram" <gokul007@gmail.com> writes:

I have currently completed the following
a) If there are only trailing nulls in the heap, no null-bitmap gets stored
b) If there are trailing nulls in addition to nulls inbetween values in the
heap, then the trailing nulls are not added to the null-bitmap. I wouldn't
have done it, but it came almost free of cost
c) If there are only trailing nulls in the index, no null-bitmap gets stored

The index part gave some issues and i hope i have fixed it.

I doubt you have fixed it; I doubt it's *possible* to fix it without
significant rejiggering of IndexTuple representation. The problem is
that IndexTuple lacks a number-of-fields field, so there is no place
to indicate how many null bitmap bits you have actually stored.
I would suggest forgetting that part and submitting the part that
has some chance of getting accepted.

I suspect there's also an awkward case that *does* need to handled when you
insert a tuple which has a null column which you're leaving out of the tuple
but which appears in an index. You would have to make sure that the index
tuple has that datum listed as NULL even though it's entirely missing from the
heap tuple.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's On-Demand Production Tuning

In reply to: Gregory Stark (#13)
1 attachment(s)
Re: [HACKERS] Proposal for Null Bitmap Optimization(for TrailingNULLs)

I have submitted the first working patch for the trailing null optimization.
It currently does the following
a) Doesn't store the null bitmap, if the heap tuple / index tuple contains
only trailing nulls
b) In Heap Tuple, the trailing nulls won't occupy space in the null bitmap.

The General design is like this
a) After checking for trailing nulls, i reduce the number of attributes
field, which gets stored in each heap tuple.
b) For Index, i have changed the Index_form_tuple to store the unaligned
total size in the size mask. While navigating through the index tuple, if
the offset exceeds the unaligned total size stored, then a null is returned

Please review it and provide suggestions.

I doubt you have fixed it; I doubt it's *possible* to fix it without
significant rejiggering of IndexTuple representation. The problem is
that IndexTuple lacks a number-of-fields field, so there is no place
to indicate how many null bitmap bits you have actually stored.

Actually i have made one change to the structure of IndexTupleData. Instead
of storing the Aligned size in the size mask, i have stored the un-aligned
size. I am storing the size before the final MAXALIGN. The interface remains
un-changed. IndexTupleSize does a MAXALIGN before returning the size value.
so the interface remains un-changed. The advantage of storing the
un-aligned size is that we can get both aligned size and un-aligned size(As
you may know). I have created two more macros to return the un-aligned size.

I would suggest forgetting that part and submitting the part that
has some chance of getting accepted.

Actually i want to submit the patch, which is best according to me.

I suspect there's also an awkward case that *does* need to handled when
you
insert a tuple which has a null column which you're leaving out of the
tuple
but which appears in an index. You would have to make sure that the index
tuple has that datum listed as NULL even though it's entirely missing from
the
heap tuple.

Actually this is taken care because of your suggestion. When you add a new

column, it doesn't appear in the heaptuple, but if you create an index on
that column afterwards, the case is handled. There is a field in HeapTuple,
which mentions the number of attributes in the tuple. If we are requesting
for attribute numbers greater than this number, it is returned as null. So
that problem was taken care.

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)

Attachments:

trailing-nulls.patch.gzapplication/x-gzip; name=trailing-nulls.patch.gzDownload
#15Andrew Dunstan
andrew@dunslane.net
In reply to: Gokulakannan Somasundaram (#14)
Re: [HACKERS] Proposal for Null Bitmap Optimization(for TrailingNULLs)

Gokulakannan Somasundaram wrote:

I would suggest forgetting that part and submitting the part that
has some chance of getting accepted.

Actually i want to submit the patch, which is best according to me.

That's not an attitude that is likely to succeed - you need to take
suggestions from Tom very seriously.

Also, please submit patches as context diffs, as set out in the
Developer FAQ, which you should probably read carefully:
http://www.postgresql.org/docs/faqs.FAQ_DEV.html

cheers

andrew

#16Joshua D. Drake
jd@commandprompt.com
In reply to: Andrew Dunstan (#15)
Re: [HACKERS] Proposal for Null Bitmap Optimization(for TrailingNULLs)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 19 Dec 2007 13:46:15 -0500
Andrew Dunstan <andrew@dunslane.net> wrote:

I would suggest forgetting that part and submitting the part
that has some chance of getting accepted.

Actually i want to submit the patch, which is best according to me.

You do need to be able to be able to feel that your work is up to a
standard that you find redeemable. However...

That's not an attitude that is likely to succeed - you need to take
suggestions from Tom very seriously.

Andrew is absolutely correct here. If you do not agree with Tom, you
best prove why. Otherwise your patch will likely be ignored on
submission.

Sincerely,

Joshua D. Drake

- --
The PostgreSQL Company: Since 1997, http://www.commandprompt.com/
Sales/Support: +1.503.667.4564 24x7/Emergency: +1.800.492.2240
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
SELECT 'Training', 'Consulting' FROM vendor WHERE name = 'CMD'

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHaWj9ATb/zqfZUUQRAqsNAJ9k6p0z7rQEcqal0JoKw/ZZG8h5kACfaB9y
xQJ4O+h1xe947O1gnTLEbTU=
=WaSW
-----END PGP SIGNATURE-----

In reply to: Joshua D. Drake (#16)
1 attachment(s)
Re: [HACKERS] Proposal for Null Bitmap Optimization(for TrailingNULLs)

Thanks for the suggestions. I am re-submitting the patch in contextual diff
format.

As far as storage savings are concened, the patch claims whatever is stated.
I checked it by creating a table with 10 columns on a 32 bit machine. i
inserted 100,000 rows with trailing nulls and i observed savings of
400Kbytes.
I did a similar test for index and i found similar space saving.

I have tested regression in both 32 bit system and 64 bit system.

Please go through the patch and provide further suggestions.

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
( www.alliedgroups.com)

Attachments:

trailing_nulls.patch.gzapplication/x-gzip; name=trailing_nulls.patch.gzDownload
#18Decibel!
decibel@decibel.org
In reply to: Gokulakannan Somasundaram (#17)
1 attachment(s)
Re: [HACKERS] Proposal for Null Bitmap Optimization(for TrailingNULLs)

On Dec 20, 2007, at 2:36 AM, Gokulakannan Somasundaram wrote:

I checked it by creating a table with 10 columns on a 32 bit
machine. i inserted 100,000 rows with trailing nulls and i observed
savings of 400Kbytes.

That doesn't really tell us anything... how big was the table
originally? Also, testing on 64 bit would be interesting.
--
Decibel!, aka Jim C. Nasby, Database Architect decibel@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload
In reply to: Decibel! (#18)
Re: [HACKERS] Proposal for Null Bitmap Optimization(for TrailingNULLs)

Hi,
Back from the holiday times. I have tried to present the proof, that the
null bitmap was absent in the table with the trailing nulls.

On Dec 22, 2007 4:43 AM, Decibel! <decibel@decibel.org> wrote:

On Dec 20, 2007, at 2:36 AM, Gokulakannan Somasundaram wrote:

I checked it by creating a table with 10 columns on a 32 bit
machine. i inserted 100,000 rows with trailing nulls and i observed
savings of 400Kbytes.

That doesn't really tell us anything...

As i said that the patch removes the null bitmap, if the tuple has trailing
nulls. Our tuple size without null bitmap is 23 bytes. Currently, as long as
the table has less than 8 columns(with null), the heaptuple header size will
be 24 bytes. But if the tuple has more than 8 columns, then it will occupy 4
more bytes in a 32 bit system and 8 more bytes in a 64 bit system. This
patch attempts to save that extra space, if the tuple has only trailing
nulls

how big was the table
originally?

I think it was 5.5 M and 5.1M before and after applying the patch. But how
is this relevant? The patch saves 4 bytes in a 32 bit system per tuple,
irrespective of the size of the tuple

Also, testing on 64 bit would be interesting.

I tested the patch on 64 bit system also for regression. The saving was 8
bytes per tuple.

I have attempted to provide an explanation. But i don't know whether i have
answered your doubts exactly.
Please revert back, in case you haven't got clarified.

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)

#20Bruce Momjian
bruce@momjian.us
In reply to: Gokulakannan Somasundaram (#1)
Re: Proposal for Null Bitmap Optimization(for Trailing NULLs)

Added to TODO:

* Consider not storing a NULL bitmap on disk if all the NULLs are
trailing

http://archives.postgresql.org/pgsql-hackers/2007-12/msg00624.php
http://archives.postgresql.org/pgsql-patches/2007-12/msg00109.php

Tom's comments are:

What this lacks is some performance testing to measure the cost of the
extra tests in heap_form_tuple. If that can be shown to be negligible
then it's probably worth doing .... though I don't like any part of the
actually submitted patch ;-). All this should need is a bit more logic
in heap_form_tuple and heap_formtuple.

---------------------------------------------------------------------------

Gokulakannan Somasundaram wrote:

Hi,
Currently we check for the existence of NULL values in the tuple and we
set the has_null flag. If the has_null flag is present, the tuple will be
storing a null bitmap. What i propose is

a) By modifying the functions, heap_form_tuple and heap_fill_tuple, we can
check whether all the nulls are trailing nulls. If all the nulls are
trailing nulls, then we will not set the has_null flag and we will not have
the null bitmap with the tuple.

b) While selecting the tuple, we will check whether the tuple offset equals
/ exceeds the length of the tuple and then mark the remaining attributes of
the tuple as null. To be exact, we need to modify the slot_deform_tuple in
order to achieve the same.

This may not give huge performance benefits, but as you may know, it will
help is reducing the disk footprint.

Expecting your comments..

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In reply to: Bruce Momjian (#20)
Re: Proposal for Null Bitmap Optimization(for Trailing NULLs)

I would work on this and try to present the performance test results.
I would also go ahead and examine, whether the logic can be added into
heap_form_tuple by any means.

Thanks,
Gokul.

On Wed, Mar 19, 2008 at 12:11 AM, Bruce Momjian <bruce@momjian.us> wrote:

Show quoted text

Added to TODO:

* Consider not storing a NULL bitmap on disk if all the NULLs are
trailing

http://archives.postgresql.org/pgsql-hackers/2007-12/msg00624.php
http://archives.postgresql.org/pgsql-patches/2007-12/msg00109.php

Tom's comments are:

What this lacks is some performance testing to measure the cost of
the
extra tests in heap_form_tuple. If that can be shown to be
negligible
then it's probably worth doing .... though I don't like any part of
the
actually submitted patch ;-). All this should need is a bit more
logic
in heap_form_tuple and heap_formtuple.

---------------------------------------------------------------------------

Gokulakannan Somasundaram wrote:

Hi,
Currently we check for the existence of NULL values in the tuple and

we

set the has_null flag. If the has_null flag is present, the tuple will

be

storing a null bitmap. What i propose is

a) By modifying the functions, heap_form_tuple and heap_fill_tuple, we

can

check whether all the nulls are trailing nulls. If all the nulls are
trailing nulls, then we will not set the has_null flag and we will not

have

the null bitmap with the tuple.

b) While selecting the tuple, we will check whether the tuple offset

equals

/ exceeds the length of the tuple and then mark the remaining attributes

of

the tuple as null. To be exact, we need to modify the slot_deform_tuple

in

order to achieve the same.

This may not give huge performance benefits, but as you may know, it

will

help is reducing the disk footprint.

Expecting your comments..

--
Thanks,
Gokul.
CertoSQL Project,
Allied Solution Group.
(www.alliedgroups.com)

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

In reply to: Gokulakannan Somasundaram (#21)
1 attachment(s)
Re: Proposal for Null Bitmap Optimization(for Trailing NULLs)

Hi,
As said, i am attaching the performance test results and the same patch
in this thread works with the latest CVS head.
Actually, i am seeing a slight performance improvement with the patch, which
i think might be either because of noise/ lesser pages. i ran it with the
default settings. i have tested only inserts and selects, because that's
where the code change has happened.

Regarding Tom's comments....
As far as the changes are concerned, the patch changes the following
functions
a) heap_fill_tuple
b) nocachegetattr
c) heap_form_tuple
d) index_form_tuple
e) nocache_index_getattr
f) changed the macros index_getattr, IndexTupleSize, IndexTupleDSize
g) Introduced a new macro IndexTupleActualSize

The patch introduces the following changes to the storage of tuples
1) If there are only trailing nulls, it doesn't store the null bitmap
2) If there are non-trailing nulls and trailing nulls, it stores the
null-bitmap only till the last non-null value. so it decreases the storage
requirement of null bitmap. This is expected to have only very few use-cases
3) It doesn't store the null-bitmap for trailing nulls in indexes also

The functions mentioned in d), e), f), g) are required for the functionality
of index null-bitmap handling. I suppose, we can't handle it with only
heap_form_tuple. Please correct me, if i am wrong..

For having the functionality 2), we have to touch the heap_fill_tuple. i
have done the trick, by asking it to use the passed number of attributes,
instead of taking it from tupdesc. Again please advice me on how to
implement this with only heap_form_tuple.

Looking forward for comments/suggestions.....

Thanks,
Gokul.

Attachments:

Trailing null - results.odsapplication/vnd.oasis.opendocument.spreadsheet; name="Trailing null - results.ods"Download
PK��y8�l9�..mimetypeapplication/vnd.oasis.opendocument.spreadsheetPK��y8Configurations2/statusbar/PK��y8'Configurations2/accelerator/current.xmlPKPK��y8Configurations2/floater/PK��y8Configurations2/popupmenu/PK��y8Configurations2/progressbar/PK��y8Configurations2/menubar/PK��y8Configurations2/toolbar/PK��y8Configurations2/images/Bitmaps/PK��y8content.xml�\�r�6��Sh�����!�$;;����I�����V�4�%�$���C��O�#��������D��?GG���7�8B�DH��u���
DX�C�F��/��Z������pH�y���)+�L�O�L����F*X�cIe�����
z<!l��3�{��|F���2{Flr+2UU�5m��k��M�P�IUfMA5���*�TF��C��+�d�4����1V*�9�d2�'-�������d�s��9]��(�
�DD+��k���6&
W�O��&�4Q94X���&�H wuaVd����qT��G����\gq�TZa�Ri�&o��xC~��,fw���qU]���@����9���9��������5�m'����Ay��<�Q0�8��
�\(,��K~��t ������2�(����~0&1^��[�I���L����6nf
8�t�Ch���
I���|#��Q>�I�n�G
5>#�i���7Y��5"�
1�*e�"�*��|��;��lW}�4����D_���1�G�p���|a��OR��96��1�y[1k��\�����8U�H�������}�l
�;WVX�O���4f��9i%6�P�H4��� ��(m�U�$������v���~��m�y/e�k_^�fZ��Lk���k��qM��{;'6���%�`�4+_��cBGc�����h�nr*��EcY&�)���
�������B�+�>���@V�G��9��!N#����Q�`C*�?���I�����^7"a���K6u#��}u��x�T�Y���(,��|�����e
�"2-V�r6v�ba����(�rL�����}����e�I>g��e5�Ne��G�4���p���!�.9#-���H:bE��e�dV�'�X�!EE�y���6A�ez5�l� �=���U
Ri	�������_�R7�%�@���0��\��f�G)��S�RA	��X}�Mn��j�>c�WN1�,�?�F����n	��$������'&���.e!�����Y��>��P�
om(����7���1zt��S!�o����nnT
Ww��[��H�{�����X�m��������r��FI�����=��}����W�������ua�[F���&Mm�mfF�=7�c���8 ���-�v�v��$�C���������:�5~���8��qbg��sjH��R��O%��k�"^��408�l��[�E{�K�jB����N��s�L�q Wz��[��!�ID����_�I��~�{�"�W��5\F���u_�8�T�"�G�����ua�9{R/B�l����6f�f'���g�Vt���w���,������+D�����Q�o�2�J"v��'���1�?eH����oe���v��|R���w�k*���K�I���:�{�X�����%S�!�E�LW6�KS��cj����u{���k��gC:J�]u����]�`������<_5P�e�{W����U���be�w��H�Z<Q!���\�Z�]����J�2E\T9��5��O-_)S)
�K��F?u�h@��g��}��G,BR�pj��H��CF$�7��?��P��������kX�j|���}��;'4"'wP|��]��������WB��"����
�O&��K}�Q!-G�J`�F��(�r�Y
��\�wW{�����3%#V_��v{]���
������\o}�����*��5������������PK���!CPK��y8
styles.xml�Ymo�6��_!(C��%9n������P��`$J&J�I���~GR�%�%Z���R������������?���c!	g[7\��Y�������w����~��iJb�Ix\��)O���e&7�p���m8�Dn����x��j�M�1�����n�mm��j���vt��|���N:�U�X�������GI��{1���EGJ����S�����pX�\d~�^�}s�7�������kg��_cs����4�+�G,fS��e�X���r���N�������g#4�;$f��wK�:�_*�I[7Gj7��[�=����;�������U� ��kZt[�s�����n�]����-�a~Da�������a��C�.����.y���Q��nT���C�KQ���TFw�N�c�5G[�WAu(��z:������0������H�AD���=](D��v���I��O�I����x ������L�x�
����3��
��<��?��Jn�Ve�ST�j�����L��bL�[��"�P|B�����(8�[wy��@e��X���"bz������������uJ.��XV�d�A�K�����{������X�lm��~=���r}�8�}��R|��nc�90���:�������M'���?��TO9aa
g����(�Yh
�ll�����\���CP�c�)��X(Qbw��)�������J_�s�������q���i&xY����"�{����c�l��rX��4��������x6�?0���M�����f�h�_�z�����xPQ��O�S\�����f_w��������u��|"��~'�o:E���(�k{\�X]q����dr ���P���*6����mb8`��`��ZHZ��	f-9�ob�K��~{�����Og�Lb&����1O�R�����W\`���W�})�?1�������",w�����|�7�r�*�y��
���:s(�~8��_���A?H�bY�uq�{�-�����/U�NE��~Lz���������S�����r�9����C�.������A�X�_�!v������T�t���w��\)���`}��[�?U���V��0�!��\<����,�����D7���
a����U`~�@���	0���VD�=^YR���8��Z��UL��?FI�wi{�����U�H6&�y]2Bmij�i���g�����~E�[�0��������V�������T���HXO�	h�i��W�t�v����_K��6��|2�G�S�~���.{���@�G���or���8EmC���O�y�.��b�Gw,���g�p������������FYt[E���/N0D��j�������w+)�o�'�h�n��_*=�]���W!�PK]@�G��PK��y8meta.xml����� ��}
�����6�=R�,��4���8��`�7���
�eG]x���/ ��:�c�V
Jw	�@1��:5���S\���]��G��p����;p4�������(���(��%�}5I��&>(L��P��:w!_���5�is�iUU��N(g3w���g$�	��O��pk��]V�Z�A#J��,I
�(�fq})j��M��[�@��N��ip{Z�����B�Y���u1�70��e�U{!y\eyY�;� �p��������Kz�JQ=���^qjhw����������:h���q����C��,!���z����
�jT�#��d�/HZx0��,�CSu��_&������x����~��C�������T3t�s8
<����4��:�(Ex�m��mX1c���n�l�`v�EB�t�\�r���f�o�W�����PK6��}�PK��y8Thumbnails/thumbnail.png��wTk�pU:�%tA:"��Ti��t�w��KG�^5T��Dz��H�(-�����w�W�~{��������y������y~�<1��KM�JA@@@���n�?V����fC]i����ULC����`z,�`/Ty�(�7�����z�zcT�z|�R&�W���mHGl6���4�����Q/x�wj�L�&.y����������wa�dN��F���4~�o@5��s���z��>��B}�LL�s$Vc��"EM�CMSB��*V��C��cQT-����ee��R���'���*l�����I������D��������J��}�e/�	|zA�}SEV>�4����3�b�9���`7p_�Y5��p67�
C8�s��2S��P6P�����pO�� �����5���V��Kg7��w������2B��T��N��EW.l�c�	}yL$-�;�L*-@�N������t������-�oq�����~m�+��v���*���j��}
D���A>�_�b����l^L4����
����p7�Q����	���Gg
�&(�H�MH���@��*�P���B|X
�p�N��������nr�C��j��
)���BYp�h{l�X���Qq��1�M+�p��:��W	�m�d�(�X�����,�Xn�i�PN��j]X����`��a�\5e8>��'��V}F�y^�k����<��{����������M���������|�������V����/�����g=�`���oqm:����z:��*-��1a�n�p�Z��fCg7A��fE���g	|�i=�����C���c��h����I���g����7r_��U������\�G��@?�������`��,��^�5���z8�����.9�
=]��K��n�4z�sM����H��3��8���#��)�\�1)�I�t�1A����������v4���6��������
����o�C�AO�#i���������>���k�z[��nN����	<�rAI�k��Z��)j��{_��U�G��|������L��O���%�s~�I�����Y1����^����G4j��E3I�R~9%u�MQ#��W]������D�J����^�y8�2�Cg����_@L���c����b%�`+*��w/�?
\SK�e|������0���)*�
SB6��� }#~G{b4.w"��=�,9��V�Q ?�Ops	E���c}l
���K�	X�����p��.:�r�������v�O�B�����U���M�'���6��KT?�r����D�f��+���i���_w�p�,�n���X����hIx�)_���GT�z��e��(V��l[�Z
E������7�\ma�b���$�0<���H���y7���?����j���r:��2���
��&:C5�0�`����]D��wX�2~_��������j�����T8Q����G�S��a�����
����.��
���a��G:e������>��(��q�#]�V��&�r-IL y�vW�����\).���):��G�x��p""���$����������Q�#�<�"-q���B��
B;_GU)0��"Z�bnH�z)t���1r�ofM����8?l�2��[3�G�	M�a����1��u}�$q���Z�JN.`[x6q�lP�S�NR��O��-�j����l����\/�U,������?���$t���-��:^(`�$>�7
��@h-j��l��6 uW)+s����Ql~�<�R���F�	=_���q����		�+"2��^Xv���~_F��eF)cL�mO���i�%
o�����3K�q=���Y+D3|;C���@��������/C����T��-�&��Q����I�����u�����"7�{��D���N�q���m^�^�~L@�)�m����9;'4���dr��`XP^�Q�P.�uZ�n��yV�f=7�;����G�}[���A'��3�.���Z����/��
�?����0���`p�����Q��Foz4�B1�!����"���OL-�i�X��^�]�)R�miA&����-��{v��5�qz�%9P�gJs7�}�2�>�`����7�[����^}��q�4��r�||_��C���2���v����$��P�V����GO_\-J�Q�x���u���
q�������d���s�|_�����F-��%B������KM��F"��YSo�]�o,1�ls�*���|�P�e��L�E��t)���P���/�LI�G���v��+�1��
?A���si�l������x1rx��Iy��*6"2�����P��Fh|>J����>tt6�����R���Yk�.�/�<�+?U�&]�N��mQ�:B��S��T='Y�uUsuF��I7�����>��@�8���	�t�P�O��B���d=��1R��w��
��=M�-������Q���X}�:\#3�,>�����D��f$=-�m���yo���z}s����2�|�N#s�A:�Z�PS����?���za�3�5y#iM����&���k���7��P�K/	5��-���8����x!?���i"���Sg�?�H�!�w?p�}Q�&���I����N�������2�<��*�M��l�=H~���5R0��Y��`�����b�&FT�D���a������F��f[��`�|R��������73w���B+A�zeW�����HY�y+a�##�3��RzL�Q�G�T{�9Y���LX�9��\�`u���j��q���tnt@a`�;W2��]����VLoj���� T1 =m��+e�v�K�-�N�����Y&�\
X��pfx\u$��R��#:����3�l���Fw��-
�����uzc<������:��&D\VD�W� al;�s2���{��}�5\s���m �@����3�3P�����oM�t$��Ln���+��9����4\>����1�MKV���v���$��������8�p����Z�m�)�fv���)���gCx���;����3&����c�Ri��V���n=s��q��Jopw����d��	=
��44�y���4
��{����<
P���"E�J-���mh����r�0�C����������1��������n�JzY.�"���������>���,p�w� �����>8��u�1N���)��N���St�E�O��d@d_��h��l�Ym�k��I��i��pp<�%2����I;��C,8����9�Y�ki����kq�J��9P����;��� �{�(���vR��,������3�o�|����s����=;)����A��������/|����[;�O~���4��P�+G��oQ��62?�\:~2h��cp�]����U&;�&K�|�I�l{vQU����7G8������2]2*Yzti4+�
K�i�k�� �,�������Inx��x���@b������_�����������b
5f��,r��/��k������{[�q=�����I������El�y���j����mb��d��Z��f'�l�������=�.�Q��Mh�����b�o-T�d&kD�X�5�t�U*#�Z�e�n��o�bI��3PX���-,Vi��	XP���o��
���	�<E�������*@,n!�vn�������<S(�<�C��M��������"�p���07Y�P�q��r��6�v�,qy���+]��I�)��#;T�7q�,�Z�0�B�x��T��>�-l��n�+�}�4?���K��������M��b3:�����gao�o<��.5�K@��������������r�o_�	������L(j��l�r�)P���}>c)�_��7���w9E��k:fY�M�O�!���^�t���������RS��Y�/.<���7��e|�4SC�
i����|�ZMc���0��z��{�t�s��l*9����S3�p���_��S���3"���!������4��o&�^����.l�K.Ju�
�ymU���,=�����~an��Q1,���j�����J�!���g����8%�t�5� T������?�]T��*@�ML���[���h��7�?5���7�.rCr���p{���X�7�����PR����/�IW���Q)��A�����k�
_��&��+~I���Q�E��u{R0�e�>�����v�@�?cG�z�3��8]0�tc��4;���$�Z��T����{?[��������Z��� ��v.V��-!�����~���YRv>��);�����e�0_�yi�?7����a�F�O���
��&W�����
�Q���ROu���yV�����<��U��I��S��97�
��Z�L:Q�Mr�v�?�uq�{{���H`�K=�<��$1��X�
� �0f+���e���d�j0
9w�&��6�x���K��,����L������q����'��2��IF�v�e���Q�����z�fe���B]��
�#93i����f9g�\����V���j"�k<��8W��zli�-������7���.�oH�s�4#����Iy�m�� �O�~z�}kdC,U���grz���"��l�����So^�'�_p�nJ��Fp�5�����A��{��T'fZg1����Q�/��������J���c4��?�f5���"����r��M���
���[������Gi���}
��u�"���tw{v�m]�����n�WH������	�>�"�7N�����)A�1�+l/F���f����H��po�}��-�������	h�����B����8����JG�R��|h	��O��4/��p��#�1����!����_%{����������0�a���zu�ml|%j�YB.�2q���������E��^bZ����D���v7�zq8�w��7���7���h�{��rI����U� �w����y������'k{	�~-
?v�f23��t��agR�&����J !+��Y� ���K+a-!�o�����1�PKO���	PK��y8settings.xml���S�@���W0y�T,�A:V[��m};�n��f�.D��{I��1���v|b���f�n�69>y�Xc	BR�=��k
����{������8�:���:`��p����"z:�v��3�m$�J���}��4{s�KZ�=c��o�f�{����iu�]3�M�:�gt���d��)D|6MH���������7k����~������k�O�*�"�4������M�K
�����y/��QI��}#�T+_wR��~��|
y�f��O��E�:�:�;��������Nwk�M��M�]x7k��U����%V�(������J�-`��N�]J#hF��h��%����@Y[��a $��T��+���V�%�w��-�>GA��+��>�������{��N]����CU��M�5���K��#���i���z+�[)vTTv�V�S�)*��;�9�����;�:�.|�
^xv>�@��D���QI��#z���HG�;��,5�V�����!J �wJ��#�:�>���.���FF���f�A`�_P"����.�WA���rD"C�A3����������
������ax��7�Z���DG���:P������"�c�&�J��9�'8"RAv��8Y	�B�o��Y���]x;�JG�,>���+~L]���P~E�|�e�N�<R9^qg!��'(�J���R�]�n_'
� ���2���Y������w������;������>R�?����4	s�CE��]������+Xsk�>�A���	��S��Xm��>[�J_�"�?�pAq��!z�m�����HJ�M����M���d	w���k>d(��0I�:�M������t��v�7�	w���p��#�
��U	?^��W_G���F�?PK�l��yPK��y8META-INF/manifest.xml��Kj�0@�=���V�U1q-��&����f��W��6��X;
H��Fi��[S�0���O����)�k7v�c�^����aa����������N��Z��u`�ZV��z��E�����dZ>T��
�yb<T�j>��`��y�������V4"BO[D������R����)o�
zL��=Kb�D�e�����R����bw�c!x�!�|R!|�cD*w�S�����)�F$���B���;���
Jn��&�F]����r�=��Wo�������s�iv�E����6��mH�i�7�
�������si�����PK�MfBQPK��y8�l9�..mimetypePK��y8TConfigurations2/statusbar/PK��y8'�Configurations2/accelerator/current.xmlPK��y8�Configurations2/floater/PK��y8Configurations2/popupmenu/PK��y8QConfigurations2/progressbar/PK��y8�Configurations2/menubar/PK��y8�Configurations2/toolbar/PK��y8�Configurations2/images/Bitmaps/PK��y8���!C4content.xmlPK��y8]@�G��
6	styles.xmlPK��y86��}��meta.xmlPK��y8O���	�Thumbnails/thumbnail.pngPK��y8�l��y�$settings.xmlPK��y8�MfBQ�(META-INF/manifest.xmlPK�"*