It is more space-efficient to simply store numeric values in a NUMBER
datatype instead of text. Of course, it is not so apparent with short
values like 11 and ?11?...
Four bytes to store it as a character string, but only three bytes needed to
store it as a NUMBER datatype, so that?s 33% ?compression?. If we keep this
up...
Six bytes instead of ten; that is a 66% compression ratio. For numeric
text values, you can count on (N/2)+1 where ?N? is the number of significant
decimal digits. And, you can do a whole lot better when you?re dealing with
lots of zeroes...
on 3/12/04 1:14 PM, Juan Cachito Reyes Pacheco at jreyes@(protected)
wrote:
> Hi, is there a function to compress test
> for example 11 you can compress to K (11th letter).
> to optimize storage in data rarely queried.
>
> Thanks
>
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
> To unsubscribe send email to: oracle-l-request@(protected)
> put 'unsubscribe ' in the subject line.
> --
> Archives are at http://www.freelists.org/archives/oracle-l/
> FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
<HTML >
<HEAD >
<TITLE >Re: Function to compress text, not encrypt </TITLE >
</HEAD >
<BODY >
<FONT FACE= "Arial " > <SPAN STYLE= 'font-size:12.0px ' >Juan Cachito, <BR >
<BR >
It is more space-efficient to simply store numeric values in a NUMBER datatype instead of text. Of course, it is not so apparent with short values like 11 and “11”... <BR >
<BR >
</SPAN > </FONT > <BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Courier " >SQL> select dump(11) from dual; <BR >
<BR >
DUMP(11) <BR >
-- ---- ---- ------ <BR >
Typ=2 Len=2: 193,12 <BR >
<BR >
SQL> select dump( '11 ') from dual; <BR >
<BR >
DUMP( '11 ') <BR >
-- ---- ---- ------ <BR >
Typ=96 Len=2: 49,49 <BR >
</FONT > </SPAN > </BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Arial " > <BR >
They both consume 2 bytes here so that represents 0% compression, but now let’s try numbers with more significant digits: <BR >
<BR >
</FONT > </SPAN > <BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Courier " >SQL> select dump(1111) from dual; <BR >
<BR >
DUMP(1111) <BR >
-- ---- ---- ---- ---- <BR >
Typ=2 Len=3: 194,12,12 <BR >
<BR >
SQL> select dump( '1111 ') from dual; <BR >
<BR >
DUMP( '1111 ') <BR >
-- ---- ---- ---- ---- -- <BR >
Typ=96 Len=4: 49,49,49,49 <BR >
</FONT > </SPAN > </BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Arial " > <BR >
Four bytes to store it as a character string, but only three bytes needed to store it as a NUMBER datatype, so that’s 33% “compression”. If we keep this up... <BR >
<BR >
</FONT > </SPAN > <BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Courier " >SQL> select dump (111111) from dual; <BR >
<BR >
DUMP(111111) <BR >
-- ---- ---- ---- ---- -- <BR >
Typ=2 Len=4: 195,12,12,12 <BR >
<BR >
SQL> select dump( '111111 ') from dual; <BR >
<BR >
DUMP( '111111 ') <BR >
-- ---- ---- ---- ---- ---- --- <BR >
Typ=96 Len=6: 49,49,49,49,49,49 <BR >
</FONT > </SPAN > </BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Arial " > <BR >
Four bytes instead of six — that’s 50% “compression”... <BR >
<BR >
</FONT > </SPAN > <BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Courier " >SQL> select dump(11111111) from dual; <BR >
<BR >
DUMP(11111111) <BR >
-- ---- ---- ---- ---- ----- <BR >
Typ=2 Len=5: 196,12,12,12,12 <BR >
<BR >
SQL> select dump( '11111111 ') from dual; <BR >
<BR >
DUMP( '11111111 ') <BR >
-- ---- ---- ---- ---- ---- ---- ---- <BR >
Typ=96 Len=8: 49,49,49,49,49,49,49,49 <BR >
</FONT > </SPAN > </BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Arial " > <BR >
Five bytes instead of eight; that represents a 60% compression ratio... <BR >
<BR >
</FONT > </SPAN > <BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Courier " >SQL> select dump(1111111111) from dual; <BR >
<BR >
DUMP(1111111111) <BR >
-- ---- ---- ---- ---- ---- --- <BR >
Typ=2 Len=6: 197,12,12,12,12,12 <BR >
<BR >
SQL> select dump( '1111111111 ') from dual; <BR >
<BR >
DUMP( '1111111111 ') <BR >
-- ---- ---- ---- ---- ---- ---- ---- ------ <BR >
Typ=96 Len=10: 49,49,49,49,49,49,49,49,49,49 <BR >
</FONT > </SPAN > </BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Arial " > <BR >
Six bytes instead of ten; that is a 66% compression ratio. For numeric text values, you can count on (N/2)+1 where “N” is the number of significant decimal digits. And, you can do a whole lot better when you’re dealing with lots of zeroes... <BR >
<BR >
</FONT > </SPAN > <BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Courier " >SQL> select dump(10000000000) from dual; <BR >
<BR >
DUMP(10000000000) <BR >
-- ---- ---- ----- <BR >
Typ=2 Len=2: 198,2 <BR >
<BR >
SQL> select dump( '10000000000 ') from dual; <BR >
<BR >
DUMP( '10000000000 ') <BR >
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- <BR >
Typ=96 Len=11: 49,48,48,48,48,48,48,48,48,48,48 <BR >
</FONT > <FONT FACE= "Arial " > <BR >
</FONT > </SPAN > </BLOCKQUOTE > <SPAN STYLE= 'font-size:12.0px ' > <FONT FACE= "Arial " >Hoo-wee! That’s about 450% compression ratio, I think... <BR >
<BR >
Hope this helps... <BR >
<BR >
-Tim <BR >
<BR >
<BR >
on 3/12/04 1:14 PM, Juan Cachito Reyes Pacheco at jreyes@(protected) wrote: <BR >
<BR >
<FONT COLOR= "#000098 " >> Hi, is there a function to compress test <BR >
> for example 11 you can compress to K (11th letter). <BR >
> to optimize storage in data rarely queried. <BR >
> <BR >
> Thanks <BR >
> <BR >
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ <BR >
> Please see the official ORACLE-L FAQ: <a href= "http://www.orafaq.com " >http://www.orafaq.com </a > <BR >
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ <BR >
> To unsubscribe send email to: oracle-l-request@(protected) <BR >
> put 'unsubscribe ' in the subject line. <BR >
> -- <BR >
> Archives are at <a href= "http://www.freelists.org/archives/oracle-l/ " >http://www.freelists.org/archives/oracle-l/ </a > <BR >
> FAQ is at <a href= "http://www.freelists.org/help/fom-serve/cache/1.html " >http://www.freelists.org/help/fom-serve/cache/1.html </a > <BR >
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- <BR >
</FONT > </FONT > </SPAN >
</BODY >
</HTML >