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.mzph.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.更改虚幻引擎默认的缓存地址。有些…