What is not suitable to put into the database __ database

Source: Internet
Author: User

The quality of the database layer design will greatly affect the performance of the application, the user experience is also closely related. What data should be avoided in the application development to enlarge the database.

1. Pictures, files, binary data, such as video, audio and other multimedia files are the most should not be put into the database.

Because: With the database more and more data, database backup and maintenance will become more and more difficult. Access to files runs through the multi-tier structure of the application, the application layer, the service layer, the database layer. The speed of database reading and writing is not up to the processing data of file system

The common practice is to store them in a large disk file system, while the database stores only their storage paths

2. Short Life Time Data
Use statistical data, measurement data, GPS positioning data, session data, any data that is useful to you in a short time, or that is constantly changing. If you find yourself using timed tasks to delete data from a table that is valid for only one hour, day, or weeks, you are not looking for the right way to do things. It might be better to use REDIS,MONGODBD

3. log file

Keeping the log data in the database looks good on the surface, and "Maybe I'll need to make complex inquiries about the data in the future." This is not a particularly bad practice, but if you store the log data and your product data in a database, it's very bad.

Maybe your log records are very conservative, and each Web request produces only one log. For every event in the entire site, this still produces a lot of database inserts, competing for the database resources your users need. So how much spare capacity do you have in your database to weigh up the amount of log data that you can do for complex queries, analytics, and logs that you put into the database?

You want to store the log data in the database, so you can use the database can do the advantage of complex queries to help you analyze the problem of the application, and do not want too much log data on the database system caused by too much pressure, perhaps the following is a good way, this is my recent learning SPRINGAOP and interceptor associated with the thought.

Using SPRINGAOP or interceptors combined with custom annotations, the classes and methods that you want to output logs to the database are annotated with annotations, which makes it easy to complete log filtering of target class method calls, combining APO and interceptors with the users you want to record, and the activity records of the roles in the database. (Perhaps the expression is not clear, this function will come soon ...) )

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.