Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
社内LT2019/11/7
Search
Kento Matsumoto
November 07, 2019
Programming
93
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
社内LT2019/11/7
Kento Matsumoto
November 07, 2019
More Decks by Kento Matsumoto
See All by Kento Matsumoto
ストーリーポイント.pdf
stepanve
0
110
社内LT2020/01/23
stepanve
0
60
社内LT2019/11/21
stepanve
0
70
社内LT2019/10/24
stepanve
0
81
Other Decks in Programming
See All in Programming
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
390
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.1k
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
330
iOSDC2026登壇資料.pdf
riofujimon
0
200
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
470
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
470
Java 27新機能 / Java 27 new features
kishida
2
190
setup-vp GitLab対応の裏側
naokihaba
0
150
Security issues being discussed on Web Platforms
petamoriken
0
1.4k
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
210
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
160
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
330
Featured
See All Featured
Un-Boring Meetings
codingconduct
0
440
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.2k
The browser strikes back
jonoalderson
0
1.7k
The Curse of the Amulet
leimatthew05
3
15k
Abbi's Birthday
coloredviolet
4
10k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Skip the Path - Find Your Career Trail
mkilby
1
240
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
530
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
First, design no harm
axbom
PRO
2
1.3k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
270
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
Transcript
PostgreSQLの便利な機能 社内勉強会:2019/11/7
テーブルとスキーマについて -- スキーマ作成 CREATE SCHEMA schema1; -- テーブル作成 CREATE TABLE
schema1.table( Id INTEGER ); -- スキーマの優先順位の調べ方 show search_path; Postgresには、データベースの中にスキーマという概念が存在する ※MySQLの場合、データベースとスキーマは同じ概念である DB1 DB2 schema1 table table schema1 同一DBに同じテー ブル名が作れる。 スキーマを指定せず に使用する場合 search_pathの順番 で検索される。
スキーマの目的 •1つのデータベースを多数のユーザが互いに干渉することなく使用できるようにする ため。 • 管理しやすくなるよう、データベースオブジェクトを論理グループに編成するため •サードパーティのアプリケーションを別々のスキーマに入れることにより、他のオブ ジェクトの名前と競合しないようにするため。 引用:https://www.postgresql.jp/document/9.4/html/ddl-schemas.html データベース内のアクセス権限を管理しやすくするため
式インデックス Indexに式を設定することができる。(ユニークキーとしても可能) -- インデックス作成 CREATE INDEX users_lower_id_idx ON users (lower(id));
-- 検索 EXPLAIN SELECT * FROM users WHERE lower(id) = '1'; * 省略 " -> Bitmap Index Scan on users_lower_id_idx (cost=0.00..4.53 rows=33 width=0)" Index Cond: (lower((id)::text) = '1'::text)
Materialized View - SQLの状態を保存することができる - 直接更新できない - 更新するタイミングを指定する必要がある (REFRESH MATERIALIZED
VIEW viewtable;) - Viewの場合、テーブルの内容を常に反映させるが、一度保存したものを使い回すため、リ ソースを使わないで済む (高速化)。 -- Materialized View 作成 CREATE MATERIALIZED VIEW viewtable AS SELECT * FROM users ORDER BY id LIMIT 10; -- Materialized View 更新 REFRESH MATERIALIZED VIEW viewtable; リアルタイム性が求められないような週次レポートのようなものに最適