KADB 是北京人大金仓信息技术股份有限公司基于开源的greenplum数据库研发的一款分布式关系型数据库,全称是KingbaseAnalyticsDataBase。
学习kadb的空间数据处理
连接测试数据库;
psql postgres
手动执行数据类型测试语句集;
1、构造并存储空间数据类型
CREATE TABLE global_points (
id SERIAL PRIMARY KEY,
name VARCHAR(64),
location GEOGRAPHY(POINT,4326)
); --创建GEOGRAPHY类型表
create table points(p point);
2、插入测试数据
INSERT INTO global_points (name, location) VALUES ('Town', 'SRID=4326;POINT(-110 30)');
INSERT INTO global_points (name, location) VALUES ('Forest', 'SRID=4326;POINT(-109 29)');
INSERT INTO global_points (name, location) VALUES ('London', 'SRID=4326;POINT(0 49)');
insert into points(p) values (point '(1,1)'), (point '(3,2)'), (point '(6,3)'),(point '(5,5)'), (point '(7,8)'), (point '(8,6)');
3、创建gist索引
create index points_p_idx on points using gist(p); --创建gist索引
4、执行查询语句,验证执行计划使用到gist索引
explain analyze select * from points where p <@ box '(2,1),(7,4)'; --查找给定矩形中包含的所有点
5、数据查询、分析
SELECT * FROM global_points; --查询数据
select st_distance(
'POINT(73.712769 15.651955)'::geography,
'POINT(74.131451 14.806993)'::geography) AS d; --计算距离
kadb数据库支持空间数据类型的存储,支持对空间数据类型列添加索引,支持空间数据类型的查询、分析,支持空间数据类型的导入导出。