欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

怎么解決PostgreSQL窗口函數(shù)調(diào)用的限制-創(chuàng)新互聯(lián)

這篇文章主要講解了“怎么解決PostgreSQL窗口函數(shù)調(diào)用的限制”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“怎么解決PostgreSQL窗口函數(shù)調(diào)用的限制”吧!

成都創(chuàng)新互聯(lián)是專業(yè)的倉山網(wǎng)站建設(shè)公司,倉山接單;提供網(wǎng)站設(shè)計制作、網(wǎng)站設(shè)計,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行倉山網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊,希望更多企業(yè)前來合作!

背景

窗口函數(shù)是分析場景常用的,目前(citus 7.5)僅支持兩種場景使用window函數(shù),

1、partition by 必須是分布鍵。

2、where條件里面帶分布鍵的等值過濾條件。

本質(zhì)上:目前(citus 7.5)window函數(shù)不支持跨shard操作,或者說過程中不進(jìn)行重分布。

而Greenplum這方面做得很好,是一個完整的MPP數(shù)據(jù)庫。

citus window函數(shù)的支持

postgres=# \set VERBOSITY verbose  
  
  
postgres=# select row_number() over(partition by bid order by aid) rn,* from pgbench_accounts;  
ERROR:  0A000: could not run distributed query because the window function that is used cannot be pushed down  
HINT:  Window functions are supported in two ways.   
Either add an equality filter on the distributed tables' partition column   
or   
use the window functions with a PARTITION BY clause containing the distribution column  
LOCATION:  DeferErrorIfQueryNotSupported, multi_logical_planner.c:938

滿足以下條件即可支持

1、partition by 必須是分布鍵。

2、where條件里面帶分布鍵的等值過濾條件。

postgres=# select row_number() over(partition by bid order by aid) rn,* from pgbench_accounts where aid=1;  
 rn | aid | bid | abalance |                                        filler                                          
----+-----+-----+----------+--------------------------------------------------------------------------------------  
  1 |   1 |   1 |        0 |                                                                                       
(1 row)  
  
postgres=# select row_number() over(partition by aid order by bid) rn,* from pgbench_accounts  limit 1;  
 rn | aid | bid | abalance |                                        filler                                          
----+-----+-----+----------+--------------------------------------------------------------------------------------  
  1 | 298 |   1 |        0 |                                                                                       
(1 row)

執(zhí)行計劃

postgres=# explain verbose select row_number() over(partition by aid order by bid) rn,* from pgbench_accounts  limit 1;  
                                                                       QUERY PLAN                                                                          
---------------------------------------------------------------------------------------------------------------------------------------------------------  
 Limit  (cost=0.00..0.00 rows=0 width=0)  
   Output: remote_scan.rn, remote_scan.aid, remote_scan.bid, remote_scan.abalance, remote_scan.filler  
   ->  Custom Scan (Citus Real-Time)  (cost=0.00..0.00 rows=0 width=0)  
         Output: remote_scan.rn, remote_scan.aid, remote_scan.bid, remote_scan.abalance, remote_scan.filler  
         Task Count: 128  
         Tasks Shown: One of 128  
         ->  Task  
               Node: host=172.24.211.224 port=1921 dbname=postgres  
               ->  Limit  (cost=705.99..706.01 rows=1 width=105)  
                     Output: (row_number() OVER (?)), pgbench_accounts.aid, pgbench_accounts.bid, pgbench_accounts.abalance, pgbench_accounts.filler  
                     ->  WindowAgg  (cost=705.99..860.95 rows=7748 width=105)  
                           Output: row_number() OVER (?), pgbench_accounts.aid, pgbench_accounts.bid, pgbench_accounts.abalance, pgbench_accounts.filler  
                           ->  Sort  (cost=705.99..725.36 rows=7748 width=97)  
                                 Output: pgbench_accounts.aid, pgbench_accounts.bid, pgbench_accounts.abalance, pgbench_accounts.filler  
                                 Sort Key: pgbench_accounts.aid, pgbench_accounts.bid  
                                 ->  Seq Scan on public.pgbench_accounts_106812 pgbench_accounts  (cost=0.00..205.48 rows=7748 width=97)  
                                       Output: pgbench_accounts.aid, pgbench_accounts.bid, pgbench_accounts.abalance, pgbench_accounts.filler  
(17 rows)  
  
postgres=# explain verbose select row_number() over(partition by bid order by aid) rn,* from pgbench_accounts where aid=1;  
                                                                         QUERY PLAN                                                                            
-------------------------------------------------------------------------------------------------------------------------------------------------------------  
 Custom Scan (Citus Router)  (cost=0.00..0.00 rows=0 width=0)  
   Output: remote_scan.rn, remote_scan.aid, remote_scan.bid, remote_scan.abalance, remote_scan.filler  
   Task Count: 1  
   Tasks Shown: All  
   ->  Task  
         Node: host=172.24.211.232 port=1921 dbname=postgres  
         ->  WindowAgg  (cost=2.51..2.53 rows=1 width=105)  
               Output: row_number() OVER (?), aid, bid, abalance, filler  
               ->  Sort  (cost=2.51..2.51 rows=1 width=97)  
                     Output: aid, bid, abalance, filler  
                     Sort Key: pgbench_accounts.bid  
                     ->  Index Scan using pgbench_accounts_pkey_106819 on public.pgbench_accounts_106819 pgbench_accounts  (cost=0.28..2.50 rows=1 width=97)  
                           Output: aid, bid, abalance, filler  
                           Index Cond: (pgbench_accounts.aid = 1)  
