0

I have a database that is being accessed by a web browser. The query is pretty simple.

select * from table where ID="string"

the question I need to ask is that do I need to worry about the response time becoming "very noticeably" slower to the end user as the server grows large??

(right now the query is returned in 0.00004 seconds. i really dont care even if it takes a few seconds.)

rm65453
  • 81
  • 1
  • 8

3 Answers3

1

As long as the id column is indexed, no, you do not really have to worry about this particular query.

Shadow
  • 33,525
  • 10
  • 51
  • 64
1

Assuming your ID is the primary key for that table - no you don't have to worry about that query. Also if it's not your primary key but you've added an index (How do I add indices to MySQL tables?) it will be also fine.

Make sure you're protecting yourself again SQL Injection (How can I prevent SQL injection in PHP?) so don't directly insert your path-parameter or query-parameter into your SQL query.

Community
  • 1
  • 1
DominikAngerer
  • 6,354
  • 5
  • 33
  • 60
  • thank you, the Id is not the primary key, the primary key is just a AI number. I will look into adding an index and i have protected against sql injection. – rm65453 Oct 09 '15 at 23:34
  • Also I just indexed my table (using your link, thank you) with the command ALTER TABLE table ADD INDEX (ID). How do I confirm that everything went well? all i got was "MySQL returned an empty result set (i.e. zero rows). (Query took 0.0276 seconds.)" – rm65453 Oct 09 '15 at 23:52
1

No, you don't need to worry about it. I have a table with roughly a billion rows and it returns immediately.

mysql> show profiles;
+----------+------------+---------------------------------------------+
| Query_ID | Duration   | Query                                       |
+----------+------------+---------------------------------------------+
|        1 | 0.00020500 | select * from xxxx where id = 768273542     |
+----------+------------+---------------------------------------------+
1 row in set (0.00 sec)
Michael Y.
  • 661
  • 7
  • 12