This project is archived and is in readonly mode.

#432 ✓invalid
Rasmus

mysql adapter with mediumt support

Reported by Rasmus | June 16th, 2008 @ 09:38 PM

First of all: this is my first time ever contributing to an open source project, so please let me know if I've done something wrong.

As of rails 2.1 the mysql adapter of activerecord, is able to use more appropriate data types for integers instead of just the standard INT data type in mysql. However, the MEDIUMINT data type seem to have been left out for some reason. Integer with a length of 5 or 6 should be stored as an mediumt in order to obtain optimal performance from mysql. With this patch, mediumint is now supported.

Also, the lengths have been corrected so that they know fit more appropriately. For instance SMALLINT is now used for integers with length 0-4 instead of 0-3.

I hope this patch is useful. If not, excuse me for my newbie-ism.

-Ras

Comments and changes to this ticket

  • Rasmus

    Rasmus June 18th, 2008 @ 07:20 PM

    • no changes were found...
  • Pratik

    Pratik July 9th, 2008 @ 01:18 PM

    • State changed from “new” to “invalid”
    • Tag set to 2.1, activerecord, enhancement, mysql, patch

    Is this still an issue with Edge rails ? I see mysql_adapter already seems to be having support for medium int.

    Thanks.

  • Rasmus

    Rasmus July 9th, 2008 @ 01:32 PM

    Thank you for your reply.

    Jeremy Kemper added mediumint here:

    http://github.com/rails/rails/co...

    However, I'm personally not sure he has done everything correct.

    Example (taken from jeremy's commit):

    when 1; 'tinyint'

    when 2; 'smallint'

    when 3; 'mediumint'

    For instance, doesn't this mean that rails will choose mediumint as data type for storing integers with a length of 3? That should be smallint! Smallint holds (if signed) -32768 to 32767 so it would easy hold an integer with length of 3 and even 4. Using mediumint here just wastes disk space and increase mysql memory consumption without any reason.

    As I understand rails and mysql data types, it should rather be something like:

    when 0..2; 'tinyint'

    when 2..4; 'smallint'

    when 5..6; 'mediumint'

    when 7..9; 'int'

    when 9..20; 'bigint'

    Or am I missing something here?

  • Pratik

    Pratik July 9th, 2008 @ 02:02 PM

    • Assigned user set to “Jeremy Kemper”

    I'm not sure to be honest. But you should probably send an email to rails core mailing list - http://groups.google.com/group/r...

    Thanks.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages