Forum Webscript.Ru
Общие => Базы данных => Тема начата: Foshvad от 01 Февраля 2003, 02:11:35
-
Вопросец.
Можно ли в общем оценить соотношение скоростей обработки MYSQL’ем запросов с REGEXP и с LIKE?
Например, что быстрее будет выполнятся:
SELECT somefield from sometable WHERE somefield REGEXP ‘*abc*’
и
SELECT somefield from sometable WHERE somefield LIKE ‘%abc%’
обработка порядка 2000-10000 строк.
somefield имеет тип VARCHAR(255), индекс создан
Кстати, кто-нить знает, REGEXP индекс использует?
-
Можно ли в общем оценить соотношение скоростей обработки MYSQL’ем запросов с REGEXP и с LIKE?
Цитата из мана:
`BENCHMARK(count,expr)\'
The `BENCHMARK()\' function executes the expression `expr\'
repeatedly `count\' times. It may be used to time how fast *MySQL*
processes the expression. The result value is always `0\'. The
intended use is in the `mysql\' client, which reports query
execution times:
mysql> select BENCHMARK(1000000,encode("hello","goodbye"));
+----------------------------------------------+
| BENCHMARK(1000000,encode("hello","goodbye")) |
+----------------------------------------------+
| 0 |
+----------------------------------------------+
1 row in set (4.74 sec)
The time reported is elapsed time on the client end, not CPU time
on the server end. It may be advisable to execute `BENCHMARK()\'
several times, and interpret the result with regard to how heavily
loaded the server machine is.
Кстати, кто-нить знает, REGEXP индекс использует?
эта информация вроде в EXPLAIN SELECT должна покзываться
-
mysql> select benchmark(100000000,\'select * from anek where anek regexp"%abc%"\'
;
+--------------------------------------------------------------------+
| benchmark(100000000,\'select * from anek where anek regexp"%abc%"\') |
+--------------------------------------------------------------------+
| 0 |
+--------------------------------------------------------------------+
1 row in set (2.42 sec)
mysql> select benchmark(100000000,\'select * from anek where anek like"%abc%"\');
+------------------------------------------------------------------+
| benchmark(100000000,\'select * from anek where anek like"%abc%"\') |
+------------------------------------------------------------------+
| 0 |
+------------------------------------------------------------------+
1 row in set (2.42 sec)
-
ЗЫ: а если поле еще и индексированное то ваще все летает
(у меня селерон но 1000000 запросов проскакивает за 0.01 с)
!хз почему %)