• I have a query that I’m caching and updating every hour. However, I would like my visitors to be able to sort the query in 3 different ways. Essentially, I would like to use that cached query, instead of having to run the query again.

    The three ways I need them to sort it are
    1. by meta_value of a particular key, if that key doesn’t exist, just set the value to zero
    2. by comment count
    3. by date

    I can operate each of these queries standalone, but am unsure how to “re-sort” a query once it has already been returned. Furhtermore, if I’m using “meta_key” as an argument along with orderby “meta_key_value” is there a way to still return posts without the meta_key?

Viewing 1 replies (of 1 total)
  • You may also wish to explore doing the query four times when you update your cache each hour, and cache all four copies.

    It sounds bad, but because they are being done immediately after each other, MySQL internal caching would probably only do the query once, and do three sorts. Assuming, of course, that you’ve got enough memory to store all four in the cache.

Viewing 1 replies (of 1 total)
  • The topic ‘Sort a cached query’ is closed to new replies.