官網:http://www.pipelinedb.com/
pipelineDB是基於postgres的stream數據庫。完全兼容pg的東西。
由於產品需要解決性能這塊瓶頸,老大讓試試這款基於流計算的數據庫。
[pipeline@localhost ~]$ pipeline
pipeline (9.4.4)
Type "help" for help.
Create a static stream
CREATE STREAM stream_test1 (x integer, y integer,z text);
Create a CONTINUOUS
CREATE CONTINUOUS VIEW v_sum as select sum( x + y ) FROM stream_test1;
CREATE CONTINUOUS VIEW V_GROUP AS SELECT count(*) as coun,x,y,z FROM stream_test1 GROUP BY x,y,z;
Stream 只能被CONTINUOUS查詢,如果直接查詢會報錯:
pipeline=# select * from stream_test1; ERROR: "stream_test1" is a stream HINT: Streams can only be read by a continuous view's FROM clause.
插入數據到Stream
pipeline=# INSERT INTO stream_test1(x,y,z) VALUES(1,2,'A'),(3,4,'B'),(5,6,'C'),(7,8,'D'),(1,2,'A'); INSERT 0 5
查詢結果
pipeline=# select * from v_sum; sum ----- 39 (1 row) pipeline=# select * from v_group; coun | x | y | z ------+---+---+--- 1 | 5 | 6 | C 1 | 7 | 8 | D 1 | 3 | 4 | B 2 | 1 | 2 | A (4 rows)
在創建CONTINUOUS,后面select能寫分析函數,各種over(),這樣數據在不同窗口內時時計算,能很方便的解決性能問題。
這個view沒太詳細研究,貌似跟oracle的物化視圖類似。
關於UDF
PG是支持存儲過程的,自己寫FUNCTION,也支持PLLUA。
因為數據是從外部入庫,我這塊想把PLLUA集成到PG里面來,自己寫LUA來做庫內計算。
拿LUA替代plpgsql,性能應該會有很大一部分提升,有待測試。
