MyBB Community Forums

Full Version: Database Optimization (slow queries): MySQL mybb_posts index
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm trying to optimize the database because I have many slow queries.

I've taken a look to the mybb_posts table and saw that index tid is composed of tid and uid. (see http://docs.mybb.com/Database_Tablesmybb_posts.html )
Is this normal and optimal ?

Would it be OK if I add fid as an index ?

Here is an example of the slow queries I have :

# Time: 131105 16:52:09
# User@Host: jpcarmybb[jpcarmybb] @ localhost []
# Query_time: 7.681529  Lock_time: 0.000050 Rows_sent: 1  Rows_examined: 771730
SET timestamp=1383666729;
SELECT pid FROM mybb_posts WHERE tid='40963' ORDER BY dateline ASC LIMIT 0, 1;

# Time: 131105 17:16:27
# User@Host: jpcarmybb[jpcarmybb] @ localhost []
# Query_time: 5.832011  Lock_time: 0.000044 Rows_sent: 1  Rows_examined: 1388070
SET timestamp=1383668187;
SELECT pid FROM mybb_posts WHERE tid='67989' ORDER BY dateline ASC LIMIT 0, 1;

# Time: 131105 18:29:48
# User@Host: jpcarmybb[jpcarmybb] @ localhost []
# Query_time: 6.306011  Lock_time: 0.000064 Rows_sent: 1  Rows_examined: 990924
SET timestamp=1383672588;
SELECT pid FROM mybb_posts WHERE tid='47615' ORDER BY dateline ASC LIMIT 0, 1;

# Time: 131105 18:40:08
# User@Host: jpcarmybb[jpcarmybb] @ localhost []
# Query_time: 5.793216  Lock_time: 0.000052 Rows_sent: 1  Rows_examined: 771730
SET timestamp=1383673208;
SELECT pid FROM mybb_posts WHERE tid='40963' ORDER BY dateline ASC LIMIT 0, 1;