2008年11月26日星期三

tuxedo 中使用进行文件锁定

用fcntl 会失败, 返回 EFAULT. 原因尚未调查明确

请转道使用 lockf
lockf可以实现劝告锁和强制锁, 依赖于chmod 的行动。
具体描述可以参考如下链接:

http://docs.sun.com/app/docs/doc/816-5168/lockf-3c?a=view

2008年11月19日星期三

count(*)、count(1)、count(rowid)的对比

原文作者 bitirainy

http://bitirainy.itpub.net/post/330/1914

经常有人说count(1)比count(*)快。实际上是这样吗?不是的,作为数据库的衡量性能的逻辑读来说,是没有差异的。但是在实际的多次反复测试中,我们可以来对比看看真实状况。


SQL> create table t as select * from all_objects;

Table created.

SQL> select count(*) from all_objects;

COUNT(*)
----------
3789

SQL> desc t
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER NOT NULL VARCHAR2(30)
OBJECT_NAME NOT NULL VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NOT NULL NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(18)
CREATED NOT NULL DATE
LAST_DDL_TIME NOT NULL DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)

先 delete statistics , 各方式分别求 1000次 count
然后 analyze table ,各方式分别求 1000次 count
然后做个时间对比

服务器无外界干扰的情况下的反复测试的结果如下
declare
n_count number;
n_time0 number;
n_time1 number;
n_time2 number;
n_time3 number;
n_time4 number;

begin
execute immediate'analyze table t delete statistics';


select count(*) into n_count from t;

n_time0 := dbms_utility.get_time;
for i in 1..1000 loop
select /*+index(t t_index)*/ count(*) into n_count from t;
end loop;

n_time1 := dbms_utility.get_time;
for i in 1..1000 loop
select count(*) into n_count from t;
end loop;

n_time2 := dbms_utility.get_time;

for i in 1..1000 loop
select count(1) into n_count from t;
end loop;
n_time3 := dbms_utility.get_time;
for i in 1..1000 loop
select count(rowid) into n_count from t;
end loop;
n_time4 := dbms_utility.get_time;

dbms_output.put_line('the count of the table T : '||to_char(n_count));
dbms_output.put_line('before analyze ,loop 1000,/*+hints*/count(*) :'||to_char(n_time1 - n_time0 ));
dbms_output.put_line('before analyze ,loop 1000,count(*) :'||to_char(n_time2 - n_time1));
dbms_output.put_line('before analyze ,loop 1000,count(1) :'||to_char(n_time3 - n_time2));
dbms_output.put_line('before analyze ,loop 1000,count(rowid) :'||to_char(n_time4 - n_time3));

execute immediate'analyze table t compute statistics';

select count(*) into n_count from t;
n_time1 := dbms_utility.get_time;
for i in 1..1000 loop
select count(*) into n_count from t;
end loop;

n_time2 := dbms_utility.get_time;

for i in 1..1000 loop
select count(1) into n_count from t;
end loop;
n_time3 := dbms_utility.get_time;
for i in 1..1000 loop
select count(rowid) into n_count from t;
end loop;
n_time4 := dbms_utility.get_time;

dbms_output.put_line('the count of the table T : '||to_char(n_count));
dbms_output.put_line('after analyze ,loop 1000,count(*) :'||to_char(n_time2 - n_time1));
dbms_output.put_line('after analyze ,loop 1000,count(1) :'||to_char(n_time3 - n_time2));
dbms_output.put_line('after analyze ,loop 1000,count(rowid) :'||to_char(n_time4 - n_time3));

end;

the count of the table T : 3789
before analyze ,loop 1000,/*+hints*/count(*) :71
before analyze ,loop 1000,count(*) :63
before analyze ,loop 1000,count(1) :91
before analyze ,loop 1000,count(rowid) :88
the count of the table T : 3789
after analyze ,loop 1000,count(*) :28
after analyze ,loop 1000,count(1) :28
after analyze ,loop 1000,count(rowid) :79

PL/SQL procedure successfully completed.

SQL> /
the count of the table T : 3789
before analyze ,loop 1000,/*+hints*/count(*) :72
before analyze ,loop 1000,count(*) :61
before analyze ,loop 1000,count(1) :88
before analyze ,loop 1000,count(rowid) :85
the count of the table T : 3789
after analyze ,loop 1000,count(*) :28
after analyze ,loop 1000,count(1) :27
after analyze ,loop 1000,count(rowid) :82

PL/SQL procedure successfully completed.

从这里我们可以看出在时间的对比上,同样通过全表扫描和走索引,除了count(rowid)在走索引的时候明显慢外,其他情况下差异都不是很大,很明显,对于这样的求和来说,我们使用 count(*) 是没有什么不好的,count(1)更快纯粹是一个谬论。

更多的讨论可以参考

http://www.cnoug.org/viewthread.php?tid=857&highlight=count%2Bbiti_rainy

2008年11月17日星期一

敢えて武器を手に


本日から、新たの日本語を使う

武器は、やむを得ず、使うことである。

武器を手に入れるのは、自信があるか

武器を昔の先生に向け、後悔することがあるのか
なぜ闘争しなければいけないなのか

いくつか厳しい状況であり、いくつか暴政である

敵を欺くために、何度も退却した、何度も  した、
何れまでにむかうなの




We will not go quietly into the night

Good morning.
In less than an hour, aircraft from here will join others from around the world. And you will be launching the largest aerial battle in the history of mankind. "Mankind."

That word should have new meaning for all of us today. We can't be consumed by our petty differences anymore. We will be united in our common interests. Perhaps it's fate that today is the Fourth of July, and you will once again be fighting for our freedom...

Not from tyranny, oppression, or persecution... but from annihilation.
We are fighting for our right to live. To exist. And should we win the day, the Fourth of July will no longer be known as an American holiday, but as the day the world declared in one voice:
"We will not go quietly into the night!
We will not vanish without a fight!
We're going to live on! We're going to survive!
Today we celebrate our Independence Day!"

2008年11月9日星期日

oralce 10g中从recycle bin恢复误删除的表

flashback table 表名 to before drop

2008年11月5日星期三

为了此地而来

我知道,为了我们能够再次来到此地,
google和blogspot都经历了许多。

我们一次又一次的开始,然后充满厌倦的离开那些不再想去的地方
正如许多次的开始,不需要过去的回忆负担,
不需要为新生而相庆, 但是,这的确是一次值得写下的开始。

opera努力了,我依然的赞赏他。