Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
社内LT2019/11/7
Search
Kento Matsumoto
November 07, 2019
Programming
89
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
100
社内LT2020/01/23
stepanve
0
56
社内LT2019/11/21
stepanve
0
69
社内LT2019/10/24
stepanve
0
77
Other Decks in Programming
See All in Programming
「つくるAI」だけではバグは見つからない ~テストに必要な「見つけるAI」を分離させる戦略~
mfunaki
0
230
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
130
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
260
Hono + Inertia + React で LP を構築した話
oukayuka
2
210
Go 1.27からのGODEBUG / Go 1.27 リリースパーティ #go127party
mazrean
0
310
業務時間外もAIに働いてもらう話
colorful12
3
10k
Seeing Through Serverless: Observability for AWS Lambda with ADOT and CloudWatch Application Signals
seike460
PRO
1
120
Press start. Python's next generation.
willingc
PRO
3
310
MIZARU@SPAJAM2026 第二回予選
1901drama
0
110
ソフトウェアラスタライザ
fadis
1
790
Building an Out-of-Order CPU
latte72
0
680
ALB ログから Trace を気合で繋げる技術
fohte
7
870
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
How to Think Like a Performance Engineer
csswizardry
28
2.8k
Site-Speed That Sticks
csswizardry
13
1.5k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
190
HDC tutorial
michielstock
2
850
Designing Powerful Visuals for Engaging Learning
tmiket
1
530
Why Our Code Smells
bkeepers
PRO
340
58k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
420
Testing 201, or: Great Expectations
jmmastey
46
8.3k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
The SEO Collaboration Effect
kristinabergwall1
1
550
The World Runs on Bad Software
bkeepers
PRO
72
12k
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; リアルタイム性が求められないような週次レポートのようなものに最適