13. JDBC and I / O
If the application needs to access a large data set, you should consider using the block extraction method. By default, JDBC extracts 32 lines of data each time. For example, suppose we want to traverse a 5000 row of record sets, JDBC must call the database 157 times to extract all data. If the block size is changed to 512, the number of calls to the database will be reduced to 10 times. This technology is invalid in some cases. For example, if you use the scrollable recording set, or specify for Update in the query, the block operation is no longer valid.
14. Memory database
Many applications need to save considerable number of data in session objects in a session object, typical applications such as shopping baskets and directories. Since such data can be organized in the form of rows / columns, many applications have created huge vector or havehmap. Saving such data in a session greatly limits the scalability of the application because the memory has at least the memory of each session takes up with the maximum number of memory, which not only makes the server are expensive, but also garbage collection The time interval may also extend to an unbearable level.
Some people transfer the shopping basket / directory function to the database layer to a certain extent increase scalability. However, putting this part of the function in the database layer also has problems, and the root cause of the problem is related to the architecture of most relational database systems. For relational databases, one of the important principles of runtime is to ensure that all write operations are stable, reliable, and thus all performance issues are related to the ability to write data to disk physically. Relational database power map reduces I / O operation, especially for read operations, but the main way to achieve this goal is just a complex algorithm for implementing a buffer mechanism, which is the main Bottleneck of the database layer, usually the main CPU. the reason.
A solution for an alternative to traditional relational databases is to use a database that runs in memory (in-Memory Database), such as TIMESTEN. The starting point of the memory database is to allow data to be temporarily written, but these data do not have to be saved to disk permanently, all operations are in memory. In this way, the memory database does not require a complex algorithm to reduce I / O operation, and can adopt a relatively simple locking mechanism, so the speed is very fast.