当前位置: 首页 > news >正文

PostgreSQL的pg_dump中 --inserts参数测试

PostgreSQL的pg_dump中 --inserts参数测试

1 准备测试数据

创建表yewu1.t1,并插入1000000条数据。

white=# create table yewu1.t1 (id int,name varchar(20));
CREATE TABLE
white=# DO $$
white$# DECLARE aa INTEGER;
white$# BEGIN
white$#     FOR aa IN 1..1000000 LOOP
white$#         INSERT INTO yewu1.t1 VALUES (aa,'white_' || aa);
white$# END LOOP;
white$# COMMIT;
white$# END $$;
DO
white=# 
white=# select count(*) from yewu1.t1;count  
---------1000000
(1 row)white=# 
white=#     SELECT 
white-#       pg_size_pretty(pg_relation_size('yewu1.t1')) AS base_size,
white-#       pg_size_pretty(pg_table_size('yewu1.t1')) AS table_size,
white-#       pg_size_pretty(pg_indexes_size('yewu1.t1')) AS indexes_size,
white-#       pg_size_pretty(pg_total_relation_size('yewu1.t1')) AS total_size;base_size | table_size | indexes_size | total_size 
-----------+------------+--------------+------------49 MB     | 49 MB      | 0 bytes      | 49 MB
(1 row)

2 pg_dump 导出测试

2.1 加 --inserts 参数

导出

pg_dump -h 192.168.10.99 -U postgres -p 5777 -W white -t yewu1.t1 --inserts > /home/pg16/tmp_20240819/bak_0821_1.sql

查看导出文件内容

[pg16@test tmp_20240819]$ more bak_0821_1.sql
--
-- PostgreSQL database dump
---- Dumped from database version 16.2
-- Dumped by pg_dump version 16.2-- Started on 2024-08-20 18:20:20 PDTSET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;SET default_tablespace = '';SET default_table_access_method = heap;--
-- TOC entry 230 (class 1259 OID 17716)
-- Name: t1; Type: TABLE; Schema: yewu1; Owner: postgres
--CREATE TABLE yewu1.t1 (id integer,name character varying(20)
);ALTER TABLE yewu1.t1 OWNER TO postgres;--
-- TOC entry 4118 (class 0 OID 17716)
-- Dependencies: 230
-- Data for Name: t1; Type: TABLE DATA; Schema: yewu1; Owner: postgres
--INSERT INTO yewu1.t1 VALUES (1, 'white_1');
INSERT INTO yewu1.t1 VALUES (2, 'white_2');
INSERT INTO yewu1.t1 VALUES (3, 'white_3');
INSERT INTO yewu1.t1 VALUES (4, 'white_4');
INSERT INTO yewu1.t1 VALUES (5, 'white_5');
INSERT INTO yewu1.t1 VALUES (6, 'white_6');
INSERT INTO yewu1.t1 VALUES (7, 'white_7');
INSERT INTO yewu1.t1 VALUES (8, 'white_8');
INSERT INTO yewu1.t1 VALUES (9, 'white_9');
INSERT INTO yewu1.t1 VALUES (10, 'white_10');
INSERT INTO yewu1.t1 VALUES (11, 'white_11');
INSERT INTO yewu1.t1 VALUES (12, 'white_12');
INSERT INTO yewu1.t1 VALUES (13, 'white_13');
。。。。。省略

导入

psql -U postgres -W -v -d white -f /home/pg16/tmp_20240819/bak_0821_1.sql

查看输出日志:

[pg16@test tmp_20240819]$ more bak_0821_1.log
SET
SET
SET
SET
SETset_config 
------------(1 row)SET
SET
SET
SET
SET
SET
CREATE TABLE
ALTER TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
。。。。。省略

2.2 不加 --inserts 参数

导出

pg_dump -h 192.168.10.99 -U postgres -p 5777 -W white -t yewu1.t1 > /home/pg16/tmp_20240819/bak_0821_2.sql

查看导出文件内容

[pg16@test tmp_20240819]$ more bak_0821_2.sql
--
-- PostgreSQL database dump
---- Dumped from database version 16.2
-- Dumped by pg_dump version 16.2SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;SET default_tablespace = '';SET default_table_access_method = heap;--
-- Name: t1; Type: TABLE; Schema: yewu1; Owner: postgres
--CREATE TABLE yewu1.t1 (id integer,name character varying(20)
);ALTER TABLE yewu1.t1 OWNER TO postgres;--
-- Data for Name: t1; Type: TABLE DATA; Schema: yewu1; Owner: postgres
--COPY yewu1.t1 (id, name) FROM stdin;
1       white_1
2       white_2
3       white_3
4       white_4
5       white_5
6       white_6
7       white_7
8       white_8
9       white_9
10      white_10
11      white_11
12      white_12
13      white_13
14      white_14
15      white_15
。。。。省略

