EncodeDateTime performance

From: George McCollister <georgem(at)novatech-llc(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: EncodeDateTime performance
Date: 2008-09-15 17:30:16
Message-ID: 48CE9BA8.3090305@novatech-llc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'm trying to optimize postgres performance on a headless solid state
hardware platform (no fans or disks). I have the database stored on a
USB 2.0 flash drive (hdparm benchmarks reads at 10 MB/s). Performance is
limited by the 533Mhz CPU.

Hardware:
IXP425 XScale (big endian) 533Mhz 64MB RAM
USB 2.0 Flash Drive

Software:
Linux 2.6.21.4
postgres 8.2.5

I created a fresh database using initdb, then added one table.

Here is the create table:
CREATE TABLE archivetbl
(
"DateTime" timestamp without time zone,
"StationNum" smallint,
"DeviceDateTime" timestamp without time zone,
"DeviceNum" smallint,
"Tagname" character(64),
"Value" double precision,
"Online" boolean
)
WITH (OIDS=FALSE);
ALTER TABLE archivetbl OWNER TO novatech;

I populated the table with 38098 rows.

I'm doing this simple query:
select * from archivetbl;

It takes 79 seconds to complete the query (when postgres is compiled
with -O2). I'm running the query from pgadmin3 over TCP/IP.

oprofile is showing that memset (via dopr) is using about 60% of the CPU. I traced back further and noticed most of the usage was coming from EncodeDateTime.

I'm not quite sure why oprofile is showing that memset is hogging so much CPU. Regardless, I found way to eliminate most of the sprintf calls that were taking place in my situation.

I made some modifications to EncodeDateTime and have attached them as a patch. These changes alone reduced the query time of the "select * from archivetbl;" from 79 seconds to just 35 seconds.

This patch is against 8.2.5. Since I'm cross compiling changing versions is a bit of a pain, but if someone thinks the performance has changed much in this area I could probably get the latest version cross compiling.

Regards,
George McCollister

Attachment Content-Type Size
datetime.diff text/x-patch 2.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2008-09-15 17:39:16 Re: Parsing of pg_hba.conf and authentication inconsistencies
Previous Message Robert Treat 2008-09-15 17:07:46 Re: Transaction Snapshots and Hot Standby