Jump to content

Recommended Posts

The only method I know of in MySQL that allows you to order anything is ORDER BY, so I don't really see how you can escape using it if you want to accomplish this in MySQL.

 

You could, however, use a combination of mysqli_data_seek() and mysqli_ num_ rows() to loop over the record set in reverse.

Thanks guys but I don't think any of these solutions will work right. I just want the results to be returned in reverse, that's all. I don't want extra overhead slowing it down. I just wanna flip the results upsidedown.

You want the server to "flip the results" but you don't want it to do any extra work??

I can't think of any reason for there to be overhead just from returning the results the other way around.

 

And yes Order By is expensive. It makes queries take significantly longer. If you don't want to take my word for it try it yourself or search google for statistics. This is completely besides the point and irrelevant though. All I'm asking is how to return the results backwards.

 

Please tell me how.. :D

And yes Order By is expensive. It makes queries take significantly longer. If you don't want to take my word for it try it yourself or search google for statistics.

 

Thanks for the suggestion that I search for myself. Good point!  I'll keep it in mind when answering your future questions.

Thanks roopurt!

 

And I'm sorry andy, I didn't mean it that way.. I'm just saying that I don't want to make a test script just to prove that Order By causes overhead.. I mean doesn't everyone know it causes overhead?? Why do I need to prove that?? Every optimization guide I've read has said so..

 

No offense.. =\

Of course it causes overhead; any sort operation creates overhead.  I think what Andy was getting at was exactly how much overhead is it causing you?  1 ms? 4 s?

 

As another solution, if this is a set of data that doesn't change often, you could always run a cron job in the morning to create a table with the rows in the order you want them and just select from there.

If you really want to be fancy, you can issue an alter table statement and sort the whole table,then the rows will be retrieved the way you want them.

 

I can't think of any reason for there to be overhead just from returning the results the other way around.

Really? It doesn't "know" how you want your results, YOU told it to be ordered a certain way.  If it can figure out a fast way to do it, it will -- otherwise it will take more work.  Try and get a card dealer to deal from the bottom of the deck instead, see if it takes any longer.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.