[TYPO3-core] RFC: improving index of sys_template

Martin Kutschker Martin.Kutschker at n0spam-blackbox.net
Wed Oct 11 16:57:05 CEST 2006


Martin Kutschker schrieb:
> Hi!
> 
> I suggest to change the index "parent" to KEY parent (pid,sorting). All 
> SELECTs that have a pid in the WHERE have also sorting in the ORDER BY.
> 
> As a test you may use this and have a look at output of EXPLAIN:
> 
> create index parent2 on sys_template (pid,sorting);
> EXPLAIn SELECT * FROM sys_template WHERE pid=1 AND deleted=0 AND 
> hidden=0 AND (starttime<=1157534861) AND (endtime=0 OR 
> endtime>1157534861) ORDER BY sorting LIMIT 1;
> 
> The point is that now the "Using filesort" is gone and another few 
> microseconds are saved by a tiny change of the code.
> 
> It probably makes sense to change other "parent" indices of tables with 
> sorting columns as well (eg pages and tt_content), but I haven't 
> investigated closely.

Done in trunk.

After same investigation (using logged EXPLAIN during a session) I suggest 
the following indices:

# changed
create index parent on pages (pid,sorting);
create index parent on tt_content (pid,sorting);

The avoid a filesort for typical queries on pages and tt_content.

# new
create index record on sys_log (recuid,uid);

The last index is only used in history/undo but avoids a scan of the 
complete sys_log table (history has WHERE recuid=<id> SORT BY <uid>).

Masi

Masi



More information about the TYPO3-team-core mailing list