主题:【探讨】论坛搜索功能的优化。 -- 铁手
MySQL also uses indexes for LIKE comparisons if the argument to LIKE is a constant string that doesn't start with a wild-card character. For example, the following SELECT statements use indexes:
mysql> select * from tbl_name where key_col LIKE "Patrick%";
mysql> select * from tbl_name where key_col LIKE "Pat%_ck%";
In the first statement, only rows with "Patrick" <= key_col < "Patricl" are considered. In the second statement, only rows with "Pat" <= key_col < "Pau" are considered.
The following SELECT statements will not use indexes:
mysql> select * from tbl_name where key_col LIKE "%Patrick%";
mysql> select * from tbl_name where key_col LIKE other_col;
In the first statement, the LIKE value begins with a wild-card character. In the second statement, the LIKE value is not a constant.
Searching using column_name IS NULL will use indexes if column_name is an index.
MySQL normally uses the index that finds the least number of rows. An index is used for columns that you compare with the following operators: =, >, >=, <, <=, BETWEEN, and a LIKE with a non-wild-card prefix like 'something%'.
Any index that doesn't span all AND levels in the WHERE clause is not used to optimize the query. In other words: To be able to use an index, a prefix of the index must be used in every AND group.
另外,前两天看到一个PHP的新闻。两个捷克的大学生开发了一套PHP的编译器,可以将PHP Code编译成.NET Assembly,结果呢,程序性能有了很大提高。
- 相关回复 上下关系8
【探讨】论坛搜索功能的优化。 铁手 字600 2005-03-21 18:26:36
看到这么个东西,
俺觉得无论如何优化,全文搜索SQL都不灵,需索引 水帘洞主 字134 2005-03-21 19:55:58
老大得找个搜索专业的来 水帘洞主 字448 2005-03-21 19:29:33
mnogosearch 是个OPENSOURCE的搜索引擎 铁手 字91 2005-03-21 19:34:12
建议老大招募志愿顾问,分担一些工作 水帘洞主 字32 2005-03-21 19:37:55
您这个太简略,让人无从置喙 看看 字109 2005-03-21 18:53:49
是 mysql 数据库。接下去会用 php+mysql 铁手 字271 2005-03-21 19:11:04