Postgresql源碼(145)優化器nestloop參數化路徑評估不準問題分析

相關
《Postgresql源碼(133)優化器動態規劃生成連接路徑的實例分析》

1 問題

最近遇到一個問題,評估行數和真實行數存在較大差距,導致計劃不準的問題。

nestloop內表評估是根據外表的參數來的。因為外表驅動表每取一條,內表才能做查詢。所以這里外表的一條數據對內表來說就是參數。內表使用參數化路徑來評估行數。

本篇針對這個實例對參數化路徑行數評估做一些分析。

postgres=# explain analyze select * from iii, mmm where iii.poid = mmm.poid;QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------Nested Loop  (cost=0.43..125.97 rows=17 width=27) (actual time=0.063..6.031 rows=1000 loops=1)->  Seq Scan on mmm  (cost=0.00..1.10 rows=10 width=13) (actual time=0.005..0.010 rows=10 loops=1)->  Index Scan using idx_iii_poid on iii  (cost=0.43..12.47 rows=2 width=14) (actual time=0.022..0.563 rows=100 loops=10)Index Cond: (poid = mmm.poid)Planning Time: 0.351 msExecution Time: 6.138 ms
(6 rows)

2 全文總結(便于查詢)

文章結論

  • get_parameterized_baserel_size計算參數化路徑的選擇率,本例中并沒有看到任何特殊的評估方法,完全是按照poid的選擇率來評估的。
clauselist_selectivity = 1.7108151058814915e-07
rel->tuples = 10000001nrows = rel->tuples * clauselist_selectivity = 2
  • pg_statistic記錄的poid列唯一值個數占比-0.58516644
  • pg_class記錄行數為10000001條,所以評估poid列的唯一值個數為10000001*0.58516644=5845167(實際9901001)。這里有一半的偏差,但不是主要原因。
  • 2行=10000001*1.71e-07,在一個均勻分布的數據集中,每一個唯一值出現的概率是1.71e-07。所以如果有1千萬行數據,隨便給一個poid,能選出來兩行不一樣的。
    • 如果唯一值非常少,那么選擇率會變大,趨近于1,則10000001行=10000001*1。隨便給一個poid,能選出來會非常多。
    • 如果唯一值非常多,那么選擇率會變小,趨近于0,則0行=10000001*0。隨便給一個poid,能選出來會非常少。
  • 評估兩行但實際是100行的原因是,數據不均勻但統計信息平均采樣,導致pg_statistic中stadistinct不準,進一步導致選擇率不準,導致計算出現偏差。

分析思路整理

  • standard_join_search逐層規劃連接順序,找到參數化path節點。1.1.1 PATH 1:用索引參數化路徑,評估2行
  • create_index_path在make_one_rel→set_base_rel_pathlists中一共調用6次,其中一次是參數化路徑,特點是入參required_outer有值,可能拿到外表信息。
  • 進一步分析create_index_path參數化成本計算,create_index_path→get_baserel_parampathinfo函數生成ParamPathInfo,ParamPathInfo中ppi_rows記錄估算函數。
  • 進一步分析ppi_rows的計算,在create_index_path→get_baserel_parampathinfo中處理,get_baserel_parampathinfo用行數1千萬乘以選擇率得到行數。
  • 進一步分析選擇率的計算
    • clauselist_selectivity → clause_selectivity_ext → restriction_selectivity → eqsel_internal → var_eq_non_const
    • 使用stadistinct = stats->stadistinct = -0.58516644 (來自pg_statistic表)
    • 使用ntuples = vardata->rel->tuples = 10000001(來自relation結構,來自pg_class表)
    • 計算唯一行數:clamp_row_est(-stadistinct * ntuples = 5845167.024516644) = 5845167
    • 進而得到選擇率selec = selec / ndistinct = 1 / 5845167 = 1.7108151058814915e-07

實例

  • 計劃二:優化器認為驅動表每一行,內表有2行能連接上,實際有100行能連接上。為什么差距大?

  • (cost=0.43..12.47 rows=2 width=14) (actual time=0.022..0.563 rows=100 loops=10)評估不準的原因是什么?

