mysql select query : server intensity

Discussion in 'PHP' started by Lordy, Oct 19, 2007.

  1. #1
    how intensive would it be if you were to do a select all querys where it matches a certain criteria, when the database gets to be 300k+?

    would it be easier to select by ID then? if so, how would you do so other than select where id='$id'
     
    Lordy, Oct 19, 2007 IP
  2. tamen

    tamen Peon

    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think it's going to use up a lot of ram if you select all rows.
     
    tamen, Oct 19, 2007 IP
  3. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Your question makes no sense without any context.

    The amount of memory depends on what each row contains. Also, as long as you process each row without storing them all in an array in PHP, there's not a memory issue.

    I have scripts for TopDuels.com that run through millions of records without any issue. Rows are just handled and tossed. I don't store millions of records in memory. I read the row, get the information I need and move on to the next one.

    You should select just the data you need using the WHERE clause to limit the results to match whatever criteria you need. You can also use the LIMIT clause to limit the results to a subset of the all the rows that match your query.

    The dataset is large then find a way to process each row without having to store them all before processing the information.
     
    KalvinB, Oct 19, 2007 IP
    Lordy likes this.
  4. Lordy

    Lordy Peon

    Messages:
    1,643
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #4
    alright thanks @ KalvinB, I got you :p

    If i don't store them, it'll be fine? what if i clean the array when i'm done?
     
    Lordy, Oct 19, 2007 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    ^^ Again, it makes no sense to us unless we know what you're doing with the rows, and what they actually contain.
     
    nico_swd, Oct 19, 2007 IP