SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    A simple update query that takes several minutes

    Does anyone know why this relatively simply update query takes several minutes? In fact, I don't even let it finish because it takes so long. In theory, this should be updating a single record, that of user ID 110.


    update users set visited = visited -1 where uID in (select uID from logins
    where entryPoint = 'Registration' and uID = 110);
    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,332
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    look at your subquery -- you tell it which uID you want, and then you return that uID

    so you can just use
    Code:
    update users set visited = visited -1 where uID = 110
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I only structured my query that way to test it first. If I had written it wrong, I only wanted it to affect one account, not several thousand. But anyway, shouldn't a query like the one I did be executed very quickly being that only one user was involved? Why did it take several minutes?

    Thanks!
    Convert your dollars into silver coins. www.convert2silver.com

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,332
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by busboy View Post
    Why did it take several minutes?
    no idea

    did you do an EXPLAIN on it?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •