Committer: vad
LJSUP-14799: Add "use index" hint to sql query get subscriptions in a appropriate time
U trunk/cgi-bin/LJ/Event.pm
Modified: trunk/cgi-bin/LJ/Event.pm
===================================================================
--- trunk/cgi-bin/LJ/Event.pm 2013-01-14 15:54:37 UTC (rev 23540)
+++ trunk/cgi-bin/LJ/Event.pm 2013-01-15 07:30:18 UTC (rev 23541)
@@ -689,11 +689,14 @@
# FIXME: journals are only on one cluster! split jidlist based on cluster
my $jidlist = join(",", @wildcards_from);
+ ## Strictly specify USE INDEX(PRIMARY) hint.
+ ## Otherwise mysql query planner is acting out and query takes inexcusable amount of time.
my $sth = $udbh->prepare(qq{
SELECT
userid, subid, is_dirty, journalid, etypeid,
arg1, arg2, ntypeid, createtime, expiretime, flags
FROM subs
+ USE INDEX(PRIMARY)
WHERE etypeid=? AND journalid=0 $and_enabled
AND userid IN ($jidlist)
});