你的JoinHint為什麼不生效

来源:https://www.cnblogs.com/huaweiyun/archive/2023/12/18/17910789.html
-Advertisement-
Play Games

本文分享自華為雲社區《你的JoinHint為什麼不生效【綻放吧!GaussDB(DWS)雲原生數倉】》,作者:你是猴子請來的救兵嗎 。 引言 提起資料庫的Hint,幾乎每個DBA都知道這一強大功能。在GaussDB(DWS)中,Hint可以被用來干預SQL的執行計劃,但是在日常工作中,很多開發人員對 ...


本文分享自華為雲社區《你的JoinHint為什麼不生效【綻放吧!GaussDB(DWS)雲原生數倉】》,作者:你是猴子請來的救兵嗎 。

引言

提起資料庫的Hint,幾乎每個DBA都知道這一強大功能。在GaussDB(DWS)中,Hint可以被用來干預SQL的執行計劃,但是在日常工作中,很多開發人員對Hint的缺乏深入瞭解,經常遇到Hint失效的情況卻又束手無策。
本次針對JoinHint從案例著手深入解析JoinHint不生效的原因,以便讀者能“知其所以然”。(本文不討論Hint的基礎語法問題)。

問題案例

內核版本 GaussDB 8.1.3

問題描述 兩表關聯查詢,使用hashjoin hint干預join方式,但hint不生效

問題用例

CREATE TABLE workitem (
    language character varying(10),
    userid character varying(240),
    opiontype character varying(240),
    processinstid character varying(240),
    workitemid character varying(240),
    type_name character varying(240),
    type_code character varying(240),
    createtime timestamp without time zone,
    endtime timestamp without time zone,
    notrejecttotal numeric,
    dws_created_time timestamp without time zone
)
WITH (orientation=column, compression=low, colversion=2.0, enable_delta=false)
DISTRIBUTE BY HASH(workitemid);

CREATE  TABLE workday (
    mm timestamp with time zone,
    rn numeric
)
WITH (orientation=column, compression=low, colversion=2.0, enable_delta=false)
DISTRIBUTE BY HASH(mm);

explain
SELECT /*+ hashjoin(c d) */
    c.userid,c.type_name,c.type_code,count(1) num
FROM workitem c INNER JOIN workday d ON c.createtime = d.mm
    WHERE c.createtime >= '2023-09-01' AND c.endtime < '2023-10-01'
    GROUP BY c.userid,c.type_name,c.type_code;

WARNING:  unused hint: HashJoin(c d)
                                                                                 QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  id |                      operation                       | E-rows | E-memory | E-width | E-costs
 ----+------------------------------------------------------+--------+----------+---------+---------
   1 | ->  Row Adapter                                      |      2 |          |    1502 | 33.12
   2 |    ->  Vector Sonic Hash Aggregate                   |      2 |          |    1502 | 33.12
   3 |       ->  Vector Streaming (type: GATHER)            |      4 |          |    1502 | 33.12
   4 |          ->  Vector Sonic Hash Aggregate             |      4 | 16MB     |    1502 | 27.12
   5 |             ->  Vector Nest Loop (6,8)               |      5 | 1MB      |    1494 | 27.08
   6 |                ->  Vector Streaming(type: BROADCAST) |     14 | 2MB      |       8 | 13.68
   7 |                   ->  CStore Scan on workday d       |      7 | 1MB      |       8 | 13.05
   8 |                ->  Vector Materialize                |      5 | 16MB     |    1502 | 13.09
   9 |                   ->  CStore Scan on workitem c      |      5 | 1MB      |    1502 | 13.08

         RunTime Analyze Information
 -------------------------------------------
         "public.workitem" runtime: 25.794ms
         "public.workday" runtime: 18.098ms

                                                               Predicate Information (identified by plan id)
 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   5 --Vector Nest Loop (6,8)
         Join Filter: (c.createtime = d.mm)
   7 --CStore Scan on workday d
         Filter: (mm >= '2023-09-01 00:00:00'::timestamp without time zone)
         Pushdown Predicate Filter: (mm >= '2023-09-01 00:00:00'::timestamp without time zone)
   9 --CStore Scan on workitem c
         Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))
         Pushdown Predicate Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))

   ====== Query Summary =====
 -------------------------------
 System available mem: 4710400KB
 Query Max mem: 4710400KB
 Query estimated mem: 5271KB
