Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8446253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:52:51+00:00 2026-06-10T09:52:51+00:00

Solution! I did what @pilcrow suggested. Looked for mysql_error_num:1062 (unique email) and returned an

  • 0

Solution!
I did what @pilcrow suggested. Looked for mysql_error_num:1062 (unique email) and returned an error if so.

Description:

I am building an application that requires many different users and possibly companies to sign up via registration forms. I want to make sure that the email entered by the individual is unique as a company might give out a generic info@company.com email to many users.

I want to be able to check against the database to see if email exists.

Problem:

I already know how to accomplish this via Javascript, ajax and PHP but I am afraid that if I have many (thousands) of users, the query is going to take forever. Especially if I decide to use a keypress event instead of a blur event on the form. I might be wrong, but I can’t see a simple WHERE email = $email is very scalable.

Question

Is there a way I can set up my code or the database (mysql) to speed up the query? I was thinking of setting up a separate table just for emails, but don’t think that would work.

Thank you!

p.s. I am pretty set on database/server technology so PHP+MYSQL it is.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:52:53+00:00Added an answer on June 10, 2026 at 9:52 am

    You ask

    Is there a way I can set up my code or the database (mysql) to speed up the query?

    Yes, omit the query entirely.

    Put a UNIQUE constraint on the email address as stored in your backend database, and then be prepared to catch ER_DUP_UNIQUE when INSERTion of a new account fails because of a duplicate email address.

    That approach prevents duplicates and warns the new user when a duplicate has been chosen.

    I very much doubt that you need to look up email addresses as they are being typed (“…if I decide to use a keypress event…”). If you really do want to check that the address exists before INSERTing, you’ll also need a transaction to prevent TOCTOU hilarity. However, since the UNIQUE constraint is your simplest but most effective defense against duplicates, just implement that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is similar to my previous question, but that solution did not solve this
I'm building a rich web application that uses a lot of data. When I'm
I was trying to find a solution but did not succeed even if it
So I've been looking for a good solution everywhere but did not find anything
This started as a question, but turned into a solution as I did some
I did a quick search, but couldn't find a specific solution to this (I'm
Solution: if you have the same problem, addElement() instead of addChild() is what did
I've read several sources now but did not find a solution: I'm using Facebook
I've searched quite a bit and found a few solutions that did not end
This is quite similar question to one older but the solution did not work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.