-- 計劃二
drop table iii;
CREATE TABLE iii (poid INT NOT NULL, value NUMERIC, status int);
-- 可以和mmm表連上
INSERT INTO iii SELECT t%1000, t, 0 FROM generate_series(1, 100000) t order by random();
-- 干擾數據,占比高擔都和mmm表連不上
INSERT INTO iii SELECT t, t, 0 FROM generate_series(100000, 10000000) t order by random();
CREATE INDEX idx_iii_poid ON iii(poid);
analyze iii;drop table mmm;
CREATE TABLE mmm (poid INT NOT NULL, value NUMERIC, status int);
INSERT INTO mmm SELECT t, t, 0 FROM generate_series(1, 10) t order by random();
CREATE INDEX idx_mmm_poid ON mmm(poid);
analyze mmm;set enable_hashjoin to off;
set enable_mergejoin to off;
set enable_bitmapscan to off;
explain analyze select * from iii, mmm where iii.poid = mmm.poid;postgres=# explain analyze select * from iii, mmm where iii.poid = mmm.poid;QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------Nested Loop  (cost=0.43..125.97 rows=17 width=27) (actual time=0.063..6.031 rows=1000 loops=1)->  Seq Scan on mmm  (cost=0.00..1.10 rows=10 width=13) (actual time=0.005..0.010 rows=10 loops=1)->  Index Scan using idx_iii_poid on iii  (cost=0.43..12.47 rows=2 width=14) (actual time=0.022..0.563 rows=100 loops=10)Index Cond: (poid = mmm.poid)Planning Time: 0.351 msExecution Time: 6.138 ms
(6 rows)

要分析這個問題需要從path生成開始看:

path生成

1 standard_join_search第一層

1.1 第一層第一個RelOptInfo(iii表)

p ((RelOptInfo*)root->join_rel_level[1].elements[0].ptr_value).pathlist

1.1.1 PATH 1:用索引參數化路徑,評估2行,代價total_cost = 12.466928526553348
$53 = {path = {type = T_IndexPath,pathtype = T_IndexScan,parent = 0x1e91558,pathtarget = 0x1e697c8,param_info = 0x1e8d340,parallel_aware = false,parallel_safe = true,parallel_workers = 0,rows = 2,startup_cost = 0.435,total_cost = 12.466928526553348,pathkeys = 0x1e8cf90},indexinfo = 0x1e91768,indexclauses = 0x1e8cef0,indexorderbys = 0x0,indexorderbycols = 0x0,indexscandir = ForwardScanDirection,indextotalcost = 4.4499999999999993,indexselectivity = 1.7108151058814915e-07
}

param_info = 0x1e8d340 記錄了什么?
在這里插入圖片描述

1.1.2 PATH 2:全表掃,代價total_cost = 154055.01000000001
(gdb) tr Path 0x1e8bbc0
$55 = {type = T_Path,pathtype = T_SeqScan,parent = 0x1e91558,pathtarget = 0x1e697c8,param_info = 0x0,parallel_aware = false,parallel_safe = true,parallel_workers = 0,rows = 10000001,startup_cost = 0,total_cost = 154055.01000000001,pathkeys = 0x0
}
1.1.3 PATH 3:用索引全表掃iii表,評估10000001行。代價total_cost = 475019.93093073595
$57 = {path = {type = T_IndexPath,pathtype = T_IndexScan,parent = 0x1e91558,pathtarget = 0x1e697c8,param_info = 0x0,parallel_aware = false,parallel_safe = true,parallel_workers = 0,rows = 10000001,startup_cost = 0.435,total_cost = 475019.93093073595,pathkeys = 0x1e8c7d0},indexinfo = 0x1e91768,indexclauses = 0x0,indexorderbys = 0x0,indexorderbycols = 0x0,indexscandir = ForwardScanDirection,indextotalcost = 158924.44,indexselectivity = 1
}

1.2 第一層第二個RelOptInfo(mmm表)

p ((RelOptInfo*)root->join_rel_level[1].elements[1].ptr_value).pathlist

