At 2:31 AM -0700 1/16/03, Prasanth Krishna wrote:
hi

i have a database with a single table say tbl1 with an index on a
particular field say col1. when i say

select * from tbl1;

it doesn't use the index on that table.

In this query, I can't see any reason to use an index...MySQL is simply returning all columns from all records in whatever order it sees fit.

If you used

select * from tbl1 order by col1

it *would* use the index.


but if i say

select col1 from tbl1;
it uses the index.

I'm guessing that in this case MySQL is reading col1 directly from the index file...it doesn't need to look at the actual data record at all. Which is good.


how to make mysql use the index on col1 for the first query?

Give it a reason to do so ;)

-steve


--
+------------------------------------------------------------------------+
| Steve Edberg                                      [EMAIL PROTECTED] |
| University of California, Davis                          (530)754-9127 |
| Programming/Database/SysAdmin               http://pgfsun.ucdavis.edu/ |
+------------------------------------------------------------------------+
| SETI@Home: 1001 Work units on 23 oct 2002                              |
| 3.152 years CPU time, 3.142 years SETI user... and STILL no aliens...  |
+------------------------------------------------------------------------+

---------------------------------------------------------------------
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to