PostgreSQL pg_repack 重新组织表并释放表空间

pg_repack

pg_repack是 PostgreSQL 的一个扩展,它允许您从表和索引中删除膨胀,并可选择恢复聚集索引的物理顺序。与CLUSTER和VACUUM FULL不同,它可以在线工作,在处理过程中无需对已处理的表保持独占锁定。pg_repack 启动效率高,性能可与直接使用 CLUSTER 相媲美。

要求

PostgreSQL 版本
PostgreSQL 9.5、9.6、10、11、12、13、14、15、16、17。

PostgreSQL 9.4 及之前版本不受支持。

磁盘
执行全表重新打包需要的可用磁盘空间大约是目标表及其索引的两倍。
例如,如果要重组的表和索引的总大小为 1GB,则需要额外的 2GB 磁盘空间。

安装

pg_repack 可以在 UNIX 或 Linux 上使用make构建。在构建之前,您可能需要安装 PostgreSQL 开发包(postgresql-devel等)并将包含pg_config的目录添加到您的$PATH。然后您可以运行:

dnf install -y lz4-develdnf install -y readline-develdnf install -y clang sudo dnf install -y llvm llvm-develwget -c 'https://github.com/reorg/pg_repack/archive/refs/tags/ver_1.5.2.zip'cd /opt unzip  pg_repack-ver_1.5.2.zip make PG_CONFIG={your pg_config path}make PG_CONFIG={your pg_config path}  install # 安装后,在你要处理的数据库中加载 pg_repack 扩展。pg_repack 被打包为一个扩展,因此你可以执行:$ psql -c "CREATE EXTENSION pg_repack" -d your_databasetest=# select repack.version(), repack.version_sql();version     |   version_sql   
-----------------+-----------------pg_repack 1.5.2 | pg_repack 1.5.2
(1 row)

pgstattuple

pgstattuple 提供了一个非常详细的表和索引空间使用统计信息,尤其是在处理表膨胀和空间碎片时非常有用。通过这些信息,您可以有效地评估表的膨胀率,并决定是否需要执行 VACUUM FULLpg_repack 等操作来回收空间并优化数据库性能。

test=# CREATE EXTENSION IF NOT EXISTS pgstattuple;
CREATE EXTENSIONtest=# select * from pg_extension ;oid  |     extname      | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition 
-------+------------------+----------+--------------+----------------+------------+-----------+--------------14528 | plpgsql          |       10 |           11 | f              | 1.0        |           | 16397 | pg_repack        |       10 |         2200 | f              | 1.5.2      |           | 16851 | pgstattuple      |       10 |         2200 | t              | 1.5        |           | 
(3 rows)

测试


