1
mysql> explain SELECT p.id ID, p.job_desc_title Title, p.url URL, substr(p.posting_date, 1, 10) Date, 
    ->                                         p.job_city_name City,
    ->                                         p.job_state_name State,
    ->                                         b.screen_name Name, b.type Type,f.name Company,IF(g.account_id IS NULL,0,1) Online
    ->                                         FROM postings p
    ->                           LEFT JOIN accounts b on p.account_id=b.id
    ->                           LEFT JOIN companies f on f.id=p.job_cmp_id
    ->                           LEFT JOIN online g ON g.account_id=p.account_id
    ->                           WHERE (MATCH(job_desc,job_desc_title,k_state,k_city,zip) AGAINST('+java' IN BOOLEAN MODE))  AND b.closed=0 AND NOT p.expired 
    ->                           
    ->                           LIMIT 0 , 5
    -> ;
+----+-------------+-------+----------+--------------------------------------------------+--------------------------------------+---------+-----------------+------+-------------+
| id | select_type | table | type     | possible_keys                                    | key                                  | key_len | ref             | rows | Extra       |
+----+-------------+-------+----------+--------------------------------------------------+--------------------------------------+---------+-----------------+------+-------------+
|  1 | SIMPLE      | p     | fulltext | FK_listings,f_postings_city_state_desc_title_zip | f_postings_city_state_desc_title_zip | 0       |                 |    1 | Using where | 
|  1 | SIMPLE      | f     | eq_ref   | PRIMARY                                          | PRIMARY                              | 4       | v3.p.job_cmp_id |    1 |             | 
|  1 | SIMPLE      | g     | eq_ref   | account_id                                       | account_id                           | 4       | v3.p.account_id |    1 | Using index | 
|  1 | SIMPLE      | b     | eq_ref   | PRIMARY                                          | PRIMARY                              | 4       | v3.p.account_id |    1 | Using where | 
+----+-------------+-------+----------+--------------------------------------------------+--------------------------------------+---------+-----------------+------+-------------+
4 rows in set (0.00 sec)

它曾经是按相关性排序的,但现在似乎不是。

4

2 回答 2

5

如果没有 order by,“默认”排序将取决于查询中使用了哪些索引以及它们的使用顺序。这可能会随着数据/统计数据的变化以及优化器选择不同的计划而改变。

如果您希望数据按特定顺序排列,请使用 ORDER BY。但我敢肯定你已经知道了:)

于 2009-06-03T17:30:45.010 回答
2

不要假设订单,如果您需要订单,请使用 ORDER BY 子句。

于 2009-06-03T17:33:23.913 回答