当日最热查询之SQL语句

Posted on 2009-01-12 21:55 Robert Su 阅读(247) 评论(0)  编辑  收藏 所属分类: 数据库
之前做联合查询很慢也很麻烦;需要对web_video表跟webvideo _day视图做联合查询,但是速度奇慢
select a.* from web_video a  webvideo b where a.id=b.id and a.site_id=?

换成这种方式之后就快多了
select a.* from web_video a where a.site_id=? and a.video_day=to_number(to_char(sysdate, 'yyyymmdd'));

video_day是一个物化视图 MATERIALIZED VIEW——可以大大提高数据库查询的速度。

只有注册用户登录后才能发表评论。


网站导航:
 

posts - 103, comments - 104, trackbacks - 0, articles - 5

Copyright © Robert Su