(33 rows)

問題定位

嘗試關閉nestloop路徑,來驗證是否可以生成hash計劃

set enable_nestloop = off;

set enable_mergejoin = off;

set enable_hashjoin = on;

WARNING:  unused hint: HashJoin(c d)
                                                                                 QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  id |                      operation                       | E-rows | E-memory | E-width | E-costs
 ----+------------------------------------------------------+--------+----------+---------+---------
   1 | ->  Row Adapter                                      |      2 |          |    1502 | 33.12
   2 |    ->  Vector Sonic Hash Aggregate                   |      2 |          |    1502 | 33.12
   3 |       ->  Vector Streaming (type: GATHER)            |      4 |          |    1502 | 33.12
   4 |          ->  Vector Sonic Hash Aggregate             |      4 | 16MB     |    1502 | 27.12
   5 |             ->  Vector Nest Loop (6,8)               |      5 | 1MB      |    1494 | 27.08
   6 |                ->  Vector Streaming(type: BROADCAST) |     14 | 2MB      |       8 | 13.68
   7 |                   ->  CStore Scan on workday d       |      7 | 1MB      |       8 | 13.05
   8 |                ->  Vector Materialize                |      5 | 16MB     |    1502 | 13.09
   9 |                   ->  CStore Scan on workitem c      |      5 | 1MB      |    1502 | 13.08

                                                               Predicate Information (identified by plan id)
 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   5 --Vector Nest Loop (6,8)
         Join Filter: (c.createtime = d.mm)
   7 --CStore Scan on workday d
         Filter: (mm >= '2023-09-01 00:00:00'::timestamp without time zone)
         Pushdown Predicate Filter: (mm >= '2023-09-01 00:00:00'::timestamp without time zone)
   9 --CStore Scan on workitem c
         Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))
         Pushdown Predicate Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))

   ====== Query Summary =====
 -------------------------------
 System available mem: 4710400KB
 Query Max mem: 4710400KB
 Query estimated mem: 5271KB
(28 rows)

關閉nestloop路徑後,仍然生成nestloop計劃,且E-costs代價中未添加懲罰代價,說明該場景語句本身不支持hashjoin。

檢查關聯表達式(c.createtime = d.mm),確認是否支持hashjoin。

  • 關聯表達式為欄位關聯,不存在函數嵌套
  • 關聯表達式兩邊數據類型為timestamp without time zone和timestamp with time zone,通過系統表pg_operator確認是否支持hashjoin。
postgres=# select * from pg_operator where oprname = '=' and oprleft = 'timestamp'::regtype and oprright = 'timestamptz'::regtype;
-[ RECORD 1 ]+-------------------------
oprname      | =
oprnamespace | 11
oprowner     | 10
oprkind      | b
oprcanmerge  | t
oprcanhash   | f
oprleft      | 1114
oprright     | 1184
oprresult    | 16
oprcom       | 2542
oprnegate    | 2539
oprcode      | timestamp_eq_timestamptz
oprrest      | eqsel
oprjoin      | eqjoinsel
  • 通過結果確認oprcanhash為false,代表該操作符不支持hash連接;原因是,左邊數據不帶時區,右邊數據帶,在比較時要先處理時區問題,不能直接拿存儲值進行判斷。

改善辦法

通過系統表確認timestamp類型的等值關聯和timestamptz的等值關聯均支持hash連接。
postgres=# select * from pg_operator where oprname = '=' and oprleft = oprright and oprleft in('timestamp'::regtype,'timestamptz'::regtype);
-[ RECORD 1 ]+---------------
oprname      | =
oprnamespace | 11
oprowner     | 10
oprkind      | b
oprcanmerge  | t
oprcanhash   | t
oprleft      | 1184
oprright     | 1184
oprresult    | 16
oprcom       | 1320
oprnegate    | 1321
oprcode      | timestamptz_eq
oprrest      | eqsel
oprjoin      | eqjoinsel
-[ RECORD 2 ]+---------------
oprname      | =
oprnamespace | 11
oprowner     | 10
oprkind      | b
oprcanmerge  | t
oprcanhash   | t
oprleft      | 1114
oprright     | 1114
oprresult    | 16
oprcom       | 2060
oprnegate    | 2061
oprcode      | timestamp_eq
oprrest      | eqsel
oprjoin      | eqjoinsel

