On 13-Jul-01 David Bouw wrote:

<snipage ahead>

> 
> Something that I noticed was that you could also add an option to say if a
> Int was unsigned ot signed..
> 
> Does it have any sence to use a signed int on a autoincrement table..?
> E.g. When using a auto-increment correctly you will never need a negative
> number..

I don't think there's ever a reason for a negative id# 
  (who lives in Apt -12; or has driver license -91678 ?).

> Do I need to do an optimize on a table when changing this from signed to
> unsigned..?
>

Wouldn't think so.
 
> 
> An Int is 4 bytes and a Medium Int is 3 bytes.. Can you roughtly say dat a
> Medium Int is 33% faster when doing queries
 

 It "could" be 33% smaller on disk, but not necessarily any faster.

> Do I throw away a lof of speed when grabbing a integer which probably is to
> large for me..?
> 

No, just (possible) disk space.

> What I also noticed is that you can add a 'length' tag to a integer. Why is
> this, why would you want to make the length shorter than
> the
> integer type permits..?
> 

The server pads the field to the length parameter.
This makes for consistent looking displays on interface(s) that don't have
formatting tools:

[ id int(11) ] 

mysql> select * from crossref where id <200;
+--------+-----+
| word   | id  |
+--------+-----+
| foobaz |  12 |
| foobar |   1 |
| foobar |  99 |
| foobar | 187 |
| foofoo |   8 |
+--------+-----+

mysql> select * from crossref where id <20; 
+--------+----+
| word   | id |
+--------+----+
| foobar |  1 |
| foofoo |  8 |
| foobaz | 12 |
+--------+----+

^ ------------^ 
^ -------------^  --- note the differing widths

[now id int(3)] 

mysql> select * from crossref where id <200;
+--------+------+
| word   | id   |
+--------+------+
| foobar |    1 |
| foofoo |    8 |
| foobaz |   12 |
| foobar |   99 |
| foobar |  187 |
+--------+------+

mysql> select * from crossref where id <20; 
+--------+------+
| word   | id   |
+--------+------+
| foobar |    1 |
| foofoo |    8 |
| foobaz |   12 |
+--------+------+

'course your app can do whatever.

Regards,
-- 
Don Read                                       [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to