I am having a website where one of my primary ( aka more frequently used table has grown to more then 15 miilion records. Now the problem with me is that i have to fetch the latest record first. I don't want to make the orderby query as it make the system slow the executuin time for a records whose index key is having 20000 + cardinality takes 0.8 sec. and when i fetch the execution time is .004 sec which is 200 times faster. please suggest how can i do fetch the latest records from mysql table without doing the order by. regards
here is bit more clarity this is like i am having end users messages in my database. and for a user named "U" i am having 20000 messages. Now i want fetch the last 10 messages for users "U". right now i am doing it with the order by command on primary key. But that sucks when it come about fetching the records for a users who have 20000 Messages in all.
I think you will have to use the order by as you need the last ten exactly .. Also you can use the LIMIT to limit it to 10 messages.
it takes even more time so no use of fetching the last 10 record. I need the table to be organized in a manner so that last entered should be fetched first.