This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =OFFSET(INDIRECT("Sheet2!A2"),0,0,COUNTA(INDIRECT("Sheet2!$A$2:$A$30")),1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SET SEARCH_PATH TO <schema name>; | |
| SELECT | |
| stv_tbl_perm.name AS table | |
| ,COUNT(*) AS mb | |
| FROM | |
| stv_blocklist, | |
| stv_tbl_perm | |
| WHERE | |
| stv_blocklist.tbl = stv_tbl_perm.id | |
| AND stv_blocklist.slice = stv_tbl_perm.slice |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- refer: http://dev.classmethod.jp/cloud/aws/amazon-redshift-tutorial-tuning-table-design/ | |
| -- システム生成の列を除外する為にWHERE句にcol < 6がある | |
| select col, max(blocknum) | |
| from stv_blocklist b, stv_tbl_perm p | |
| where (b.tbl=p.id) and name ='<table name>' | |
| and col < 6 | |
| group by name, col | |
| order by col; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| MAX(endtime) + INTERVAL '9 hour' AS last_query_time | |
| FROM | |
| stl_query r1 | |
| WHERE | |
| EXISTS (SELECT * | |
| FROM | |
| stl_querytext r2 | |
| WHERE | |
| r1.userid = r2.userid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| TO_CHAR(starttime + INTERVAL '9 hour', 'YYYY-MM-DD HH24:MI:SS') AS starttime | |
| ,TO_CHAR(endtime + INTERVAL '9 hour', 'YYYY-MM-DD HH24:MI:SS') AS endtime | |
| ,DATE_DIFF('sec', starttime, endtime) AS secs | |
| ,text | |
| FROM | |
| svl_statementtext | |
| WHERE | |
| sequence = 0 | |
| AND xid IN ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - gen.sh | |
| ``` bash | |
| #!/bin/sh | |
| # | |
| # [Usage] | |
| # args | |
| # 1. User ID | |
| # 2. Password | |
| # 3. Host | |
| # 4. Database Name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select current_time, c.relname, l.database, l.transaction, l.pid, a.usename, l.mode, l.granted from pg_catalog.pg_locks l join pg_catalog.pg_class c on c.oid = l.relation join pg_catalog.pg_stat_activity a on a.procpid = l.pid; | |
| set query_group to 'superuser'; | |
| select pg_terminate_backend(<pid>); | |
| reset query_group; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while :; do {処理}; sleep 1; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| REVOKE ALL ON DATABASE {db name} FROM {user id} CASCADE; | |
| REVOKE ALL ON SCHEMA {schema name 1} FROM {user id} CASCADE; | |
| REVOKE ALL ON SCHEMA {schema name 2} FROM {user id} CASCADE; | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --------------------------------------------------------------------------------------------- | |
| -- 以下を実行し、レポート表示に要した時間を取得する。 | |
| -- (Tableau Server データベースへの接続に関しては下記を参照) | |
| -- http://onlinehelp.tableau.com/current/server/ja-jp/help.htm#adminview_postgres.htm%3FTocPath%3D%25E7%25AE%25A1%25E7%2590%2586%25E8%2580%2585%25E3%2582%25AC%25E3%2582%25A4%25E3%2583%2589%7C%25E3%2582%25B5%25E3%2583%25BC%25E3%2583%2590%25E3%2583%25BC%25E3%2581%25AE%25E6%2593%258D%25E4%25BD%259C%7C%25E3%2582%25AB%25E3%2582%25B9%25E3%2582%25BF%25E3%2583%25A0%25E7%25AE%25A1%25E7%2590%2586%25E3%2583%2593%25E3%2583%25A5%25E3%2583%25BC%25E3%2581%25AE%25E4%25BD%259C%25E6%2588%2590%7C_____0 | |
| --------------------------------------------------------------------------------------------- | |
| SELECT | |
| r2.name AS site_name | |
| ,r1.currentsheet AS report_name | |
| ,r1.vizql_session AS session_id |