Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 08B6D64FCCC for ; Fri, 12 Sep 2008 11:48:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 41075-08 for ; Fri, 12 Sep 2008 11:48:42 -0300 (ADT) X-Greylist: delayed 00:34:57.539733 by SQLgrey-1.7.6 Received: from linuxserver.novatech-llc.com (mail.novatech-llc.com [64.126.95.172]) by postgresql.org (Postfix) with ESMTP id DA0A864FCC1 for ; Fri, 12 Sep 2008 11:48:41 -0300 (ADT) Received: from [172.16.64.2] by linuxserver.novatech-llc.com with esmtp (Exim 4.63) (envelope-from ) id 1Ke9Os-00049V-1M for pgsql-performance@postgresql.org; Fri, 12 Sep 2008 09:13:39 -0500 Message-ID: <48CA78F9.5090902@novatech-llc.com> Date: Fri, 12 Sep 2008 09:13:13 -0500 From: George McCollister User-Agent: Thunderbird 1.5 (X11/20060317) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Postgres Performance on CPU limited Platforms Content-Type: multipart/mixed; boundary="------------070206030400020002080400" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2 tagged_above=0 required=5 tests=SARE_RAND_1=2 X-Spam-Level: ** X-Archive-Number: 200809/165 X-Sequence-Number: 31478 This is a multi-part message in MIME format. --------------070206030400020002080400 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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've attached my postgresql.conf 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. top shows CPU usage is at 100% with 95% being in userspace. oprofile shows memset is using 58% of the CPU cycles! CPU: ARM/XScale PMU2, speed 0 MHz (estimated) Counted CPU_CYCLES events (clock cycles counter) with a unit mask of 0x00 (No unit mask) count 100000 samples % app name symbol name 288445 57.9263 libc-2.5.so memset 33273 6.6820 vmlinux default_idle 27910 5.6050 vmlinux cpu_idle 12611 2.5326 vmlinux schedule 8803 1.7678 libc-2.5.so __printf_fp 7448 1.4957 postgres dopr 6404 1.2861 libc-2.5.so vfprintf 6398 1.2849 oprofiled (no symbols) 4992 1.0025 postgres __udivdi3 4818 0.9676 vmlinux run_timer_softirq I was having trouble getting oprofile to give a back trace for memset (probably because my libc is optimized). So I redefined MemSet to call this: void * gmm_memset(void *s, int c, size_t n) { int i=0; unsigned char * p = (unsigned char *)s; for(i=0; i ' #log_statement = 'none' # none, ddl, mod, all #log_hostname = off #--------------------------------------------------------------------------- # RUNTIME STATISTICS #--------------------------------------------------------------------------- # - Query/Index Statistics Collector - #stats_command_string = on #update_process_title = on #stats_start_collector = on # needed for block or row stats # (change requires restart) #stats_block_level = off #stats_row_level = off stats_row_level = on #stats_reset_on_server_start = off # (change requires restart) # - Statistics Monitoring - #log_parser_stats = off #log_planner_stats = off #log_executor_stats = off #log_statement_stats = off #--------------------------------------------------------------------------- # AUTOVACUUM PARAMETERS #--------------------------------------------------------------------------- #autovacuum = off # enable autovacuum subprocess? # 'on' requires stats_start_collector # and stats_row_level to also be on autovacuum = on #autovacuum_naptime = 1min # time between autovacuum runs #autovacuum_vacuum_threshold = 500 # min # of tuple updates before # vacuum #autovacuum_analyze_threshold = 250 # min # of tuple updates before # analyze #autovacuum_vacuum_scale_factor = 0.2 # fraction of rel size before # vacuum #autovacuum_analyze_scale_factor = 0.1 # fraction of rel size before # analyze #autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum # (change requires restart) #autovacuum_vacuum_cost_delay = -1 # default vacuum cost delay for # autovacuum, -1 means use # vacuum_cost_delay #autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for # autovacuum, -1 means use # vacuum_cost_limit #--------------------------------------------------------------------------- # CLIENT CONNECTION DEFAULTS #--------------------------------------------------------------------------- # - Statement Behavior - #search_path = '"$user",public' # schema names #default_tablespace = '' # a tablespace name, '' uses # the default #check_function_bodies = on #default_transaction_isolation = 'read committed' #default_transaction_read_only = off #statement_timeout = 0 # 0 is disabled #vacuum_freeze_min_age = 100000000 # - Locale and Formatting - datestyle = 'iso, mdy' #timezone = unknown # actually, defaults to TZ # environment setting #timezone_abbreviations = 'Default' # select the set of available timezone # abbreviations. Currently, there are # Default # Australia # India # However you can also create your own # file in share/timezonesets/. #extra_float_digits = 0 # min -15, max 2 #client_encoding = sql_ascii # actually, defaults to database # encoding # These settings are initialized by initdb -- they might be changed lc_messages = 'C' # locale for system error message # strings lc_monetary = 'C' # locale for monetary formatting lc_numeric = 'C' # locale for number formatting lc_time = 'C' # locale for time formatting # - Other Defaults - #explain_pretty_print = on #dynamic_library_path = '$libdir' #local_preload_libraries = '' #--------------------------------------------------------------------------- # LOCK MANAGEMENT #--------------------------------------------------------------------------- #deadlock_timeout = 1s #max_locks_per_transaction = 64 # min 10 # (change requires restart) # Note: each lock table slot uses ~270 bytes of shared memory, and there are # max_locks_per_transaction * (max_connections + max_prepared_transactions) # lock table slots. #--------------------------------------------------------------------------- # VERSION/PLATFORM COMPATIBILITY #--------------------------------------------------------------------------- # - Previous Postgres Versions - #add_missing_from = off #array_nulls = on #backslash_quote = safe_encoding # on, off, or safe_encoding #default_with_oids = off #escape_string_warning = on #standard_conforming_strings = off #regex_flavor = advanced # advanced, extended, or basic #sql_inheritance = on # - Other Platforms & Clients - #transform_null_equals = off #--------------------------------------------------------------------------- # CUSTOMIZED OPTIONS #--------------------------------------------------------------------------- #custom_variable_classes = '' # list of custom variable class names --------------070206030400020002080400--