#100296Add DB Index to sys_news
Description
Hello,
the query of sys_news is not using index. With an index you can “speed up” the query from 0.004 to 0.0005 seconds.
Stefan
Reviews 1
History 24
-
Gerrit Code Review pushed patch set 1 for main to change 78252 status
NewUnder Review 03/24/23, 21:13 -
Stefan Froemken commented 03/24/23, 21:15
-
Gerrit Code Review pushed patch set 2 for main to change 78252 03/24/23, 22:04
-
Stefan Froemken commented and changed status
Under ReviewClosed 03/27/23, 20:10The columns starttime, endtime, hidden and deleted are in 98% always 0. So the QueryParser decides: reading all data from disc is faster than reading and checking values from index. As no index is used now, it also make no sense to create an index on just crdate.
It’s this query:
SELECT `uid`, `title`, `content`, `crdate` FROM `sys_news` WHERE ( (`sys_news`.`deleted` = 0) AND (`sys_news`.`hidden` = 0) AND ( `sys_news`.`starttime` <= 1679690460 ) AND ( ( (`sys_news`.`endtime` = 0) OR ( `sys_news`.`endtime` > 1679690460 ) ) ) ) ORDER BY `crdate` DESC;