在關聯條件上添加類型轉換,保證兩邊類型一致,即(c.createtime::timestamptz = d.mm)或(c.createtime = d.mm::timestamp)。

postgres=# explain
postgres-# SELECT /*+ hashjoin(c d) */
postgres-#     c.userid,c.type_name,c.type_code,count(1) num
postgres-# FROM workitem c INNER JOIN workday d ON c.createtime::timestamptz = d.mm
postgres-#     WHERE c.createtime >= '2023-09-01' AND c.endtime < '2023-10-01'
postgres-#     GROUP BY c.userid,c.type_name,c.type_code;
                                                                                 QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  id |                      operation                       | E-rows | E-memory | E-width | E-costs
 ----+------------------------------------------------------+--------+----------+---------+---------
   1 | ->  Row Adapter                                      |      2 |          |    1502 | 34.29
   2 |    ->  Vector Sonic Hash Aggregate                   |      2 |          |    1502 | 34.29
   3 |       ->  Vector Streaming (type: GATHER)            |      4 |          |    1502 | 34.29
   4 |          ->  Vector Sonic Hash Aggregate             |      4 | 16MB     |    1502 | 28.29
   5 |             ->  Vector Sonic Hash Join (6,8)         |      5 | 16MB     |    1494 | 28.25
   6 |                ->  Vector Streaming(type: BROADCAST) |     40 | 2MB      |       8 | 15.06
   7 |                   ->  CStore Scan on workday d       |     20 | 1MB      |       8 | 13.01
   8 |                ->  CStore Scan on workitem c         |      5 | 1MB      |    1502 | 13.08

                                                               Predicate Information (identified by plan id)
 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   5 --Vector Sonic Hash Join (6,8)
         Hash Cond: (d.mm = (c.createtime)::timestamp with time zone)
   8 --CStore Scan on workitem c
         Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))
         Pushdown Predicate Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))

   ====== Query Summary =====
 -------------------------------
 System available mem: 4710400KB
 Query Max mem: 4710400KB
 Query estimated mem: 5530KB
(24 rows)

postgres=# explain
SELECT /*+ hashjoin(c d) */
    c.userid,c.type_name,c.type_code,count(1) num
FROM workitem c INNER JOIN workday d ON c.createtime = d.mm::timestamp
    WHERE c.createtime >= '2023-09-01' AND c.endtime < '2023-10-01'
    GROUP BY c.userid,c.type_name,c.type_code;
                                                                                 QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  id |                      operation                       | E-rows | E-memory | E-width | E-costs
 ----+------------------------------------------------------+--------+----------+---------+---------
   1 | ->  Row Adapter                                      |      2 |          |    1502 | 32.91
   2 |    ->  Vector Sonic Hash Aggregate                   |      2 |          |    1502 | 32.91
   3 |       ->  Vector Streaming (type: GATHER)            |      4 |          |    1502 | 32.91
   4 |          ->  Vector Sonic Hash Aggregate             |      4 | 16MB     |    1502 | 26.91
   5 |             ->  Vector Sonic Hash Join (6,8)         |      5 | 16MB     |    1494 | 26.87
   6 |                ->  Vector Streaming(type: BROADCAST) |     14 | 2MB      |       8 | 13.71
   7 |                   ->  CStore Scan on workday d       |      7 | 1MB      |       8 | 13.08
   8 |                ->  CStore Scan on workitem c         |      5 | 1MB      |    1502 | 13.08

                                                               Predicate Information (identified by plan id)
 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   5 --Vector Sonic Hash Join (6,8)
         Hash Cond: ((d.mm)::timestamp without time zone = c.createtime)
   7 --CStore Scan on workday d
         Filter: ((mm)::timestamp without time zone >= '2023-09-01 00:00:00'::timestamp without time zone)
   8 --CStore Scan on workitem c
         Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))
         Pushdown Predicate Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))

   ====== Query Summary =====
 -------------------------------
 System available mem: 4710400KB
 Query Max mem: 4710400KB
 Query estimated mem: 5530KB
(26 rows)

知識小結

