[TYPO3-dev] Optimizing last 20 query
Martin Kutschker
Martin.Kutschker at n0spam-blackbox.net
Fri Mar 16 09:49:24 CET 2007
John Angel schrieb:
> Hi Peter,
>
>> As queries for latest records are pretty common it might be helpful to
>> index crdate and tstamp by default.
>
>
> EXPLAIN says:
> - pages: using parent key, rows: 5000, extra info: Using where; Using
> filesort
> - tt_content: using parent key, extra info: Using where
>
> The majority of records is coming from pages tables, so tt_content indexes
> are not making much sense. Also, additional pages indexes are not doing any
> good, it always uses parent key.
Adding additional indices won't help as only one index is used for a table
in one query.
But you could create an index with more fields:
pid,crdate,deleted,hidden,t3ver_state.
And maybe it helps to move the page restriction into the join:
INNER JOIN pages ON (tt_content.pid = pages.uid AND pages.deleted =0
AND pages.t3ver_state !=1 AND pages.hidden =0 )
Masi
More information about the TYPO3-dev
mailing list