Rails 2.1 and mysql's mediumint

Hi there,

Browsing the activerecord-2.1.0 source code I found the following:

        case limit         when 0..3           "smallint(#{limit})"         when 4..8           "int(#{limit})"         when 9..20           "bigint(#{limit})"         else           'int(11)'         end

The mysql adapter of activerecord is now able to use more appropriate data types for integers! Finally! That's awesome!

However, where is the mediumint data type? Numbers with length of 5 and 6 should be stored as a mediumint in order to obtain optimal performance from mysql.

Shouldn't this be fixed somehow? I'm considering applying a patch myself (however, I don't know how yet), but I thought I'd hear you guys out first...

Thanks in advance.

Anyone?

Maybe I should post question somewhere else. If you got an idea to where it would be wise to post please let me know.

Better yet: write a patch. I think you can see what to do :wink:

James

Anyone?

Maybe I should post question somewhere else. If you got an idea to
where it would be wise to post please let me know.

the rubyonrails-core list or the rails-contrib irc channel are good
places for questions about the development of rails itself etc..

Fred

James Herdman wrote:

Better yet: write a patch. I think you can see what to do :wink:

James

On Jun 16, 1:40�pm, Rasmus Nielsen <rails-mailing-l...@andreas-s.net>

Consider it done! :slight_smile: http://rails.lighthouseapp.com/projects/8994/tickets/432-mysql-adapter-with-mediumt-support#ticket-432-1

This is my first open source contribution ever. Woohoo! I wonder if it is any good :slight_smile:

May I ask as to what the advantage is of using mediumint’s to just regular ints? Is it disk space or something more sinister?

Ryan Bigg wrote:

May I ask as to what the advantage is of using mediumint's to just regular ints? Is it disk space or something more sinister?

Mediumtints requires dramatically less disk space. The main advantage is that this allows mysql to hold more rows in memory which boosts performance.

Using the right data types is crucial for larger databases...