實際使用過程中導致hint生效的原因很多,這裡總結排查hashjoin hint步驟以供參考:

  • 檢查hint中的表名是否正確、是否存在重名、是否在當前層可見,此類場景通常在explain中會給出提示,自行排查即可。
  • 判斷關聯hint中的表名是否被提升導致表名不存在,此類場景通常在explain中會給出提示
postgres=# explain
SELECT /*+ hashjoin(c d) */
    c.userid,c.type_name,c.type_code,count(1) num
FROM workitem c INNER JOIN (select * from workday where mm >= '2023-09-01') d ON c.createtime = d.mm::timestamp
    WHERE c.createtime >= '2023-09-01' AND c.endtime < '2023-10-01'
    GROUP BY c.userid,c.type_name,c.type_code;
WARNING:  Error hint: HashJoin(c d), relation name "d" is not found.
                                                                                 QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  id |                      operation                       | E-rows | E-memory | E-width | E-costs
 ----+------------------------------------------------------+--------+----------+---------+---------
   1 | ->  Row Adapter                                      |      2 |          |    1502 | 32.78
   2 |    ->  Vector Sonic Hash Aggregate                   |      2 |          |    1502 | 32.78
   3 |       ->  Vector Streaming (type: GATHER)            |      4 |          |    1502 | 32.78
   4 |          ->  Vector Sonic Hash Aggregate             |      4 | 16MB     |    1502 | 26.78
   5 |             ->  Vector Sonic Hash Join (6,8)         |      5 | 16MB     |    1494 | 26.74
   6 |                ->  Vector Streaming(type: BROADCAST) |     10 | 2MB      |       8 | 13.58
   7 |                   ->  CStore Scan on workday         |      5 | 1MB      |       8 | 13.11
   8 |                ->  CStore Scan on workitem c         |      5 | 1MB      |    1502 | 13.08

                                                               Predicate Information (identified by plan id)
 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   5 --Vector Sonic Hash Join (6,8)
         Hash Cond: ((workday.mm)::timestamp without time zone = c.createtime)
   7 --CStore Scan on workday
         Filter: ((mm >= '2023-09-01 00:00:00+08'::timestamp with time zone) AND ((mm)::timestamp without time zone >= '2023-09-01 00:00:00'::timestamp without time zone))
         Pushdown Predicate Filter: (mm >= '2023-09-01 00:00:00+08'::timestamp with time zone)
   8 --CStore Scan on workitem c
         Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))
         Pushdown Predicate Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))

   ====== Query Summary =====
 -------------------------------
 System available mem: 4710400KB
 Query Max mem: 4710400KB
 Query estimated mem: 5530KB
(27 rows)

針對此種情況,8.2.0及以上版本可以通過添加no merge hint來禁用子查詢提升從而規避hint失效問題。

通過join路徑參數驗證目標路徑是否可生效。
--如通過關閉其他路徑參數來驗證某一路徑是否可達
set enable_nestloop = off;
set enable_mergejoin = off;
set enable_hashjoin = on;
檢查關聯條件中是否存在volatile函數。
postgres=# create or replace function gettimediff(timestamp) returns interval language sql as 'select $1-timeofday()::timestamp' volatile;
CREATE FUNCTION
postgres=# explain
SELECT /*+ hashjoin(c d) */
    c.userid,c.type_name,c.type_code,count(1) num
FROM workitem c INNER JOIN workday d ON gettimediff(c.createtime) = gettimediff(d.mm::timestamp)
    WHERE c.createtime >= '2023-09-01' AND c.endtime < '2023-10-01'
    GROUP BY c.userid,c.type_name,c.type_code;
WARNING:  unused hint: HashJoin(c d)
                                                                               QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  id |                          operation                          | E-rows | E-width | E-costs
 ----+-------------------------------------------------------------+--------+---------+---------
   1 | ->  HashAggregate                                           |      5 |    1502 | 3.10
   2 |    ->  Nested Loop (3,4)                                    |      5 |    1494 | 3.00
   3 |       ->  Data Node Scan on workitem "_REMOTE_TABLE_QUERY_" |      5 |    1502 | 0.00
   4 |       ->  Data Node Scan on workday "_REMOTE_TABLE_QUERY_"  |     20 |       8 | 0.00

                                                              Predicate Information (identified by plan id)
 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
   2 --Nested Loop (3,4)
         Join Filter: ((c.createtime - (timeofday())::timestamp without time zone) = ((d.mm)::timestamp without time zone - (timeofday())::timestamp without time zone))
