Re: IPv4 addresses, unsigned integers, space
Re: IPv4 addresses, unsigned integers, space
От:
Bruno Wolff III <bruno@wolff.to>
Дата:
On Tue, Jul 15, 2003 at 12:59:34 +0200, Florian Weimer wrote: > If I switched from signed integers to unsigned integers (and from INET > to "real" IPv4 addresses, consisting of the relevant 32 bits only) I > think I could save about 25% of my table size. > > Does PostgreSQL already implement these data types? I don't think so. > If I succeed in implementing them, would you accept a patch? You can have unsigned integers using a domain with a check constraint.
Re: IPv4 addresses, unsigned integers, space
От:
Bruno Wolff III <bruno@wolff.to>
Дата:
On Tue, Jul 15, 2003 at 22:12:13 +0200, Florian Weimer wrote: > Bruno Wolff III writes: > > >> Does PostgreSQL already implement these data types? I don't think so. > >> If I succeed in implementing them, would you accept a patch? > > > > You can have unsigned integers using a domain with a check constraint. > > They take twice as much storage as necessary. This depends on the range of numbers you need. If you specifically need integers greater than 2^31-1 and don't need any greater than 2^32-1, then that is true. In most cases there won't be a per item space penalty.
Re: IPv4 addresses, unsigned integers, space
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Florian Weimer writes: > If I switched from signed integers to unsigned integers (and from INET > to "real" IPv4 addresses, consisting of the relevant 32 bits only) I > think I could save about 25% of my table size. > Does PostgreSQL already implement these data types? I don't think so. > If I succeed in implementing them, would you accept a patch? I doubt you will find any enthusiasm for a dumbed-down INET type, considering that IPv6 capability will be increasingly necessary in the future. As for unsigned ints, I have no objection to 'em in principle, but in practice we have more than enough problems already deducing the appropriate type for a numeric constant. Unless you've got a super new solution to that set of problems, adding unsigned ints to the numeric hierarchy is going to be unmanageable. regards, tom lane
IPv4 addresses, unsigned integers, space
От:
Florian Weimer <fw@deneb.enyo.de>
Дата:
If I switched from signed integers to unsigned integers (and from INET to "real" IPv4 addresses, consisting of the relevant 32 bits only) I think I could save about 25% of my table size. Does PostgreSQL already implement these data types? I don't think so. If I succeed in implementing them, would you accept a patch?
Re: IPv4 addresses, unsigned integers, space
От:
Florian Weimer <fw@deneb.enyo.de>
Дата:
Jim Crate writes: > on 7/15/03, Florian Weimer wrote: > >>If I switched from signed integers to unsigned integers (and from INET >>to "real" IPv4 addresses, consisting of the relevant 32 bits only) I >>think I could save about 25% of my table size. > > Why do you need unsigned ints to hold IP addresses? This is a misunderstanding. I could use both space-conservative IP addresses and unsigned integers. > What difference does it make if IP addresses with a class A higher > than 127 appear as negative numbers? The mapping does not preserve ordering if not done carefully.
Re: IPv4 addresses, unsigned integers, space
От:
Florian Weimer <fw@deneb.enyo.de>
Дата:
Bruno Wolff III writes: >> Does PostgreSQL already implement these data types? I don't think so. >> If I succeed in implementing them, would you accept a patch? > > You can have unsigned integers using a domain with a check constraint. They take twice as much storage as necessary.
Re: IPv4 addresses, unsigned integers, space
От:
Jim Crate <jcrate@deepskytech.com>
Дата:
on 7/15/03, Florian Weimer wrote: >If I switched from signed integers to unsigned integers (and from INET >to "real" IPv4 addresses, consisting of the relevant 32 bits only) I >think I could save about 25% of my table size. Why do you need unsigned ints to hold IP addresses? Signed ints are also 32 bits wide and hold IPv4 addresses just fine. What difference does it make if IP addresses with a class A higher than 127 appear as negative numbers? Here's a couple of convenience function that convert between integer and dotted notation. These functions work fine with the signed integers we have in PostgreSQL. -- Jim Crate Deep Sky Technologies, Inc.