Inefficient query After partitioning of large data volumes in Oracle

Source: Internet
Author: User

Scenario Description:

There are two tables in the Oracle database, one being tm_bus_realtime_log. The current table only contains data from the previous day. The data volume has millions of data records. There is also a table where the History Table tm_bus_realtime_his is partitioned. Every 10 days, there are three partitions each month. The entire history table contains hundreds of millions of data records. Each partition has tens of millions of data records.

Problem description:

When querying data from a partition in a history table, it is slow. Because the data volume is very large, if you want to query data for several days, it is slower? How can I increase the query speed?

I posted a post on this topic on the Forum. Thank you very much for your comments. Some good suggestions are as follows:

1. Change to one partition per day.

2. Clean up historical data, for example, only store data for 2 years.

3. Based on the plan, check whether the index is suitable or not.

4. If there are other fields besides time in your query conditions, you must create a local index accordingly.

5. If the historical table data is not changed, you can create a trunc (XX) bitmap function index in the time field and specify the partition during query.

6 Table partitions, that index Partition

7 depends on the where condition.

Some of my practices:

In fact, we want to make two interfaces to query and display the required comprehensive information, which has a large amount of data. Partition. However, when the data is displayed in the query, the data of the day can still be queried, but the query speed is particularly slow after the cross-partition operation.

1. For the current table tm_bus_realtime_log. View its index, there is only one (index name: INDEX_BUS_REALTIME field name: UPLOAD_TIME)

In my query SQL, there are two fields in the condition, bus_no and upload_tiime. The index field should be followed by the where condition.

2. Do not use * For the queried data. It is best to use a specific field.

3. Press F5 in plsql to view the execution plan of the SQL statement, whether it is a full table scan or an index.

4 indexes are not suitable for creating many indexes. If more indexes are created, query efficiency may be affected. At that time, a useless redundant index was deleted. The speed is faster.

5. Try not to use in. Use exists.

6. Optimize the code.

Now the data is much faster!

Related Article

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: 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.