Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 8E0279FBB52 for ; Mon, 25 Jun 2007 19:20:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 11280-06 for ; Mon, 25 Jun 2007 19:20:15 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.179]) by postgresql.org (Postfix) with ESMTP id 5E00E9FB1D4 for ; Mon, 25 Jun 2007 19:20:19 -0300 (ADT) Received: by py-out-1112.google.com with SMTP id a73so1665322pye for ; Mon, 25 Jun 2007 15:20:18 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=OeaQP2AF2rlgBAtuYad0Gf+nO8yThCUzFWOwopczzE2PQNIyuSPH7VcDt5q9vbSnqN2olRJONqklI6ih2otzj2OfOkddCwxtftuMgfTkrNFSCFTZYPOYQl4zQnoXWDlRMaBSGxnOWCJ5jilnY+0RTw+hz8AvbKZNqtmSuxvwij8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=cXNX0Xt8VZHqB0T+1ZP0lzQycqylUJ9DSbXpJOYfNnlOcECoKJI6mCUcoeHLNIl14ABHEjkc/zFVQeZVkjF/rP34beSXr/jQE7OOg6vOMa44rT47+mzzBDVN2cDTv7bbtV9TLJY4WOfwLWQLiBSCLCAqcR+f8cKaPDL90WVnr5A= Received: by 10.65.124.8 with SMTP id b8mr10194940qbn.1182810017893; Mon, 25 Jun 2007 15:20:17 -0700 (PDT) Received: by 10.64.209.19 with HTTP; Mon, 25 Jun 2007 15:20:17 -0700 (PDT) Message-ID: Date: Mon, 25 Jun 2007 17:20:17 -0500 From: "Bryan Murphy" To: "Oleg Bartunov" Subject: Re: startup caching suggestions Cc: pgsql-performance@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_120053_952204.1182810017859" References: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/590 X-Sequence-Number: 25623 ------=_Part_120053_952204.1182810017859 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline No, but I was just informed of that trick earlier and intend to try it soon. Sometimes, the solution is so simple it's TOO obvious... :) Bryan On 6/25/07, Oleg Bartunov wrote: > > On Mon, 25 Jun 2007, Bryan Murphy wrote: > > > We have a search facility in our database that uses full text indexing > to > > search about 300,000 records spread across 2 tables. Nothing fancy > there. > > > > The problem is, whenever we restart the database (system crash, lost > > connectivity to SAN, upgrade, configuration change, etc.) our data is > not > > cached and query performance is really sketchy the first five to ten > minutes > > or so after the restart. This is particularly problematic because the > only > > way the data gets cached in memory is if somebody actively searches for > it, > > and the first few people who visit our site after a restart are pretty > much > > screwed. > > > > I'd like to know what are the recommended strategies for dealing with > this > > problem. We need our search queries to be near instantaneous, and we > just > > can't afford the startup penalty. > > Bryan, did you try 'dd if=/path/to/your/table of=/dev/null' trick ? > It will very fast read you data into kernel's buffers. > > > > > I'm also concerned that Postgres may not be pulling data off the SAN as > > efficiently as theory dictates. What's the best way I can diagnose if > the > > SAN is performing up to spec? I've been using iostat, and some of what > I'm > > seeing concerns me. Here's a typical iostat output (iostat -m -d 1): > > > > Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn > > sda 0.00 0.00 0.00 0 0 > > sdb 102.97 2.03 0.00 2 0 > > sdc 0.00 0.00 0.00 0 0 > > sdd 0.00 0.00 0.00 0 0 > > > > sda is the os partitionn (local), sdb is the primary database partion > (SAN), > > sdc is the log file partition (SAN), and sdd is used only for backups > > (SAN). I very rarely seen sdb MB_read/s much above 2, and most of the > time > > it hovers around 1 or lower. This seems awfully goddamn slow to me, but > > maybe I just don't fully understand what iostat is telling me. I've > seen > > sdc writes get as high as 10 during a database restore. > > > > A few bits of information about our setup: > > > > Debian Linux 2.6.18-4-amd64 (stable) > > 4x Intel(R) Xeon(R) CPU 5110 @ 1.60GHz (100% dedicated to database) > > RAID 1+0 iSCSI partitions over Gig/E MTU 9000 (99% dedicated to > database) > > 8GB RAM > > Postgres v8.1.9 > > > > The database is only about 4GB in size and the key tables total about > 700MB. > > Primary keys are CHAR(32) GUIDs > > > > Thanks, > > Bryan > > > > Regards, > Oleg > _____________________________________________________________ > Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru), > Sternberg Astronomical Institute, Moscow University, Russia > Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ > phone: +007(495)939-16-83, +007(495)939-23-83 > ------=_Part_120053_952204.1182810017859 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline No, but I was just informed of that trick earlier and intend to try it soon.  Sometimes, the solution is so simple it's TOO obvious... :)

Bryan

On 6/25/07, Oleg Bartunov <oleg@sai.msu.su> wrote:
On Mon, 25 Jun 2007, Bryan Murphy wrote:

> We have a search facility in our database that uses full text indexing to
> search about 300,000 records spread across 2 tables.  Nothing fancy there.
>
> The problem is, whenever we restart the database (system crash, lost
> connectivity to SAN, upgrade, configuration change, etc.) our data is not
> cached and query performance is really sketchy the first five to ten minutes
> or so after the restart.  This is particularly problematic because the only
> way the data gets cached in memory is if somebody actively searches for it,
> and the first few people who visit our site after a restart are pretty much
> screwed.
>
> I'd like to know what are the recommended strategies for dealing with this
> problem.  We need our search queries to be near instantaneous, and we just
> can't afford the startup penalty.

Bryan, did you try 'dd if=/path/to/your/table of=/dev/null' trick ?
It will very fast read you data into kernel's buffers.

>
> I'm also concerned that Postgres may not be pulling data off the SAN as
> efficiently as theory dictates.  What's the best way I can diagnose if the
> SAN is performing up to spec?  I've been using iostat, and some of what I'm
> seeing concerns me.  Here's a typical iostat output (iostat -m -d 1):
>
> Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
> sda               0.00         0.00         0.00          0          0
> sdb             102.97         2.03         0.00           2          0
> sdc               0.00         0.00         0.00          0          0
> sdd               0.00         0.00         0.00          0          0
>
> sda is the os partitionn (local), sdb is the primary database partion (SAN),
> sdc is the log file partition (SAN), and sdd is used only for backups
> (SAN).  I very rarely seen sdb MB_read/s much above 2, and most of the time
> it hovers around 1 or lower.  This seems awfully goddamn slow to me, but
> maybe I just don't fully understand what iostat is telling me.  I've seen
> sdc writes get as high as 10 during a database restore.
>
> A few bits of information about our setup:
>
> Debian Linux 2.6.18-4-amd64 (stable)
> 4x Intel(R) Xeon(R) CPU 5110 @ 1.60GHz (100% dedicated to database)
> RAID 1+0 iSCSI partitions over Gig/E MTU 9000 (99% dedicated to database)
> 8GB RAM
> Postgres v8.1.9
>
> The database is only about 4GB in size and the key tables total about 700MB.
> Primary keys are CHAR(32) GUIDs
>
> Thanks,
> Bryan
>

        Regards,
                Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83

------=_Part_120053_952204.1182810017859--