Thousands of lines of stored procedure felt!

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/u010695794/article/details/88076001

This article first appeared in the personal micro-channel public number "andyqian", expecting you to pull up!

One

To tell the truth, I have been for some time did not write MySQL series of articles, but usually also have been concerned about MySQL related technologies. Just the other day, by chance timeline know almost appeared such a question:

How would you assess sql stored procedure a few thousand lines? (Link below)

https://www.zhihu.com/question/311546275

 

To tell the truth, see the problem, he said he was shocked! Was just thinking, what kind of business need to write thousands of lines of stored procedure? What kind of system need to write thousands of lines of stored procedure?

My original answer is this:

First of all: to show my point of view, standing now, ask me how thousands of lines of SQL stored procedures? I can only say that is not good, no matter how pretty you write, realize the function of multi Niubi, in my eyes is worthless. (Do not accept refute!)

For the following reasons:

  1. Thousands of lines of stored procedure in my eyes, it represents the former C / S architecture of the times, which is a client of the times. To popular mobile Internet era is now mostly used in the B / S (Browser / Server) architecture, (I am here to see Browser app has become a B / S architecture).
  2. The difference is: C / S architecture, most of the logic is implemented directly through SQL, because this is the fastest and probably the best at the time. In this day and age, no need to consider high concurrency, RPC, distributed and other issues (or rather, the question is no B / S era outstanding). But now stand point of view: SQL you write thousands of lines to try? Estimates on the line, CPU 100% in respect of services in relation to hang up.
  3. Thousands of lines of stored procedure, it must be to achieve a certain function, or to achieve a particular business. (Now in service in the prevalence of micro, small serving size, each perform their duties, can maximize optimization service, low cost modification, more maintainable). Maintenance stored procedure thousands of lines you try? Let alone someone else, he said he wrote, about a week later did not know what that means, right?

Overall: thousands of lines of SQL, in the present situation, maintainability performance + is simply bad news! There are for example: debugging, portability and optimization are unthinkable.

two

We all know that in the development of science and technology, technological advances, C / S architecture to the B / S architecture evolution is also accompanied by a lot of technical challenges. From single application -> MVC-> RPC-> Micro service. The core idea is to divide and conquer, divided into different modules, the next module is divided into different services. Internal service operations caching, database operation, using a queue. Service interaction, program processing, inter-related, cross-vertical complicated. A user requests over, as long as the abnormal ring or a slow response, will result in experience Caton, or no response!

Under such a premise, common practice is to implement the business logic through the code. It will not carry out complex operations in the database, not even recommend the use of multi-table join queries. Thus, the fall in the database are generally simple SQL. Even so, it often needs to be optimized, which optimization techniques there are a lot of knowledge. In production systems, services and even for slow SQL system, they are often fatal.

Now look at "thousands of lines of stored procedure", can not help but leave a cold sweat!


 

Finally: what you encounter things that make you cold sweats? Share chant together under the comments section!


 

Related Reading:

" On the JPDA the Java "

" On the MySQL SQL optimization ."

" Said the collapse of several small details of the system! "

" Write and MySQL index "


                                                                                     Scan code concerned, together with progress

                                                                        Personal blog: http://www.andyqian.com

Guess you like

Origin blog.csdn.net/u010695794/article/details/88076001