I’m developing a fully ajax community WP theme that comes with alot of custom quaries.
Everything is fine, there is no bug but recently but I had a few client that have a huge database and my theme started to kill CPU. I wonder how can I make it more faster.
What this code is doing?
This code is trying to get posts that contains only have “comment” type comments (comment_type=”comment”) AND approved ones.
database information: Mysql – mariaDB
table name I’m trying to get result – wp_comments
how many data that table have – 380.000 (380K) comments
query’s raw output time on phpmyadmin (w/o php) – 0.23 seconds
time to get this data on front end – 0.85-90 seconds
JS Code that calls function
PHP Code to get data
INDEX I used in this query
How can I make it more faster, more stable. Is there something wront with my SQL code or PHP code? This code is really killing the CPU…
Without this index, query is around 0.5 seconds (phpymyadmin exec. time. 1.5 seconds when calling with ajax).
Thank you and sorry for my bad English! ^_^