Ask Experts Questions for FREE Help !
Ask
    DrJ's Avatar
    DrJ Posts: 1,328, Reputation: 339
    Ultra Member
     
    #1

    Jul 7, 2009, 12:36 PM
    DB timing out?
    When I submit this query, it is just returning a blank white page.

    Code:
    SELECT * FROM `leads`
    WHERE (`id` != "31769629-4a63-83b2-de31-49b3a5e72271"
    OR `id` != "162541ac-8842-86c9-6fa8-49af50d437e6"
    OR `id` != "df61cc92-4af1-6f22-6aa3-4a4a9fd293e6")
    Except it is MUCH bigger... I am trying to pull all IDs from a DB of over 22,000 records EXCEPT about 3000 of them.

    Any ideas how I can do that without the DB timing out like that?
    slapshot_oi's Avatar
    slapshot_oi Posts: 1,537, Reputation: 589
    Ultra Member
     
    #2

    Jul 21, 2009, 08:01 PM

    SELECT *'s pull a lot of data and is slow, especially with MySQL. I wrote a PHP webapp using MSSQL, and working on one now with MySQL, and MySQL is dog slow.

    Anyway, try selecting just one field.

    Or, you could selecting one-third of the table and union that with the two-thirds and final third.
    DrJ's Avatar
    DrJ Posts: 1,328, Reputation: 339
    Ultra Member
     
    #3

    Jul 22, 2009, 08:59 AM

    I thought of trying that.. but I don't know how I would sift out just a third, then grab another third without grabbing any of the same records, then the final third without grab anymore of the same records.

    The only way I know how to do this is using a != and that seams to be what is causing it all to time out.

    The temporary solution I had to do was pull the whole table... then use Excel to find the matching ID#s from another tab and marking the original list. Then sorting and deleting based on that marking.

    With 20,000 records though, it was a pain in my @ss...
    slapshot_oi's Avatar
    slapshot_oi Posts: 1,537, Reputation: 589
    Ultra Member
     
    #4

    Jul 22, 2009, 09:23 AM
    Quote Originally Posted by DrJizzle View Post
    I thought of trying that.. but I dont know how I would sift out just a third, then grab another third without grabbing any of the same records, then the final third without grab anymore of the same records.
    I didn't realize what I posted. I wrote one thing but was thinking another. I guess this would be how to do it, not sure if it'll run but it looks okay.
    [CODE="SQL"]
    SELECT *
    FROM table_a
    WHERE (`id` != "31769629-4a63-83b2-de31-49b3a5e72271"
    OR `id` != "162541ac-8842-86c9-6fa8-49af50d437e6"
    OR `id` != "df61cc92-4af1-6f22-6aa3-4a4a9fd293e6")
    LIMIT 0, (SELECT COUNT(*) * 1/3 FROM table_a)

    UNION

    SELECT *
    FROM table_a
    WHERE (`id` != "31769629-4a63-83b2-de31-49b3a5e72271"
    OR `id` != "162541ac-8842-86c9-6fa8-49af50d437e6"
    OR `id` != "df61cc92-4af1-6f22-6aa3-4a4a9fd293e6")
    LIMIT (SELECT COUNT(*) * 1/3 FROM table_a), (SELECT COUNT(*) * 2/3 FROM table_a)

    UNION

    SELECT *
    FROM table_a
    WHERE (`id` != "31769629-4a63-83b2-de31-49b3a5e72271"
    OR `id` != "162541ac-8842-86c9-6fa8-49af50d437e6"
    OR `id` != "df61cc92-4af1-6f22-6aa3-4a4a9fd293e6")
    LIMIT (SELECT COUNT(*) * 2/3 FROM table_a), (SELECT COUNT(*) FROM table_a)
    [/CODE]
    slapshot_oi's Avatar
    slapshot_oi Posts: 1,537, Reputation: 589
    Ultra Member
     
    #5

    Jul 22, 2009, 12:17 PM

    Wait a second, are you trying to retrieve all records but those three? If that's the case, use AND instead of OR.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Two timing B/F. [ 23 Answers ]

I broke up with my b/f of 1.5 yrs because of DISTANCE 2 months ago.The break up isn't mutual as I only sent an email to him. 3 days after I sent such email, I learned he cheated on me by chatting online with a woman he had a relationship with for 1.5 yrs too because that woman sent an email to me...

Right guy, bad timing? [ 2 Answers ]

I've adored this man as a friend for many years. There has always been a certain chemistry between us, but because he was married I maintained a distant attraction. Recently, I was told that he had filed for divorce. A few weekends ago, several of our mutual friends (who have always observed the...

Is it Really Bad Timing? [ 6 Answers ]

I need some advise from some female bloggers... Recently I've been dating a co-worker who has just ended a 3 1/2 year relationship about 4 months ago. We hit it off great as we have so many Things in common especially our outlook in life. However, when things started to get more serious in...


View more questions Search