How to Optimize WP site for millions of posts

1. Set the query before WP_Query is run This seems to be the most important thing to keep in mind when trying to keep database queries to a minimum since the only opportunity to alter the query is, of course, before it is run in the SQL database. Normal Queries For a normal query, WordPress … Read more

Fastest way to put contents of Set to a single String with words separated by a whitespace?

With commons/lang you can do this using StringUtils.join: You can’t really beat that for brevity. Update: Re-reading this answer, I would prefer the other answer regarding Guava’s Joiner now. In fact, these days I don’t go near apache commons. Another Update: Java 8 introduced the method String.join() While this isn’t as flexible as the Guava version, it’s handy when … Read more

SQL: How to properly check if a record exists

It’s better to use either of the following: The first alternative should give you no result or one result, the second count should be zero or one. How old is the documentation you’re using? Although you’ve read good advice, most query optimizers in recent RDBMS’s optimize SELECT COUNT(*) anyway, so while there is a difference … Read more

Image rotation algorithm

One of the best pages describing image rotation algorithms I’ve found on the internet is tied to Dan Bloomberg’s excellent leptonica library. While the leptonica library itself is written in C and won’t help you, his page on image rotation algorithms: http://www.leptonica.org/rotation.html is definitely worth a read. You will most likely want to implement something … Read more

Most efficient way to increment a Map value in Java

Some test results I’ve gotten a lot of good answers to this question–thanks folks–so I decided to run some tests and figure out which method is actually fastest. The five methods I tested are these: the “ContainsKey” method that I presented in the question the “TestForNull” method suggested by Aleksandar Dimitrov the “AtomicLong” method suggested … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)