### 关闭 autovacuum -- 仅测试 test=# alter system set autovacuum=off; 
ALTER SYSTEMtest=# select pg_reload_conf();pg_reload_conf 
----------------t
(1 row)test=# show autovacuum;autovacuum 
------------off
(1 row)#### 创建数据库表CREATE TABLE big_table (id SERIAL PRIMARY KEY,name varchar(100),value INT
);CREATE INDEX idx_name on big_table(name);#### 插入测试数据#  插入 300 万行数据
# -- 生成 Name 1, Name 2, Name 3... 的格式
# -- 生成一个在 1 到 100 之间的值INSERT INTO big_table (name, value)
SELECT'Name ' || gs,         (gs % 100) + 1        
FROM generate_series(1, 3000000) gs;# 查看表的大小和死行数量test=# SELECT * FROM pg_stat_user_tables WHERE relname = 'big_table'\gx
-[ RECORD 1 ]-------+----------
relid               | 16929
schemaname          | public
relname             | big_table
seq_scan            | 2
seq_tup_read        | 0
idx_scan            | 0
idx_tup_fetch       | 0
n_tup_ins           | 3000000
n_tup_upd           | 0
n_tup_del           | 0
n_tup_hot_upd       | 0
n_live_tup          | 3000000
n_dead_tup          | 0
n_mod_since_analyze | 3000000
n_ins_since_vacuum  | 3000000
last_vacuum         | 
last_autovacuum     | 
last_analyze        | 
last_autoanalyze    | 
vacuum_count        | 0
autovacuum_count    | 0
analyze_count       | 0
autoanalyze_count   | 0# 查看表的空间大小、索引大小,总大小
test=# SELECT
test-#      pg_size_pretty(pg_table_size('big_table')) AS table_size,
test-#      pg_size_pretty(pg_indexes_size('big_table')) AS indexes_size,
test-#      pg_size_pretty(pg_total_relation_size('big_table')) AS total_size;table_size | indexes_size | total_size 
------------+--------------+------------149 MB     | 219 MB       | 369 MB# 查询默认表空间路径(pg_default)中的物理文件test=# SELECT oid, datname FROM pg_database WHERE datname = 'test';oid  | datname 
-------+---------16389 | test
(1 row)test=# SELECT pg_relation_filepath('big_table');pg_relation_filepath 
----------------------base/16389/16929
(1 row)# 物理文件空间大小ls -lth |grep 16929
-rw-------. 1 postgres postgres 150M Feb 14 16:23 16929
-rw-------. 1 postgres postgres 56K Feb 14 16:22 16929_fsm# 这个查询会返回有关指定表的空间使用统计信息。test=# SELECT * FROM pgstattuple('big_table');table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent 
-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------156540928 |     3000000 | 139999608 |         89.43 |                0 |              0 |                  0 |       6668 |            0
(1 row)#### 执行一些删除和更新操作#为了模拟数据库的实际负载,删除和更新一些行,产生死行和空洞:# 删除一些数据 33%
test=# DELETE FROM big_table WHERE id%3 = 0; 
DELETE 1000000test=# select count(*) from big_table;count  
---------2000000
(1 row)test=# SELECT * FROM pg_stat_user_tables WHERE relname = 'big_table'\gx
-[ RECORD 1 ]-------+----------
relid               | 16929
schemaname          | public
relname             | big_table
seq_scan            | 8
seq_tup_read        | 11000000
idx_scan            | 0
idx_tup_fetch       | 0
n_tup_ins           | 3000000
n_tup_upd           | 0
n_tup_del           | 1000000   # 被删除的行数 
n_tup_hot_upd       | 0
n_live_tup          | 2000000
n_dead_tup          | 1000000   # 产生死行的数量
n_mod_since_analyze | 4000000
n_ins_since_vacuum  | 3000000
last_vacuum         | 
last_autovacuum     | 
last_analyze        | 
last_autoanalyze    | 
vacuum_count        | 0
autovacuum_count    | 0
analyze_count       | 0
autoanalyze_count   | 0test=# SELECT * FROM pgstattuple('big_table');table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent 
-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------156540928 |     2000000 |  93333072 |         59.62 |               10 |            480 |                  0 |   48005924 |        30.67
(1 row)# 查询 物理文件是否发生变化ls -lth |grep 16929
-rw-------. 1 postgres postgres 150M Feb 14 16:37 16929
-rw-------. 1 postgres postgres   56K Feb 14 16:22 16929_fsm# 更新一些数据test=# UPDATE big_table SET name = name || 'updated' WHERE id%3 = 1; 
UPDATE 1000000test=# select count(*) from big_table;count  
---------2000000
(1 row)test=# SELECT * FROM pg_stat_user_tables WHERE relname = 'big_table'\gx
-[ RECORD 1 ]-------+----------
relid               | 16929
schemaname          | public
relname             | big_table
seq_scan            | 15
seq_tup_read        | 21000020
idx_scan            | 0
idx_tup_fetch       | 0
n_tup_ins           | 3000000
n_tup_upd           | 1000000  # 已更新的行
n_tup_del           | 1000000
n_tup_hot_upd       | 0
n_live_tup          | 2000000
n_dead_tup          | 2000000  # 产生死行的数量 1000000+1000000=2000000 ( n_tup_del + n_tup_upd) 
n_mod_since_analyze | 5000000
n_ins_since_vacuum  | 3000000
last_vacuum         | 
last_autovacuum     | 
last_analyze        | 
last_autoanalyze    | 
vacuum_count        | 0
autovacuum_count    | 0
analyze_count       | 0
autoanalyze_count   | 0# 检查数据、索引文件大小 test=# SELECT * FROM pgstattuple('big_table');table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent 
-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------169197568 |     2000000 |  98665204 |         58.31 |                0 |              0 |                  0 |   48622184 |        28.74
(1 row)# 查询 物理文件是否发生变化ls -lth |grep 16929
-rw-------. 1 postgres postgres 162M Feb 14 16:44 16929
-rw-------. 1 postgres postgres  64K Feb 14 16:39 16929_fsm#运行 pg_repack 来重建表。这将移除死行并优化表:pg_repack -d test --table public.big_table --echo-------------------  日志如下  ------------------
LOG: (query) SET search_path TO pg_catalog, pg_temp, public
LOG: (query) SET search_path TO pg_catalog, pg_temp, public
LOG: (query) select repack.version(), repack.version_sql()
LOG: (query) SET statement_timeout = 0
LOG: (query) SET search_path = pg_catalog, pg_temp, public
LOG: (query) SET client_min_messages = warning
LOG: (query) SELECT r FROM (VALUES ($1, 'r')) AS given_t(r,kind) WHERE NOT EXISTS(  SELECT FROM repack.tables WHERE relid=to_regclass(given_t.r)) AND NOT EXISTS(  SELECT FROM pg_catalog.pg_class c WHERE c.oid=to_regclass(given_t.r) AND c.relkind = given_t.kind AND given_t.kind = 'p')
LOG:    (param:0) = public.big_table
LOG: (query) SELECT t.*, coalesce(v.tablespace, t.tablespace_orig) as tablespace_dest FROM repack.tables t,  (VALUES ($1::text)) as v (tablespace) WHERE (relid = $2::regclass) ORDER BY t.relname, t.schemaname
LOG:    (param:0) = (null)
LOG:    (param:1) = public.big_table
INFO: repacking table "public.big_table"
LOG: (query) SELECT pg_try_advisory_lock($1, CAST(-2147483648 + $2::bigint AS integer))
LOG:    (param:0) = 16185446
LOG:    (param:1) = 16929
LOG: (query) BEGIN ISOLATION LEVEL READ COMMITTED
LOG: (query) SET LOCAL lock_timeout = 100
LOG: (query) LOCK TABLE public.big_table IN ACCESS EXCLUSIVE MODE
LOG: (query) RESET lock_timeout
LOG: (query) SELECT pg_get_indexdef(indexrelid) FROM pg_index WHERE indrelid = $1 AND NOT indisvalid
LOG:    (param:0) = 16929
LOG: (query) SELECT indexrelid, repack.repack_indexdef(indexrelid, indrelid, $2, FALSE)  FROM pg_index WHERE indrelid = $1 AND indisvalid
LOG:    (param:0) = 16929
LOG:    (param:1) = (null)
LOG: (query) SELECT repack.conflicted_triggers($1)
LOG:    (param:0) = 16929
LOG: (query) SELECT repack.create_index_type(16933,16929)
LOG: (query) SELECT repack.create_log_table(16929)
LOG: (query) CREATE TRIGGER repack_trigger AFTER INSERT OR DELETE OR UPDATE ON public.big_table FOR EACH ROW EXECUTE PROCEDURE repack.repack_trigger('id')
LOG: (query) ALTER TABLE public.big_table ENABLE ALWAYS TRIGGER repack_trigger
LOG: (query) SELECT repack.disable_autovacuum('repack.log_16929')
LOG: (query) BEGIN ISOLATION LEVEL READ COMMITTED
LOG: (query) SELECT pg_backend_pid()
LOG: (query) SELECT pid FROM pg_locks WHERE locktype = 'relation' AND granted = false AND relation = 16929 AND mode = 'AccessExclusiveLock' AND pid <> pg_backend_pid()
LOG: (query) COMMIT
LOG: (query) BEGIN ISOLATION LEVEL SERIALIZABLE
LOG: (query) SELECT set_config('work_mem', current_setting('maintenance_work_mem'), true)
LOG: (query) SELECT coalesce(array_agg(l.virtualtransaction), '{}')   FROM pg_locks AS l   LEFT JOIN pg_stat_activity AS a     ON l.pid = a.pid   LEFT JOIN pg_database AS d     ON a.datid = d.oid   WHERE l.locktype = 'virtualxid'   AND l.pid NOT IN (pg_backend_pid(), $1)   AND (l.virtualxid, l.virtualtransaction) <> ('1/1', '-1/0')   AND (a.application_name IS NULL OR a.application_name <> $2)  AND a.query !~* E'^\\s*vacuum\\s+'   AND a.query !~ E'^autovacuum: '   AND ((d.datname IS NULL OR d.datname = current_database()) OR l.database = 0)
LOG:    (param:0) = 12616
LOG:    (param:1) = pg_repack
LOG: (query) DELETE FROM repack.log_16929
LOG: (query) SAVEPOINT repack_sp1
LOG: (query) SELECT pid FROM pg_locks WHERE locktype = 'relation' AND granted = false AND relation = 16929 AND mode = 'AccessExclusiveLock' AND pid <> pg_backend_pid()
LOG: (query) SET LOCAL lock_timeout = 100
LOG: (query) LOCK TABLE public.big_table IN ACCESS SHARE MODE
LOG: (query) RESET lock_timeout
LOG: (query) SELECT repack.create_table($1, $2)
LOG:    (param:0) = 16929
LOG:    (param:1) = pg_default
LOG: (query) INSERT INTO repack.table_16929 SELECT id,name,value FROM ONLY public.big_table
LOG: (query) SELECT repack.disable_autovacuum('repack.table_16929')
LOG: (query) COMMIT
LOG: (query) SELECT 'repack.table_16929'::regclass::oid
LOG: (query) CREATE UNIQUE INDEX index_16933 ON repack.table_16929 USING btree (id)
LOG: (query) CREATE INDEX index_16935 ON repack.table_16929 USING btree (name)
LOG: (query) SELECT repack.repack_apply($1, $2, $3, $4, $5, $6)
LOG:    (param:0) = SELECT * FROM repack.log_16929 ORDER BY id LIMIT $1
LOG:    (param:1) = INSERT INTO repack.table_16929 VALUES ($1.*)
LOG:    (param:2) = DELETE FROM repack.table_16929 WHERE (id) = ($1.id)
LOG:    (param:3) = UPDATE repack.table_16929 SET (id, name, value) = ($2.id, $2.name, $2.value) WHERE (id) = ($1.id)
LOG:    (param:4) = DELETE FROM repack.log_16929 WHERE id IN (
LOG:    (param:5) = 1000
LOG: (query) SELECT pid FROM pg_locks WHERE locktype = 'virtualxid' AND pid <> pg_backend_pid() AND virtualtransaction = ANY($1)
LOG:    (param:0) = {}
LOG: (query) SAVEPOINT repack_sp1
LOG: (query) SET LOCAL lock_timeout = 100
LOG: (query) LOCK TABLE public.big_table IN ACCESS EXCLUSIVE MODE
LOG: (query) RESET lock_timeout
LOG: (query) SAVEPOINT repack_sp1
LOG: (query) SET LOCAL lock_timeout = 100
LOG: (query) LOCK TABLE repack.table_16929 IN ACCESS EXCLUSIVE MODE
LOG: (query) RESET lock_timeout
LOG: (query) SELECT repack.repack_apply($1, $2, $3, $4, $5, $6)
LOG:    (param:0) = SELECT * FROM repack.log_16929 ORDER BY id LIMIT $1
LOG:    (param:1) = INSERT INTO repack.table_16929 VALUES ($1.*)
LOG:    (param:2) = DELETE FROM repack.table_16929 WHERE (id) = ($1.id)
LOG:    (param:3) = UPDATE repack.table_16929 SET (id, name, value) = ($2.id, $2.name, $2.value) WHERE (id) = ($1.id)
LOG:    (param:4) = DELETE FROM repack.log_16929 WHERE id IN (
LOG:    (param:5) = 0
LOG: (query) SELECT repack.repack_swap($1)
LOG:    (param:0) = 16929
LOG: (query) COMMIT
LOG: (query) BEGIN ISOLATION LEVEL READ COMMITTED
LOG: (query) SAVEPOINT repack_sp1
LOG: (query) SET LOCAL lock_timeout = 100
LOG: (query) LOCK TABLE public.big_table IN ACCESS EXCLUSIVE MODE
LOG: (query) RESET lock_timeout
LOG: (query) SELECT repack.repack_drop($1, $2)
LOG:    (param:0) = 16929
LOG:    (param:1) = 4
LOG: (query) COMMIT
LOG: (query) BEGIN ISOLATION LEVEL READ COMMITTED
LOG: (query) ANALYZE public.big_table
LOG: (query) COMMIT
LOG: (query) SELECT pg_advisory_unlock($1, CAST(-2147483648 + $2::bigint AS integer))
LOG:    (param:0) = 16185446
LOG:    (param:1) = 16929# 创建触发器跟踪新表--旧表test=# \d big_tableTable "public.big_table"Column |          Type          | Collation | Nullable |                Default                
--------+------------------------+-----------+----------+---------------------------------------id     | integer                |           | not null | nextval('big_table_id_seq'::regclass)name   | character varying(100) |           |          | value  | integer                |           |          | 
Indexes:"big_table_pkey" PRIMARY KEY, btree (id)"idx_name" btree (name)
Triggers firing always:repack_trigger AFTER INSERT OR DELETE OR UPDATE ON big_table FOR EACH ROW EXECUTE FUNCTION repack.repack_trigger('id')# 创建新表
test=# set search_path=public,repack;
SETtest=# \dList of relationsSchema |       Name        |   Type   |    Owner     
--------+-------------------+----------+--------------public | big_table         | table    | postgrespublic | big_table_id_seq  | sequence | postgrespublic | student           | table    | postgrespublic | test_table        | table    | postgrespublic | test_table_id_seq | sequence | postgresrepack | log_16929         | table    | postgres   # 创建日志表:  log_[relid], 新数据记录到这张表 repack | log_16929_id_seq  | sequence | postgresrepack | primary_keys      | view     | postgresrepack | table_16929       | table    | postgres   # 创建临时表:  表名_[relid]repack | tables            | view     | postgres
(10 rows)# 产生新的数据test=# select * from log_16929;id |    pk     |               row                
----+-----------+----------------------------------1 |           | (3000004,"name inserted",99)2 | (367871)  | (367871,"Name 367871updated",72)3 | (3000004) | 4 |           | (3000005,"name inserted",99)5 | (3000005) | 
(5 rows)test=# SELECT pg_relation_filepath('big_table');pg_relation_filepath 
----------------------base/16389/16949
(1 row)# 查询 物理文件是否发生变化ls -lth |grep 16949
-rw-------. 1 postgres postgres 108M Feb 14 16:52 16949
-rw-------. 1 postgres postgres  48K Feb 14 16:52 16949_fsm# 检查膨胀率  test=# SELECT * FROM pgstattuple('big_table');table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent 
-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------112607232 |     2000000 |  98665260 |         87.62 |                8 |            384 |                  0 |     229804 |          0.2
(1 row)

重建表总结:

原理介绍

pg_repack插件支持对全表和索引进行repack操作。
对全表进行repack的实现原理如下:

1.创建日志表,记录repack期间对原表的变更。
2.在原表上创建触发器,将原表的INSERT、UPDATE和DELETE操作记录到日志表中。
3.创建原表结构相同的新表并将原表数据导入其中。
4.在新表中创建与原表相同的索引。
5.将日志表里的变更(即repack期间表上产生的增量数据)应用到新表。
6.在系统catalog交换新旧表。
7.删除旧表。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/76426.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

5G_WiFi_CE_射频输出功率、发射功率控制(TPC)和功率密度测试

目录 一、规范要求 1、法规目录&#xff1a; &#xff08;1&#xff09;RF Output Power (2)Transmit Power Control (TPC) &#xff08;3&#xff09;Power Density 2、限值&#xff1a; 二、EIRP测试方法 &#xff08;1&#xff09;测试条件 &#xff08;2&#xff…

扫描线离散化线段树解决矩形面积并-洛谷P5490

https://www.luogu.com.cn/problem/P5490 题目描述 求 n n n 个四边平行于坐标轴的矩形的面积并。 输入格式 第一行一个正整数 n n n。 接下来 n n n 行每行四个非负整数 x 1 , y 1 , x 2 , y 2 x_1, y_1, x_2, y_2 x1​,y1​,x2​,y2​&#xff0c;表示一个矩形的四个…

Java项目之基于ssm的简易版营业厅宽带系统(源码+文档)

项目简介 简易版营业厅宽带系统实现了以下功能&#xff1a; 此营业厅宽带系统利用当下成熟完善的SSM框架&#xff0c;使用跨平台的可开发大型商业网站的Java语言&#xff0c;以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了营业厅宽带系统基础数据的管理&…

从入门到入土,SQLServer 2022慢查询问题总结

列为,由于公司原因,作者接触了一个SQLServer 2022作为数据存储到项目,可能是上一任的哥们儿离开的时候带有情绪,所以现在项目的主要问题就是,所有功能都实现了,但是就是慢,列表页3s打底,客户很生气,经过几周摸爬滚打,作以下总结,作为自己的成长记录。 一、索引问题…

PDF处理控件Aspose.PDF教程:在Python、Java 和 C# 中旋转 PDF 文档

您是否希望快速轻松地在线旋转PDF文档&#xff1f;无论您需要修复文档的方向还是只想重新排列页面&#xff0c;本指南都能满足您的需求。有简单的方法可以解决此问题 - 无论您喜欢在线工具还是编程解决方案。 在本指南中&#xff0c;我们将向您展示如何免费在线旋转 PDF&#…

编译原理:first集和follow

一、First 集&#xff08;首符号集&#xff09; 定义&#xff1a; 对于符号&#xff08;非终结符或终结符&#xff09;或符号串&#xff0c;First 集是该符号串能够推导出的所有可能开头的终结符的集合。若符号串可以推导出空串&#xff08;ε&#xff09;&#xff0c;则 ε 也…

python实现简单fast-cgi服务,对接到nginx

python代码 import socket import struct import threading# FastCGI 头格式&#xff08;8 字节&#xff09; FCGI_HEADER_FORMAT "!BBHHBx" FCGI_VERSION 1 FCGI_TYPE_BEGIN_REQUEST 1 FCGI_TYPE_PARAMS 4 FCGI_TYPE_STDIN 5 FCGI_TYPE_STDOUT 6 FCGI_TYPE_E…

vue开始时间小于等于结束时间,且开始时间小于等于系统时间,时间格式:年月日时分

// 日期配置 export const DATA_CONFIGS [{itemKey: "startDate",startDateKey: "startDate",endDateKey: "endDate",isStart: true,},{itemKey: "endDate",startDateKey: "startDate",endDateKey: "endDate",is…

PyCharm 下载与安装教程:从零开始搭建你的 Python 开发环境

PyCharm 是一款专为 Python 开发设计的集成开发环境&#xff08;IDE&#xff09;&#xff0c;它提供了强大的代码编辑、调试、版本控制等功能&#xff0c;是 Python 开发者的必备工具之一。如果你是初学者&#xff0c;或者正在寻找一款高效的开发工具&#xff0c;这篇文章将帮助…

Qt线程等待条件QWaitCondition

Qt 线程等待条件 概念 Qt提供了QWaitCondition类实现“等待条件”式的线程控制方法&#xff0c;它让线程阻塞在等待条件的地方&#xff0c;直到条件满足后才继续执行下去。也就是说&#xff0c;QWaitCondition可以使一个线程在满足一定条件时通知其他多个线程&#xff0c;使它…

RAG 和 RAGFlow 学习笔记

一、RAG&#xff08;检索增强生成&#xff09; 1. RAG 的定义与核心思想 RAG&#xff08;Retrieval-Augmented Generation&#xff0c;检索增强生成&#xff09; 是一种结合 信息检索&#xff08;Retrieval&#xff09; 和 文本生成&#xff08;Generation&#xff09; 的技术…

Windows连接服务器Ubuntu_MobaXterm

通过 SSH 远程连接&#xff08;命令行方式&#xff09; &#x1f527; 所需工具&#xff1a; Windows&#xff1a;MobaXterm&#xff08;强烈推荐&#xff09;或 PuTTY Ubuntu&#xff1a;已开启 SSH 服务 Ubuntu 开启 SSH 服务&#xff08;仅需一次&#xff09; 在 Ubuntu …

Rust 中的高效视频处理:利用硬件加速应对高分辨率视频

引言 在视频处理领域&#xff0c;随着4K、8K甚至更高分辨率内容的普及&#xff0c;传统的CPU计算方式逐渐显得力不从心。无论是视频剪辑、直播流处理还是格式转换&#xff0c;高负载场景下CPU占用过高的问题常常让开发者头疼。硬件加速技术通过利用GPU等专用硬件分担编解码任务…

大模型提示工程中,提示、补全、指令、上下文和样本这几个概念的区别是什么?

提示 (Prompt) 定义&#xff1a;输入给大模型的完整文本刺激&#xff0c;是与模型交互的主要方式。 特点&#xff1a; 是最广义的概念&#xff0c;包含其他几个元素整体输入的总和&#xff0c;包括指令、上下文和样本等内容决定模型如何理解和处理请求 示例&#xff1a; 分…

AI的未来演进

企业数字IP实战&#xff1a;创始人分身如何实现品宣获客双赢&#xff1f; ——从量子化建模到联邦学习的全链路技术拆解 一、行业痛点&#xff1a;品牌信任与获客效率的双重困局 2025年数据显示&#xff0c;73%的企业因传统营销模式效率低下错失市场机遇&#xff08;家居品牌…

软件定义无线电39

13.8 RFSoC上PYNQ的SDR设计流程 本节中详细介绍的设计过程可以分为六个独立的步骤&#xff0c;如图13.16所示&#xff0c;并在接下来的几页中进行讨论。 13.8.1 初始设计过程 。在这里&#xff0c;系统设计人员必须考虑许多因素&#xff0c;例如RFDC接收和/或发送的频率范围…

​自动化网络架构搜索(Neural Architecture Search,NAS)

NAS是一种旨在自动设计神经网络结构的技术。传统上&#xff0c;神经网络的架构设计依赖于专家的经验和大量的试错过程&#xff0c;而NAS通过算法自动搜索网络架构&#xff0c;以发现最适合特定任务的神经网络设计。 NAS的主要组成部分包括&#xff1a; 搜索空间&#xff1a;定…

Ubuntu 22.04 安装和运行 EDK2 超详细教程

Ubuntu 22.04 安装和运行 EDK2 超详细教程 适合新手小白&#xff0c;从零开始 &#x1f31f; 1. 什么是 EDK2&#xff1f; EDK2&#xff08;EFI Development Kit 2&#xff09;是一个开源的 UEFI&#xff08;统一可扩展固件接口&#xff09;开发环境&#xff0c;主要用于编写和…

什么是STEP认证

**什么是STEP认证** STEP认证&#xff0c;全称为“可持续纺织生产认证”&#xff08;Sustainable Textile Production&#xff09;&#xff0c;是一项由国际环保纺织协会Oeko-Tex提供的权威独立认证体系。这一认证体系犹如纺织和皮革行业的绿色灯塔&#xff0c;为追求可持续发…

odoo-045 ModuleNotFoundError: No module named ‘_sqlite3‘

文章目录 一、问题二、解决思路 一、问题 就是项目启动&#xff0c;本来好好地&#xff0c;忽然有一天报错&#xff0c;不知道什么原因。 背景&#xff1a; 我是在虚拟环境中使用的python3.7。 二、解决思路 虚拟环境和公共环境直接安装 sqlite3 都会报找不到这个库的问题…