https://bugzilla.wikimedia.org/show_bug.cgi?id=27081

           Summary: Forcing an index on a select query when doing a table
                    join gives a query error
           Product: MediaWiki
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: Normal
         Component: Database
        AssignedTo: wikibugs-l@lists.wikimedia.org
        ReportedBy: s...@reedyboy.net


Forcing an index on a select query when doing a table join gives a query error,
we get

SELECT page_title,page_namespace FROM `mw_page` JOIN `mw_categorylinks` ON
((page_id=cl_from)) FORCE INDEX (page_random) WHERE page_is_redirect = '0' AND
(page_random >= 0.757003172866) AND cl_to = 'Test' ORDER BY page_random LIMIT 1

from within function "RandomPage::selectRandomPageFromDB". Database returned
error "1064: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'FORCE INDEX (page_random) WHERE page_is_redirect = '0' AND (page_random >=
0.757' at line 1 (localhost)".

When we want

SELECT page_title,page_namespace FROM `mw_page` FORCE INDEX (page_random) JOIN
`mw_categorylinks` ON ((page_id=cl_from))  WHERE page_is_redirect = '0' AND
(page_random >= 0.757003172866) AND cl_to = 'Test' ORDER BY page_random LIMIT 1


Noticed when refactoring RandomPage and RandomInCategory to reduce code
duplication

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to