表查询很慢问题? 一个原来有大量记录的表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; 以释放空间。 PL/SQL中一打逗号就死机了? 大家帮我看看这个SQL语句 如何在oracle中获取并写入图片? Oracle 创建Package Body 的问题 ORA-00604: 递归 SQL 层 1 出现错误 对oracle感兴趣的请进!(综合应用) 求达到10万人的ORACLE数据库,ORACLE的性能如何优化,扣谢各位 在SQLPlus Worksheet里面,输出的错误信息是乱码,要修改哪里才能正确显示? 求一个SQL语句 我在xp下安装Oracle 9i为什么只好使了2次就不好用了呢!? convert的使用 存储过程中传入参数问题 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; 以释放空间。