search
HomeDatabaseMysql Tutorial[置顶] PostgreSQL介绍及PCIe SSD对其性能的提升效果分析

在关系数据库领域,PostgreSQL是一款非常受欢迎的开源数据库软件。自1996年发布至今,已经积累了近20年的实践经验,不论是PostgreSQL本身还是社区生态都已经非常成熟。不仅是中小企业,很多大型的行业客户也会使用PostgreSQL搭建自己的数据库系统。这篇文章

在关系数据库领域,PostgreSQL是一款非常受欢迎的开源数据库软件。自1996年发布至今,已经积累了近20年的实践经验,不论是PostgreSQL本身还是社区生态都已经非常成熟。不仅是中小企业,很多大型的行业客户也会使用PostgreSQL搭建自己的数据库系统。这篇文章主要对PostgreSQL做一个介绍,并比较了在PCIe SSD(本文使用Memblaze的PBlaze4 PCIe SSD)和硬件RAID聚合的SAS磁盘两种环境下,PostgreSQL数据库的联机事务处理(OLTP)的性能。

PostgreSQL及参数配置

最新的PostgreSQL基于SQL2011标准编写,能够实现ACID、多版本并发控制、完全串行,和复杂语句查询等功能。此外,作为开源数据库,PostgreSQL还有很多第三方组织提供的插件,在扩展、数据库迁移等方面,PostgreSQL同样具有很大的优势。

操作系统支持方面,PostgreSQL支持Linux、FreeBSD,OS X,Solaris以及Windows等。在OS X中,PostgreSQL已经是缺省的数据库软件(Mac OS X 10.7 Lion服务器或者更高的版本)。主流的Linux版本也已经有相应的PostgreSQL支持包。

测试之前,我们将参数full_page_write=on,PostgreSQL服务器在检查点之后对页面的第一次写入时将整个页面写到 WAL 里面。这么做是因为当页面写入非易失介质的过程中,同时发生了操作系统崩溃,可能只有部分页面写入磁盘, 从而导致在同一个页面中包含新旧数据的混合。如果关闭full_page_writes,在崩溃后的恢复期间, 由于在WAL里面存储的行变化信息不够完整,因此无法完全恢复该页。存储完整的页面内容可以保证页面可以正确恢复,但这样做的缺点是增加了必须写入WAL中的数据量,更多的读写操作。

测试环境介绍

BenchmarkSQL是使用Java开发的TPCC基准测试的开源应用程序,它满足TPCC行业基准协会的要求。本次测试中的BenchmarkSQL通过模拟操作人员设定了1000个仓库,并模拟了5项业务,分别为新订单、付款、订单状态、发货和库存。

整体测试环境如下:

服务器: Dell PowerEdge R730xd, 2 Intel XeonE5-2620(6核)v3 CPU,32GB DRAM

存储设备 : 1 x Memblaze 1.6T PBlaze4 PCIe SSD

6* 600GB 15K + 1 * 300GB 15K HDD

 LSI SAS-3 3008 RAID Fury

测试工具:Benchmarksql 4.1.1,PostgreSQL的TPC-C测试工具

pgcluu 2.4,PostgreSQL性能监测和稽核工具

软件: PostgreSQL 9.2.14

CentOS 7.1

测试前提条件

在测试之前,需要考虑以下操作:

1. 确保PBlaze4的分区有4KiB对齐,分区偏移量从1MiB开始。

2. 打开irqbalance服务,并设置CPU的使用模式为最大性能模式。

3. 调整操作系统内核参数,以匹配PostgreSQL。避免使用操作系统交换功能,并调整共享内存参数/文件系统脏页参数。如下所示:

vm.swappiness=0

kernel.shmmax=21474836480

net.core.rmem_max=4194304

net.core.wmem_max=4194304

kernel.sem=50100 64128000 50100 1280

vm.dirty_background_bytes=33554432

4. 使用XFS时,PostgreSQL的默认块大小为8KiB,但在当前Linux环境中,运行“mount xfs”会弹出“功能未实现”错误,因此应将块大小调整为4KiB。分配组数量的增加意味着可分配更多并行块和索引节点。nvme设备分区大小为1601GB,并设置agsize=2g。设置inode64/nobarrier/nolargeio/allocsize=16M作为挂载选项。

5. 设置PostgreSQL数据库群可以使用3/4的服务器物理内存,并且设置shared_buffer=6GB,最大连接=600。

6. 在Benchmarksql工具中配置1000仓库,并设置128个终端。

7. 预处理PBlaze4,并确保文件系统的可用容量低于50%。

测试结果


图1,IOPS和带宽在PBlaze4 PCIe SSD和RAID HDD下的表现

图1清楚地显示了在不同的存储介质情况下,IOPS和数据吞吐量的流量。对比测试结果,PBlaze4 PCIe SSD读写IOPS之和大约是RAID HDD读写IOPS之和的10倍,PBlaze4 PCIe SSD 读写吞吐量之和大约是RAID HDD读写吞吐量之和的8倍。


图2,不同存储介质状态下的读写平均响应时间

