宠辱不惊,看庭前花开花落;去留无意,望天空云卷云舒

每秒N条记录到数据库history表中.

上一篇 / 下一篇  2007-09-19 16:20:08

思想:统计到history表中一秒中记录数,stamp为写入数据庫的系统时间。convert(varchar,stamp,20),把系统时间转换为秒,SQL里的显示是微秒。在SQL里stamp最好加索引。增加查询速度。

SQL:
select top 100 convert(varchar,stamp,20) ,count(1) from history where stamp< getdate()-1 group by convert(varchar,stamp,20)

oracle:

select stamp,count(1) from history where stamp>SYSDATE-100 group by stamp order by count(1) desc


TAG:

 

评分:0

我来说两句

Open Toolbar