我在redshift DB中有几个架构,让我们说 sch1 和 sch2 ,并有一个名为 txn 的表格我可以访问 sch1.txn和sch2.txn
在根据以下来自redshift doc(http://docs.aws.amazon.com/redshift/latest/dg/diagnostic-queries-for-query-tuning.html#identify-tables-with-data-skew-or-unsorted-rows)的查询识别数据偏差的过程中,我无法找到列出的表 txn sch2 但仅限 sch1
SELECT trim(pgn.nspname) AS SCHEMA,
trim(a.name) AS TABLE,
id AS tableid,
decode(pgc.reldiststyle,0, 'even',1,det.distkey,8,'all') AS distkey,
dist_ratio.ratio::decimal(10,4) AS skew,
det.head_sort AS "sortkey",
det.n_sortkeys AS "#sks",
b.mbytes,
decode(b.mbytes,0,0,((b.mbytes/part.total::decimal)*100)::decimal(5,2)) AS pct_of_total,
decode(det.max_enc,0,'n','y') AS enc,
a.rows,
decode(det.n_sortkeys, 0, NULL, a.unsorted_rows) AS unsorted_rows,
decode(det.n_sortkeys, 0, NULL, decode(a.rows,0,0, (a.unsorted_rows::decimal(32)/a.rows)*100))::decimal(5,2) AS pct_unsorted
FROM
(SELECT db_id,
id,
name,
sum(ROWS) AS ROWS,
sum(ROWS)-sum(sorted_rows) AS unsorted_rows
FROM stv_tbl_perm a
GROUP BY db_id,
id,
name) AS a
JOIN pg_class AS pgc ON pgc.oid = a.id
JOIN pg_namespace AS pgn ON pgn.oid = pgc.relnamespace
LEFT OUTER JOIN
(SELECT tbl,
count(*) AS mbytes
FROM stv_blocklist
GROUP BY tbl) b ON a.id=b.tbl
INNER JOIN
(SELECT attrelid,
min(CASE attisdistkey
WHEN 't' THEN attname
ELSE NULL
END) AS "distkey",
min(CASE attsortkeyord
WHEN 1 THEN attname
ELSE NULL
END) AS head_sort,
max(attsortkeyord) AS n_sortkeys,
max(attencodingtype) AS max_enc
FROM pg_attribute
GROUP BY 1) AS det ON det.attrelid = a.id
INNER JOIN
(SELECT tbl,
max(mbytes)::decimal(32)/min(mbytes) AS ratio
FROM
(SELECT tbl,
trim(name) AS name,
slice,
count(*) AS mbytes
FROM svv_diskusage
GROUP BY tbl,
name,
slice)
GROUP BY tbl,
name) AS dist_ratio ON a.id = dist_ratio.tbl
JOIN
(SELECT sum(capacity) AS total
FROM stv_partitions
WHERE part_begin=0 ) AS part ON 1=1
WHERE mbytes IS NOT NULL
ORDER BY mbytes DESC;
在调试原因如下所示,我发现txn只列出一次,对应于 sch1 ,但正如我之前提到的,我可以用sch1和sch2访问它们。这非常令人困惑。
有人可以帮助我理解,如果这是模式的某些权限问题,但我也发现基于ACL,用户有权同时使用&为架构创建。
是否可以在schema ???
之间隐式链接表rsdb=# SELECT db_id,
id,
name,
sum(ROWS) AS ROWS,
sum(ROWS)-sum(sorted_rows) AS unsorted_rows
FROM stv_tbl_perm a where name = 'txn'
GROUP BY db_id,
id,
name;
db_id | id | name | rows | unsorted_rows
--------+--------+--------------------------------------------------------------------------+----------+---------------
100082 | 242000 | txn | 65540000 | 65540000