- 论坛徽章:
- 11
|
select count(*) from t1;
----------------------- test@test -------------- Press CTRL-W ...
sqlnet 发表于 2010-03-26 20:55 ![]()
- select t.tabname, p.nrows, t.nrows
- from sysmaster:sysptnhdr p, systables t
- where p.partnum = t.partnum
- and t.tabname = 't1';
- -----------
- tabname t1
- nrows 16657
- nrows 16657.00000000
复制代码 select count(*) from t1 实际取的就是p.nrows的值, 这也是为什么这个语句的explain走索引的原因..
若我们在这个语句后加上 1=1 ,就会发现这走的是顺序扫描~.
若是p.nrows跟t.nrows相差太多,表时你这个表需要做统计更新了.
- QUERY: (OPTIMIZATION TIMESTAMP: 03-26-2010 21:07:10)
- ------
- select count(*) from t1
- Estimated Cost: 1
- Estimated # of Rows Returned: 1
- 1) informix.t1: INDEX PATH
- (1) Index Name: (count)
- Index Keys: (count)
- Query statistics:
- -----------------
- Table map :
- ----------------------------
- Internal name Table name
- ----------------------------
- type rows_prod est_rows rows_cons time
- -------------------------------------------------
- group 1 1 0 00:00.00
- QUERY: (OPTIMIZATION TIMESTAMP: 03-26-2010 21:07:19)
- ------
- select count(*) from t1 where 1=1
- Estimated Cost: 790
- Estimated # of Rows Returned: 1
- 1) informix.t1: SEQUENTIAL SCAN
- Filters: t
- Query statistics:
- -----------------
- Table map :
- ----------------------------
- Internal name Table name
- ----------------------------
- t1 t1
- type table rows_prod est_rows rows_scan time est_cost
- -------------------------------------------------------------------
- scan t1 16657 16657 16657 00:01.04 791
- type rows_prod est_rows rows_cons time
- -------------------------------------------------
- group 1 1 16657 00:01.27
复制代码 |
|