[quote=renee,08.06.2004, 21:10]wie wär's mit [sql]SELECT accesslog_id from accesslog WHERE accessdate >= "2004-01 -01 00:00:00" ORDER BY accesslog DESC LIMIT 0, 1 ;[/sql][/quote]
Das muss wohl "ASC" statt "DESC" sein. Trotzdem das gleiche Ergebnis:
1 row in set (4 min 32.05 sec)
@thorium: int_time bringt auch keinen grossen Geschwindigkeitsgewinn:
mysql> select min(accesslog_id) from accesslog where int_time >1080770400;
1 row in set (4 min 20.73 sec)
int_time ist als KEY angelegt.
@oesi50: Laut EXPLAIN scheint es immer einen Table-Scan zu geben. Hier die verschiedenen Varianten:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
mysql> explain select min(accesslog_id) from accesslog where int_time >1080770400;
+-----------+------+---------------+------+---------+------+----------+------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+-----------+------+---------------+------+---------+------+----------+------------+
| accesslog | ALL | int_time | NULL | NULL | NULL | 13563083 | where used |
+-----------+------+---------------+------+---------+------+----------+------------+
1 row in set (0.01 sec)
mysql> explain select accesslog_id from accesslog where int_time >1080770400 order by accesslog_id LIMIT 0,1;
+-----------+-------+---------------+----------+---------+------+----------+--------------
--------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+-----------+-------+---------------+----------+---------+------+----------+--------------
--------------+
| accesslog | range | int_time | int_time | 5 | NULL | 13563083 | where used; Using filesort |
+-----------+-------+---------------+----------+---------+------+----------+--------------
--------------+
1 row in set (0.00 sec)