MySQL Forums
Forum List  »  General

Re: Procedure Inconsistent Performance
Posted by: Peter Brawley
Date: April 09, 2018 09:43AM

Best strategy is to debug and tune each query in turn outside an sproc.

Re the first query, select a,b,c,d,min(e) ... group by a returns arbitrary results for b,c,d unless there is a 1:1 relationship between a, and b c and d. You need to prove those relationships are 1:1 before leaving b,c,d out of the Group By clause.

Re both queries, as the manual's page on joins makes clear, comma join syntax (...from pqrs, abcd where...) can yield errors when combined with explicit join syntax (...from ... join ... on...). Since explicit join syntax is much easier to write debug and maintain, best practice is to avoid comma join syntax altogether.

Once each query is proved to return correct results in all relevant cases, run Explain on each one and configure table indexes to optimise performance. When the query involves Insert...Select, run Explain on the Select portion first, get that query tuned, then run Explain on the whole query. See the manual pages on optimisation and on Explain.

Options: ReplyQuote


Subject
Written By
Posted
April 08, 2018 09:36PM
Re: Procedure Inconsistent Performance
April 09, 2018 09:43AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.