Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Possible Improvements:</p> <p>First, you'll gain a couple microseconds per query if you name your fields instead of using SELECT posts.* which causes a schema lookup. Change your query to:</p> <pre><code>SELECT posts.post_n, posts.id, posts.date FROM posts, subscriptions WHERE posts.id=subscriptions.subscribe_id AND subscriptions.id=1 ORDER BY date DESC LIMIT 0, 15 </code></pre> <p>Next, this requires MySQL 5.1 or higher, but you might want to consider partitioning your tables. You might consider KEY partitioning for both tables. </p> <p>This should get you started. <a href="http://dev.mysql.com/doc/refman/5.1/en/partitioning-types.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/partitioning-types.html</a> </p> <p>E.g.</p> <pre><code>SET SQL_MODE = 'ANSI'; -- to allow default date CREATE TABLE IF NOT EXISTS `posts` ( `post_n` int(10) NOT NULL auto_increment, `id` int(10) default NULL, `date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`post_n`,`id`), KEY `id` (`id`), KEY `date` (`date`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin PARTITION BY KEY(id) PARTITIONS 32; -- CREATE TABLE IF NOT EXISTS `subscriptions` ( `subscription_n` int(10) NOT NULL auto_increment, `id` int(10) NOT NULL, `subscribe_id` int(10) NOT NULL, PRIMARY KEY (`subscription_n`,`subscribe_id`), KEY `id` (`id`), KEY `subscribe_id` (`subscribe_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin PARTITION BY KEY(subscribe_id) PARTITIONS 32; </code></pre> <p>I had to adjust your primary key a bit. So, beware, this may NOT work for you. Please test it and make sure. I hope, this does though. Make sure to run sysbench against the old and new structures/queries to compare results before going to production. :-)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload