免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8182 | 回复: 5
打印 上一主题 下一主题

关于大数据量的处理方法 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-03-24 10:14 |只看该作者 |倒序浏览
SYBASE版本12.5ASE
请教一下啊.我现在要处理一批比较大的数据,由于数据来源很多.目前是放在一个临时表内.
但是在后一步处理需要用一个实表与临时表做关联判断.发现很慢很慢,处理一次要4\5个小时.不知道有什么好的处理方法.

目前临时表我已加了索引.但是效果还是很慢.我把表结构放上来.

有处理\优化心得的朋友帮帮忙啊

create table #a_user_cost_tq
       (user_id char(14) not null,
       cal_date datetime not null,
       serial_num int default 0 not null,
       e_cost decimal(14,2) null,
       e_quan int null,
       book_id char(7) null,
       deal_flag_id char(1) null,
       dept_id char(6) null,
       invc_id char(2) null,
       invc_count int default 0 null,
       print_flag char(1) null,
       print_count int default 0 null,
       if_late_fee decimal(14,2) default 0 null,
       charge_enddate char(3) default '115' null,
       pay_type_id char(2) null,
       user_name varchar(60) null,
       user_addr varchar(60) null,
       coll_cost decimal(14,2) null,
       coll_date datetime null,
       coll_staff char(10) null,
       coll_dept char(6) null,
       old_user_id char(14) null,
       lock_bank char(2) null,
       lock_time datetime null,
       bank_pay_type char(1) null,
       plan_cost decimal(12,2) null,
       tpchrg_late_fee decimal(14,2) default 0 null,
       odd_cost decimal(12,2) null,
       tran_date datetime null,
       transfer_num char( null,
       bank_account char(30) null,
       late_fee decimal(12,2) default 0 null,
       user_type_id char(2) null,
       bank_serial char(12) null,
       charge_type_id char(1) default 'A' null,
       tqys int null,
       tqcs int null,
       score int null, primary key (user_id,cal_date,serial_num))

实表与这个临时表结构基本一致
select      @cal_date_1,a.user_id,"",'0700','',5,'0',a.dept_id
from collect_cost a  (INDEX PK_collect_cost)
where
a.cal_date>=dateadd(mm,-6,@cal_date_1)
and a.dept_id =@dept_id //and a.user_id <'010004748'
and NOT EXISTS (SELECT 'X'
                     from #a_user_cost_tq b
                    WHERE b.cal_date >= dateadd(mm, -6, @cal_date_1)
                      and b.dept_id = @dept_id
                      AND b.user_id = a.user_id
AND a.user_id >= CHAR(0)
and a.serial_num=0

论坛徽章:
0
2 [报告]
发表于 2008-03-24 18:13 |只看该作者
扩充tempdb试试看

论坛徽章:
0
3 [报告]
发表于 2008-03-28 13:40 |只看该作者
把你需要对比的主表数据也放到临时表中
把你以下部分共存的删掉不比你用not exists快呀,not exists 用不上索引
SELECT 'X'
                     from #a_user_cost_tq b
                    WHERE b.cal_date >= dateadd(mm, -6, @cal_date_1)
                      and b.dept_id = @dept_id
                      AND b.user_id = a.user_id
AND a.user_id >= CHAR(0)
and a.serial_num=0

论坛徽章:
0
4 [报告]
发表于 2008-06-15 15:54 |只看该作者
大数据量处理办法其实就是一个核心问题:数据存储算法。
只要针对系统需求,设计良好的算法,任何大数据量都不是问题。可以到我们的研究中心看看。http://www.distributed-cluster.com

论坛徽章:
71
15-16赛季CBA联赛之同曦
日期:2018-08-23 15:41:42辰龙
日期:2014-08-15 09:07:43狮子座
日期:2014-06-03 13:55:33亥猪
日期:2014-06-02 11:17:08巨蟹座
日期:2014-05-06 10:02:03午马
日期:2014-05-04 08:18:27亥猪
日期:2014-04-29 11:11:32技术图书徽章
日期:2014-04-24 15:51:26技术图书徽章
日期:2014-04-17 11:01:53辰龙
日期:2014-04-15 12:45:46亥猪
日期:2014-04-11 09:06:23射手座
日期:2014-04-01 15:28:10
5 [报告]
发表于 2008-06-15 17:05 |只看该作者
给tempdb绑定高速缓冲,试试

论坛徽章:
1
2017金鸡报晓
日期:2017-01-10 15:19:56
6 [报告]
发表于 2008-06-16 09:20 |只看该作者
SELECT 'X'
                     from #a_user_cost_tq b
                    WHERE b.cal_date >= dateadd(mm, -6, @cal_date_1)
                      and b.dept_id = @dept_id
                      AND b.user_id = a.user_id

1、看你的这个语句中只用到了#a_user_cost_tq 的几个字段,是否这个表没必要建这么多列?
2、用show plan看一下查询计划吧
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP