Solved

"Error Code : 1037 - Out of memory; restart server and try again" when using order by clause

Posted on 2006-11-19
1
864 Views
Last Modified: 2007-12-19
I've just re-installed mysql and now certain queries cause my app to fail.

Specifically, the query "select distinct * from mytable order by name" causes the following error:

Error Code : 1037 Out of memory; restart server and try again (needed 65528 bytes)

If I remove the "order by" clause then it runs just fine so I'm guessing that the memory issue is a red herring? If not, then how do you determine what an acceptable memory value should be?
0
Comment
Question by:groovyjon
1 Comment
 
LVL 35

Accepted Solution

by:
Raynard7 earned 125 total points
ID: 17975925
Hi,

each thread / connection has a memory limit assigned to it - this is the maximum amount of room for all temp tables and memory tables at any point in time.

If you have this too small then if you need to do a sort - it creates a temporary table and then sorts by it - then there is not enough room to create it in memory.

The size of memory depends on what system you are running, what queries that you are using and the number of simultaneous users.

If you have say 512 MB free normally and you only have 20 users or so then 6MB would do your job, if you had less and many many more users then this would start paging memory on your machine.

I would probably say that 1 MB should be sufficient for most normal purposes.

Additionally it is important to note the memory is not allocated until it is being used by the user - so even if you have three connections at 1MB memory they probably will not take 3MB but probably 1 until the others take more when runnign queries.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL - Restore Database SQL File 5 55
Whether to use true/false, yes/no or 0/1 11 60
Sql query on a varchar that is numeric. 8 38
Complex MySQL Query 2 20
Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question