Re: IP regex
Michael Stassen <[email protected]>
| Newsgroups | gmane.comp.db.mysql.perl |
|---|---|
| Message-ID | <[email protected]> |
Vladimir V. Kolpakov wrote: > On Sun, Oct 31, 2004 at 11:31:33PM -0500, Jamie McCarthy wrote: > >>[email protected] (Vladimir V. Kolpakov) writes: >> >>>On Sun, Oct 31, 2004 at 02:02:26PM -0500, Michael Stassen wrote: >>> >>>>Then you store an IP using INET_ATON(IP) and retrieve it with >>>>INET_NTOA(ip_column). That takes 4 bytes instead of 8 to 16 >>> >>>It's very common mistake, -- to think integer occupies in >>>databases 4 bytes. Please look DESC on your table, and you can >>>find it takes 11 bytes, because is stored in character form. >> >>You misunderstand the output of DESCRIBE. INT is stored in 4 bytes. >>The "(11)" is the display width, which doesn't really affect anything >>done through the perl interface. > > > It's true,... but only for field data either, -- unless index is not created. > > > --w I don't understand. Are you saying that an INT column will be more than 4 bytes if you take its index into account? Well, yes, but the same will be true for an indexed VARCHAR(15). Furthermore, an index on a VARCHAR(15) will be larger than an index on an INT. Try it. You'll see that an index on an INT column has key_len=5, and an index on a VARCHAR(15) has key_len=16. Together, a VARCHAR(15) column + index is at least twice the size of an INT column + index. Michael -- MySQL Perl Mailing List For list archives: http://lists.mysql.com/perl To unsubscribe: http://lists.mysql.com/[email protected]