(14 rows)

Citus未在window調(diào)用中支持重分布的過程。

greenplum window函數(shù)的支持

支持任意姿勢的window調(diào)用

postgres=# create table t(id int, c1 int, c2 int);  
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table.  
HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.  
CREATE TABLE  
  
postgres=# insert into t select random()*100000, random()*10, random()*100 from generate_series(1,10000000);  
INSERT 0 10000000  
  
postgres=# explain select row_number() over (partition by c1 order by id) rn,* from t ;  
                                                    QUERY PLAN                                                      
------------------------------------------------------------------------------------------------------------------  
 Gather Motion 33:1  (slice2; segments: 33)  (cost=1477974.88..1553064.94 rows=10012008 width=12)  
   ->  Window  (cost=1477974.88..1553064.94 rows=303395 width=12)  
         Partition By: c1  
         Order By: id  
         ->  Sort  (cost=1477974.88..1503004.90 rows=303395 width=12)  
               Sort Key: c1, id  
               // 以下在citus中用臨時表代替  
	       ->  Redistribute Motion 33:33  (slice1; segments: 33)  (cost=0.00..313817.24 rows=303395 width=12)  
                     Hash Key: c1  
                     ->  Seq Scan on t  (cost=0.00..113577.08 rows=303395 width=12)  
 Optimizer status: legacy query optimizer  
(10 rows)

甚至一個SQL中支持多個不同維度的partition

postgres=# explain select row_number() over (partition by c1 order by id) rn1, row_number() over (partition by c2 order by c1) rn2, * from t ;  
                                                                   QUERY PLAN                                                                     
------------------------------------------------------------------------------------------------------------------------------------------------  
 Gather Motion 33:1  (slice3; segments: 33)  (cost=3017582.83..3192792.97 rows=10012008 width=12)  
   ->  Subquery Scan coplan  (cost=3017582.83..3192792.97 rows=303395 width=12)  
         ->  Window  (cost=3017582.83..3092672.89 rows=303395 width=12)  
               Partition By: coplan.c1  
               Order By: coplan.id  
               ->  Sort  (cost=3017582.83..3042612.85 rows=303395 width=12)  
                     Sort Key: coplan.c1, coplan.id  
                     // 以下在citus中用臨時表代替  
		     ->  Redistribute Motion 33:33  (slice2; segments: 33)  (cost=1477974.88..1853425.18 rows=303395 width=12)  
                           Hash Key: coplan.c1  
                           ->  Subquery Scan coplan  (cost=1477974.88..1653185.02 rows=303395 width=12)  
                                 ->  Window  (cost=1477974.88..1553064.94 rows=303395 width=12)  
                                       Partition By: t.c2  
                                       Order By: t.c1  
                                       ->  Sort  (cost=1477974.88..1503004.90 rows=303395 width=12)  
                                             Sort Key: t.c2, t.c1  
                                             // 以下在citus中用臨時表代替  
					     ->  Redistribute Motion 33:33  (slice1; segments: 33)  (cost=0.00..313817.24 rows=303395 width=12)  
                                                   Hash Key: t.c2  
                                                   ->  Seq Scan on t  (cost=0.00..113577.08 rows=303395 width=12)  
 Optimizer status: legacy query optimizer  
(19 rows)

感謝各位的閱讀,以上就是“怎么解決PostgreSQL窗口函數(shù)調(diào)用的限制”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對怎么解決PostgreSQL窗口函數(shù)調(diào)用的限制這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

網(wǎng)站欄目:怎么解決PostgreSQL窗口函數(shù)調(diào)用的限制-創(chuàng)新互聯(lián)
網(wǎng)址分享:http://aaarwkj.com/article12/cdhedc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計、移動網(wǎng)站建設(shè)App設(shè)計、建站公司、營銷型網(wǎng)站建設(shè)、面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司
欧美性大片一区二区三区| 蜜桃av噜噜一区二区三| 免费黄色一区二区三区| 日本东京热二三四区不卡免费的 | 日本一区两区三区不卡视频| 久久99热婷婷精品一区| 91麻豆粉色视频在线| 日本东京热在线免费观看| 精品人妻区二区三区蜜桃| 高清高潮少妇一区二区三区| 91精品人妻一区二区三区| 亚洲一区二区三区av蜜桃| 国产三级国产精品三级| 国产三级黄色大片在线免费看| 免费人成黄页网站在线播放国产| 日本欧美三级高潮受不了| 日韩一区二区三级电影| 91伊人手机在线观看| av天堂网站在线观看| 国产成人综合久久二区| 久久成人激情免费视频| 欧美另类精品一区二区三区| 日本少妇激情后入嗯啊| 国产精品美女自拍视频| 亚洲精品美女久久久久高潮| 麻豆视频91免费观看| 日本束缚人妻一区二区三区| 天天干夜夜操天天射| 中文字幕一区二区精品区| 国产区青青操自拍视频| 国产一级二级三级黄色| 国产a情人一区二区国产| 国产成人免费公开视频| 激情五月婷婷久久av| 国产一区二区黑丝美女| 麻豆国产av巨做国产剧情| 精品久久久噜噜噜久久| 精品亚洲国产成人av| 亚洲人成免费观看网站| 一区二区三区av夏目彩春| 中文日本强暴人妻另类视频|