表查询很慢问题? 一个原来有大量记录的表tab,删除了大部分记录之后,虽然只剩下几百条,但查询(如:select count(*) from tab)起来还是特别慢,请问为什么?是不是要做什么重建或者释放空间之类的工作? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 建议重建个表create table tab1 as select * from tab; 几百条会有多慢?try:rename tbname to tbname_new;create table tbname as select * from tbname_new;drop table tbname;select count(*) from tbname; try:rename tab to tab_old;create table tab as select * from tab_old;select count(*) from tab; 把你原来表上现在看来没有必要的约束去掉建立索引还有要想得到总条数,不要全扫描select count(1) from tab;得到结果一样,但是快 alter table tab deallocate unused;select * from tab alter table tab deallocate unused;select count(*) from tab 执行execute dbms_stats.gather_schema_stats('ALL');重新收集系统信息 删除数据不会影响表的高水位标志,全表扫描还是一样慢move一下表 重新做一下表分析.最好是重建表.rename之后,create一个新的. 你删除大部分的记录是通过DELETE来完成的吧?这样表空间和相应的约束都没有释放,建议以后册除批量数据不要用DELETE,可以使用truncate来完成 select count(索引字段) from tab 试试 用alter table tabname deallcate unused 时不能全部收回,当DELETE表时,记录的High-water 并没完全下来,而alter table tabname deallcate unused 只能回收到High-water 处。建议用 bzszp(SongZip)的方法:rename tab to tab_old;create table tab as select * from tab_old;select count(*) from tab;再加一条:drop table tab_old; 以释放空间。 .dat文件导入问题 求一条SQL语句 请教Oracle中如何在sql语句执行之前截获Sql语句? 创建表空间的问题 关于批量插入的问题 在windows2003 EM要怎么打开啊?oracle10g在线等 oracle自动重启问题,大家帮忙,急 一个sql语句 怎么恢复 计算百分比(在线等啊) 存储过程中传入参数问题 Oracle數據庫加載失敗
try:
rename tbname to tbname_new;
create table tbname as select * from tbname_new;
drop table tbname;
select count(*) from tbname;
rename tab to tab_old;
create table tab as select * from tab_old;
select count(*) from tab;
建立索引还有要想得到总条数,不要全扫描select count(1) from tab;得到结果一样,但是快
select * from tab
select count(*) from tab
重新收集系统信息
最好是重建表.
rename之后,create一个新的.
这样表空间和相应的约束都没有释放,建议以后册除批量数
据不要用DELETE,可以使用truncate来完成
建议用 bzszp(SongZip)的方法:
rename tab to tab_old;
create table tab as select * from tab_old;
select count(*) from tab;再加一条:drop table tab_old; 以释放空间。