Note that there are some explanatory texts on larger screens.

plurals
  1. POMysql index configuration
    primarykey
    data
    text
    <p>I have a table with 450000 row full of news. The table schema is like this:</p> <pre><code>CREATE TABLE IF NOT EXISTS `news` ( `id` int(11) NOT NULL auto_increment, `cat_id` int(11) NOT NULL, `title` tinytext NOT NULL, `content` text NOT NULL, `date` int(11) NOT NULL, `readcount` int(11) NOT NULL default '0', PRIMARY KEY (`id`), KEY `cat_id` (`cat_id`), KEY `cat_id_2` (`cat_id`,`id`), KEY `cat_id_date` (`cat_id`,`date`) ) ENGINE=MyISAM DEFAULT CHARSET=latin5 AUTO_INCREMENT=462679 ; </code></pre> <p>When i run a sql command like below to take some news for a page "x" of the category page it takes more than 15 seconds if x is over 100:</p> <pre><code>select * news where cat_id='4' order by id desc limit 150000,10; </code></pre> <p>explain shows that its using "where" and the index "cat_id_2"</p> <p>While writing this question i also checked a more simple sql query like this and it also took near to a minute:</p> <pre><code>select * from haberler order by id desc limit 40000,10; </code></pre> <p>if the sql is like the following one it takes just a few milliseconds:</p> <pre><code>select * from haberler order by id desc limit 20,10; </code></pre> <p>My my.cnf configuration is like this:</p> <pre><code>skip-locking skip-innodb query_cache_limit=1M query_cache_size=256M query_cache_type=1 max_connections=30 interactive_timeout=600000 #wait_timeout=5 #connect_timeout=5 thread_cache_size=384 key_buffer=256M join_buffer=4M max_allowed_packet=16M table_cache=1024 record_buffer=1M sort_buffer_size=64M read_buffer_size=16M max_connect_errors=10 # Try number of CPU's*2 for thread_concurrency thread_concurrency=2 myisam_sort_buffer_size=128M long_query_time = 1 log_slow_queries = /var/log/mysql/mysql-slow.log max_heap_table_size=512M </code></pre> <p>The website is running on a core2duo with 2GB of RAM. I think that the problem may be caused by the sort_buffer_size but i'm not sure. thanks in advance.</p>
    singulars
    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.
 

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