2

I'm using a table to do login, the table has a record of 2500. when i try to login it takes nearly 30-40 seconds to load. I'm using PHP and MySQL.I need to make the sql query faster to check the data. Solutions are welcomed thanks in advance pls help me out

10
  • Use indexes, and instead of retrieving all fields using *, try retrieving only the fields you require. Commented Apr 30, 2012 at 6:42
  • If the table has only 2500 records it should even with no indexes be way faster. Commented Apr 30, 2012 at 6:43
  • Without any code, we can only guess what you did wrong. Show us. Commented Apr 30, 2012 at 6:43
  • I have index on the login id's even its slow Commented Apr 30, 2012 at 6:44
  • 3
    @Boopaathy Edit your question and include it there. By the way, your scheme is terribly wrong. You should ever never never store passwords plaintext! Especially not so when your code is vulnerable to SQL injections! Commented Apr 30, 2012 at 6:55

2 Answers 2

1

When locating the causes of problems of performance issues, there are many things to consider in the your application stack:

  1. Database: Indexes, Joins, Query Formation
  2. Network in between: Routing issues, Bandwith, connectivity speed
  3. Code: Check if your code structure is not creating unecessary delays, forexample some people have their validations span over client and server both in a single method which increases method lifetime longer. Try to put validation's core logic on database side like in stored procedures. Try to use methods with lesser overheads.
Sign up to request clarification or add additional context in comments.

Comments

0

You should have included your query so we can examine it. Don't pull all your records (e.g. don't use Select * from users) and then loop through to find a match. Instead, use WHERE clause to limit your records to (i.e. one row). That is

SELECT col1,col2,.. FROM Users WHERE username='username' AND password='password'

You can try that and see the performance...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.