-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL query fails in region.php #328
Comments
I'm thinking the code installed on tmtest is missing some of the recent changes. Let me check it out. @yakra Is what's in GitHub now the same as what's on lab2 (where this works)? |
Reinstalled GitHub latest onto tmtest and loaded into a fresh browser in case it was caching some code or something. Same problem. I suspect something important on lab2 didn't make it into GitHub yet. |
Further investigation: on lab2, the same query is run but is successful. So it appears that we have some sort of DB difference. noreaster is at MySQL Server version: 5.7.26-log. What's on lab2? |
However, the fact that I pasted in a multiline SQL query from lab2's page source gives an error message with a better indication where noreaster's version becomes unhappy.
|
And...now I know what's up. The |
A workaround could be to do 2 queries and 2 calls to |
MySQL 8 has binary logging enabled by default. This may be what slowed me down the most during my first attempts at ingesting the SQL file. If you do upgrade, this may be something to look out for. |
If the workaround is not too bad, I think it's best to do that than try to do a major version upgrade on the DB. |
region.php: Among the slower queries I've seen, but not completely awful. system.php SELECT
ccr.traveler,
count(ccr.route) as driven,
sum(ccr.clinched) as clinched,
RANK() OVER (ORDER BY COUNT(ccr.route) DESC) drivenRank,
RANK() OVER (ORDER BY SUM(ccr.clinched) DESC) clinchedRank
FROM connectedRoutes as cr
LEFT JOIN clinchedConnectedRoutes as ccr
ON cr.firstRoot = ccr.route
WHERE cr.systemName = 'usany'
GROUP BY traveler; takes 0.10-0.12 sec. system stats for a single region: SELECT
ccr.traveler,
count(ccr.route) as driven,
sum(ccr.clinched) as clinched,
RANK() OVER (ORDER BY COUNT(ccr.route) DESC) drivenRank,
RANK() OVER (ORDER BY SUM(ccr.clinched) DESC) clinchedRank
FROM routes as cr
LEFT JOIN clinchedRoutes as ccr
ON cr.root = ccr.route
WHERE cr.region = 'NY' AND cr.systemName = 'usany'
GROUP BY ccr.traveler; takes 0.06-0.08 sec, with no noticeable difference snipping region.php rounds percentages in the SQL query, while system.php rounds them itself when writing to the HTML table. We've got to round all this stuff anyway, but maybe we could save a little time but not putting all these values into the result table? I googled |
Sounds good, thanks. |
Mileage rank is also buggy. http://travelmapping.net/user/region.php?u=yakra&rg=NY ranks me as # 42 in both the Active and the Active+Preview tables. On Lab2, This is differently sorted, and I'm on the # 43 line on the Active Systems table. But the rank value up top still has me at # 42, not # 43. Why?
Fixing either one of these bullet points should be sufficient to squash this bug. |
The result table receives a bunch of values whether rounded or not. Won't change. |
MySQL 5.7-compatible ranking fix for #328
Related to #325, decided to open a new Issue rather than discussing in the closed PR.
Starting at http://tmtest.teresco.org/user/?units=miles&u=terescoj, I click on a region (say, NY), to get to http://tmtest.teresco.org/user/region.php?units=miles&u=terescoj&rg=NY, and I get an SQL error:
Query failed: SELECT traveler, COUNT(cr.route) AS driven, SUM(cr.clinched) AS clinched, ROUND(COUNT(cr.route) / 578 * 100, 2) as drivenPct, ROUND(sum(cr.clinched) / 578 * 100, 2) as clinchedPct, RANK() OVER (ORDER BY COUNT(cr.route) DESC) drivenRank, RANK() OVER (ORDER BY SUM(cr.clinched) DESC) clinchedRank FROM routes AS r LEFT JOIN clinchedRoutes AS cr ON cr.route = r.root LEFT JOIN systems ON r.systemName = systems.systemName WHERE (r.region = 'NY' AND systems.level = 'active') GROUP BY traveler;
Running that query interactively in mysql on noreaster gives this error:
ERROR 1064 (42000): 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 'Query failed: SELECT traveler, COUNT(cr.route) AS driven, SUM(cr.clinched) AS cl' at line 1
The text was updated successfully, but these errors were encountered: