加了日期條件後查詢結果慢了100倍

2022-05-28 08:27:11 字數 1272 閱讀 2922

--下面這句秒出,不加use_hash也是秒出。

select /*+use_hash(i j d)*/ count(distinct i.f3070220000101_000048002) 戶,count(1) 人

from t3070220000101_000048_v1 i , t3070220000101_000042_v1 j ,dim_area_5lvl d

where i.f3070220000101_000048002=j.f3070220000101_000042003

and i.f3070220000101_000048036='否' and j.f3070220000101_000042040='否'

and nvl(j.f3070220000101_000042036,'正常')<>'減少'

and nvl(i.f3070220000101_000048029,'沒有變動')='沒有變動'

and substr(i.f3070220000101_000048005,1,12)=d.country_id

and d.city_name_s='清遠市';

--下面這句過了很久很久才有結果,不在為啥,ij表只有乙個時間片的記錄.

select /*+use_hash(i j d)*/ count(distinct i.f3070220000101_000048002) 戶,count(1) 人

from t3070220000101_000048_v1 i , t3070220000101_000042_v1 j ,dim_area_5lvl d

where i.f3070220000101_000048002=j.f3070220000101_000042003

and i.f3070220000101_000048036='否' and j.f3070220000101_000042040='否'

and nvl(j.f3070220000101_000042036,'正常')<>'減少'

and nvl(i.f3070220000101_000048029,'沒有變動')='沒有變動'

and substr(i.f3070220000101_000048005,1,12)=d.country_id

and i.f3070220000101_000048001=20190827             -----多加的條件

and j.f3070220000101_000042001=20190827             -----多加的條件

and d.city_name_s='清遠市';

java mysql 條件查詢日期時間

1 查詢當天的記錄 select from hb article view where to days hb addtime to days now 查詢當前這週的資料 select name,submittime from enterprise where yearweek date format...

對jdbcTemplated查詢後的結果進行處理

對jdbctemplated查詢後的結果進行處理 string sql select work for building ids from face sign contract woker string a jdbctemplate.queryforobject sql,string.class 用...

使用Sql按日期條件查詢

查詢當天 1 select from shoporder where datediff day,ordtime,getdate 1 0 查詢當天 2 select from info where datediff dd,datetime,getdate 0 前30天 select from a wh...