|
22 | 22 | <note>
|
23 | 23 | <para>
|
24 | 24 | <!--
|
25 |
| - Basically following SELECTs will not be cached: |
| 25 | + First of all if the query starts with SQL comment: |
26 | 26 | <programlisting>
|
27 |
| - SELECTs including non immutable functions |
28 |
| - SELECTs including temp tables, unlogged tables |
29 |
| - SELECT result is too large (memqcache_maxcache) |
30 |
| - SELECT FOR SHARE/UPDATE |
31 |
| - SELECT starting with "/*NO QUERY CACHE*/" comment |
32 |
| - SELECT including system catalogs |
33 |
| - SELECT uses TABLESAMPLE |
34 |
| - </programlisting> |
| 27 | + /*FORCE QUERY CACHE*/ |
| 28 | + </programlisting> |
| 29 | + is checked (case insensitive). If so, the result of the query is |
| 30 | + cached unconditionally as long as it is not SELECT or WITH + SELECT. |
| 31 | + However you must be very careful to use this feature. For example, |
| 32 | + <programlisting> |
| 33 | + /*FORCE QUERY CACHE*/SELECT now(); |
| 34 | + </programlisting> |
| 35 | + will return the same timestamp until pgpool restarts, once the |
| 36 | + query is cached. The query cache will not be discarded even with a |
| 37 | + query: |
| 38 | + <programlisting> |
| 39 | + /*NO QUERY CACHE*/SELECT now(); |
| 40 | + </programlisting> |
| 41 | + Because it just prevents to create a cache entry for the query, and |
| 42 | + does not affect the query using the FORCE QUERY CACHE comment. |
| 43 | + </programlisting> |
| 44 | + Because it just prevents to create a cache entry for the query, and |
| 45 | + does not affect the query using the FORCE QUERY CACHE comment. |
| 46 | + --> |
| 47 | + まず、クエリが以下のSQLコメントで始まるかどうかがチェックされます(大文字小文字は区別されません)。 |
| 48 | + <programlisting> |
| 49 | + /*FORCE QUERY CACHE*/ |
| 50 | + </programlisting> |
| 51 | + もしこのコメントで始まっているなら、そのクエリがSELECTあるいはWITH + SELECTである限り無条件にキャッシュされます。 |
| 52 | + しかし、この機能は注意深く使う必要があります。 |
| 53 | + たとえば、 |
| 54 | + <programlisting> |
| 55 | + /*FORCE QUERY CACHE*/SELECT now(); |
| 56 | + </programlisting> |
| 57 | + このクエリがキャッシュされると、pgpoolが再起動するまで同じタイムスタンプを返し続けます。 |
| 58 | + このクエリキャッシュは、以下のクエリによってさえも削除されません。 |
| 59 | + <programlisting> |
| 60 | + /*NO QUERY CACHE*/SELECT now(); |
| 61 | + </programlisting> |
| 62 | + なぜなら、これはこのクエリのキャッシュエントリが作成されないようにするだけで、FORCE QUERY CACHEコメントを使ったクエリには影響を与えないからです。 |
| 63 | + </para> |
| 64 | + <para> |
| 65 | + <!-- |
| 66 | + Note that for following query: |
| 67 | + <programlisting> |
| 68 | + /*FORCE QUERY CACHE*/SELECT * FROM t1; |
| 69 | + </programlisting> |
| 70 | + usual cache validation due to an update to the table (in this case |
| 71 | + t1) works. |
| 72 | + --> |
| 73 | + 次のクエリ |
| 74 | + <programlisting> |
| 75 | + /*FORCE QUERY CACHE*/SELECT * FROM t1; |
| 76 | + </programlisting> |
| 77 | + に対しては、テーブル(この場合はt1)の更新によるキャッシュの削除は機能することに注意してください。 |
| 78 | + </para> |
| 79 | + <para> |
| 80 | + <!-- |
| 81 | + If the query does not start with FORCE QUERY CACHE comment, |
| 82 | + following checks are performed. If one of followings is satisfied, |
| 83 | + SELECT will not be cached. |
| 84 | + <programlisting> |
| 85 | + SELECT including non immutable functions |
| 86 | + SELECT including temp tables, unlogged tables |
| 87 | + SELECT including TIMESTAMP WITH TIMEZONE or TIME WITH TIMEZONE |
| 88 | + SELECT including CAST to TIMESTAMP WITH TIMEZONE or TIME WITH TIMEZONE |
| 89 | + SELECT including SQLValueFunction (CURRENT_TIME, CURRENT_USER etc.) |
| 90 | + SELECT result is too large (memqcache_maxcache) |
| 91 | + SELECT FOR SHARE/UPDATE |
| 92 | + SELECT starting with "/*NO QUERY CACHE*/" comment (case insensitive) |
| 93 | + SELECT including system catalogs |
| 94 | + SELECT using TABLESAMPLE |
| 95 | + SELECT uses row security enabled tables |
| 96 | + </programlisting> |
35 | 97 | However, VIEWs and SELECTs accessing unlogged tables can be
|
36 | 98 | cached by specifying in
|
37 | 99 | the <xref linkend="guc-cache-safe-memqcache-table-list">.
|
38 | 100 | -->
|
39 |
| - 基本的に以下のSELECTはキャッシュされません。 |
| 101 | + クエリがFORCE QUERY CACHEコメントで始まっていなければ、以下のチェックが行われます。 |
| 102 | + 以下の一つでも該当すれば、SELECTはキャッシュされません。 |
40 | 103 | <programlisting>
|
41 | 104 | immutableでない関数を含むSELECT
|
| 105 | + 一時テーブル、unloggedテーブルを使ったSELECT |
42 | 106 | TIMESTAMP WITH TIMEZONE、TIME WITH TIMEZONEを返す関数を使っているSELECT
|
43 | 107 | TIMESTAMP WITH TIMEZONE、TIME WITH TIMEZONEへのキャストを含むSELECT
|
44 | 108 | SQLValueFunction (CURRENT_TIME, CURRENT_USERなど)を含むSELECT
|
45 |
| - 一時テーブル、unloggedテーブルを使ったSELECT |
46 | 109 | 検索結果が memqcache_maxcache を越えるようなSELECT
|
47 | 110 | SELECT FOR SHARE/UPDATE
|
48 |
| - /*NO QUERY CACHE*/コメントで始まるSELECT |
| 111 | + /*NO QUERY CACHE*/コメント(大文字小文字は区別されません)で始まるSELECT |
49 | 112 | システムカタログを使用しているSELECT
|
50 | 113 | TABLESAMPLEを使っているSELECT
|
51 | 114 | 行セキュリティが設定されているテーブルを使っているSELECT
|
|
0 commit comments