« first day (2215 days earlier)      last day (443 days later) » 

3:50 PM
Hello? anyone there?
 
4:39 PM
@Shaheer as the topic says, Ask your question, and then hang around a while to see if an expert looks back at their screen and answers it!
 
4:51 PM
ok,
can anyone answer this question: stackoverflow.com/questions/43121141/…
 
 
2 hours later…
6:23 PM
@Shaheer That's the "groupwise max" problem: jan.kneschke.de/projects/mysql/groupwise-max
In your case, you'll probably want to write one query to get the groupwise max, and another query to get the groupwise min, and then union them together.
 
6:40 PM
Fighting a huge performance issue in a query: stackoverflow.com/questions/43124102/… Anyone have a few minutes to look at this with me? Most easily explained by giving access to the test enviroment I set up.
 
 
2 hours later…
8:58 PM
@TehShrike that does not solve my problem, it gives me max record per group, but that is not what I am looking for, anyways I solved my problem using some variable-fu which I will post in the same question tomo, thanks anyway
 
@Shaheer but that's what you asked for - you said you wanted the "first" and "last" in each group
first = min, last = max
@DarbyM For anyone to help you too much, I think you'd need to provide the schema of your tables - the result of SHOW CREATE TABLE [tablename] for each table involved in the query
It sounds like you've already done a big part in the debugging, by narrowing it down to the subqueries
The next step I would take would be to run each of the subqueries on its own, and see how long they take by themselves. It may be just one or two of the subqueries that are the main culprit.
 
@TehShrike Thats the problem... too many table to list.... Thats why I setup a test enviroment to let interested parties connect and poke around... would be easier on all
@ TehShrike P.S. each and every subquery on its own runs in under .05 Its the cumulative result of them all that seems to be the issue.
 
9:50 PM
@TehShrike I simplified the query and posted the Table Create statements.
 
@DarbyM ah cool - is it just that join with the one subquery, then? All the other subqueries don't slow it down as much?
I worry about that cse.PSAActivityID < ss.PSAActivityID - MySQL has never been good about using indexes to do greater than/less than comparisons of fields
 
@TehShrike On the contrary.. they all slow it down just as bad as this one.. so I'm going with the assumption that once this solution is found, It will apply to all.. (since they are all systematically the same)
 
Gotcha.
 
Well I have the option of a timestamp field that can be Joined from a not listed here table. But I figured the > operation was simple enough to not matter.
the visual explain shows 6.02 Million rows after the final block nested Loop. SubmissionStatus has ~4k rows, and TrackDetails has ~15K rows...
Clearly something in here is doing more work then needed if i'm ending with 6 million rows
 
@DarbyM yeah, I can't blame you for thinking that - I was pretty shocked when I realized MySQL didn't try to do any kind of index use for that case at all
If you can eliminate the >, I'd try that first.
 
9:58 PM
working on it as we speak. You wouldn't be interested in connectiong to the DB and seeing the MySQL Workbench results first hand would you?
Ah crap.. never mind.. the entries in SubmissionStatus have a Many to One relationship with the table that has the timestamps. And the TimeStamp column in the SubmissionStatus is a "last modified" time stamp instead of creation timestamp. So won't work for this purpose. PSAActivityID incremental is all I have.
 
10:56 PM
@DarbyM Not tonight, maybe sometime later if I feel some SQL hacking coming on
 
Think I just finally made a little progress on the thing.. Instead of doing SubQuerries, I'm building a Temp table.. that way I can define indexes. The second I got the right 2 indexes in place, the query dropped from 3.2 seconds to .281 seconds
 
With as many tables/subqueries as you're pulling in, that seems justified.
 
yeah.. other wise it is having to blindly scan through literally millions of billions of rows. with NO index to help
 

« first day (2215 days earlier)      last day (443 days later) »