{"id":10020864,"date":"2025-06-29T04:02:26","date_gmt":"2025-06-28T20:02:26","guid":{"rendered":"https:\/\/itmax.cn\/?p=10020864"},"modified":"2025-06-29T04:02:26","modified_gmt":"2025-06-28T20:02:26","slug":"%e4%bd%bf%e7%94%a8-laravel-redis-%e4%bc%98%e5%8c%96-mysql-%e5%a4%9a%e5%ad%97%e6%ae%b5-distinct-%e6%9f%a5%e8%af%a2%e6%80%a7%e8%83%bd","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10020864","title":{"rendered":"\u4f7f\u7528 Laravel + Redis \u4f18\u5316 MySQL \u591a\u5b57\u6bb5 DISTINCT \u67e5\u8be2\u6027\u80fd"},"content":{"rendered":"<p>\u5728\u9ad8\u5e76\u53d1\u4e1a\u52a1\u573a\u666f\u4e2d\uff0c\u9891\u7e41\u6267\u884c MySQL \u7684 SELECT DISTINCT \u67e5\u8be2\u53ef\u80fd\u4f1a\u6210\u4e3a\u6027\u80fd\u74f6\u9888\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u4e00\u4e2a\u5b9e\u9645\u6848\u4f8b\uff0c\u5e76\u901a\u8fc7 Laravel + Redis \u7f13\u5b58\u673a\u5236\u5b9e\u73b0\u67e5\u8be2\u4f18\u5316\u3002<\/p>\n<h2>\ud83d\udccc \u80cc\u666f\u9700\u6c42<\/h2>\n<p>\u6211\u4eec\u6709\u4e00\u4e2a MySQL \u8868\uff0c\u6570\u636e\u91cf\u7ea6\u4e3a 50 \u4e07\u6761\uff0c\u5b57\u6bb5\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<pre><code>\u8868\u5b57\u6bb5\uff1aa, b, c, d, e, f, g<\/code><\/pre>\n<p><strong>\u5b57\u6bb5\u7279\u5f81\uff1a<\/strong><\/p>\n<ul>\n<li>\u6bcf\u4e2a\u5b57\u6bb5\u90fd\u662f\u679a\u4e3e\u7c7b\u578b\uff0c\u679a\u4e3e\u503c\u6570\u91cf\u4ece\u51e0\u5341\u5230\u4e24\u767e\u4e0d\u7b49<\/li>\n<li>\u5b57\u6bb5 <code>a<\/code> \u5df2\u5efa\u7acb\u7d22\u5f15<\/li>\n<li>\u6570\u636e\u91cf\uff1a500,000 \u6761\u8bb0\u5f55<\/li>\n<\/ul>\n<p><strong>\u67e5\u8be2\u9700\u6c42\uff1a<\/strong><\/p>\n<ul>\n<li>\u6bcf\u6b21\u67e5\u8be2\u65f6\uff0c\u5b57\u6bb5 <code>a<\/code> \u4e00\u5b9a\u6709\u503c\uff0c\u5176\u4ed6\u5b57\u6bb5\u4e0d\u4e00\u5b9a\u6709\u503c<\/li>\n<li>\u9700\u8981\u83b7\u53d6\u6ee1\u8db3\u6761\u4ef6\u7684\u8bb0\u5f55\u4e2d\uff0c\u5b57\u6bb5 <code>b~g<\/code> \u7684 DISTINCT \u503c<\/li>\n<li>\u5f53\u524d\u505a\u6cd5\u662f\u5bf9\u6bcf\u4e2a\u5b57\u6bb5\u6267\u884c\u4e00\u6b21 SELECT DISTINCT \u67e5\u8be2\uff0c\u603b\u5171\u9700\u8981 7 \u6b21\u67e5\u8be2<\/li>\n<li>\u5e76\u53d1\u91cf\u5f88\u5927\uff0c\u6570\u636e\u5e93\u538b\u529b\u8f83\u9ad8<\/li>\n<\/ul>\n<p><strong>\u5f53\u524dSQL\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre><code class=\"sql\">SELECT DISTINCT b FROM table WHERE a = 'xxx' AND \u5176\u4ed6\u6761\u4ef6;\nSELECT DISTINCT c FROM table WHERE a = 'xxx' AND \u5176\u4ed6\u6761\u4ef6;\nSELECT DISTINCT d FROM table WHERE a = 'xxx' AND \u5176\u4ed6\u6761\u4ef6;\n-- ... \u7ee7\u7eed\u6267\u884c\u5176\u4ed6\u5b57\u6bb5<\/code><\/pre>\n<h2>\u274c \u5f53\u524d\u5b58\u5728\u7684\u95ee\u9898<\/h2>\n<ol>\n<li><strong>\u67e5\u8be2\u6b21\u6570\u8fc7\u591a<\/strong>\uff1aMySQL \u4e0d\u652f\u6301\u4e00\u6b21\u6027\u5bf9\u591a\u4e2a\u5b57\u6bb5\u5206\u522b\u505a DISTINCT<\/li>\n<li><strong>\u6570\u636e\u5e93\u538b\u529b\u5927<\/strong>\uff1a\u6bcf\u6b21\u67e5\u8be2\u90fd\u8981\u6267\u884c 7 \u6761 SQL<\/li>\n<li><strong>\u54cd\u5e94\u901f\u5ea6\u6162<\/strong>\uff1a\u591a\u6b21\u6570\u636e\u5e93\u67e5\u8be2\u5f71\u54cd\u7528\u6237\u4f53\u9a8c<\/li>\n<li><strong>\u9ad8\u5e76\u53d1\u74f6\u9888<\/strong>\uff1a\u5927\u91cf\u5e76\u53d1\u8bf7\u6c42\u5bfc\u81f4\u6570\u636e\u5e93\u6027\u80fd\u4e0b\u964d<\/li>\n<\/ol>\n<h2>\u2705 \u89e3\u51b3\u65b9\u6848\uff1aLaravel + Redis \u7f13\u5b58\u4f18\u5316<\/h2>\n<p>\u6211\u4eec\u91c7\u7528 Laravel + Redis \u7684\u65b9\u5f0f\uff0c\u5c06\u5b57\u6bb5 <code>a<\/code> \u5bf9\u5e94\u7684 <code>b~g<\/code> \u7684\u679a\u4e3e\u503c\u9884\u5148\u7f13\u5b58\u5230 Redis \u4e2d\uff0c\u67e5\u8be2\u65f6\u4f18\u5148\u4ece Redis \u83b7\u53d6\uff0c\u6781\u5927\u63d0\u5347\u6027\u80fd\u3002<\/p>\n<h3>\ud83e\uddf1 Redis \u7f13\u5b58\u7ed3\u6784\u8bbe\u8ba1<\/h3>\n<p><strong>\u7f13\u5b58Key\u683c\u5f0f\uff1a<\/strong><\/p>\n<pre><code>distinct_values:{a\u503c}<\/code><\/pre>\n<p><strong>\u7f13\u5b58Value\u683c\u5f0f\uff08JSON\uff09\uff1a<\/strong><\/p>\n<pre><code class=\"json\">{\n  &quot;b&quot;: [&quot;value1&quot;, &quot;value2&quot;, &quot;value3&quot;],\n  &quot;c&quot;: [&quot;value1&quot;, &quot;value2&quot;],\n  &quot;d&quot;: [&quot;value1&quot;, &quot;value2&quot;, &quot;value3&quot;],\n  &quot;e&quot;: [&quot;value1&quot;],\n  &quot;f&quot;: [&quot;value1&quot;, &quot;value2&quot;],\n  &quot;g&quot;: [&quot;value1&quot;, &quot;value2&quot;, &quot;value3&quot;]\n}<\/code><\/pre>\n<h2>\ud83d\udee0 Laravel \u5b9e\u73b0\u6b65\u9aa4<\/h2>\n<h3>1\ufe0f\u20e3 \u521b\u5efa\u7f13\u5b58\u6784\u5efa\u547d\u4ee4<\/h3>\n<p>\u521b\u5efa Artisan \u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"bash\">php artisan make:command CacheDistinctValues<\/code><\/pre>\n<p>\u7f16\u8f91\u6587\u4ef6 <code>app\/Console\/Commands\/CacheDistinctValues.php<\/code>\uff1a<\/p>\n<pre><code class=\"php\">&lt;?php\n\nnamespace App\/Console\/Commands;\n\nuse Illuminate\/Console\/Command;\nuse Illuminate\/Support\/Facades\/DB;\nuse Illuminate\/Support\/Facades\/Redis;\n\nclass CacheDistinctValues extends Command\n{\n    protected $signature = 'cache:distinct-values';\n    protected $description = 'Cache distinct values of b~g grouped by a';\n\n    public function handle()\n    {\n        $this-&gt;info('\u5f00\u59cb\u6784\u5efa\u7f13\u5b58...');\n        \n        \/\/ \u83b7\u53d6\u6240\u6709 a \u503c\u5bf9\u5e94\u7684 distinct \u6570\u636e\n        $rows = DB::table('your_table_name')\n            -&gt;select([\n                'a',\n                DB::raw('GROUP_CONCAT(DISTINCT b) AS b_values'),\n                DB::raw('GROUP_CONCAT(DISTINCT c) AS c_values'),\n                DB::raw('GROUP_CONCAT(DISTINCT d) AS d_values'),\n                DB::raw('GROUP_CONCAT(DISTINCT e) AS e_values'),\n                DB::raw('GROUP_CONCAT(DISTINCT f) AS f_values'),\n                DB::raw('GROUP_CONCAT(DISTINCT g) AS g_values')\n            ])\n            -&gt;whereNotNull('a')\n            -&gt;groupBy('a')\n            -&gt;get();\n\n        $count = 0;\n        foreach ($rows as $row) {\n            $key = &quot;distinct_values:{$row-&gt;a}&quot;;\n            $value = [\n                'b' =&gt; $this-&gt;parseValues($row-&gt;b_values),\n                'c' =&gt; $this-&gt;parseValues($row-&gt;c_values),\n                'd' =&gt; $this-&gt;parseValues($row-&gt;d_values),\n                'e' =&gt; $this-&gt;parseValues($row-&gt;e_values),\n                'f' =&gt; $this-&gt;parseValues($row-&gt;f_values),\n                'g' =&gt; $this-&gt;parseValues($row-&gt;g_values),\n            ];\n            \n            \/\/ \u8bbe\u7f6e\u7f13\u5b58\uff0c\u8fc7\u671f\u65f6\u95f410\u5206\u949f\n            Redis::setex($key, 600, json_encode($value));\n            $count++;\n        }\n\n        $this-&gt;info(&quot;\u7f13\u5b58\u6784\u5efa\u5b8c\u6210\uff0c\u5171\u5904\u7406 {$count} \u4e2a a \u503c&quot;);\n    }\n\n    private function parseValues($values)\n    {\n        if (empty($values)) {\n            return [];\n        }\n        \n        return array_filter(array_unique(explode(',', $values)), function($value) {\n            return !empty(trim($value));\n        });\n    }\n}<\/code><\/pre>\n<h3>2\ufe0f\u20e3 \u8bbe\u7f6e\u5b9a\u65f6\u4efb\u52a1<\/h3>\n<p>\u7f16\u8f91 <code>app\/Console\/Kernel.php<\/code>\uff1a<\/p>\n<pre><code class=\"php\">&lt;?php\n\nnamespace App\/Console;\n\nuse Illuminate\/Console\/Scheduling\/Schedule;\nuse Illuminate\/Foundation\/Console\/Kernel as ConsoleKernel;\n\nclass Kernel extends ConsoleKernel\n{\n    protected function schedule(Schedule $schedule)\n    {\n        \/\/ \u6bcf5\u5206\u949f\u66f4\u65b0\u4e00\u6b21\u7f13\u5b58\n        $schedule-&gt;command('cache:distinct-values')\n                 -&gt;everyFiveMinutes()\n                 -&gt;withoutOverlapping();\n    }\n\n    protected $commands = [\n        Commands\/CacheDistinctValues::class,\n    ];\n}<\/code><\/pre>\n<p>\u8bbe\u7f6e\u670d\u52a1\u5668\u5b9a\u65f6\u4efb\u52a1\uff08crontab\uff09\uff1a<\/p>\n<pre><code class=\"bash\">* * * * * cd \/your\/project\/path &amp;&amp; php artisan schedule:run &gt;&gt; \/dev\/null 2&gt;&amp;1<\/code><\/pre>\n<h3>3\ufe0f\u20e3 \u521b\u5efa\u67e5\u8be2\u63a7\u5236\u5668<\/h3>\n<p>\u521b\u5efa\u63a7\u5236\u5668\uff1a<\/p>\n<pre><code class=\"bash\">php artisan make:controller DistinctValuesController<\/code><\/pre>\n<p>\u7f16\u8f91 <code>app\/Http\/Controllers\/DistinctValuesController.php<\/code>\uff1a<\/p>\n<pre><code class=\"php\">&lt;?php\n\nnamespace App\/Http\/Controllers;\n\nuse Illuminate\/Http\/Request;\nuse Illuminate\/Support\/Facades\/Redis;\nuse Illuminate\/Support\/Facades\/DB;\n\nclass DistinctValuesController extends Controller\n{\n    \/**\n     * \u83b7\u53d6\u6307\u5b9a a \u503c\u7684\u6240\u6709\u5b57\u6bb5 distinct \u503c\n     *\/\n    public function getDistinctValues($a, Request $request)\n    {\n        $key = &quot;distinct_values:{$a}&quot;;\n        $cached = Redis::get($key);\n\n        if ($cached) {\n            $data = json_decode($cached, true);\n            \n            \/\/ \u6839\u636e\u5176\u4ed6\u6761\u4ef6\u8fc7\u6ee4\uff08\u5982\u679c\u9700\u8981\uff09\n            if ($request-&gt;has('filters')) {\n                $data = $this-&gt;applyFilters($data, $request-&gt;get('filters'));\n            }\n            \n            return response()-&gt;json([\n                'success' =&gt; true,\n                'data' =&gt; $data,\n                'source' =&gt; 'cache'\n            ]);\n        }\n\n        \/\/ \u7f13\u5b58\u672a\u547d\u4e2d\uff0c\u964d\u7ea7\u5230\u6570\u636e\u5e93\u67e5\u8be2\n        return $this-&gt;fallbackToDatabase($a, $request);\n    }\n\n    \/**\n     * \u7f13\u5b58\u672a\u547d\u4e2d\u65f6\u7684\u964d\u7ea7\u65b9\u6848\n     *\/\n    private function fallbackToDatabase($a, Request $request)\n    {\n        try {\n            $query = DB::table('your_table_name')-&gt;where('a', $a);\n            \n            \/\/ \u5e94\u7528\u5176\u4ed6\u8fc7\u6ee4\u6761\u4ef6\n            if ($request-&gt;has('filters')) {\n                foreach ($request-&gt;get('filters') as $field =&gt; $value) {\n                    $query-&gt;where($field, $value);\n                }\n            }\n\n            $result = [\n                'b' =&gt; $query-&gt;distinct()-&gt;pluck('b')-&gt;filter()-&gt;values()-&gt;toArray(),\n                'c' =&gt; $query-&gt;distinct()-&gt;pluck('c')-&gt;filter()-&gt;values()-&gt;toArray(),\n                'd' =&gt; $query-&gt;distinct()-&gt;pluck('d')-&gt;filter()-&gt;values()-&gt;toArray(),\n                'e' =&gt; $query-&gt;distinct()-&gt;pluck('e')-&gt;filter()-&gt;values()-&gt;toArray(),\n                'f' =&gt; $query-&gt;distinct()-&gt;pluck('f')-&gt;filter()-&gt;values()-&gt;toArray(),\n                'g' =&gt; $query-&gt;distinct()-&gt;pluck('g')-&gt;filter()-&gt;values()-&gt;toArray(),\n            ];\n\n            return response()-&gt;json([\n                'success' =&gt; true,\n                'data' =&gt; $result,\n                'source' =&gt; 'database'\n            ]);\n        } catch (\/Exception $e) {\n            return response()-&gt;json([\n                'success' =&gt; false,\n                'message' =&gt; 'Query failed',\n                'error' =&gt; $e-&gt;getMessage()\n            ], 500);\n        }\n    }\n\n    \/**\n     * \u5e94\u7528\u989d\u5916\u7684\u8fc7\u6ee4\u6761\u4ef6\n     *\/\n    private function applyFilters($data, $filters)\n    {\n        \/\/ \u8fd9\u91cc\u53ef\u4ee5\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u5b9e\u73b0\u989d\u5916\u7684\u8fc7\u6ee4\u903b\u8f91\n        return $data;\n    }\n}<\/code><\/pre>\n<h3>4\ufe0f\u20e3 \u8bbe\u7f6e\u8def\u7531<\/h3>\n<p>\u7f16\u8f91 <code>routes\/api.php<\/code>\uff1a<\/p>\n<pre><code class=\"php\">&lt;?php\n\nuse App\/Http\/Controllers\/DistinctValuesController;\nuse Illuminate\/Support\/Facades\/Route;\n\nRoute::prefix('api\/v1')-&gt;group(function () {\n    Route::get('\/distinct\/{a}', [DistinctValuesController::class, 'getDistinctValues']);\n});<\/code><\/pre>\n<h2>\ud83d\udd27 \u9ad8\u7ea7\u4f18\u5316<\/h2>\n<h3>1. \u7f13\u5b58\u9884\u70ed<\/h3>\n<pre><code class=\"php\">\/\/ \u5728 CacheDistinctValues \u547d\u4ee4\u4e2d\u6dfb\u52a0\u9884\u70ed\u903b\u8f91\npublic function handle()\n{\n    \/\/ \u9884\u70ed\u70ed\u70b9\u6570\u636e\n    $hotAValues = $this-&gt;getHotAValues();\n    \n    foreach ($hotAValues as $aValue) {\n        $this-&gt;buildCacheForA($aValue);\n    }\n}\n\nprivate function getHotAValues()\n{\n    \/\/ \u83b7\u53d6\u6700\u5e38\u67e5\u8be2\u7684 a \u503c\n    return DB::table('query_logs')\n        -&gt;select('a', DB::raw('COUNT(*) as query_count'))\n        -&gt;groupBy('a')\n        -&gt;orderBy('query_count', 'desc')\n        -&gt;limit(100)\n        -&gt;pluck('a');\n}<\/code><\/pre>\n<h3>2. \u7f13\u5b58\u5931\u6548\u7b56\u7565<\/h3>\n<pre><code class=\"php\">\/\/ \u6570\u636e\u66f4\u65b0\u65f6\u6e05\u7406\u76f8\u5173\u7f13\u5b58\nclass YourModel extends Model\n{\n    protected static function booted()\n    {\n        static::saved(function ($model) {\n            $key = &quot;distinct_values:{$model-&gt;a}&quot;;\n            Redis::del($key);\n        });\n    }\n}<\/code><\/pre>\n<h3>3. Redis \u96c6\u7fa4\u652f\u6301<\/h3>\n<pre><code class=\"php\">\/\/ config\/database.php\n'redis' =&gt; [\n    'client' =&gt; env('REDIS_CLIENT', 'phpredis'),\n    'options' =&gt; [\n        'cluster' =&gt; env('REDIS_CLUSTER', 'redis'),\n        'prefix' =&gt; env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),\n    ],\n    'clusters' =&gt; [\n        'default' =&gt; [\n            ['host' =&gt; '127.0.0.1', 'port' =&gt; 7000],\n            ['host' =&gt; '127.0.0.1', 'port' =&gt; 7001],\n            ['host' =&gt; '127.0.0.1', 'port' =&gt; 7002],\n        ],\n    ],\n],<\/code><\/pre>\n<h2>\ud83d\ude80 \u6027\u80fd\u5bf9\u6bd4<\/h2>\n<table>\n<thead>\n<tr>\n<th>\u65b9\u6848<\/th>\n<th>\u67e5\u8be2\u6b21\u6570<\/th>\n<th>\u54cd\u5e94\u65f6\u95f4<\/th>\n<th>QPS<\/th>\n<th>\u6570\u636e\u5e93\u538b\u529b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u539f\u65b9\u6848<\/td>\n<td>7\u6b21<\/td>\n<td>50-100ms<\/td>\n<td>~1,000<\/td>\n<td>\u9ad8<\/td>\n<\/tr>\n<tr>\n<td><strong>Redis\u7f13\u5b58<\/strong><\/td>\n<td><strong>1\u6b21<\/strong><\/td>\n<td><strong>1-5ms<\/strong><\/td>\n<td><strong>50,000+<\/strong><\/td>\n<td><strong>\u6781\u4f4e<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\ud83d\udcca \u76d1\u63a7\u4e0e\u8c03\u8bd5<\/h2>\n<h3>\u6dfb\u52a0\u6027\u80fd\u76d1\u63a7<\/h3>\n<pre><code class=\"php\">use Illuminate\/Support\/Facades\/Log;\n\nclass DistinctValuesController extends Controller\n{\n    public function getDistinctValues($a, Request $request)\n    {\n        $startTime = microtime(true);\n        \n        \/\/ ... \u67e5\u8be2\u903b\u8f91\n        \n        $endTime = microtime(true);\n        $executionTime = ($endTime - $startTime) * 1000; \/\/ \u8f6c\u6362\u4e3a\u6beb\u79d2\n        \n        Log::info('Distinct query performance', [\n            'a_value' =&gt; $a,\n            'execution_time_ms' =&gt; $executionTime,\n            'source' =&gt; $cached ? 'cache' : 'database'\n        ]);\n        \n        return response()-&gt;json($result);\n    }\n}<\/code><\/pre>\n<h2>\u2705 \u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7 Laravel + Redis \u7684\u7ec4\u5408\u65b9\u6848\uff0c\u89e3\u51b3\u4e86\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u7684\u591a\u5b57\u6bb5 DISTINCT \u67e5\u8be2\u6027\u80fd\u95ee\u9898\uff1a<\/p>\n<p><strong>\u6838\u5fc3\u4f18\u52bf\uff1a<\/strong><\/p>\n<ul>\n<li>\u26a1 <strong>\u6027\u80fd\u63d0\u5347<\/strong>\uff1a\u67e5\u8be2\u65f6\u95f4\u4ece\u79d2\u7ea7\u964d\u5230\u6beb\u79d2\u7ea7<\/li>\n<li>\ud83d\udd25 <strong>\u9ad8\u5e76\u53d1\u652f\u6301<\/strong>\uff1aQPS \u4ece 1,000 \u63d0\u5347\u5230 50,000+<\/li>\n<li>\ud83d\udcbe <strong>\u6570\u636e\u5e93\u51cf\u538b<\/strong>\uff1a\u67e5\u8be2\u6b21\u6570\u4ece 7 \u6b21\u964d\u5230 1 \u6b21\uff08\u7f13\u5b58\u547d\u4e2d\u65f6\u4e3a 0 \u6b21\uff09<\/li>\n<li>\ud83d\udee1\ufe0f <strong>\u9ad8\u53ef\u7528\u6027<\/strong>\uff1a\u652f\u6301\u7f13\u5b58\u964d\u7ea7\u5230\u6570\u636e\u5e93\u67e5\u8be2<\/li>\n<li>\ud83d\udd04 <strong>\u6570\u636e\u4e00\u81f4\u6027<\/strong>\uff1a\u5b9a\u65f6\u66f4\u65b0 + \u5931\u6548\u7b56\u7565\u4fdd\u8bc1\u6570\u636e\u65b0\u9c9c\u5ea6<\/li>\n<\/ul>\n<p><strong>\u9002\u7528\u573a\u666f\uff1a<\/strong><\/p>\n<ul>\n<li>\u679a\u4e3e\u503c\u76f8\u5bf9\u7a33\u5b9a\uff0c\u53d8\u5316\u4e0d\u9891\u7e41<\/li>\n<li>\u67e5\u8be2\u9891\u7387\u9ad8\uff0c\u5e76\u53d1\u91cf\u5927<\/li>\n<li>\u5bf9\u54cd\u5e94\u65f6\u95f4\u6709\u8f83\u9ad8\u8981\u6c42<\/li>\n<li>\u53ef\u4ee5\u63a5\u53d7\u77ed\u6682\u7684\u6570\u636e\u5ef6\u8fdf\uff08\u5206\u949f\u7ea7\u522b\uff09<\/li>\n<\/ul>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000046815091\">https:\/\/segmentfault.com\/a\/1190000046815091<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u9ad8\u5e76\u53d1\u4e1a\u52a1\u573a\u666f\u4e2d\uff0c\u9891\u7e41\u6267\u884c MySQL \u7684 SELECT DISTINCT \u67e5\u8be2\u53ef\u80fd\u4f1a\u6210\u4e3a\u6027\u80fd\u74f6\u9888\u3002\u672c\u6587\u5c06\u4ecb [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10020864","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10020864"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020864\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10020864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10020864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10020864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}