views:

303

answers:

3

Hi there,

I have an old MySQL 4.1 database with a table that has a few millions rows and an old Java application that connects to this database and returns several thousand rows from this this table on a frequent basis via a simple SQL query (i.e. SELECT * FROM people WHERE first_name = 'Bob'. I think the Java application uses client side prepared statements but was looking at switching this to the server, and in the example mentioned the value for first_name will vary depending on what the user enters).

I would like to speed up performance on the select query and was wondering if I should switch to Prepared Statements or Stored Procedures. Is there a general rule of thumb of what is quicker/less resource intensive (or if a combination of both is better)

+2  A: 

You do have an index of first_name, right? That will speed up your query a lot more than choosing between prepared statements and stored procedures.

Marius
Hi, sorry I should have mentioned that it is indexed. I've not tried to boost performance on tables with several million rows (and MySQL for that matter) so I'm not too sure where to start looking/testing.If a table has say 5m rows will indexing a column in that table help or will it have problems/performance issues trying to index that number of rows (the hardware the MySQL database is on isn't the most up to date)?
amardilo
A: 

If you have just one query to worry about, you should be able to implement the two alternatives (on your test platform of course!) and see which one gives you the best performance.

(My guess is that there won't be much difference though ...)

Stephen C
A: 

Looks like the best way is just to make the change and test it out in a test environment.

Thanks for the help.

amardilo