Forum: Ruby on Rails MySQL client ran out of memory

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Nicholas Van W. (Guest)
on 2006-02-25 06:03
(Received via mailing list)
I'm getting the following error unexpectedly for my rails app. I just
exported the databae from dreamhost and imported it on textdrive for
my rails app.

Mysql::Error: MySQL client ran out of memory: SELECT COUNT(*) FROM
comments WHERE (comments.listing_id = 2666)


Anyone have any suggestions as to what the issue might be?

David M. (Guest)
on 2006-02-25 07:28
(Received via mailing list)
A few ideas:
- how much memory is on the Textdrive machine vs. the Dreamhost
machine?  If it's less, that may be the problem right there
- did you bring your indexes across from Dreamhost to the Textdrive
- are you presenting seriously big wads of data on a single Web page?
- is it consistently happening?  If not, maybe some other user is
doing something at the same time that's causing you grief
- do you have indexes on your tables, and are they indexing the
correct fields?  If not, and you're using a few joins in your SQL
statements, your code may be causing MySQL to load in lots of unwanted
data unnecessarily
- are you doing a big SELECT, maybe across a few joined tables, with
an ORDER BY?  That's a common cause of exhausting memory in most
databases; lots of data has to be held in memory at once, so the ORDER
BY can do its stuff.  Typically you can restructure your SQL statement
to get around this; you might need to resort to manually using
find_by_sql with Rails to do so

You can use EXPLAIN in the MySQL command line client to see how
specific SQL statements work.  That might be a help, if you understand

Good luck

Dave M.
David M. (Guest)
on 2006-02-25 07:31
(Received via mailing list)
Ah, sorry - just noticed in your error message...

Do you have an index on the comments.listing_id field?  If not, you
probably should.  If you do, is it the correct type of index?  For
example, MySQL ideally wants to see different types of indexes for
fields that must be unique vs. fields that may have many records with
the same index value.


Dave M.
Nicholas Van W. (Guest)
on 2006-02-26 00:29
(Received via mailing list)

Textdrive has a 80MB virtual and 48M physical limit for my user account,
I'm hitting that. Now to get that down...

David M. (Guest)
on 2006-02-26 01:15
(Received via mailing list)
I'd look at your indexes - if you've got any big tables, you really
don't want to be doing sequential scans through them if you can avoid


Dave M.
Nicholas Van W. (Guest)
on 2006-02-26 03:11
(Received via mailing list)

But would that effect dispatch.fcgi memory? I would have thought mysql
server memory.

This topic is locked and can not be replied to.