(11 rows)
檢查關聯條件中兩表欄位是否在等號兩側,若不是則進行調整。
postgres=# explain
SELECT /*+ hashjoin(c d) */
    c.userid,c.type_name,c.type_code,count(1) num
FROM workitem c INNER JOIN workday d ON ifnull(c.createtime,d.mm) = now()
    WHERE c.createtime >= '2023-09-01' AND c.endtime < '2023-10-01'
    GROUP BY c.userid,c.type_name,c.type_code;
WARNING:  unused hint: HashJoin(c d)
                                                                                 QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  id |                      operation                       | E-rows | E-memory | E-width | E-costs
 ----+------------------------------------------------------+--------+----------+---------+---------
   1 | ->  Row Adapter                                      |      1 |          |    1502 | 35.37
   2 |    ->  Vector Sonic Hash Aggregate                   |      1 |          |    1502 | 35.37
   3 |       ->  Vector Streaming (type: GATHER)            |      2 |          |    1502 | 35.37
   4 |          ->  Vector Sonic Hash Aggregate             |      2 | 16MB     |    1502 | 29.37
   5 |             ->  Vector Nest Loop (6,8)               |      2 | 1MB      |    1494 | 29.35
   6 |                ->  Vector Streaming(type: BROADCAST) |     40 | 2MB      |       8 | 15.06
   7 |                   ->  CStore Scan on workday d       |     20 | 1MB      |       8 | 13.01
   8 |                ->  Vector Materialize                |      5 | 16MB     |    1502 | 13.09
   9 |                   ->  CStore Scan on workitem c      |      5 | 1MB      |    1502 | 13.08

                                                               Predicate Information (identified by plan id)
 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   5 --Vector Nest Loop (6,8)
         Join Filter: (COALESCE((c.createtime)::timestamp with time zone, d.mm) = now())
   9 --CStore Scan on workitem c
         Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))
         Pushdown Predicate Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))

   ====== Query Summary =====
 -------------------------------
 System available mem: 4710400KB
 Query Max mem: 4710400KB
 Query estimated mem: 5275KB
(25 rows)
檢查關聯條件是否為等值關聯,若不是則進行調整。
postgres=# explain
SELECT /*+ hashjoin(c d) */
    c.userid,c.type_name,c.type_code,count(1) num
FROM workitem c INNER JOIN workday d ON c.createtime::timestamptz > d.mm
    WHERE c.createtime >= '2023-09-01' AND c.endtime < '2023-10-01'
    GROUP BY c.userid,c.type_name,c.type_code;
WARNING:  unused hint: HashJoin(c d)
                                                                                 QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  id |                      operation                       | E-rows | E-memory | E-width | E-costs
 ----+------------------------------------------------------+--------+----------+---------+---------
   1 | ->  Row Adapter                                      |      5 |          |    1502 | 35.41
   2 |    ->  Vector Sonic Hash Aggregate                   |      5 |          |    1502 | 35.41
   3 |       ->  Vector Streaming (type: GATHER)            |     10 |          |    1502 | 35.41
   4 |          ->  Vector Sonic Hash Aggregate             |     10 | 16MB     |    1502 | 29.41
   5 |             ->  Vector Nest Loop (6,8)               |     33 | 1MB      |    1494 | 29.20
   6 |                ->  Vector Streaming(type: BROADCAST) |     40 | 2MB      |       8 | 15.06
   7 |                   ->  CStore Scan on workday d       |     20 | 1MB      |       8 | 13.01
   8 |                ->  Vector Materialize                |      5 | 16MB     |    1502 | 13.09
   9 |                   ->  CStore Scan on workitem c      |      5 | 1MB      |    1502 | 13.08

                                                               Predicate Information (identified by plan id)
 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   5 --Vector Nest Loop (6,8)
         Join Filter: ((c.createtime)::timestamp with time zone > d.mm)
   9 --CStore Scan on workitem c
         Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))
         Pushdown Predicate Filter: ((createtime >= '2023-09-01 00:00:00'::timestamp without time zone) AND (endtime < '2023-10-01 00:00:00'::timestamp without time zone))

   ====== Query Summary =====
 -------------------------------
 System available mem: 4710400KB
 Query Max mem: 4710400KB
 Query estimated mem: 5281KB
