ORDER BY causing disk space error

Discussion in 'MySQL' started by cesarcesar, Mar 4, 2008.

  1. #1
    The following query is causing a mysql error The Error number is 28, which means low disk space. So I clear some space, retry and get the error again after a few times querying. After playing with query i find that the ORDER BY statement is what make it fail. If i remove it the script runs.

    So my question is, is there something about an ORDER BY statement that takes up a lot of disk space? I can sort in PHP, but if MySQL has the ability then i prefer it to sort with.

    Thanks for all the suggestions.

     
    cesarcesar, Mar 4, 2008 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    How big is the database? Also, have you adjusted sort_buffer_size? That controls how much memory is used for sorting. If there isn't enough, the server resorts to using swap which is really slow and may not be enough in your case.
     
    jestep, Mar 4, 2008 IP
  3. cesarcesar

    cesarcesar Peon

    Messages:
    188
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Very small new database. 67k
     
    cesarcesar, Mar 4, 2008 IP
  4. bluegrass special

    bluegrass special Peon

    Messages:
    790
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The tmp file is filling up. After the query shuts down the file gets cleaned, so it looks like there is plenty of room. You need to resize this file. More information can be found here.
     
    bluegrass special, Mar 4, 2008 IP
  5. MrGamma

    MrGamma Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    An order by statement requires that keys... unique,primary, index be placed on the columms you wish to sort by otherwise the sort relies on a disk write...

    Try adding this to the start of your queries... EXPLAIN...
     
    MrGamma, Mar 6, 2008 IP