tags:

views:

39

answers:

2

Hi, how optimisation mysql query?

Now I use Limit function, don't use *.

how else can I speed up the operation?

Thanks

+1  A: 

To give you any specific advice, we'd need to see a specific query.

In general, the rules are simple:

  1. Select only what you need (no extra columns, no extra rows), including when JOINing
  2. Create an INDEX on columns (or combinations of columns) that you're likely to use often, especially those you're using to filter results.

Optimizing a specific query will often involve subtle changes to grouping, joins, conditions, fields, and ultimately every part of the query, but of course that sort of attention requires having a specific query to work with.

VoteyDisciple
+1  A: 

@lolalola, you will probably get better responses if you provide your query for people to look at.

Without that the best I can do is direct you to mySQL's documentation on optimization:

http://dev.mysql.com/doc/refman/5.0/en/optimization.html

You will probably get the most bang for your buck by reading up on the following:

Abe Miessler
not only a query but rather a query along with EXPLAIN output, as well as CREATE TABLE output for all tables involved.
Col. Shrapnel