SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2009
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Searching for users email contacts in db

    Hi

    I'm busying building a tool for my site where i get a users email contacts which i then want to match with email addresses of users in my database.

    This is all fine, but my question is that if a user has hundreds of contacts, and im searching through thousands of users, isn't this going to be a very intensive query?
    PHP Code:
    SELECT userid FROM users WHERE email IN (" . implode(",",$contacts) . "
    Should i be doing this some other way or limit the number of users that i search for or is this not a problem? I have set the 'email' field as unique, but should i be doing some other kind of indexing?

    Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,340
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    no, the unique index is sufficient

    do an EXPLAIN on the query to confirm

    by the way, i have more than one email address, and i don't think i am very unique
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2009
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    thanks very much!


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
  •