Beste,
Als wij op onze testserver een fulltext search doen zonder een 'order by', dan gaat dit razendsnel en werkt het goed.
Echter als wij een 'order by id' oid doen dan gaat MySQL over op filesorting -- en dit is supertraag!
Hoe kom ik hier vanaf?
Tabledef:
Indices:
Query zonder order by:
Query met order by:
We zouden het erg fijn vinden om eindelijk de fulltext search te kunnen gebruiken, op het moment hebben we een eigen dictionary en zoekmethode..
Als wij op onze testserver een fulltext search doen zonder een 'order by', dan gaat dit razendsnel en werkt het goed.
Echter als wij een 'order by id' oid doen dan gaat MySQL over op filesorting -- en dit is supertraag!
Hoe kom ik hier vanaf?
Tabledef:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| mysql> describe books; +---------------+---------------------+------+-----+------------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+---------------------+------+-----+------------+----------------+ | RecordNumber | int(11) | | PRI | NULL | auto_increment | | MemberNumber | int(11) | | MUL | 0 | | | BookNumber | varchar(20) | | MUL | | | | Author | varchar(60) | | MUL | | | | Titel | text | | | | | | Description | varchar(100) | | | | | | DescripRest | text | | | | | | Price | bigint(20) unsigned | | | 0 | | | Keywords | varchar(100) | | | | | | DollarPrice | bigint(20) unsigned | | MUL | 0 | | | CountryNumber | tinyint(3) unsigned | | MUL | 0 | | | EntryDate | date | | MUL | 0000-00-00 | | | Status | char(1) | | MUL | | | | RecordType | tinyint(4) | | MUL | 0 | | | BookFlags | smallint(6) | | MUL | 0 | | | Year | smallint(6) | | MUL | 0 | | | FirstEdition | tinyint(4) | | MUL | 0 | | | DustWrapper | tinyint(4) | | MUL | 0 | | | Signed | tinyint(4) | | MUL | 0 | | | Cover | tinyint(4) | | MUL | 0 | | | SpecialField | tinyint(4) | | MUL | 0 | | +---------------+---------------------+------+-----+------------+----------------+ |
Indices:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
| -------+------------+-----------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | +-------+------------+-----------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+ | books | 0 | PRIMARY | 1 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | BookFlags | 1 | BookFlags | A | 47 | NULL | NULL | | BTREE | | | books | 1 | CountryBook | 1 | CountryNumber | A | 19 | NULL | NULL | | BTREE | | | books | 1 | CountryBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | MemberBook | 1 | MemberNumber | A | 436 | NULL | NULL | | BTREE | | | books | 1 | MemberBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | DollarBook | 1 | DollarPrice | A | 11914 | NULL | NULL | | BTREE | | | books | 1 | DollarBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | FirstBook | 1 | FirstEdition | A | 2 | NULL | NULL | | BTREE | | | books | 1 | FirstBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | YearBook | 1 | Year | A | 1001 | NULL | NULL | | BTREE | | | books | 1 | YearBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | EntryBook | 1 | EntryDate | A | 897 | NULL | NULL | | BTREE | | | books | 1 | EntryBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | RecordTypeBook | 1 | RecordType | A | 3 | NULL | NULL | | BTREE | | | books | 1 | RecordTypeBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | DustWrapperBook | 1 | DustWrapper | A | 2 | NULL | NULL | | BTREE | | | books | 1 | DustWrapperBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | SignedBook | 1 | Signed | A | 2 | NULL | NULL | | BTREE | | | books | 1 | SignedBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | CoverBook | 1 | Cover | A | 3 | NULL | NULL | | BTREE | | | books | 1 | CoverBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | StatusBook | 1 | Status | A | 1 | NULL | NULL | | BTREE | | | books | 1 | StatusBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | BookBook | 1 | BookNumber | A | 1620356 | NULL | NULL | | BTREE | | | books | 1 | BookBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | SpecialBook | 1 | SpecialField | A | 2 | NULL | NULL | | BTREE | | | books | 1 | SpecialBook | 2 | RecordNumber | A | 3240712 | NULL | NULL | | BTREE | | | books | 1 | totidx | 1 | Author | A | 1620356 | NULL | NULL | | FULLTEXT | | | books | 1 | totidx | 2 | Titel | A | 1620356 | 1 | NULL | | FULLTEXT | | | books | 1 | totidx | 3 | Description | A | 3240712 | NULL | NULL | | FULLTEXT | | | books | 1 | totidx | 4 | DescripRest | A | 3240712 | 1 | NULL | | FULLTEXT | | | books | 1 | totidx | 5 | Keywords | A | 3240712 | NULL | NULL | | FULLTEXT | | +-------+------------+-----------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+ 33 rows in set (0.00 sec) |
Query zonder order by:
code:
1
2
3
4
5
6
7
8
9
10
| mysql> select Titel,Price from books where match(Author,Titel,Description,DescripRest,Keywords) against ('+press' in boolean mode) limit 0,500; [...] 500 rows in set (0.01 sec) mysql> describe select Titel,Price from books where match(Author,Titel,Description,DescripRest,Keywords) against ('+press' in boolean mode) limit 0,500; +-------+----------+---------------+--------+---------+------+------+-------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +-------+----------+---------------+--------+---------+------+------+-------------+ | books | fulltext | totidx | totidx | 0 | | 1 | Using where | +-------+----------+---------------+--------+---------+------+------+-------------+ 1 row in set (0.00 sec) |
Query met order by:
code:
1
2
3
4
5
6
7
8
9
10
| mysql> select Titel,Price from books where match(Author,Titel,Description,DescripRest,Keywords) against ('+press' in boolean mode) limit 0,500; [...] 500 rows in set (13.03 sec) mysql> describe select Titel,Price from books where match(Author,Titel,Description,DescripRest,Keywords) against ('+press' in boolean mode) order by RecordNumber desc limit 0,500; +-------+----------+---------------+--------+---------+------+------+-----------------------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +-------+----------+---------------+--------+---------+------+------+-----------------------------+ | books | fulltext | totidx | totidx | 0 | | 1 | Using where; Using filesort | +-------+----------+---------------+--------+---------+------+------+-----------------------------+ 1 row in set (0.00 sec) |
We zouden het erg fijn vinden om eindelijk de fulltext search te kunnen gebruiken, op het moment hebben we een eigen dictionary en zoekmethode..