导入

psql -U postgres -W -d white -f /home/pg16/tmp_20240819/bak_0821_2.sql

查看输出日志

[pg16@test tmp_20240819]$ more bak_0821_2.log
SET
SET
SET
SET
SETset_config 
------------(1 row)SET
SET
SET
SET
SET
SET
CREATE TABLE
ALTER TABLE
COPY 1000000

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 随机优化中基于任务的端到端模型学习
  • 为什么使用网络请求时,遇到 HTTP 请求返回 404(Not Found)错误,而使用 HTTPS 请求则正常工作
  • 蛇优化算法(Snake Optimization, SO)优化RBF神经网络的扩散速度实现多数入多输出数据预测,可以更改数据集(MATLAB代码)
  • 建筑楼宇电气安全与能效管理
  • 【JVM】JVM解析字节码文件过程(一)
  • Vue条件判断:v-if、v-else、v-else-if、v-show 指令
  • MySQL 升级:MySQL Server 变更详解 (8.0.36 ~ 8.0.37)
  • Fiddler不仅可以抓包,还可以做接口测试喔
  • 【ACM出版,高录用EI快检索】第七届计算机信息科学与人工智能国际学术会议(CISAI 2024,9月6-8)
  • 硬布线控制器的设计
  • MinerU pdf文档解析markdown格式、内容提取
  • 【Qt笔记】Qt建立UDP通信
  • 面试题:Rabbitmq怎么保证消息的可靠性?
  • 电脑桌面管理如何做?2024电脑桌面终极管理方法分享
  • 【安全靶场】-DC-5
  • AWS实战 - 利用IAM对S3做访问控制
  • Babel配置的不完全指南
  • Cookie 在前端中的实践
  •  D - 粉碎叛乱F - 其他起义
  • emacs初体验
  • GDB 调试 Mysql 实战(三)优先队列排序算法中的行记录长度统计是怎么来的(上)...
  • JavaScript 一些 DOM 的知识点
  • Quartz实现数据同步 | 从0开始构建SpringCloud微服务(3)
  • Spring Security中异常上抛机制及对于转型处理的一些感悟
  • 阿里云Kubernetes容器服务上体验Knative
  • 开源SQL-on-Hadoop系统一览
  • 前端技术周刊 2019-01-14:客户端存储
  • 如何使用 OAuth 2.0 将 LinkedIn 集成入 iOS 应用
  • 入职第二天:使用koa搭建node server是种怎样的体验
  • 它承受着该等级不该有的简单, leetcode 564 寻找最近的回文数
  • 硬币翻转问题,区间操作
  • 从如何停掉 Promise 链说起
  • ​LeetCode解法汇总518. 零钱兑换 II
  • #《AI中文版》V3 第 1 章 概述
  • #单片机(TB6600驱动42步进电机)
  • #我与Java虚拟机的故事#连载09:面试大厂逃不过的JVM
  • $L^p$ 调和函数恒为零
  • $nextTick的使用场景介绍
  • (AtCoder Beginner Contest 340) -- F - S = 1 -- 题解
  • (Python第六天)文件处理
  • (Redis使用系列) Springboot 在redis中使用BloomFilter布隆过滤器机制 六
  • (zt)最盛行的警世狂言(爆笑)
  • (三)Kafka 监控之 Streams 监控(Streams Monitoring)和其他
  • (三)Pytorch快速搭建卷积神经网络模型实现手写数字识别(代码+详细注解)
  • (文章复现)基于主从博弈的售电商多元零售套餐设计与多级市场购电策略
  • (转) 深度模型优化性能 调参
  • (转)jdk与jre的区别
  • (转)setTimeout 和 setInterval 的区别
  • (转)总结使用Unity 3D优化游戏运行性能的经验
  • .gitignore不生效的解决方案
  • .mysql secret在哪_MYSQL基本操作(上)
  • .net core 调用c dll_用C++生成一个简单的DLL文件VS2008
  • .NET Entity FrameWork 总结 ,在项目中用处个人感觉不大。适合初级用用,不涉及到与数据库通信。
  • .net oracle 连接超时_Mysql连接数据库异常汇总【必收藏】
  • .net Stream篇(六)