[wp-hackers] wp_cache function tutorials?
Jeremy Clarke
jer at simianuprising.com
Wed Jul 28 13:44:01 UTC 2010
When you have such a large data set I think you move from worrying about
caching the particular data and into optimizing your database caching as a
whole.
Like Mike I wonder if you wouldn't be better off using the posts/custom
posts system rather than your own table. Doing so would simplify your life
in many ways including the fact that once your content was in post format
you could take advantage of all the build-in caching stuff that wordpress
has there. Obviously you'd also get all the query/db optimization that has
gone into the posts system over the years. Starting from scratch with
queries to your custom table will probably generate more database issues
than anything.
That aside, you should focus on having good general caching of your DB
queries and of your pages. Use something like Supercache to make sure that
the homepage etc. don't hit the DB every time, and something like memcached
to try to avoid hitting the database when possible.
On Mon, Jul 26, 2010 at 5:45 PM, Otto <otto at ottodestruct.com> wrote:
>
> Transients should not be used for storing data that you retrieved from
> the database, since it stores them in the database by default anyway.
>
>
Otto is right for the most part but IMHO there are scenarios where saving
data 'from the database' in a transient can make sense even though it is
still stored in the database by the transient system. Specifically, there
are times when you pull data from multiple tables using complex/expensive
joins, often followed by heavy PHP processing resulting in a very specific
data set that itself isn't huge but in the end takes a lot of resources to
regenerate. In these cases a transient can save a lot of resources because
they are autoloaded from the options table as part of a single query that
fetches all options. This means that the only extra database strain is the
exact amount of data you saved in the transient. So if your resulting
dataset is humongous (i.e. hundreds of kilobytes) then it might not be
efficient to store them in options, but if its relatively small then there
are huge gains to be had, especially for data that is used on every page in
the same way (like a list of authors who have posted recently, or a list of
recent songs with high popularity).
--
Jeremy Clarke | http://jeremyclarke.org
Code and Design | http://globalvoicesonline.org
More information about the wp-hackers
mailing list