This link has been bookmarked by 30 people . It was first bookmarked on 08 Apr 2008, by Piotr Golabek.
-
17 Aug 10
-
23 Jul 10
-
04 May 09
Rodrigo de OliveiraThis article is about Ruby On Rails and its interaction with MySQL in general.
banco_de_dados mysql programação rails ruby sql from_delicious
-
24 Aug 08
-
This leaves us with the problem of avoiding the star in the "select *" that AR generates. For this as well, there is an option to find(): the find method accepts an option hash as its final parameter, and that option has not only allows for the usual :conditions, :order or :limit options, but also for ":select => [ fieldlist ]".
-
Inside the database, this becomes a table definition with VARCHAR(255) columns of the default character set - in many MySQL installations that is utf8.
-
AR cannot specify the database character set in its "create_database" method. So the default value from charset_server is being used. Make sure that in your server this is set to "latin1" or any other single byte character set - never use utf8 by default. Alternatively, specify each "create_table" with an :option => "engine = innodb charset latin1" or similar to avoid using utf8 as a default
-
You should also specify a :limit clause for each and every string, limiting the length of the string to something useful and avoiding the wasteful VARCHAR(255).
-
RoR really should make all values it uses as primary keys and foreign keys UNSIGNED by default.
-
By default, RoR will also create an id column in memberships, which is useless, and not create a unique constraint or even primary key for ( user_id, class_id) which expresses the fact that each user can only be a member in each class once.
"add_index(:memberships, [:user_id, :class_id], :unique => true)" will create such a compound unique index. -
Since all attributes in AR are always wrapped in accessor methods, it would be easy to keep change flags for all fields and generate minimal UPDATE statements. It would even be possible to forgo the statement completely if nothing has been changed.
-
Apparently Ruby uses InnoDB by default. Apparently Ruby uses transactions a lot. That means that the query cache is of very limited use, because queries inside a transaction cannot use the query cache.
-
If a FOREIGN KEY constraint is defined on a table, any insert, update, or delete that requires the constraint condition to be checked sets shared record-level locks on the records that it looks at to check the constraint. InnoDB also sets these locks in the case where the constraint fails.
-
-
23 Aug 08
-
08 Apr 08
-
07 Jan 08
-
11 Aug 07
-
23 Jul 07
-
22 Jul 07
-
21 Jul 07
-
Nicolas PerriaultThis article is about Ruby On Rails and its interaction with MySQL in general.
mysql rails ruby performance activerecord database optimization clevermarks
-
This article is about Ruby On Rails and its interaction with MySQL in general.
mysql rails ruby performance activerecord database optimization clevermarks
-
20 Jul 07
Mathieu MartinDiscussion of different possible optimizations for Rails sites using MySQL as a back-end
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.