技术开发 频道

行式数据库PostgreSQL 9.04版本评测

   三、TPCH测试

  和前几次测试一样,主要测试数据加载和查询性能。

  1.准备工作

  构造测试环境,首先建立一个名为pgdb的数据库,这一步前面安装阶段已经执行过了。然后用psql连接pgdb数据库执行创建表的脚本。\i 命令用于执行一个脚本文件。\d命令显示当前数据库的表。

pgdb=# \i /user1/postgresql/dss.ddl
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
pgdb
=# \d
          List
of relations
Schema |   Name   | Type  |  Owner  
--------+----------+-------+----------
public | customer | table | postgres
public | lineitem | table | postgres
public | nation   | table | postgres
public | orders   | table | postgres
public | part     | table | postgres
public | partsupp | table | postgres
public | region   | table | postgres
public | supplier | table | postgres...

   psql有个有用的选项-E,可以显示\命令的真实SQL,如果通过其他应用程序访问数据库,无法用到psql的命令,那么可以利用这个功能查出SQL语句,然后用SQL查询。例如,显示\d命令的SQL语句:

-bash-3.2$ psql -d pgdb -E
pgdb
=# \d
********* QUERY **********
SELECT n.nspname as "Schema",
  c.relname
as "Name",
  
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' END as "Type",
  r.rolname
as "Owner"
FROM pg_catalog.pg_class c
    
JOIN pg_catalog.pg_roles r ON r.oid = c.relowner
    
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')
      
AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
      
AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;
**************************
0