123
返回列表 发新帖
楼主: vfast21

[讨论] 求助 oracle like%..%模糊查询优化

[复制链接]
论坛徽章:
1
优秀写手
日期:2014-04-16 06:00:13
21#
 楼主| 发表于 2014-10-11 10:12 | 只看该作者
Yong Huang 发表于 2014-10-10 22:33
By the way, why is your index not partitioned?

Your 40-second response time (see msg #1) must be  ...

测试数据库
SQL> select component,current_size,min_size from v$sga_dynamic_components;

COMPONENT            CURRENT_SIZE   MIN_SIZE
-------------------- ------------ ----------
shared pool            1476395008 1207959552
large pool               67108864   67108864
java pool                67108864   67108864
streams pool             67108864   67108864
DEFAULT buffer cache   3154116608 3019898880
KEEP buffer cache               0          0
RECYCLE buffer cache            0          0
DEFAULT 2K buffer ca            0          0
che

DEFAULT 4K buffer ca            0          0

走组合索引过滤车牌号的时候产生了很多的逻辑读。

使用道具 举报

回复
论坛徽章:
86
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11优秀写手
日期:2013-12-18 09:29:11日产
日期:2013-10-17 08:44:39马自达
日期:2013-08-26 16:28:022013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-23 16:55:51马上有房
日期:2014-02-19 11:55:14
22#
发表于 2014-10-11 16:11 | 只看该作者
2、现在经理逼着我不管时间范围,查询数据量一亿,还要快速出结果。

有这个需求,还怎么搞?

使用道具 举报

回复
论坛徽章:
1
优秀写手
日期:2014-04-16 06:00:13
23#
 楼主| 发表于 2014-10-13 20:09 | 只看该作者
sundog315 发表于 2014-10-11 16:11
2、现在经理逼着我不管时间范围,查询数据量一亿,还要快速出结果。

有这个需求,还怎么搞?

嗯嗯,现在我按一个月一亿数据来考虑,数据保留三个月。

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
24#
发表于 2014-10-13 22:22 | 只看该作者
Why is your index not partitioned?

How much memory does the server have? Show us:
select * from v$osstat;
or type 'free' on command line (if it's Linux). Since you have a 3GB buffer cache, I suppose you don't have enough memory. Get a bigger box, with at least 64 GB RAM to meet the requirement and configure at least 40 GB as buffer cache.

If you have ASMM configured, "show parameter sga".

使用道具 举报

回复
论坛徽章:
25
生肖徽章2007版:虎
日期:2008-12-30 12:36:432011新春纪念徽章
日期:2011-03-17 20:18:272011新春纪念徽章
日期:2011-03-29 00:01:40ITPUB十周年纪念徽章
日期:2011-11-01 16:23:26紫蛋头
日期:2012-05-20 17:44:452014年新春福章
日期:2014-02-18 16:42:02马上有房
日期:2014-02-18 16:42:02马上有车
日期:2014-02-24 20:18:47慢羊羊
日期:2015-03-04 14:51:352015年新春福章
日期:2015-03-06 11:57:31
25#
发表于 2014-10-14 17:24 | 只看该作者
1亿的数据量,通过主键找都需要1秒。何况是用like‘‘%%’’。
希望有大师给你一个好的解决方案.

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
26#
发表于 2014-10-16 01:04 | 只看该作者
I tried to create a text index with chinese_lexer. But it doesn't seem to be what you want, unless I didn't get it right.

create table testcn (x varchar2(30));
insert into testcn values ('你好,川ABC123');
exec ctx_ddl.create_preference('chinese_lexer_pref', 'chinese_lexer')
exec ctx_ddl.set_attribute('chinese_lexer_pref', 'mixed_case_ASCII7', 'TRUE')
create index testcn_i on testcn (x) indextype is ctxsys.context parameters ('lexer chinese_lexer_pref');
select token_text from dr$testcn_i$i;

The last query shows 3 tokens (i.e. search keywords) have been created: ABC123, 你好, 川. Your application query would be like

select * from testcn where contains(x, 'ABC123') > 0;
select * from testcn where contains(x, '川') > 0;

Unfortunately, the following doesn't return anything:
select * from testcn where contains(x, 'BC123') > 0;
or even a fuzzy search ("fuzzy" in the real sense as in Oracle's Text Reference documentation)
select * from testcn where contains(x, 'fuzzy(BC123,,,weight)', 1) > 0;

使用道具 举报

回复
论坛徽章:
78
ITPUB15周年纪念
日期:2020-08-28 17:23:53双鱼座
日期:2016-03-19 19:38:31秀才
日期:2016-02-18 09:31:52秀才
日期:2016-01-25 15:02:04双子座
日期:2016-01-19 20:35:54秀才
日期:2016-01-13 12:14:26秀才
日期:2015-12-25 15:31:10秀才
日期:2015-12-18 09:28:57秀才
日期:2015-12-14 14:56:09秀才
日期:2015-12-14 14:51:16
27#
发表于 2014-10-16 16:56 来自手机 | 只看该作者
别想了,加快io,exadata肯定可以

使用道具 举报

回复
论坛徽章:
1
优秀写手
日期:2014-04-16 06:00:13
28#
 楼主| 发表于 2014-10-21 21:53 | 只看该作者
wolfop 发表于 2014-10-16 16:56
别想了,加快io,exadata肯定可以

谢谢!

使用道具 举报

回复
论坛徽章:
0
29#
发表于 2014-11-6 00:01 | 只看该作者
不认为建立其他索引能解决问题,每个月的数据已经3000万,维护索引也是要成本的。 3000万的数据下来每天平均100万行数据,范围查询一天的数据走索引还要回表100万次了,3秒怎么能出结果。。。 我觉得改成日分区, like '%闽KWHWTQ%'  能改成 like '闽KWHWTQ%' 不回表还有点可能。。。

使用道具 举报

回复
论坛徽章:
1
优秀写手
日期:2014-04-16 06:00:13
30#
 楼主| 发表于 2014-11-6 15:10 | 只看该作者
VipHop 发表于 2014-11-6 00:01
不认为建立其他索引能解决问题,每个月的数据已经3000万,维护索引也是要成本的。 3000万的数据下来每天平均 ...

现在是要俩边都匹配%!郁闷!

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表