1.2.1 PATH 1:用索引參數化路徑,評估1行,代價total_cost = 0.15250119999987999
$70 = {path = {type = T_IndexPath,pathtype = T_IndexScan,parent = 0x1e90d28,pathtarget = 0x1e698f8,param_info = 0x1eac2d8,parallel_aware = false,parallel_safe = true,parallel_workers = 0,rows = 1,startup_cost = 0.13500000000000001,total_cost = 0.15250119999987999,pathkeys = 0x1eabfd8},indexinfo = 0x1e8b8c8,indexclauses = 0x1eabf38,indexorderbys = 0x0,indexorderbycols = 0x0,indexscandir = ForwardScanDirection,indextotalcost = 0.14250079999991999,indexselectivity = 0.10000000000000001
}
1.2.2 PATH 2:全表掃,評估10行,代價total_cost = 1.1000000000000001
$71 = {type = T_Path,pathtype = T_SeqScan,parent = 0x1e90d28,pathtarget = 0x1e698f8,param_info = 0x0,parallel_aware = false,parallel_safe = true,parallel_workers = 0,rows = 10,startup_cost = 0,total_cost = 1.1000000000000001,pathkeys = 0x0
}
1.2.3 PATH 3:索引全表掃,評估10行,代價otal_cost = 12.285
{path = {type = T_IndexPath,pathtype = T_IndexScan,parent = 0x1e90d28,pathtarget = 0x1e698f8,param_info = 0x0,parallel_aware = false,parallel_safe = true,parallel_workers = 0,rows = 10,startup_cost = 0.13500000000000001,total_cost = 12.285,pathkeys = 0x1eab998},indexinfo = 0x1e8b8c8,indexclauses = 0x0,indexorderbys = 0x0,indexorderbycols = 0x0,indexscandir = ForwardScanDirection,indextotalcost = 8.1850000000000005,indexselectivity = 1
}

2 standard_join_search第二層,只有一個RelOptInfo

p ((RelOptInfo*)root->join_rel_level[2].elements[0].ptr_value).pathlist

只有一個PATH

$91 = {jpath = {path = {type = T_NestPath,pathtype = T_NestLoop,parent = 0x1eacc28,pathtarget = 0x1eace58,param_info = 0x0,parallel_aware = false,parallel_safe = true,parallel_workers = 0,rows = 17,startup_cost = 0.435,total_cost = 125.96928526553347,pathkeys = 0x0},jointype = JOIN_INNER,inner_unique = false,outerjoinpath = 0x1e8d780,  innerjoinpath = 0x1e8d020,joinrestrictinfo = 0x0}
}
  • outerjoinpath = 0x1e8d780:選擇了1.2.2 PATH 2:全表掃,評估10行,代價total_cost = 1.1000000000000001。
  • innerjoinpath = 0x1e8d020:選擇了1.1.1 PATH 1:用索引參數化路徑,評估2行,代價total_cost = 12.466928526553348。

為什么iii表的索引參數化路徑評估只有2行?

  • 現階段只有nestloop的內表需要參數化路徑,因為內表評估行數時,無法確切知道能連上多少行,所以只能計算出一個行數。
  • 在上文 1.1.1 PATH 1:用索引參數化路徑,評估2行,代價total_cost = 12.466928526553348中,參數化node評估的行數是怎么計算出來的?
$53 = {path = {type = T_IndexPath,pathtype = T_IndexScan,parent = 0x1e91558,pathtarget = 0x1e697c8,param_info = 0x1e8d340,parallel_aware = false,parallel_safe = true,parallel_workers = 0,rows = 2,startup_cost = 0.435,total_cost = 12.466928526553348,pathkeys = 0x1e8cf90},indexinfo = 0x1e91768,indexclauses = 0x1e8cef0,indexorderbys = 0x0,indexorderbycols = 0x0,indexscandir = ForwardScanDirection,indextotalcost = 4.4499999999999993,indexselectivity = 1.7108151058814915e-07
}

create_index_path在make_one_rel→set_base_rel_pathlists中一共調用6次:

