Skip to:

Re: front page takes 50 mysql queries



No, all those are properly cached and do not reduce mysql queries.

topic_last_poster() for some reason forces a new metadata reload and two new mysql queries, uncached. It’s meant to be able to be used outside loops so it basically has to. It can’t just peek at the entire topics table just returned from the database.

Any plugin that affects the username has already affected it on the write to the topics table. It’s already set for presentation. No need to hook it unless you are doing something really crazy. Even the “admin use display names” plugin will still work correctly.

It’s the only really easy optimization.

“topic_last_poster()” sticks out badly if you install the plugin I posted above and look at the results.

update: if you are really worried about filters you can either have a lightweight pseudo function or do it this way

echo apply_filters( 'topic_last_poster', $topic->topic_last_poster_name, $topic->topic_last_poster);

instead of just

echo $topic->topic_last_poster_name;

and that will apply any filters looking for it

Skip to toolbar