At 9:26 +0200 9/3/03, Hoeven, Maarten van der wrote:
Hi all,

consider I want to compare one field stored in two tables (the field
being a key in both tables), like

SELECT table1.field FROM table1, table2 WHERE table1.field=table2.field

I have the choice (I'm developping the datamodel right now) to define
this field as an INT(6) or as an VARCHAR(6).

The question is: if I only store numerical values in this field, what
definition (INT or VARCHAR) will be the fastest in the query above? More
general: are INT-fields faster of slower in this kind of comparisons?

INT will be faster.


By the way, INT(6) uses 4 bytes.  The 6 refers to the display width,
and has nothing to do with the storage size.


PS. The reason I'm considering VARCHAR is that it might be possible I need to store characters in the field, in stead of only figures.

In that case, your choice is made for you. You cannot use INT.





Thanks, Maarten The Netherlands -------------------------------------------------------------- Zie ook/see also: http://www.knmi.nl/maildisclaimer.html


--
Paul DuBois, Senior Technical Writer
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

Are you MySQL certified? http://www.mysql.com/certification/


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to