{ "7b9c73363ea4807a652bbda1b51c2770d0976c1a7ef9336c81f84667b4665803": { "original": "# Query cache\n\nQuery cache stores compressed result sets in memory and reuses them for subsequent queries when possible. You can configure it using the following directives:\n\n* [qcache_max_bytes](../Server_settings/Searchd.md#qcache_max_bytes), a limit on the RAM usage for cached query storage. Defaults to 16 MB. Setting `qcache_max_bytes` to 0 completely disables the query cache.\n* [qcache_thresh_msec](../Server_settings/Searchd.md#qcache_thresh_msec), the minimum wall query time to cache. Queries that complete faster than this will *not* be cached. Defaults to 3000 msec, or 3 seconds.\n* [qcache_ttl_sec](../Server_settings/Searchd.md#qcache_ttl_sec), cached entry TTL, or time to live. Queries will stay cached for this duration. Defaults to 60 seconds, or 1 minute.\n\nThese settings can be changed on the fly using the `SET GLOBAL` statement:\n\nCODE_BLOCK_0\n\nThese changes are applied immediately, and cached result sets that no longer satisfy the constraints are immediately discarded. When reducing the cache size on the fly, MRU (most recently used) result sets win.\n\nQuery cache operates as follows. When enabled, every full-text search result is completely stored in memory. This occurs after full-text matching, filtering, and ranking, so essentially we store `total_found` {docid,weight} pairs. Compressed matches can consume anywhere from 2 bytes to 12 bytes per match on average, mostly depending on the deltas between subsequent docids. Once the query is complete, we check the wall time and size thresholds, and either save the compressed result set for reuse or discard it.\n\nNote that the query cache's impact on RAM is not limited by`qcache_max_bytes`! If you run, for example, 10 concurrent queries, each matching up to 1M matches (after filters), then the peak temporary RAM usage will be in the range of 40 MB to 240 MB, even if the queries are fast enough and don't get cached.\n\nQueries can use cache when the table, full-text query (i.e.,`MATCH()` contents), and ranker all match, and filters are compatible. This means:\n\n* The full-text part within `MATCH()` must be a bytewise match. Add a single extra space, and it's now a different query as far as the query cache is concerned.\n* The ranker (and its parameters, if any, for user-defined rankers) must be a bytewise match.\n* The filters must be a superset of the original filters. You can add extra filters and still hit the cache. (In this case, the extra filters will be applied to the cached result.) But if you remove one, that will be a new query again.\n\nCache entries expire with TTL and also get invalidated on table rotation, or on `TRUNCATE`, or on `ATTACH`. Note that currently, entries are not invalidated on arbitrary RT table writes! So a cached query might return older results for the duration of its TTL.\n\nYou can inspect the current cache status with [SHOW STATUS](../Node_info_and_management/Node_status.md#SHOW-STATUS) through the `qcache_XXX` variables:\n\nCODE_BLOCK_1\n\n\n", "translations": { "chinese": "# \u67e5\u8be2\u7f13\u5b58\n\n\u67e5\u8be2\u7f13\u5b58\u5c06\u538b\u7f29\u7684\u7ed3\u679c\u96c6\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u5e76\u5728\u53ef\u80fd\u65f6\u5bf9\u540e\u7eed\u67e5\u8be2\u91cd\u7528\u5b83\u4eec\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6307\u4ee4\u8fdb\u884c\u914d\u7f6e\uff1a\n\n* [qcache_max_bytes](../Server_settings/Searchd.md#qcache_max_bytes)\uff0c\u7f13\u5b58\u67e5\u8be2\u5b58\u50a8\u7684\u5185\u5b58\u4f7f\u7528\u9650\u5236\u3002\u9ed8\u8ba4\u503c\u4e3a16 MB\u3002\u5c06`qcache_max_bytes`\u8bbe\u7f6e\u4e3a0\u4f1a\u5b8c\u5168\u7981\u7528\u67e5\u8be2\u7f13\u5b58\u3002\n* [qcache_thresh_msec](../Server_settings/Searchd.md#qcache_thresh_msec)\uff0c\u7f13\u5b58\u7684\u6700\u5c0f\u67e5\u8be2\u8017\u65f6\u9608\u503c\u3002\u67e5\u8be2\u5b8c\u6210\u65f6\u95f4\u5feb\u4e8e\u8be5\u503c\u7684\u5c06*\u4e0d*\u88ab\u7f13\u5b58\u3002\u9ed8\u8ba4\u503c\u4e3a3000\u6beb\u79d2\uff0c\u53733\u79d2\u3002\n* [qcache_ttl_sec](../Server_settings/Searchd.md#qcache_ttl_sec)\uff0c\u7f13\u5b58\u6761\u76ee\u7684TTL\uff0c\u5373\u5b58\u6d3b\u65f6\u95f4\u3002\u67e5\u8be2\u5c06\u5728\u6b64\u65f6\u95f4\u5185\u4fdd\u6301\u7f13\u5b58\u3002\u9ed8\u8ba4\u503c\u4e3a60\u79d2\uff0c\u53731\u5206\u949f\u3002\n\n\u8fd9\u4e9b\u8bbe\u7f6e\u53ef\u4ee5\u4f7f\u7528`SET GLOBAL`\u8bed\u53e5\u52a8\u6001\u66f4\u6539\uff1a\n\nCODE_BLOCK_0\n\n\u8fd9\u4e9b\u66f4\u6539\u4f1a\u7acb\u5373\u751f\u6548\uff0c\u4e0d\u518d\u6ee1\u8db3\u7ea6\u675f\u7684\u7f13\u5b58\u7ed3\u679c\u96c6\u4f1a\u88ab\u7acb\u5373\u4e22\u5f03\u3002\u5f53\u52a8\u6001\u7f29\u51cf\u7f13\u5b58\u5927\u5c0f\u65f6\uff0c\u6700\u8fd1\u6700\u5e38\u7528\uff08MRU\uff09\u7684\u7ed3\u679c\u96c6\u4f18\u5148\u4fdd\u7559\u3002\n\n\u67e5\u8be2\u7f13\u5b58\u7684\u5de5\u4f5c\u65b9\u5f0f\u5982\u4e0b\u3002\u542f\u7528\u65f6\uff0c\u6bcf\u4e2a\u5168\u6587\u641c\u7d22\u7ed3\u679c\u5c06\u5b8c\u6574\u5b58\u50a8\u4e8e\u5185\u5b58\u4e2d\u3002\u8fd9\u53d1\u751f\u5728\u5168\u6587\u5339\u914d\u3001\u8fc7\u6ee4\u548c\u6392\u540d\u4e4b\u540e\uff0c\u56e0\u6b64\u672c\u8d28\u4e0a\u6211\u4eec\u5b58\u50a8\u7684\u662f`total_found`\u4e2a{docid,weight}\u5bf9\u3002\u538b\u7f29\u5339\u914d\u5e73\u5747\u6bcf\u4e2a\u5339\u914d\u8017\u75282\u523012\u5b57\u8282\u4e0d\u7b49\uff0c\u4e3b\u8981\u53d6\u51b3\u4e8e\u8fde\u7eeddocid\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u67e5\u8be2\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u68c0\u67e5\u8017\u65f6\u548c\u5927\u5c0f\u9608\u503c\uff0c\u8981\u4e48\u4fdd\u5b58\u538b\u7f29\u540e\u7684\u7ed3\u679c\u96c6\u4ee5\u4f9b\u91cd\u7528\uff0c\u8981\u4e48\u4e22\u5f03\u5b83\u3002\n\n\u8bf7\u6ce8\u610f\uff0c\u67e5\u8be2\u7f13\u5b58\u5bf9\u5185\u5b58\u7684\u5f71\u54cd\u4e0d\u9650\u4e8e`qcache_max_bytes`\uff01\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u8fd0\u884c10\u4e2a\u5e76\u53d1\u67e5\u8be2\uff0c\u6bcf\u4e2a\u67e5\u8be2\u5339\u914d\u6700\u591a100\u4e07\u6761\u7ed3\u679c\uff08\u7ecf\u8fc7\u8fc7\u6ee4\u540e\uff09\uff0c\u90a3\u4e48\u5cf0\u503c\u4e34\u65f6\u5185\u5b58\u4f7f\u7528\u53ef\u80fd\u572840 MB\u5230240 MB\u4e4b\u95f4\uff0c\u5373\u4f7f\u67e5\u8be2\u591f\u5feb\u4e14\u672a\u88ab\u7f13\u5b58\u3002\n\n\u5f53\u8868\u3001\u5168\u6587\u67e5\u8be2\uff08\u5373`MATCH()`\u5185\u5bb9\uff09\u548c\u6392\u5e8f\u5668\u90fd\u5339\u914d\uff0c\u4e14\u8fc7\u6ee4\u6761\u4ef6\u517c\u5bb9\u65f6\uff0c\u67e5\u8be2\u53ef\u4ee5\u4f7f\u7528\u7f13\u5b58\u3002\u5177\u4f53\u800c\u8a00\uff1a\n\n* `MATCH()`\u4e2d\u7684\u5168\u6587\u90e8\u5206\u5fc5\u987b\u9010\u5b57\u8282\u5339\u914d\u3002\u6dfb\u52a0\u4e00\u4e2a\u989d\u5916\u7684\u7a7a\u683c\uff0c\u5728\u67e5\u8be2\u7f13\u5b58\u770b\u6765\u5c31\u662f\u4e00\u4e2a\u4e0d\u540c\u7684\u67e5\u8be2\u3002\n* \u6392\u5e8f\u5668\uff08\u53ca\u5176\u53c2\u6570\uff0c\u5982\u81ea\u5b9a\u4e49\u6392\u5e8f\u5668\u7684\u53c2\u6570\uff09\u5fc5\u987b\u9010\u5b57\u8282\u5339\u914d\u3002\n* \u8fc7\u6ee4\u6761\u4ef6\u5fc5\u987b\u662f\u539f\u8fc7\u6ee4\u6761\u4ef6\u7684\u8d85\u96c6\u3002\u60a8\u53ef\u4ee5\u6dfb\u52a0\u989d\u5916\u8fc7\u6ee4\u6761\u4ef6\u4ecd\u7136\u547d\u4e2d\u7f13\u5b58\u3002\uff08\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u989d\u5916\u8fc7\u6ee4\u6761\u4ef6\u5c06\u5728\u7f13\u5b58\u7ed3\u679c\u4e0a\u5e94\u7528\u3002\uff09\u4f46\u5982\u679c\u79fb\u9664\u4e00\u4e2a\u8fc7\u6ee4\u6761\u4ef6\uff0c\u5219\u89c6\u4e3a\u65b0\u7684\u67e5\u8be2\u3002\n\n\u7f13\u5b58\u6761\u76ee\u4f1a\u6309TTL\u8fc7\u671f\uff0c\u5e76\u5728\u8868\u8f6e\u6362\u3001`TRUNCATE`\u6216`ATTACH`\u65f6\u5931\u6548\u3002\u8bf7\u6ce8\u610f\uff0c\u76ee\u524d\u6761\u76ee\u4e0d\u4f1a\u56e0\u4efb\u610fRT\u8868\u5199\u5165\u800c\u5931\u6548\uff01\u56e0\u6b64\u7f13\u5b58\u7684\u67e5\u8be2\u53ef\u80fd\u5728TTL\u671f\u95f4\u8fd4\u56de\u8f83\u65e7\u7684\u7ed3\u679c\u3002\n\n\u60a8\u53ef\u4ee5\u901a\u8fc7[SHOW STATUS](../Node_info_and_management/Node_status.md#SHOW-STATUS) \u4f7f\u7528`qcache_XXX`\u53d8\u91cf\u67e5\u770b\u5f53\u524d\u7f13\u5b58\u72b6\u6001\uff1a\n\nCODE_BLOCK_1\n", "russian": "# \u041a\u044d\u0448 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\n\n\u041a\u044d\u0448 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0436\u0430\u0442\u044b\u0435 \u043d\u0430\u0431\u043e\u0440\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u0445 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432:\n\n* [qcache_max_bytes](../Server_settings/Searchd.md#qcache_max_bytes) \u2014 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 RAM \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0432 16 \u041c\u0411. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 `qcache_max_bytes` \u0432 0 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043a\u044d\u0448 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.\n* [qcache_thresh_msec](../Server_settings/Searchd.md#qcache_thresh_msec) \u2014 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \u0434\u043b\u044f \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0417\u0430\u043f\u0440\u043e\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, *\u043d\u0435 \u0431\u0443\u0434\u0443\u0442* \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 3000 \u043c\u0441, \u0438\u043b\u0438 3 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.\n* [qcache_ttl_sec](../Server_settings/Searchd.md#qcache_ttl_sec) \u2014 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438, \u0438\u043b\u0438 TTL. \u0417\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u044d\u0448\u0435 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 60 \u0441\u0435\u043a\u0443\u043d\u0434, \u0438\u043b\u0438 1 \u043c\u0438\u043d\u0443\u0442\u0430.\n\n\u042d\u0442\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u043b\u0435\u0442\u0443, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 `SET GLOBAL`:\n\nCODE_BLOCK_0\n\n\u042d\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u0438 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u0431\u043e\u0440\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c, \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f. \u041f\u0440\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u044d\u0448\u0430 \u043d\u0430 \u043b\u0435\u0442\u0443 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 (MRU) \u043d\u0430\u0431\u043e\u0440\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.\n\n\u041a\u044d\u0448 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u041f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u043d\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u043d\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f, \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u043e \u0441\u0443\u0442\u0438 \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043f\u0430\u0440\u044b {docid,weight} \u0434\u043b\u044f `total_found`. \u0421\u0436\u0430\u0442\u044b\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043e\u0442 2 \u0434\u043e 12 \u0431\u0430\u0439\u0442 \u043d\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u0435\u043b\u044c\u0442 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 docid. \u041f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u043e\u0440\u043e\u0433\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0438 \u043b\u0438\u0431\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0441\u0436\u0430\u0442\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043b\u0438\u0431\u043e \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e.\n\n\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043a\u044d\u0448\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 RAM \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f `qcache_max_bytes`! \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f 10 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0434\u043e 1 \u043c\u043b\u043d \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 (\u043f\u043e\u0441\u043b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432), \u0442\u043e \u043f\u0438\u043a\u043e\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 RAM \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 40 \u041c\u0411 \u0434\u043e 240 \u041c\u0411, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u044b\u0435 \u0438 \u043d\u0435 \u043a\u044d\u0448\u0438\u0440\u0443\u044e\u0442\u0441\u044f.\n\n\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u044d\u0448, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u043f\u043e\u043b\u043d\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 (\u0442\u043e \u0435\u0441\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 `MATCH()`), \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0438 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u044b. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442:\n\n* \u041f\u043e\u043b\u043d\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 `MATCH()` \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u043f\u043e\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0431\u0435\u043b \u2014 \u0438 \u044d\u0442\u043e \u0443\u0436\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.\n* \u0420\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0449\u0438\u043a (\u0438 \u0435\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c, \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u043e\u0432) \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u043f\u043e\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e.\n* \u0424\u0438\u043b\u044c\u0442\u0440\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043d\u0430\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u0438 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u043a\u044d\u0448. (\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u044b \u043a \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443.) \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0431\u0435\u0440\u0451\u0442\u0435 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0444\u0438\u043b\u044c\u0442\u0440, \u044d\u0442\u043e \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441.\n\n\u0417\u0430\u043f\u0438\u0441\u0438 \u043a\u044d\u0448\u0430 \u0438\u0441\u0442\u0435\u043a\u0430\u044e\u0442 \u043f\u043e TTL \u0438 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0440\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446, \u0438\u043b\u0438 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 `TRUNCATE`, \u0438\u043b\u0438 `ATTACH`. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0435 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u044f\u0445 \u0432 RT-\u0442\u0430\u0431\u043b\u0438\u0446\u0443! \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 TTL.\n\n\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u043a\u044d\u0448\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e [SHOW STATUS](../Node_info_and_management/Node_status.md#SHOW-STATUS) \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 `qcache_XXX`:\n\nCODE_BLOCK_1\n" }, "is_code_or_comment": false, "model": "openai:gpt-4.1-mini", "updated_at": 1766339795 }, "__meta": { "source_text": "# Query cache\n\nQuery cache stores compressed result sets in memory and reuses them for subsequent queries when possible. You can configure it using the following directives:\n\n* [qcache_max_bytes](../Server_settings/Searchd.md#qcache_max_bytes), a limit on the RAM usage for cached query storage. Defaults to 16 MB. Setting `qcache_max_bytes` to 0 completely disables the query cache.\n* [qcache_thresh_msec](../Server_settings/Searchd.md#qcache_thresh_msec), the minimum wall query time to cache. Queries that complete faster than this will *not* be cached. Defaults to 3000 msec, or 3 seconds.\n* [qcache_ttl_sec](../Server_settings/Searchd.md#qcache_ttl_sec), cached entry TTL, or time to live. Queries will stay cached for this duration. Defaults to 60 seconds, or 1 minute.\n\nThese settings can be changed on the fly using the `SET GLOBAL` statement:\n\n```sql\nmysql> SET GLOBAL qcache_max_bytes=128000000;\n```\n\nThese changes are applied immediately, and cached result sets that no longer satisfy the constraints are immediately discarded. When reducing the cache size on the fly, MRU (most recently used) result sets win.\n\nQuery cache operates as follows. When enabled, every full-text search result is completely stored in memory. This occurs after full-text matching, filtering, and ranking, so essentially we store `total_found` {docid,weight} pairs. Compressed matches can consume anywhere from 2 bytes to 12 bytes per match on average, mostly depending on the deltas between subsequent docids. Once the query is complete, we check the wall time and size thresholds, and either save the compressed result set for reuse or discard it.\n\nNote that the query cache's impact on RAM is not limited by`qcache_max_bytes`! If you run, for example, 10 concurrent queries, each matching up to 1M matches (after filters), then the peak temporary RAM usage will be in the range of 40 MB to 240 MB, even if the queries are fast enough and don't get cached.\n\nQueries can use cache when the table, full-text query (i.e.,`MATCH()` contents), and ranker all match, and filters are compatible. This means:\n\n* The full-text part within `MATCH()` must be a bytewise match. Add a single extra space, and it's now a different query as far as the query cache is concerned.\n* The ranker (and its parameters, if any, for user-defined rankers) must be a bytewise match.\n* The filters must be a superset of the original filters. You can add extra filters and still hit the cache. (In this case, the extra filters will be applied to the cached result.) But if you remove one, that will be a new query again.\n\nCache entries expire with TTL and also get invalidated on table rotation, or on `TRUNCATE`, or on `ATTACH`. Note that currently, entries are not invalidated on arbitrary RT table writes! So a cached query might return older results for the duration of its TTL.\n\nYou can inspect the current cache status with [SHOW STATUS](../Node_info_and_management/Node_status.md#SHOW-STATUS) through the `qcache_XXX` variables:\n\n```sql\nmysql> SHOW STATUS LIKE 'qcache%';\n+-----------------------+----------+\n| Counter | Value |\n+-----------------------+----------+\n| qcache_max_bytes | 16777216 |\n| qcache_thresh_msec | 3000 |\n| qcache_ttl_sec | 60 |\n| qcache_cached_queries | 0 |\n| qcache_used_bytes | 0 |\n| qcache_hits | 0 |\n+-----------------------+----------+\n6 rows in set (0.00 sec)\n```\n\n\n", "updated_at": 1768530797, "source_md5": "d0c881a3530d594d29eee3a7109df44b" } }