リビジョン | 69bda1b7d91617da011bad54ea6e9e332fe6b685 (tree) |
---|---|
日時 | 2013-08-15 14:01:07 |
作者 | Takashi Suzuki <suzuki.takashi@metr...> |
コミッター | Takashi Suzuki |
Merge branch 'add_id'
@@ -110,7 +110,7 @@ postgres=# | ||
110 | 110 | </tr></thead> |
111 | 111 | <tbody> |
112 | 112 | <tr><td>id</td> |
113 | - <td>識別番号です。連番型ですので、新しいヒントを登録するときにはこの列を指定せずに登録してください。クエリやアプリケーション名やヒントを更新するときに使用してください。</td></tr> | |
113 | + <td>ユーザがヒントを識別するための番号です。連番型ですので、新しいヒントを登録するときにはこの列を指定しないでください。</td></tr> | |
114 | 114 | <tr><td>norm_query_string</td> |
115 | 115 | <td>実行計画を制御したいクエリを指定します。対象のクエリに定数があるときは、下記の例のように「?」に置き換えます。キーワード間の空白の数が、登録するクエリと実行するクエリで異なると別のSQL文として扱われます。</td></tr> |
116 | 116 | <tr><td>application_name</td> |
@@ -119,6 +119,27 @@ postgres=# | ||
119 | 119 | <td>ヒントを指定します。ヒント以外のもの(SQLコメントなど)を含めないでください。</td></tr> |
120 | 120 | </tbody> |
121 | 121 | </table> |
122 | +<p>ヒントの登録情報を変更する場合は、変更したい登録情報のidを指定して登録情報を更新してください。</br> | |
123 | +ヒントの登録を解除する場合は、解除したい登録情報のidを指定してテーブルから削除してください。</p> | |
124 | +<p>以下の例では、ヒントの登録、ヒント登録情報の変更、ヒントの登録解除の順に、クエリの実行結果を示しています。 | |
125 | +</p> | |
126 | +<pre> | |
127 | +postgres=# INSERT INTO hint_plan.hints(norm_query_string, application_name, hints) | |
128 | +postgres-# VALUES ( | |
129 | +postgres(# 'EXPLAIN (COSTS false) SELECT * FROM t1 WHERE t1.id = ?;', | |
130 | +postgres(# '', | |
131 | +postgres(# 'SeqScan(t1)' | |
132 | +postgres(# ); | |
133 | +INSERT 0 1 | |
134 | +postgres=# UPDATE hint_plan.hints | |
135 | +postgres-# SET hints = 'IndexScan(t1)' | |
136 | +postgres-# WHERE id = 1; | |
137 | +UPDATE 1 | |
138 | +postgres=# DELETE FROM hint_plan.hints | |
139 | +postgres-# WHERE id = 1; | |
140 | +DELETE 1 | |
141 | +postgres=# | |
142 | +</pre> | |
122 | 143 | <p>以下の例では、テーブルに登録した「コメントでの指定」の例と同じヒントと、登録したクエリの実行結果を示しています。</p> |
123 | 144 | <pre> |
124 | 145 | postgres=# SELECT * FROM hint_plan.hints; |
@@ -142,6 +142,7 @@ SET pg_hint_plan.enable_hint_table TO on; | ||
142 | 142 | hints | text | not null |
143 | 143 | Indexes: |
144 | 144 | "hints_pkey" PRIMARY KEY, btree (id) |
145 | + "hints_norm_and_app" UNIQUE, btree (norm_query_string, application_name) | |
145 | 146 | |
146 | 147 | ---- |
147 | 148 | ---- No. A-6-2 search condition |
@@ -142,6 +142,7 @@ SET pg_hint_plan.enable_hint_table TO on; | ||
142 | 142 | hints | text | not null |
143 | 143 | Indexes: |
144 | 144 | "hints_pkey" PRIMARY KEY, btree (id) |
145 | + "hints_norm_and_app" UNIQUE, btree (norm_query_string, application_name) | |
145 | 146 | |
146 | 147 | ---- |
147 | 148 | ---- No. A-6-2 search condition |
@@ -10,3 +10,7 @@ CREATE TABLE hint_plan.hints ( | ||
10 | 10 | hints text NOT NULL, |
11 | 11 | PRIMARY KEY (id) |
12 | 12 | ); |
13 | +CREATE UNIQUE INDEX hints_norm_and_app ON hint_plan.hints ( | |
14 | + norm_query_string, | |
15 | + application_name | |
16 | +); |