Hi List,

why are subqueries so slow? Is this because their implementation is
still not optimized? Take for example the following queries and have
a look at the timing:

mysql> select wordid from words where val = 'henning';
+--------+
| wordid |
+--------+
| 144005 |
+--------+
1 row in set (0.00 sec)

mysql> select count(*) from wordlist where wordid in (select wordid from words where val = 'henning');
+----------+
| count(*) |
+----------+
| 55 |
+----------+
1 row in set (0.88 sec)


mysql> select count(*) from wordlist where wordid in (144005);
+----------+
| count(*) |
+----------+
|       55 |
+----------+
1 row in set (0.00 sec)


I did more tests and observed a constant time factor around 1 sec that is introduced
by using subqueries. I depend on those queries running fast and if I have a 0.88 sec
overhead it will sum up quickly. So for now, I either use local code to do the query
first and insert the value manually or use a join.


Bottom line: I would really love to use subqueries but something seems not right.

Andreas Pardeike


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to