T_medflow table has 10 million data flowid is primary key has primary key index
Total number of statistics
Select COUNT (flowid) from T_medflow t
Spents: 1.5 seconds
Select COUNT (*) from T_medflow t
Spents: 1.46 seconds
Multiple test efficiency is almost
Add a conditional query
Select COUNT (flowid) from T_medflow t where pname like '% '
Spents: 25S [The total number of statistics for a query is 25 seconds and the basic user experience is very poor]
Statistical analysis of the following table to prevent the wrong execution plan
ANALYZE TABLE t_medflow COMPUTE STATISTICS;
are checking
Select COUNT (flowid) from T_medflow t where pname like '% '
Spents: 22 seconds
Using multiple CPUs for parallel processing
Select/*+ PARALLEL (t_medflow,14) */COUNT (*) from T_medflow
Where pname like '% of% '
Spents: 1.7 Seconds [My database environment is 4CPU]
Solve the problem of count (*) slow
The number of CPU settings based on the actual number of CPUs will not be more than 4 times CPU but inefficient
Using indexes for parallel efficiency is low don't know what the problem is
Select/*+ Parallel_index (T_medflow, Pk_flowid,)/count (*) from T_medflow
Where pname like '% of% '