Oracle Rapid Statistics Large table total record number __oracle

Source: Internet
Author: User

You're still struggling to figure out how to quickly count the total number of records in a table with lots of data.

Are you still using SELECT COUNT (*) from table_name?

I can try my new discovery:

Direct COUNT (*) is time-consuming when you want to count tens of millions or billions of data, and tens of millions of of the data is expected to wait several minutes.

The total number of records in a quick query table:

Select table_name, T.num_rows, t.last_analyzed from tabs t;

Here you can find out the number of records in all the tables for this user in the database.

After the query data found that the data obtained from the tabs table is not very accurate, in the tabs table there is a field last_analyzed, there is a final analysis of the date,

seem to be not up to date, and may result in data not being very accurate.

You can do this by following the command

EXEC dbms_stats.gather_table_stats (' Space name ', ' tablename ', cascade=>true);

You can refresh the Num_rows column in the tabs table and the last update time

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