![]() |
1) Does not work becasue MAX() is a grouping function
2) Does work, but gives the same output as in Post #3, eg. Table Scan :( |
interesting as mysql.com said using force index makes it so it uses indexes only and requires no table scan>_>
maybe substitute FORCE INDEX with USE INDEX ;) |
[sql]select * from post where postid = (select max(postid) from post)[/sql]But i think this will only work for MySQL 4.1 and up.
Otherwise create 2 queries: 1 to get max postid, and 1 to retrieve the row. Ohh my example is for post table, but should be the same for thread. Also please notice that you should check with a fully loaded table, since the optimizer might decide that if there are only a few rows, it is more efficient to use a full table scan then to use the index. |
Quote:
[sql]EXPLAIN SELECT * FROM thread ORDER BY threadid DESC LIMIT 1 [/sql] Code:
table type possible_keys key key_len ref rows Extra |
Quote:
|
Quote:
|
All times are GMT. The time now is 07:42 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|