List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:December 13 2006 10:50pm
Subject:Re: How to determine MyISAM sort order?
View as plain text  
In the last episode (Dec 13), Jacek Becla said:
> Is there a way to find which index was used to sort
> MyISAM table (suppose someone run
> "myisamchk --sort-index --sort-records=2" in the past,
> how to find that sorting was done based on index #2?)

You can run a "select * from mytable" and see whether any columns are
in order; that's about it.  Note that if records were inserted/deleted
since the sort, no column may be completely in order.
> And a related question: how to determine which is
> the index "#2"? I guess if I look at the order of indexes
> in the 'SHOW CREATE TABLE <name>' report that will do it.
> Is that the right way? Is there more official way?

You can also use SHOW FIELDS from <name>, or 

select column_name from information_schema.columns 
 where table_name="<name>" and table_schema="<schema>" 
       and ordinal_position=2;

	Dan Nelson
How to determine MyISAM sort order?Jacek Becla13 Dec
  • Re: How to determine MyISAM sort order?Dan Nelson13 Dec