(25 rows)
檢查關聯關係兩側的數據類型,並通過pg_operator.oprcanhash確認是否支持hash連接,若不支持則需改寫為支持的操作符。
postgres=# select * from pg_operator where oprname = '=' and oprleft = 'timestamp'::regtype and oprright = 'timestamptz'::regtype;
-[ RECORD 1 ]+-------------------------
oprname      | =
oprnamespace | 11
oprowner     | 10
oprkind      | b
oprcanmerge  | t
oprcanhash   | f
oprleft      | 1114
oprright     | 1184
oprresult    | 16
oprcom       | 2542
oprnegate    | 2539
oprcode      | timestamp_eq_timestamptz
oprrest      | eqsel
oprjoin      | eqjoinsel
如果是指定join順序的hint,如leading(c e),會存在邏輯本身衝突導致hint失敗的情況。
postgres=# explain SELECT /*+ leading(c e) */
    c.userid,c.type_name,c.type_code,count(1) num
FROM workitem c LEFT JOIN workday d ON c.createtime = d.mm LEFT JOIN workday e ON d.mm = e.mm
    WHERE c.createtime >= '2023-09-01' AND c.endtime < '2023-10-01'
    GROUP BY c.userid,c.type_name,c.type_code;
WARNING:  unused hint: Leading(c e)
                               

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 來源:https://mp.weixin.qq.com/s/ydBWABy7kwOWxNCQu4qYMA 在visual studio開發winform程式,生成msi安裝包以後,代碼運行似乎沒有問題。但是,若是軟體安裝到了C盤,軟體在執行某些操作,比如寫文件、讀文件等操作時,有可能會因為操作系統用 ...
  • 使用過visio的都知道,在繪製流程圖時,當選擇或滑鼠移動到控制項時,都會在控制項的四周出現錨點,以便於修改大小,移動位置,或連接線等,那此功能是如何實現的呢?在WPF開發中,想要在控制項四周實現錨點,可以通過裝飾器來實現,今天通過一個簡單的小例子,簡述如何在WPF開發中,應用裝飾器,僅供學習分享使用,如... ...
  • 接上文:https://www.cnblogs.com/wy123/p/17905118.html,關於AlwaysOn主副本與輔助副本之間提交模式與安全故障轉移的話題 參考AlwaysOn屬性面板中的信息 1,主節點非同步提交模式:如果主要副本配置為“非同步提交模式” ,則從節點不管是同步或者非同步,主 ...
  • 隨著雲計算技術的快速發展,雲資料庫作為雲計算的重要組成部分,為企業提供了高效、靈活和可靠的數據存儲和管理服務。其中,MySQL作為一款流行的開源關係型資料庫,在雲資料庫領域具有廣泛的應用。多人協同開發是軟體開發過程中的重要環節,本文將探討雲資料庫MySQL多人協同開發的實踐。 ...
  • 近日,天池FT-Data Ranker競賽落下帷幕,天翼雲智能邊緣事業部AI團隊(後稱天翼雲AI團隊)憑藉在大語言模型(LLM)訓練數據增強方面的卓越研究,榮獲大語言模型微調數據競賽——7B模型賽道冠軍。 ...
  • 目錄創建表用法示例資料分享參考文章 ODBC集成表引擎使得ClickHouse可以通過ODBC方式連接到外部資料庫. 為了安全地實現 ODBC 連接,ClickHouse 使用了一個獨立程式 clickhouse-odbc-bridge. 如果ODBC驅動程式是直接從 clickhouse-serv ...
  • 假設你要為用戶名為'username'@'localhost'的用戶設置新密碼,你可以這樣做: 其中,username 是用戶名,localhost 是主機名, 123456是要更改的新密碼。 方法1: 用 ALTER 語句 ALTER USER 'username'@'localhost' IDE ...
  • MySQL提供了多種方法來鎖定解鎖賬號,下麵是幾種常用的方法: 1.使用ALTER語句鎖定賬號 鎖定賬號: ALTER USER 'username'@'localhost' ACCOUNT LOCK; 解鎖賬號: ALTER USER'username'@'localhost' ACCOUNT U ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...