List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:January 26 2001 4:45pm
Subject:Re: Are index file only for querying?
View as plain text  
In the last episode (Jan 26), Don said:
> I have a table called Ports that contains Port information and has
> several columns.  I've designated the Portname column as Primary as
> it is unique (I did not specify it as unique). When I do a:
> SELECT * FROM Ports;
> It does NOT show the table contents in index order (Portname
> beginning with "A" all the way through "Z") but rather in the order
> they were entered.

SQL tries to give you your results as fast as possible.  Indexes are
used when they can help.  They cause more disk I/O though, so if MySQL
determines that a query will read more than 10% (I think) of the
records in a table, it simply drops to a full table scan.
> So, it seems to me that indexes are only used for querying.  If I run
> through the data or issue the above SELECT statement, how do I
> display my rows in Primary Key order?

SELECT * FROM Ports ORDER BY Portname;

	Dan Nelson
Are index file only for querying?Don26 Jan
  • Re: Are index file only for querying?Steve Ruby26 Jan
  • Re: Are index file only for querying?Dan Nelson26 Jan
RE: Are index file only for querying?Ha Linh Don31 Jan
  • RE: Are index file only for querying?Andrei Cojocaru31 Jan