Need to use indexes in SELECT * without using where, How to do that ?
I've a table like that
Table name : table1
And I use indexes in (a_name,a_id (Primary key), a_code,a_number)
Now I want to make select * from table1 to get all of the data
However no indexes are use in explain query, How I can tell the query to use index without using the where clause for sure as I don't want to specific the values.
Also I tried use index and force index and nothing changed
There's no point using an index because the entire table will have to be scanned anyway.
I also tried to specific the select query (selecting about 70% of the table) and also no luck, No way to get a key appears in the explain.
Also tried the force index and use index after specific the query data.
Any suggestions ? I've made the query more specific by selecting some columns however I also can't get an index to be used in the query.
High Energy Magic Dept.
It might help to see some examples of the queries, but as stated in the first reply: if you don't have a where clause, then no indexes will be used. Even if you have a where clause, index usage isn't guaranteed, depending on what is in that where clause, or at least an order by on and indexed column. (E.g.: if your where clause would select 70% of the records, the DBMS may decide it can actually run faster by just reading all the rows anyway, rather than doing index processing.)
Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett
"But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because he’s a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html
Columns or rows? Restricting which columns are selected wouldn't make a difference because you'd still be scanning every row in the table.
Originally Posted by 2CODE
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)