如图2所示,PBlaze4 PCIe SSD在整个测试过程中保持了稳定的响应时间。

从以上结果可见,Memblaze PBlaze4 PCIe SSD在PostgreSQL数据库联机事务处理测试中表现了出色。


图3,PBlaze4 PCIe SSD在测试过程中的功耗和温度

如图3所示,功耗和温度指标均证明PBlaze4 PCIe SSD具有稳定的交付状态。

图4,联机事务处理总交易和新订单指标

如图4所示,每分钟处理事务总量(tpmC)包含5个事务模型。运行在PBlaze4 PCIe SSD 上的测试结果远远高于基于RAID HDD的测试结果。

结论 

本测试清晰地显示出运行在Memblaze PBlaze4 PCIe SSD 上得到的出色联机事务测试结果,并且在测试过程中,PBlaze4 PCIe SSD 的功率和温度表现稳定。对于业务类型简单,数TiB级别的数据库系统,使用Memblaze PBlaze4 PCIe SSD 是一个替换传统专用存储系统,提升性能同时大幅度降低TCO的可行方案。

本文作者

武豪,Memblaze产品部AE。长期从事存储相关的系统集成工作,主要的研究方向包括主要研究逻辑卷、传统存储和关系数据库的IO路径优化等。


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Explain the role of InnoDB redo logs and undo logs.Explain the role of InnoDB redo logs and undo logs.Apr 15, 2025 am 12:16 AM

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

What are the key metrics to look for in an EXPLAIN output (type, key, rows, Extra)?What are the key metrics to look for in an EXPLAIN output (type, key, rows, Extra)?Apr 15, 2025 am 12:15 AM

Key metrics for EXPLAIN commands include type, key, rows, and Extra. 1) The type reflects the access type of the query. The higher the value, the higher the efficiency, such as const is better than ALL. 2) The key displays the index used, and NULL indicates no index. 3) rows estimates the number of scanned rows, affecting query performance. 4) Extra provides additional information, such as Usingfilesort prompts that it needs to be optimized.

What is the Using temporary status in EXPLAIN and how to avoid it?What is the Using temporary status in EXPLAIN and how to avoid it?Apr 15, 2025 am 12:14 AM

Usingtemporary indicates that the need to create temporary tables in MySQL queries, which are commonly found in ORDERBY using DISTINCT, GROUPBY, or non-indexed columns. You can avoid the occurrence of indexes and rewrite queries and improve query performance. Specifically, when Usingtemporary appears in EXPLAIN output, it means that MySQL needs to create temporary tables to handle queries. This usually occurs when: 1) deduplication or grouping when using DISTINCT or GROUPBY; 2) sort when ORDERBY contains non-index columns; 3) use complex subquery or join operations. Optimization methods include: 1) ORDERBY and GROUPB

Describe the different SQL transaction isolation levels (Read Uncommitted, Read Committed, Repeatable Read, Serializable) and their implications in MySQL/InnoDB.Describe the different SQL transaction isolation levels (Read Uncommitted, Read Committed, Repeatable Read, Serializable) and their implications in MySQL/InnoDB.Apr 15, 2025 am 12:11 AM

MySQL/InnoDB supports four transaction isolation levels: ReadUncommitted, ReadCommitted, RepeatableRead and Serializable. 1.ReadUncommitted allows reading of uncommitted data, which may cause dirty reading. 2. ReadCommitted avoids dirty reading, but non-repeatable reading may occur. 3.RepeatableRead is the default level, avoiding dirty reading and non-repeatable reading, but phantom reading may occur. 4. Serializable avoids all concurrency problems but reduces concurrency. Choosing the appropriate isolation level requires balancing data consistency and performance requirements.

MySQL vs. Other Databases: Comparing the OptionsMySQL vs. Other Databases: Comparing the OptionsApr 15, 2025 am 12:08 AM

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.

How does MySQL index cardinality affect query performance?How does MySQL index cardinality affect query performance?Apr 14, 2025 am 12:18 AM

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

MySQL: Resources and Tutorials for New UsersMySQL: Resources and Tutorials for New UsersApr 14, 2025 am 12:16 AM

The MySQL learning path includes basic knowledge, core concepts, usage examples, and optimization techniques. 1) Understand basic concepts such as tables, rows, columns, and SQL queries. 2) Learn the definition, working principles and advantages of MySQL. 3) Master basic CRUD operations and advanced usage, such as indexes and stored procedures. 4) Familiar with common error debugging and performance optimization suggestions, such as rational use of indexes and optimization queries. Through these steps, you will have a full grasp of the use and optimization of MySQL.

Real-World MySQL: Examples and Use CasesReal-World MySQL: Examples and Use CasesApr 14, 2025 am 12:15 AM

MySQL's real-world applications include basic database design and complex query optimization. 1) Basic usage: used to store and manage user data, such as inserting, querying, updating and deleting user information. 2) Advanced usage: Handle complex business logic, such as order and inventory management of e-commerce platforms. 3) Performance optimization: Improve performance by rationally using indexes, partition tables and query caches.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.