Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 785199FA363 for ; Sun, 17 Dec 2006 03:18:58 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 11021-07 for ; Sun, 17 Dec 2006 03:18:56 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from exprod6og56.obsmtp.com (exprod6og56.obsmtp.com [64.18.1.208]) by postgresql.org (Postfix) with SMTP id 4C9939F9F46 for ; Sun, 17 Dec 2006 03:18:56 -0400 (AST) Received: from source ([63.240.6.44]) (using TLSv1) by exprod6ob56.postini.com ([64.18.5.12]) with SMTP; Sat, 16 Dec 2006 23:18:54 PST Received: from 172.16.1.148 by mail.mi8.com with ESMTP (- Welcome to Mi8 Corporation www.Mi8.com (D4)); Sun, 17 Dec 2006 02:18:29 -0500 X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 Received: from MI8NYCMAIL08.Mi8.com ([172.16.1.164]) by D01SMTP05.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Sun, 17 Dec 2006 02:18:28 -0500 Received: from 69.181.100.71 ([69.181.100.71]) by MI8NYCMAIL08.Mi8.com ( [172.16.1.190]) via Exchange Front-End Server mi8owa.mi8.com ( [172.16.1.106]) with Microsoft Exchange Server HTTP-DAV ; Sun, 17 Dec 2006 07:18:28 +0000 User-Agent: Microsoft-Entourage/11.2.5.060620 Date: Sat, 16 Dec 2006 23:18:25 -0800 Subject: Re: Scaling concerns From: "Luke Lonergan" To: "tsuraan" , pgsql-performance@postgresql.org Message-ID: Thread-Topic: [PERFORM] Scaling concerns Thread-Index: Acchq4p+yVHnCY2eEduqsAAWy4o9DA== In-Reply-To: <84fb38e30612160926l609ec55cs352b2495289bae0c@mail.gmail.com> MIME-Version: 1.0 X-OriginalArrivalTime: 17 Dec 2006 07:18:28.0457 (UTC) FILETIME=[8C8DB590:01C721AB] X-WSS-ID: 699A30CF27014413206-01-01 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/449 X-Sequence-Number: 22505 Tsuraan, "Select count(*) from bigtable" is testing your disk drive speed up till about 300MB/s, after which it is CPU limited in Postgres. My guess is that your system has a very slow I/O configuration, either due to faulty driver/hardware or the configuration. The first thing you should do is run a simple I/O test on your data directory - write a file twice the size of memory using dd like this: time bash -c "dd if=/dev/zero of=data_directory/bigfile bs=8k count=(2 * memory_size / 8192) && sync" time dd if=data_directory/bigfile of=/dev/null bs=8k Then report the times here. - Luke On 12/16/06 9:26 AM, "tsuraan" wrote: > I'm writing a webmail-type application that is meant to be used in a > corporate environment. The core of my system is a Postgres database > that is used as a message header cache. The two (relevant) tables > being used are pasted into the end of this message. My problem is > that, as the messages table increases to tens of millions of rows, > pgsql slows down considerably. Even an operation like "select > count(*) from messages" can take minutes, with a totally idle system. > Postgres seems to be the most scalable Free database out there, so I > must be doing something wrong. > > As for the most common strategy of having a slower (more rows) > "archival" database and a smaller, faster "live" database, all the > clients in the company are using their normal corporate email server > for day-to-day email handling. The webmail is used for access email > that's no longer on the corporate server, so it's not really simple to > say which emails should be considered live and which are really > out-of-date. > > My postgres settings are entirely default with the exception of > shared_buffers being set to 40,000 and max_connections set to 400. > I'm not sure what the meaning of most of the other settings are, so I > haven't touched them. The machines running the database servers are > my home desktop (a dual-core athlon 3200+ with 2GB RAM and a 120GB > SATA II drive), and a production server with two dual-core Intel > chips, 4 GB RAM, and a RAID 5 array of SATA II drives on a 3Ware 9550 > controller. Both machines are running Gentoo Linux with a 2.6.1x > kernel, and both exhibit significant performance degradation when I > start getting tens of millions of records. > > Any advice would be most appreciated. Thanks in advance! > > Tables: > > CREATE TABLE EmailAddresses ( > emailid SERIAL PRIMARY KEY, -- The unique identifier of this address > name TEXT NOT NULL, -- The friendly name in the address > addrspec TEXT NOT NULL, -- The user@domain part of the address > UNIQUE(name, addrspec) > ); > > and > > CREATE TABLE Messages ( > -- Store info: > msgkey BIGSERIAL PRIMARY KEY, -- Unique identifier for a message > path TEXT NOT NULL, -- Where the message is on the file > system > inserted TIMESTAMP DEFAULT now(),-- When the message was fetched > -- Message Info: > msgid TEXT UNIQUE NOT NULL, -- Message's Message-Id field > mfrom INTEGER -- Who sent the message > REFERENCES EmailAddresses > DEFAULT NULL, > mdate TIMESTAMP DEFAULT NULL, -- Message "date" header field > replyto TEXT DEFAULT NULL, -- Message-ID of replied-to message > subject TEXT DEFAULT NULL, -- Message "subject" header field > numatch INTEGER DEFAULT NULL, -- Number of attachments > UNIQUE(path) > ); > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq >