Home » Performance » MySQL » Optimizing ORDER BY - Returned data is not in the expected order
Optimizing ORDER BY - Returned data is not in the expected order [message #2658] Thu, 21 February 2008 07:18 Go to previous message
arthurica  is currently offline arthurica
Messages: 7
Registered: January 2008
Junior Member
I have a weird problem... I have a very large table with products and I am trying to optimize some queries for retrieving data from this table

I run this query on the table

ALTER TABLE prod ORDER BY prod_rank DESC;

So when I retrieve data I expect to have the records sorted by prod_rank descending... This is happening for most of categories BUT not for few ones when data appears to by arranged randomly

I have tried it with 2 differnet indexes and the results are about the same

1. index RANK (fk_cat, prod_rank DESC)
2. index fk_cat (fk_cat)

So for example this query will return the results sorted just fine

select prod_key, prod_rank from products
where fk_cat = 100
limit 1000

but this one will not

select prod_key, prod_rank from products
where fk_cat = 250
limit 1000

This appears to be randomly as far as the category ID

Am I doing something wrong or am I missing somthine obviously?

Read Message
Read Message
Previous Topic:Slow query - Using where; Using temporary; Using filesort
Next Topic:Merge table Vs Big Table
Goto Forum:

  



Current Time: Fri Dec 5 11:49:25 EST 2008

Total time taken to generate the page: 0.00994 seconds
.:: Contact :: Home :: MySQL Support by Percona.com ::.

Powered by: FUDforum 2.7.5.
Copyright ©2001-2006 FUD Forum Bulletin Board Software

MySQL Performance | Forum authority Badge