Posted 51CTO鎶€鏈爤
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了相关的知识,希望对你有一定的参考价值。
閫?绂?鍒?鍟?/strong>
鍏虫敞HarmonyOS鎶€鏈ぞ鍖?/strong>锛屽洖澶?/span>銆愰缚钂欍€?/span>閫?/span>浠峰€?/span>399鍏?/strong>鐨勯缚钂?/span>寮€鍙戞澘濂椾欢锛堟暟閲忎笉澶氾紝鍏堝埌鍏堝緱锛?/span>锛岃繕鍙互鍏嶈垂涓嬭浇楦胯挋鍏ラ棬璧勬枡锛?br class="mq-50">
馃憞鎵爜绔嬪埢鍏虫敞馃憞
涓撴敞寮€婧愭妧鏈紝鍏卞缓楦胯挋鐢熸€?/span>
鍓嶆鏃堕棿搴旀€ョ兢鏈夊鏈嶅弽棣堬紝浼氬憳绠$悊鍔熻兘鏃犳硶鎸夊埌搴楁椂闂淬€佸埌搴楁鏁般€佹秷璐归噾棰濊繘琛屾帓搴忋€傜粡杩囨帓鏌ュ彂鐜版槸 SQL 鎵ц鏁堢巼浣庯紝骞朵笖绱㈠紩鏁堢巼浣庝笅銆?/span>
搴旀€ラ棶棰?/p>
鍟嗘埛鍙嶉浼氬憳绠$悊鍔熻兘鏃犳硶鎸夊埌搴楁椂闂淬€佸埌搴楁鏁般€佹秷璐归噾棰濊繘琛屾帓搴忥紝涓€鐩磋浆鍦堝湀鎴栬浆瀹屾棤鍙樺寲锛屽晢鎴疯浠ユ鏁版嵁鏉ュ仛娲诲姩锛屾瘮杈冪潃鎬ワ紝璇峰敖蹇鐞嗭紝璋㈣阿銆?br>
绾夸笂鏁版嵁閲?/p>
merchant_member_info锛?/span>7000W 鏉℃暟鎹€?br>
member_info锛?/span>3000W銆?/span>
涓嶈闂垜涓轰粈涔堜笉鍒嗚〃锛屾敼鍔ㄥお澶э紝鏃犺兘涓哄姏銆?br>
闂 SQL
闂 SQL 濡備笅锛?/span>
SELECT
mui.id,
mui.merchant_id,
mui.member_id,
DATE_FORMAT(
mui.recently_consume_time,
'%Y%m%d%H%i%s'
) recently_consume_time,
IFNULL(mui.total_consume_num, 0) total_consume_num,
IFNULL(mui.total_consume_amount, 0) total_consume_amount,
(
CASE
WHEN u.nick_name IS NULL THEN
'浼氬憳'
WHEN u.nick_name = '' THEN
'浼氬憳'
ELSE
u.nick_name
END
) AS 'nickname',
u.sex,
u.head_image_url,
u.province,
u.city,
u.country
FROM
merchant_member_info mui
LEFT JOIN member_info u ON mui.member_id = u.id
WHERE
1 = 1
AND mui.merchant_id = '鍟嗘埛缂栧彿'
ORDER BY
mui.recently_consume_time DESC / ASC
LIMIT 0,
10
鍑虹幇鐨勫師鍥?/p>
缁忚繃楠岃瘉鍙互鎸夌収鈥滃埌搴楁椂闂粹€濊繘琛岄檷搴忔帓搴忥紝浣嗘槸鏃犳硶鎸夌収鍗囧簭杩涜鎺掑簭涓昏鏄煡璇㈠お鎱簡銆?/span>
涓昏鍘熷洜鏄細铏界劧璇ユ煡璇娇鐢ㄥ缓绔嬩簡 recently_consume_time 绱㈠紩锛屼絾鏄储寮曟晥鐜囦綆涓嬶紝闇€瑕佹煡璇㈡暣涓储寮曟爲锛屽鑷存煡璇㈡椂闂磋繃闀裤€侱ESC 鏌ヨ澶ф闇€瑕?4s锛孉SC 鏌ヨ澶參鑰楁椂鏈煡銆?br>
涓轰粈涔堥檷搴忔帓搴忓揩鍜岃€屽崌搴忔參鍛紵
濡備笅鍥撅細
鍥犱负鏄鏃堕棿寤虹珛浜嗙储寮曪紝鏈€杩戠殑鏃堕棿涓€瀹氬湪鏈€鍚庨潰锛屽崌搴忔煡璇紝闇€瑕佹煡璇㈡洿澶氱殑鏁版嵁锛屾墠鑳借繃婊ゅ嚭鐩稿簲鐨勭粨鏋滐紝鎵€浠ユ參銆?/span>
瑙e喅鏂规
鐩墠鐢熶骇搴撶殑绱㈠紩锛屽涓嬪浘锛?/span>
鈶犺皟鏁寸储寮?/span> 鈶㈣皟鏁村墠鍚庣粨鏋滃姣旓紙鍑嗙敓浜э級 娴嬭瘯鏁版嵁锛?/span> merchant_member_info 鏈?902606 鏉¤褰曘€?/span> member_info 琛ㄦ湁 775 鏉¤褰曘€?/span> 浼樺寲鍓嶏紝濡備笅鍥撅細 浼樺寲鍚庯紝濡備笅鍥撅細 type 鐢?index鈫抮ef锛宺ef 鐢?null鈫抍onst锛?/span> 璋冩暣绱㈠紩闇€瑕佹墽琛岀殑 SQL 缁忚闂紝閲嶅缓绱㈠紩鑺变簡 30 鍒嗛挓銆?br> 鏈€缁堢殑鍒嗛〉鏌ヨ浼樺寲 鏈€缁堢殑 SQL 缂栬緫锛氶櫠瀹堕緳 鍑哄锛歫uejin.cn/post/6844904053239971854 绮惧僵鏂囩珷鎺ㄨ崘锛?/strong> 以上是关于的主要内容,如果未能解决你的问题,请参考以下文章
闇€瑕佸垹闄?index_merchant_user_last_time 绱㈠紩锛屽悓鏃跺皢 index_merchant_user_merchant_ids 鍗曚緥绱㈠紩锛屽彉涓?nbsp; merchant_id锛宺ecently_consume_time 缁勫悎绱㈠紩銆?/span>
鈶¤皟鏁寸粨鏋滐紙鍑嗙敓浜э級
鈶QL 鎵ц鏁堢巼
# 鍒犻櫎杩戞湡娑堣垂鏃堕棿绱㈠紩
ALTER TABLE merchant_member_info DROP INDEX index_merchant_user_last_time;
# 鍒犻櫎鍟嗘埛缂栧彿绱㈠紩
ALTER TABLE merchant_member_info DROP INDEX index_merchant_user_merchant_ids;
# 寤虹珛鍟嗘埛缂栧彿鍜岃繎鏈熸秷璐规椂闂寸粍鍚堢储寮?nbsp;
ALTER TABLE merchant_member_info ADD INDEX idx_merchant_id_recently_time (`merchant_id`,`recently_consume_time`);
SELECT
mui.id,
mui.merchant_id,
mui.member_id,
DATE_FORMAT(
mui.recently_consume_time,
'%Y%m%d%H%i%s'
) recently_consume_time,
IFNULL(mui.total_consume_num, 0) total_consume_num,
IFNULL(mui.total_consume_amount, 0) total_consume_amount,
(
CASE
WHEN u.nick_name IS NULL THEN
'浼氬憳'
WHEN u.nick_name = '' THEN
'浼氬憳'
ELSE
u.nick_name
END
) AS 'nickname',
u.sex,
u.head_image_url,
u.province,
u.city,
u.country
FROM
merchant_member_info mui
INNER JOIN (
SELECT
id
FROM
merchant_member_info
WHERE
merchant_id = '鍟嗘埛ID'
ORDER BY
recently_consume_time DESC
LIMIT 9000,
10
) AS tmp ON tmp.id = mui.id
LEFT JOIN member_info u ON mui.member_id = u.id