Home » Performance » MySQL » [solved] Performance using INT/SMALLINT
[solved] Performance using INT/SMALLINT [message #636] Thu, 25 January 2007 04:45 Go to next message
texnoti  is currently offline texnoti
Messages: 3
Registered: January 2007
Location: Stockholm
Junior Member
Hi!
Perhaps this is a question for INTEL or likewise but i figured someone would know.

I nag about using apropriate type for integer (and other). Don't use INT when TINYINT is enaugh. That way storage space is saved.
But last week someone mentioned that what you win in storage is lost in execution.

INT require 4 bytes and SMALLINT 2 bytes. The theory was that it's faster to calculate with 4 bytes than with 1, 2 or 3 bytes and that the processor (?) anyway padds (or truncate) the value to 4 bytes.

Something to do with 32-bit processor and that 32/2=> 16/2=8

Anyone who can explain this?

Rgds
thomas

[Updated on: Thu, 25 January 2007 05:08]


http://www.reklamberget.se
Re: Performance using INT/SMALLINT [message #637 is a reply to message #636 ] Thu, 25 January 2007 04:51 Go to previous messageGo to next message
Peter  is currently offline Peter
Messages: 405
Registered: August 2006
Senior Member
Super Guru
Do not mix storage and computation.

Computation is always done using signed 64bit integer in MySQL (even for 32bit)


Peter Zaitsev, MySQL Performance Expert
MySQL Performance Blog - http://www.mysqlperformanceblog.com
MySQL Consulting http://www.mysqlperformanceblog.com/mysql-consulting/
Re: Performance using INT/SMALLINT [message #638 is a reply to message #637 ] Thu, 25 January 2007 04:58 Go to previous messageGo to next message
texnoti  is currently offline texnoti
Messages: 3
Registered: January 2007
Location: Stockholm
Junior Member
Ok, so computing don't get affected by the fact that i store a value as INT or SMALLINT?


http://www.reklamberget.se
Re: Performance using INT/SMALLINT [message #639 is a reply to message #638 ] Thu, 25 January 2007 05:02 Go to previous messageGo to next message
Peter  is currently offline Peter
Messages: 405
Registered: August 2006
Senior Member
Super Guru
Right. It does not.


Peter Zaitsev, MySQL Performance Expert
MySQL Performance Blog - http://www.mysqlperformanceblog.com
MySQL Consulting http://www.mysqlperformanceblog.com/mysql-consulting/
Re: [solved] Performance using INT/SMALLINT [message #640 is a reply to message #636 ] Thu, 25 January 2007 05:09 Go to previous message
texnoti  is currently offline texnoti
Messages: 3
Registered: January 2007
Location: Stockholm
Junior Member
Thanks!
Btw, great blog and forum!!!!


http://www.reklamberget.se
Previous Topic:Connecting to Mysql with ODBC vs C library
Next Topic:slow query
Goto Forum:
  


Current Time: Fri Jul 10 04:46:20 EDT 2009

Total time taken to generate the page: 0.00520 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.