-- iii表的索引 idx_iii_poid,非參數化路徑
create_index_path (root=0x1e68cb8, index=0x1e91768, indexclauses=0x0,       indexorderbys=0x0, indexorderbycols=0x0, pathkeys=0x1e8c7d0, indexscandir=ForwardScanDirection, indexonly=false, required_outer=0x0,       loop_count=1, partial_path=false)
-- iii表的索引 idx_iii_poid,非參數化路徑
create_index_path (root=0x1e68cb8, index=0x1e91768, indexclauses=0x0,       indexorderbys=0x0, indexorderbycols=0x0, pathkeys=0x1e8c7d0, indexscandir=ForwardScanDirection, indexonly=false, required_outer=0x0,       loop_count=1, partial_path=true)
-- iii表的索引 idx_iii_poid,required_outer有值,計算參數化路徑
create_index_path (root=0x1e68cb8, index=0x1e91768, indexclauses=0x1e8cef0, indexorderbys=0x0, indexorderbycols=0x0, pathkeys=0x1e8cf90, indexscandir=ForwardScanDirection, indexonly=false, required_outer=0x1e8cca0, loop_count=10, partial_path=false)-- mmm表的索引 idx_mmm_poid
create_index_path (root=0x1e68cb8, index=0x1e8b8c8, indexclauses=0x0,       indexorderbys=0x0, indexorderbycols=0x0, pathkeys=0x1eab998, indexscandir=ForwardScanDirection, indexonly=false, required_outer=0x0,       loop_count=1, partial_path=false)
create_index_path (root=0x1e68cb8, index=0x1e8b8c8, indexclauses=0x0,       indexorderbys=0x0, indexorderbycols=0x0, pathkeys=0x1eab998, indexscandir=ForwardScanDirection, indexonly=false, required_outer=0x0,       loop_count=1, partial_path=true)
create_index_path (root=0x1e68cb8, index=0x1e8b8c8, indexclauses=0x1eabf38, indexorderbys=0x0, indexorderbycols=0x0, pathkeys=0x1eabfd8, indexscandir=ForwardScanDirection, indexonly=false, required_outer=0x1e8d2d0, loop_count=10000001, partial_path=false)
  • required_outer有值,表示參數化的indexpath:
-- iii表的索引 idx_iii_poid,required_outer有值,計算參數化路徑
create_index_path (root=0x1e68cb8, index=0x1e91768, indexclauses=0x1e8cef0, indexorderbys=0x0, indexorderbycols=0x0, pathkeys=0x1e8cf90, indexscandir=ForwardScanDirection, indexonly=false, required_outer=0x1e8cca0, loop_count=10, partial_path=false)

在這里插入圖片描述

參數化路徑計算

create_index_path→get_baserel_parampathinfo函數生成ParamPathInfo

get_baserel_parampathinfo調用get_parameterized_baserel_size評估,當前節點是幾行。例如評估出來2行。explain時內表看到的rows就是2行,含義是外表每一行過來,內表有兩行能連上。

get_parameterized_baserel_size

double
get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,List *param_clauses)
{List	   *allclauses;double		nrows;allclauses = list_concat_copy(param_clauses, rel->baserestrictinfo);nrows = rel->tuples *clauselist_selectivity(root,allclauses,rel->relid,	/* do not use 0! */JOIN_INNER,NULL);nrows = clamp_row_est(nrows);/* For safety, make sure result is not more than the base estimate */if (nrows > rel->rows)nrows = rel->rows;return nrows;
}
  • allclauses合并param_clauses參數化條件和rel->baserestrictinfo當前表自身的約束條件,得到綜合條件列表??。
  • 使用 clauselist_selectivity 函數計算這些條件的綜合選擇率,再乘以表的基數rel->tuples,最終得到參數化路徑下的預估行數。

當前的allclauses表本身沒有條件,只有外表提供的參數化條件:
在這里插入圖片描述

  • 上圖中opexpr是等號,指向varno=1、varno=2指向兩個基表。

  • nrows = rel->tuples * clauselist_selectivity = 2

    • clauselist_selectivity = 1.7108151058814915e-07
    • rel->tuples = 10000001

clauselist_selectivity → clause_selectivity_ext的計算邏輯分支較多,這里只給出本例走到的分支:

clause_selectivity_ext......clause = (Node *) rinfo->clause;......else if (is_opclause(clause) || IsA(clause, DistinctExpr))......restriction_selectivity...

restriction_selectivity用于計算條件(where中過濾條件)的選擇率:

