Powerful relational database

xiaoxiao2021-03-06  44

Powerful relational database example:

Field Description Field Name Field Type Length Aircraft Machine Number Planecodechar88 Time TakeOfftimeDateTime Land Time LandTimedateTime

The amount of data is approximately 8,000 records per plane (because some hair aircraft will fly a lot of landing)

You can get the flight time of each aircraft through the table.

Now the user proposes a new request: requesting the parking time between the two flights of each aircraft, and the parking time is half a day, one day, three days, one week, the number of times the number of times is a number of records, you can get Parking time. In the face of such a problem, we will first think of two cursors. It handles this normal method of this progressive calculation problem. Through the circulation of two cursors, the progressive extracting this take-off time and last landing time, The difference between these two times is the parking time of the aircraft.

In fact, there is a better way.

SELECT T.TAKEOFFTIME-L.LANDTIME AS FLYDIV FORM (SELECT ROWNUM 1 AS R, Takeofftime From Flyhis) (Select Rownum As n, Landtime From Flyhis) lwhere L.N = T.R

This is certainly greatly improved than the efficiency of the cursor.

Of course, you need to do some processing, such as the first and last one.

To be handled separately (since they don't concentrate on the results), the total speed will increase.

Look at an example, it is encountered when developing an inventory management system. In order to improve the response speed of the system, an intermediate table (inventory number table)

Used to record the actual stock number of each item, we started using a cursor in the process of increasing inventory, which records are updated. When the user handles the trial, if the item is more, the time will update the number of databases. Very long, after research, we will rewrite this process as

Update inventory number table set quantity = quantity This time INFOR number Form IntriosTex Single Watch WHERE Update Conditions;

Through this modification, the speed of the system is greatly improved.

It can be seen that the use of cursors can improve performance from essentially.

转载请注明原文地址:https://www.9cbs.com/read-80061.html

New Post(0)