From: | André Volpato <andre(dot)volpato(at)ecomtecnologia(dot)com(dot)br> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Faster data type for one-length values |
Date: | 2007-05-23 14:39:11 |
Message-ID: | 4654520F.6080701@ecomtecnologia.com.br |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Tom Lane escreveu:
<blockquote cite="mid20197(dot)1179929832(at)sss(dot)pgh(dot)pa(dot)us" type="cite">
<pre wrap="">=?ISO-8859-1?Q?Andr=E9_Volpato?= <a class="moz-txt-link-rfc2396E" href="mailto:andre(dot)volpato(at)ecomtecnologia(dot)com(dot)br"><andre(dot)volpato(at)ecomtecnologia(dot)com(dot)br></a> writes:
</pre>
<blockquote type="cite">
<pre wrap="">I need to store one-length values like '1', '2', '3' or '4' .
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
<blockquote type="cite">
<pre wrap="">Today, this field is indexed with btree and is of type smallint (int2).
How much performance will be improved if I change it to "char" (1 byte
length) ?
</pre>
</blockquote>
<pre wrap=""><!---->
The improvement will be zero. Because of alignment restrictions, you
don't save any space from making an index entry smaller than 4 bytes.
If you have several such fields adjacent in a table row, making them all
narrower can save space, but it doesn't help for standalone index
entries.
regards, tom lane
</pre>
</blockquote>
<br>
Tom,<br>
<br>
The ammount of space saved seems pretty clear to me. <br>
<br>
What are you saying is that the index behaviour is the same, for all
types smaller than 4 bytes ? For query performance, in a search is
based on that standalone indexed field, would be any difference using :<br>
a. char(1) ; b. int2; c. "char"<br>
<br>
Thanks again !<br>
<br>
<pre class="moz-signature" cols="72">--
[]´s,
André Volpato
ECOM Tecnologia Ltda
<a class="moz-txt-link-abbreviated" href="mailto:andre(dot)volpato(at)ecomtecnologia(dot)com(dot)br">andre(dot)volpato(at)ecomtecnologia(dot)com(dot)br</a>
(41) 3014 2322</pre>
</body>
</html>
Attachment | Content-Type | Size |
---|---|---|
unknown_filename | text/html | 1.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-05-23 14:44:25 | Re: Sequential scan from simple query |
Previous Message | Leif B. Kristensen | 2007-05-23 14:31:48 | Sequential scan from simple query |