Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to optimize database this query in large database?
    primarykey
    data
    text
    <p><strong>Query</strong></p> <pre><code>SELECT id FROM `user_tmp` WHERE `code` = '9s5xs1sy' AND `go` NOT REGEXP 'http://www.xxxx.example.com/aflam/|http://xx.example.com|http://www.xxxxx..example.com/aflam/|http://www.xxxxxx.example.com/v/|http://www.xxxxxx.example.com/vb/' AND check='done' AND `dataip` &lt;1319992460 ORDER BY id DESC LIMIT 50 </code></pre> <p>MySQL returns:</p> <pre><code>Showing rows 0 - 29 ( 50 total, Query took 21.3102 sec) [id: 2622270 - 2602288] </code></pre> <p><strong>Query took 21.3102 sec</strong></p> <p>if i remove</p> <p>AND <code>dataip</code> &lt;1319992460 </p> <p>MySQL returns</p> <pre><code>Showing rows 0 - 29 ( 50 total, Query took 0.0859 sec) [id: 3637556 - 3627005] </code></pre> <p><strong>Query took 0.0859 sec</strong></p> <p>and if no data, MySQL returns</p> <pre><code>MySQL returned an empty result set (i.e. zero rows). ( Query took 21.7332 sec ) </code></pre> <p><strong>Query took 21.7332 sec</strong> </p> <p>Explain plan:</p> <pre><code> SQL query: Explain SELECT * FROM `user_tmp` WHERE `code` = '93mhco3s5y' AND `too` NOT REGEXP 'http://www.10neen.com/aflam/|http://3ltool.com|http://www.10neen.com/aflam/|http://www.10neen.com/v/|http://www.m1-w3d.com/vb/' and checkopen='2010' and `dataip` &lt;1319992460 ORDER BY id DESC LIMIT 50; Rows: 1 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE user_tmp index NULL PRIMARY 4 NULL 50 Using where </code></pre> <p><strong>Example of the database used</strong></p> <blockquote> <p>CREATE TABLE IF NOT EXISTS <code>user_tmp</code> ( <code>id</code> int(9) NOT NULL AUTO_INCREMENT, <code>ip</code> text NOT NULL, <code>dataip</code> bigint(20) NOT NULL, <code>ref</code> text NOT NULL, <code>click</code> int(20) NOT NULL, <code>code</code> text NOT NULL, <code>too</code> text NOT NULL, <code>name</code> text NOT NULL, <code>checkopen</code> text NOT NULL, <code>contry</code> text NOT NULL, <code>vOperation</code> text NOT NULL, <code>vBrowser</code> text NOT NULL, <code>iconOperation</code> text NOT NULL,<br> <code>iconBrowser</code> text NOT NULL,</p> </blockquote> <pre><code> PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4653425 ; </code></pre> <p>--</p> <h2>-- Dumping data for table <code>user_tmp</code></h2> <pre><code>INSERT INTO `user_tmp` (`id`, `ip`, `dataip`, `ref`, `click`, `code`, `too`, `name`, `checkopen`, `contry`, `vOperation`, `vBrowser`, `iconOperation`, `iconBrowser`) VALUES (1, '54.125.78.84', 1319506641, 'http://xxxx.example.com/vb/showthread.php%D8%AA%D8%AD%D9%85%D9%8A%D9%84-%D8%A7%D8%BA%D9%86%D9%8A%D8%A9-%D8%A7%D9%84%D8%A8%D9%88%D9%85-giovanni-marradi-lovers-rendezvous-3cd-1999-a-155712.html', 0, '4mxxxxx5', 'http://www.xxx.example.com/aflam/', 'xxxxe', '2010', 'US', 'Linux', 'Chrome 12.0.742 ', 'linux.png', 'chrome.png'); </code></pre> <p>I want the correct way to do the query and optimize database </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.
 

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