Selectivity
restriction_selectivity(PlannerInfo *root,Oid operatorid,List *args,Oid inputcollid,int varRelid)
{
  • 這里operatorid=96是等號。
  • get_oprrest從系統表中拿到oprrest 字段,字段指向一個注冊的選擇率計算函數oid=101,eqsel函數。
	RegProcedure oprrest = get_oprrest(operatorid);float8		result;/** if the oprrest procedure is missing for whatever reason, use a* selectivity of 0.5*/if (!oprrest)return (Selectivity) 0.5;result = DatumGetFloat8(OidFunctionCall4Coll(oprrest,inputcollid,PointerGetDatum(root),ObjectIdGetDatum(operatorid),PointerGetDatum(args),Int32GetDatum(varRelid)));if (result < 0.0 || result > 1.0)elog(ERROR, "invalid restriction selectivity: %f", result);return (Selectivity) result;
}

進入eqsel函數開始計算選擇率,eqsel用于計算等值和??不等值操作符的選擇率,是優化器代價模型的核心組成部分。

  • root:優化器上下文(包含統計信息、表元數據等)
  • operator:操作符的 OID(如 = 或 <>)
  • args:操作符的參數列表(如 a = 5 中的列 a 和常量 5)
  • varRelid:關聯的關系 ID(用于確定統計信息范圍)
  • collation:排序規則(影響字符串比較)
