首页 文章 精选 留言 我的

精选列表

搜索[逻辑模型],共10006篇文章
优秀的个人博客,低调大师

MaxCompute 实现增量数据推送(全量比对增量逻辑)

ODPS 2.0 支持了很多新的集合命令(专有云升级到3版本后陆续支持),简化了日常工作中求集合操作的繁琐程度。增加的SQL语法包括:UNOIN ALL、UNION DISTINCT并集,INTERSECT ALL、INTERSECTDISTINCT交集,EXCEPT ALL、EXCEPT DISTINCT补集。语法格式如下: select_statement UNION ALL select_statement; select_statement UNION [DISTINCT] select_statement; select_statement INTERSECT ALL select_statement; select_statement INTERSECT [DISTINCT] select_statement; select_statement EXCEPT ALL select_statement; select_statement EXCEPT [DISTINCT] select_statement; select_statement MINUS ALL select_statement; select_statement MINUS [DISTINCT] select_statement; 用途:分别求两个数据集的并集、交集以及求第二个数据集在第一个数据集中的补集。参数说明:• UNION: 求两个数据集的并集,即将两个数据集合并成一个数据集。• INTERSECT:求两个数据集的交集。即输出两个数据集均包含的记录。• EXCEPT: 求第二个数据集在第一个数据集中的补集。即输出第一个数据集包含而第二个数据集不包含的记录。• MINUS: 等同于EXCEPT。 具体语法参考:https://help.aliyun.com/document_detail/73782.html?spm=5176.11065259.1996646101.searchclickresult.718d3520fmmOJ0 实际项目中有一个利用两日全量数据,比对出增量的需求(推送全量数据速度很慢,ADB/DRDS等产品数据量超过1亿,建议试用增量同步)。我按照旧的JOIN方法和新的集合方法做了下比对验证,试用了下新的集合命令EXCEPT ALL。测试 -- 方法一:JOIN -- other_columns 代表很多列 create table tmp_opcode1 as select * from( select uuid,other_columns,opcode2 from( -- 今日新增+今日变化 select t1.uuid ,t1.other_columns ,case when t2.uuid is null then 'I' else 'U' end AS opcode2 from prject1.table1 t1 left outer join prject1.table1 t2 on t1.uuid=t2.uuid and t2.dt='20200730' where t1.dt='20200731' and(t2.uuid is null or coalesce(t1.other_columns,'')<>coalesce(t2.other_columns,'')) union all -- 今日删除 select t2.uuid ,t2.other_columns ,'D' as opcode2 from prject1.table1 t2 left outer join prject1.table1 t1 on t1.uuid=t2.uuid and t1.dt='20200731' where t2.dt='20200730' and t1.uuid is null)t3)t4 ; Summary: resource cost: cpu 13.37 Core * Min, memory 30.48 GB * Min inputs: prject1.table1/dt=20200730: 32530802 (946172216 bytes) prject1.table1/dt=20200731: 32533538 (947161664 bytes) outputs: prject1.tmp_opcode1: 4506 (271632 bytes) Job run time: 26.000 -- 方法二:集合 -- other_columns 代表很多列 create table tmp_opcode2 as select * from( select t3.* from( -- 今日新增+今日变化 select uuid,other_columns,'I' as opcode2 from( select uuid,other_columns from prject1.table1 where dt = '20200731' except all select uuid,other_columns from prject1.table1 where dt = '20200730')t union all -- 今日删除 select t2.uuid ,t2.other_columns ,'D' as opcode2 from prject1.table1 t2 left outer join prject1.table1 t1 on t1.uuid=t2.uuid and t1.dt='20200731' where t2.dt='20200730' and t1.uuid is null)t3)t4 ; Summary: resource cost: cpu 35.92 Core * Min, memory 74.26 GB * Min inputs: prject1.table1/rfq=20200730: 32530802 (946172216 bytes) prject1.table1/rfq=20200731: 32533538 (947161664 bytes) outputs: prject1.tmp_opcode2: 4506 (259416 bytes) Job run time: 66.000 性能集合的方法与JOIN的方法相比,在资源(1倍)使用和时间(1倍)上都有较多的劣势。建议实际使用JOIN方法。结果通过多种方法比对验证,两种方法的增量识别均正确,可以向下游提供增量数据。

优秀的个人博客,低调大师

阿里云postgreSQL数据库跨区域逻辑备份

一、创建阿里云存储网关参考链接:https://help.aliyun.com/document_detail/108244.html 注意购买OSS bucket的区域与数据库实例所在的区域不同。 二、在与存储网关同一区域的ECS机器上面,挂载存储网关:mount.nfs x.x.x.x:/shares /ossx.x.x.x:/shares是网关的挂载点,/oss为本地目录参考链接:https://help.aliyun.com/document_detail/108284.html最好将nfs挂载点也写入/etc/fstab文件,重启自动挂载。 三、在ECS机器上安装postgreSQL备份工具1、https://www.postgresql.org/ftp/source/ 下载相应的数据库版本(与云rds版本相近) 2、解压、安装编译安装目录为:/usr/local/pgsql/gunzip postgresql-10.1.tar.gztar xf postgresql-10.1.tar./configure --prefix=/usr/local/pgsql/makemake install 在pg_dump用户目录下,新建.pgpass文件,权限设为600,或者更小的权限格式形如: hostname:port:database:username:password 四、编写postgreSQL备份脚本 #!/bin/bash hostname=xxx.pg.rds.aliyuncs.com username=xxx port=xxx database=xxx dt=`date +%Y%m%d` /usr/local/pgsql/bin/pg_dump -h $hostname -U $username -p $port -d $database -o -f /oss/db_$dt.bak if [ -z "`find /oss -name "*.bak" -mtime 0 -print0`" ] then echo "warning!postgreSQL_backup is failure,please check it!" | mail -s postgreSQL-backup xxx@xxx.com fi 将脚本添加进任务计划中,即可。 五、还原方法登录ECS主机,执行命令:/usr/local/pgsql/bin/pgsql -h xxx.pg.rds.aliyuncs.com -U xxx -d xxx < db_xxx.bak

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册