tags:

views:

30

answers:

2

Hello !

I have a table with 25.000 rows (columns with strings).

I would like to improve my select query. "SELECT name FROM table WHERE name LIKE 'something' ORDER BY name LIMIT 15"

The database will be static.

I would like to know if it's possible to order a column when I am inserting a row in my table and if it will reduce the time of the select query if the table is already order by name ?

+1  A: 

What you're asking doesn't make sense - the ORDER clause only applies to SELECT, not INSERT operations. (What would you order for example?)

If you're talking about building some form of index, as long as you've specified that the name column is an index (ideally when constructing the table) there's not a lot else you can do - it's up to the authors of the RDBMS system to handle the rest. (i.e.: They decide when indexes are constructed/updated, etc. - you can't control this.)

middaparka
Note that clustered indexes typically control the order of data on disk, and so might be what he wants - declare a clustered index on the name column. Although as with any optimisation the RDBMS might just take that as a hint rather than acting on it.
Rup
+1  A: 

If the database will be static why use it at all? Just hardcode those 15 names in the program. If you mean that the table will not be changing then to improve your query you can put an index on name column name or use more amount of cache.

Giorgi
+1 An exceedingly good point. :-)
middaparka