/** Common code for eqsel() and neqsel()*/
static double
eqsel_internal(PG_FUNCTION_ARGS, bool negate)
{PlannerInfo *root = (PlannerInfo *) PG_GETARG_POINTER(0);Oid			operator = PG_GETARG_OID(1);List	   *args = (List *) PG_GETARG_POINTER(2);int			varRelid = PG_GETARG_INT32(3);Oid			collation = PG_GET_COLLATION();VariableStatData vardata;Node	   *other;bool		varonleft;double		selec;

negate表示不等值。

	if (negate){operator = get_negator(operator);if (!OidIsValid(operator)){/* Use default selectivity (should we raise an error instead?) */return 1.0 - DEFAULT_EQ_SEL;}}

本例中的args:

  • Var = {xpr = {type = T_Var}, varno = 1, varattno = 1, vartype = 23}
  • Var = {xpr = {type = T_Var}, varno = 2, varattno = 1, vartype = 23}
  • varRelid = 1
	/** If expression is not variable = something or something = variable, then* punt and return a default estimate.*/if (!get_restriction_variable(root, args, varRelid,&vardata, &other, &varonleft))return negate ? (1.0 - DEFAULT_EQ_SEL) : DEFAULT_EQ_SEL;

get_restriction_variable將條件拆分為變量和??常量或其他表達式??。

  • vardata
    • {var = 0x1e6b2c0, rel = 0x1e8b8f8, statsTuple = 0x7f4874e75e08, freefunc = 0xb73cd6 , vartype = 23, atttype = 23, atttypmod = -1, isunique = false, acl_ok = true}
      • var = {xpr = {type = T_Var}, varno = 1, varattno = 1, vartype = 23}
      • statsTuple = pg_stat_statistic對應的行。
  • other = {{xpr = {type = T_Var}, varno = 2, varattno = 1, vartype = 2}
  • varonleft = true

開始計算選擇率 var_eq_non_const

	/** We can do a lot better if the something is a constant.  (Note: the* Const might result from estimation rather than being a simple constant* in the query.)*/if (IsA(other, Const))selec = var_eq_const(&vardata, operator, collation,((Const *) other)->constvalue,((Const *) other)->constisnull,varonleft, negate);elseselec = var_eq_non_const(&vardata, operator, collation, other,varonleft, negate);ReleaseVariableStats(vardata);return selec;
}

var_eq_non_const用于計算變量與非常量表達式(如其他列或子查詢結果)的等值條件(= 或 <>)的選擇率??,例如 a = b 或 x <> y。核心邏輯是基于統計信息(如唯一性約束、NULL值比例、不同值數量等),結合啟發式規則估算滿足條件的行數比例

  • vardata:變量統計信息(如列 a 的直方圖、MCV列表等)。
  • oproid:操作符OID(如 = 或 <>)。
  • other:非常量表達式(如另一列 b 或表達式 b + 1)。
  • negate:不等。

/** var_eq_non_const --- eqsel for var = something-other-than-const case** This is exported so that some other estimation functions can use it.*/
double
var_eq_non_const(VariableStatData *vardata, Oid oproid, Oid collation,Node *other,bool varonleft, bool negate)
{double		selec;double		nullfrac = 0.0;bool		isdefault;

先拿到pg_statistic表對應的行。

	if (HeapTupleIsValid(vardata->statsTuple)){Form_pg_statistic stats;stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);nullfrac = stats->stanullfrac;}...else if (HeapTupleIsValid(vardata->statsTuple)){double		ndistinct;AttStatsSlot sslot;

基于統計信息估算:

  1. 計算非NULL值比例 1 - nullfrac。
  2. 通過 get_variable_numdistinct 獲取變量不同值數量 ndistinct。
  3. 假設每個不同值均勻分布,選擇率為 (1 - nullfrac) / ndistinct。
  4. 與MCV(最常見值)的最大頻率比較,避免高估。
		selec = 1.0 - nullfrac;ndistinct = get_variable_numdistinct(vardata, &isdefault);

get_variable_numdistinct計算結果:5845167

  1. stadistinct = stats->stadistinct = -0.58516644 (來自pg_statistic表)
  2. stanullfrac = 0
  3. ntuples = vardata->rel->tuples = 10000001(來自relation結構,來自pg_class表)
  4. 計算結果:clamp_row_est(-stadistinct * ntuples = 5845167.024516644) = 5845167

get_variable_numdistinct計算方法總結:pg_statistic表的stadistinct中取得選擇率 乘以 評估行數,等于評估出來多少個唯一值。stadistinct含義:stadistinct > 0表示該列中非空唯一值的實際數量。stadistinct < 0表示非空唯一值的數量占總行數的比例。stadistinct = 0表示無法確定該列的非空唯一值數量。

		if (ndistinct > 1)selec /= ndistinct;......return selec;

計算得到選擇率
selec = selec / ndistinct = 1 / 5845167 = 1.7108151058814915e-07

回到最初的行數評估函數get_parameterized_baserel_size中:

  • nrows = rel->tuples * clauselist_selectivity = 2
    • clauselist_selectivity = 1.7108151058814915e-07
    • rel->tuples = 10000001

總結:

  • pg_statistic記錄的poid列唯一值個數占比-0.58516644
  • pg_class記錄行數為10000001條,所以評估poid列的唯一值個數為10000001*0.58516644=5845167(實際9901001)。這里有一半的偏差,但不是主要原因。
  • 2行=10000001*1.71e-07,在一個均勻分布的數據集中,每一個唯一值出現的概率是1.71e-07。所以如果有1千萬行數據,隨便給一個poid,能選出來兩行不一樣的。
    • 如果唯一值非常少,那么選擇率會變大,趨近于1,則10000001行=10000001*1。隨便給一個poid,能選出來會非常多。
    • 如果唯一值非常多,那么選擇率會變小,趨近于0,則0行=10000001*0。隨便給一個poid,能選出來會非常少。
  • 評估兩行但實際是100行的原因是,pg_statistic中stadistinct記錄的連接條件poid列的唯一值。

create_index_path→cost_index計算參數化路徑評估行數(從上一步的ParamPathInfo結果中取得)

  • cost_index中如果發現參數化路徑,會從ParamPathInfo中取評估行數
  • 本例中path->path.param_info->ppi_rows=2。
  • ??param_info存在表示當前索引掃描路徑是參數化的,依賴外部循環(如嵌套循環連接的外層表)提供的參數值。
  • ??行數估算??:ppi_rows 表示參數化路徑的預估行數,這是優化器根據外層表(如嵌套循環中的驅動表)的約束條件和連接關系動態調整的結果,比如ppi_rows=2表示,優化器評估外表每一條,內表有兩條能連得上。
void
cost_index(IndexPath *path, PlannerInfo *root, double loop_count,bool partial_path)......if (path->path.param_info){path->path.rows = path->path.param_info->ppi_rows;/* qpquals come from the rel's restriction clauses and ppi_clauses */qpquals = list_concat(extract_nonindex_conditions(path->indexinfo->indrestrictinfo,path->indexclauses),extract_nonindex_conditions(path->path.param_info->ppi_clauses,path->indexclauses));}else{path->path.rows = baserel->rows;/* qpquals come from just the rel's restriction clauses */qpquals = extract_nonindex_conditions(path->indexinfo->indrestrictinfo,path->indexclauses);}...

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/79266.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/79266.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/79266.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

HTML與CSS實現風車旋轉圖形的代碼技術詳解

在前端開發中&#xff0c;HTML和CSS是構建網頁的基礎技術。通過巧妙運用HTML的結構搭建和CSS的樣式控制&#xff0c;我們能夠實現各種精美的視覺效果。本文將對一段實現旋轉圖形效果的HTML和CSS代碼進行詳細解讀&#xff0c;剖析其中的技術要點。 一、運行效果 HTML與CSS實現風…

linux下,ollama會把模型文件保存在哪里?

文章目錄 運行ollama,有兩種形式,估計得分開討論首先是使用自動啟動的ollama:先跑個“小一點的大模型”但是現在模型文件存在哪兒呢?運行ollama,有兩種形式,估計得分開討論 我們用兩種方式,來運行ollama。 首先是使用自動啟動的ollama: ps -aux | grep ollama系統自…

鼎訊信通 智能通信干擾設備:多頻段多模態信號壓制解決方案

在萬物互聯時代&#xff0c;通信安全已成為現代社會的核心基礎設施防護重點。面對日益復雜的電磁環境挑戰&#xff0c;新一代智能通信干擾設備通過技術創新實現了信號壓制能力的革命性突破。本文將深入解析該設備的八大核心功能與技術特性&#xff0c;展現其在商業通信保障、工…

【2025軟考高級架構師】——案例分析總結(13)

摘要 本文對2025年軟考高級架構師的考綱及案例分析進行了總結。內容涵蓋系統規劃、架構設計、系統建模、安全架構、可靠性分析、大數據架構等多方面知識點&#xff0c;還涉及軟件質量特性、系統流程圖與數據流圖、嵌入式系統架構、分布式系統設計等考查內容&#xff0c;詳細列…

js單調棧解題模板

模板 function solve(arr) {const stack [];const result new Array(arr.length).fill(默認值);for (let i 0; i < arr.length; i) {while (stack.length && 比較條件(arr[i], arr[棧頂])) {const top stack.pop();result[top] 計算結果(i, top); }stack.push…

[藍橋杯真題題目及解析]2025年C++b組

移動距離&#xff08;填空&#xff09;** 小明初始在二維平面的原點&#xff0c;他想前往坐標 (233,666)。在移動過程中&#xff0c;他只能采用以下兩種移動方式&#xff0c;并且這兩種移動方式可以交替、不限次數地使用&#xff1a; 水平向右移動&#xff0c;即沿著 x 軸正方…

【ICMP協議深度解析】從網絡診斷到安全實踐

目錄 前言技術背景與價值當前技術痛點解決方案概述目標讀者說明 一、技術原理剖析核心概念圖解核心作用講解關鍵報文類型說明協議版本對比 二、實戰演示環境配置要求核心實驗實現實驗1&#xff1a;標準ping流程實驗2&#xff1a;traceroute路徑發現實驗3&#xff1a;自定義ICMP…

安卓基礎(懸浮窗分級菜單和彈窗)

initializeViews() 初始化 把全部的按鈕都弄出來 // 主菜單按鈕ImageButton mainButton floatingMenuView.findViewById(R.id.main_button);// 二級菜單按鈕subButtons new ImageButton[3];subButtons[0] floatingMenuView.findViewById(R.id.sub_button_1);subButtons[1]…

馮·諾依曼體系:現代計算機的底層邏輯與百年傳承

在智能手機流暢運行復雜游戲、超級計算機模擬氣候變化的今天&#xff0c;很少有人會想到&#xff0c;驅動這些神奇機器運轉的核心架構&#xff0c;依然遵循著70多年前提出的設計理念。這就是由匈牙利裔美國科學家約翰馮諾依曼&#xff08;John von Neumann&#xff09;奠定的馮…

【云備份】服務端工具類實現

1.文件實用工具類設計 不管是客戶端還是服務端&#xff0c;文件的傳輸備份都涉及到文件的讀寫&#xff0c;包括數據管理信息的持久化也是如此&#xff0c;因此首先設 計封裝文件操作類&#xff0c;這個類封裝完畢之后&#xff0c;則在任意模塊中對文件進行操作時都將變的簡單化…

CGI 協議是否會具體到通訊報文?

CGI&#xff08;Common Gateway Interface&#xff09;不涉及具體的網絡通訊報文格式&#xff0c;它定義的是 Web服務器與外部程序之間的數據交互方式&#xff0c;而不是像HTTP或FastCGI那樣的二進制協議。下面分幾個方面詳細說明&#xff1a; 1. CGI 的交互方式&#xff08;非…

【Mytais系列】Type模塊:類型轉換

MyBatis 的 類型系統&#xff08;Type System&#xff09; 是框架處理 Java 類型與數據庫類型之間映射的核心模塊&#xff0c;它通過 類型處理器&#xff08;TypeHandler&#xff09;、類型別名&#xff08;TypeAlias&#xff09; 和 類型轉換器 等機制&#xff0c;實現了數據庫…

新華三H3CNE網絡工程師認證—動態NAT

靜態NAT嚴格地一對一進行地址映射&#xff0c;這就導致即便內網主機長時間離線或者不發送數據時&#xff0c;與之對應的共有地址也處于使用狀態。為了避免地址浪費&#xff0c;動態NAT提出了地址池的概念&#xff1a;所有可用的共用地址組成地址池。 當內部主機訪問外部網絡時臨…

華為OD機試真題 Java 實現【水庫蓄水問題】

前言 博主刷的華為機考題&#xff0c;代碼僅供參考&#xff0c;因為沒有后臺數據&#xff0c;可能有沒考慮到的情況 如果感覺對你有幫助&#xff0c;請點點關注點點贊吧&#xff0c;謝謝你&#xff01; 題目描述 思路 1. 其實就是找一個最大的水坑&#xff0c;兩個…

【Linux】Petalinux驅動開發基礎

基于Petalinux做Linux驅動開發。 部分圖片和經驗來源于網絡,若有侵權麻煩聯系我刪除,主要是做筆記的時候忘記寫來源了,做完筆記很久才寫博客。 專欄目錄:記錄自己的嵌入式學習之路-CSDN博客 目錄 1 一個完整的Linux系統(針對Zynq) 1.1 PS部分 1.2 PL部分(若…

JAVA刷題記錄: 遞歸,搜索與回溯

專題一 遞歸 面試題 08.06. 漢諾塔問題 - 力扣&#xff08;LeetCode&#xff09; class Solution {public void hanota(List<Integer> A, List<Integer> B, List<Integer> C) {dfs(A, B, C, A.size());}public void dfs(List<Integer> a, List<In…

YOLOv11改進:利用RT-DETR主干網絡PPHGNetV2助力輕量化目標檢測

這里寫自定義目錄標題 YOLOv11改進&#xff1a;利用RT-DETR主干網絡PPHGNetV2助力輕量化目標檢測1. 介紹2. 引言3. 技術背景3.1 YOLOv11概述3.2 RT-DETR與PPHGNetV23.3 相關工作 4. 應用使用場景5. 詳細代碼實現5.1 環境準備5.2 PPHGNetV2主干網絡實現5.3 YOLOv11與PPHGNetV2集…

WPF之Button控件詳解

文章目錄 1. 引言2. Button控件基礎Button類定義 3. Button控件的核心屬性3.1 Content屬性3.2 IsDefault屬性3.3 IsCancel屬性3.4 其他常用屬性 4. 按鈕樣式與模板自定義4.1 簡單樣式設置4.2 使用Style對象4.3 觸發器使用4.4 使用ControlTemplate完全自定義4.5 按鈕視覺狀態 5.…

【Java】2025 年 Java 學習路線:從入門到精通

文章目錄 一、Java基礎階段(4-8周)1. 開發環境搭建2. 核心語法基礎3. 面向對象編程(OOP)4. 核心類庫二、Java進階階段(6-10周)1. JVM深度理解2. 并發編程3. 新特性掌握4. 設計模式三、開發框架與中間件(8-12周)1. Spring生態2. 持久層框架3. 常用中間件四、項目實戰階段…

虛幻引擎入門筆記

【虛幻5】UE5新手入門嘗試 虛幻引擎的基礎設置 1.驗證-當文件誤刪的時候&#xff0c;對其進行驗證&#xff0c;可以恢復。 2.虛幻引擎極其強大&#xff0c;可以實現多種復合技能&#xff0c;所在創建項目頁面可以看見不只是創建游戲的項目 3.更改虛幻引擎默認的緩存地址。有些…