From pgsql-performance-owner@postgresql.org Sun Oct 31 23:59:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 342643A4329 for ; Sun, 31 Oct 2004 23:59:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18531-08 for ; Sun, 31 Oct 2004 23:58:59 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 20C143A4317 for ; Sun, 31 Oct 2004 23:59:01 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6587956; Sun, 31 Oct 2004 16:00:27 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: Speeding up Gist Index creations Date: Sun, 31 Oct 2004 16:01:15 -0800 User-Agent: KMail/1.6.2 Cc: mallah@trade-india.com References: <46946.192.168.0.11.1099256590.squirrel@office1.trade-india.com> In-Reply-To: <46946.192.168.0.11.1099256590.squirrel@office1.trade-india.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200410311601.15408.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/478 X-Sequence-Number: 8954 Mallah, > Gist indexes take a long time to create as compared > to normal indexes is there any way to speed them up ? > > (for example by modifying sort_mem or something temporarily ) More sort_mem will indeed help. So will more RAM and a faster CPU. Our GIST-index-creation process is probably not optimized; this has been marked as "needs work" in the code for several versions. If you know anyone who can help Oleg & Teodor out, be put them in touch ... -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Nov 1 01:23:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C7E4F3A437E for ; Mon, 1 Nov 2004 01:23:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39554-01 for ; Mon, 1 Nov 2004 01:22:57 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id E419D3A4368 for ; Mon, 1 Nov 2004 01:23:00 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iA11MuJ7039809 for ; Mon, 1 Nov 2004 01:22:56 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iA11C0Jf037666 for pgsql-performance@postgresql.org; Mon, 1 Nov 2004 01:12:00 GMT From: Gaetano Mendola X-Newsgroups: comp.databases.postgresql.performance Subject: Re: [PATCHES] [HACKERS] ARC Memory Usage analysis Date: Mon, 01 Nov 2004 02:11:45 +0100 Organization: Hub.Org Networking Services Lines: 27 Message-ID: References: <1098471059.20926.49.camel@localhost.localdomain> <41796115.2020501@Yahoo.com> <20041022200955.GC4382@it.is.rice.edu> <417D1D01.3090401@Yahoo.com> <20651.1098720192@sss.pgh.pa.us> <1098780555.6807.136.camel@localhost.localdomain> <74778BDA-27AC-11D9-B369-000D93AE0944@sitening.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en In-Reply-To: <74778BDA-27AC-11D9-B369-000D93AE0944@sitening.com> X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/1 X-Sequence-Number: 8955 Thomas F.O'Connell wrote: > > As a result, I was intending to inflate the value of > effective_cache_size to closer to the amount of unused RAM on some of > the machines I admin (once I've verified that they all have a unified > buffer cache). Is that correct? > Effective cache size is IMHO a "bogus" parameter on postgresql.conf, this because: 1) That parameter is not intended to instruct postgres to use that ram but is only an hint to the engine on what the "DBA" *believe* the OS cache memory for postgres 2) This parameter change only the cost evaluation of plans ( and not soo much ) so don't hope to double this parameter and push postgres to use more RAM. Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Mon Nov 1 13:00:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E55C83A3C17 for ; Mon, 1 Nov 2004 13:00:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15068-01 for ; Mon, 1 Nov 2004 12:59:49 +0000 (GMT) Received: from druid.net (druid.net [216.126.72.98]) by svr1.postgresql.org (Postfix) with ESMTP id 27D393A4547 for ; Mon, 1 Nov 2004 12:59:51 +0000 (GMT) Received: from imp.druid.net (imp [216.126.72.111]) by druid.net (Postfix) with SMTP id 279D51C99; Mon, 1 Nov 2004 07:59:51 -0500 (EST) Date: Mon, 1 Nov 2004 07:59:49 -0500 From: "D'Arcy J.M. Cain" To: brew@theMode.com Cc: ammulder@alumni.princeton.edu, pgsql-performance@postgresql.org Subject: Re: Thanks Chariot Solutions Message-Id: <20041101075949.306f7925.darcy@druid.net> In-Reply-To: References: X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; i386--netbsdelf) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/2 X-Sequence-Number: 8956 On Sun, 31 Oct 2004 13:38:55 -0500 (EST) brew@theMode.com wrote: > > Many thanks to Chariot Solutions, http://chariotsolutions.com, for > hosting Bruce Momjian giving one of his PostgreSQL seminars outside of > Philadelphia, PA yesterday. There were about sixty folks there, one > person driving from Toronto and another coming from California (!). Seconded. It was definitely worth the drive from Toronto. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From pgsql-performance-owner@postgresql.org Mon Nov 1 13:46:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9B8443A455D for ; Mon, 1 Nov 2004 13:46:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27243-07 for ; Mon, 1 Nov 2004 13:46:22 +0000 (GMT) Received: from linuxworld.com.au (unknown [203.34.46.50]) by svr1.postgresql.org (Postfix) with ESMTP id 3E1C43A455C for ; Mon, 1 Nov 2004 13:46:23 +0000 (GMT) Received: from localhost (swm@localhost) by linuxworld.com.au (8.11.6/8.11.4) with ESMTP id iA1Dj7e05430; Tue, 2 Nov 2004 00:45:10 +1100 Date: Tue, 2 Nov 2004 00:45:07 +1100 (EST) From: Gavin Sherry X-X-Sender: swm@linuxworld.com.au To: Dustin Sallings Cc: TTK Ciar , pgsql-performance@postgresql.org Subject: Re: psql large RSS (1.6GB) In-Reply-To: <8132EBC8-2B02-11D9-A2DE-000A957659CC@spy.net> Message-ID: References: <20041027075748.GA8355@hardpoint.ciar.org> <8132EBC8-2B02-11D9-A2DE-000A957659CC@spy.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/3 X-Sequence-Number: 8957 On Sat, 30 Oct 2004, Dustin Sallings wrote: > > If the solution is to just write a little client that uses perl > > DBI to fetch rows one at a time and write them out, that's doable, > > but it would be nice if psql could be made to "just work" without > > the monster RSS. > > It wouldn't make a difference unless that driver implements the > underlying protocol on its own. Even though we can tell people to make use of cursors, it seems that memory usage for large result sets should be addressed. A quick search of the archives does not reveal any discussion about having libpq spill to disk if a result set reaches some threshold. Has this been canvassed in the past? Thanks, Gavin From pgsql-performance-owner@postgresql.org Mon Nov 1 14:05:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A3ABC3A4539 for ; Mon, 1 Nov 2004 14:05:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33252-04 for ; Mon, 1 Nov 2004 14:05:18 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id F3C683A4530 for ; Mon, 1 Nov 2004 14:05:18 +0000 (GMT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id iA1E4i407690; Mon, 1 Nov 2004 09:04:44 -0500 (EST) From: Bruce Momjian Message-Id: <200411011404.iA1E4i407690@candle.pha.pa.us> Subject: Re: psql large RSS (1.6GB) In-Reply-To: To: Gavin Sherry Date: Mon, 1 Nov 2004 09:04:44 -0500 (EST) Cc: Dustin Sallings , TTK Ciar , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/4 X-Sequence-Number: 8958 Gavin Sherry wrote: > On Sat, 30 Oct 2004, Dustin Sallings wrote: > > > > If the solution is to just write a little client that uses perl > > > DBI to fetch rows one at a time and write them out, that's doable, > > > but it would be nice if psql could be made to "just work" without > > > the monster RSS. > > > > It wouldn't make a difference unless that driver implements the > > underlying protocol on its own. > > Even though we can tell people to make use of cursors, it seems that > memory usage for large result sets should be addressed. A quick search of > the archives does not reveal any discussion about having libpq spill to > disk if a result set reaches some threshold. Has this been canvassed in > the past? No, I don't remember hearing this discussed and I don't think most people would want libpq spilling to disk by default. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Mon Nov 1 16:04:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B1E803A45E8 for ; Mon, 1 Nov 2004 16:03:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70925-08 for ; Mon, 1 Nov 2004 16:03:44 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id BB4CA3A45C6 for ; Mon, 1 Nov 2004 16:03:43 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA1G378r014204; Mon, 1 Nov 2004 11:03:07 -0500 (EST) To: Bruce Momjian Cc: Gavin Sherry , Dustin Sallings , TTK Ciar , pgsql-performance@postgresql.org Subject: Re: psql large RSS (1.6GB) In-reply-to: <200411011404.iA1E4i407690@candle.pha.pa.us> References: <200411011404.iA1E4i407690@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Mon, 01 Nov 2004 09:04:44 -0500" Date: Mon, 01 Nov 2004 11:03:07 -0500 Message-ID: <14203.1099324987@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/5 X-Sequence-Number: 8959 Bruce Momjian writes: > No, I don't remember hearing this discussed and I don't think most > people would want libpq spilling to disk by default. Far more useful would be some sort of streaming API to let the application process the rows as they arrive, or at least fetch the rows in small batches (the V3 protocol supports the latter even without any explicit use of a cursor). I'm not sure if this can be bolted onto the existing libpq framework reasonably, but that's the direction I'd prefer to go in. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Nov 1 17:38:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 46CC13A460D for ; Mon, 1 Nov 2004 17:37:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01568-08 for ; Mon, 1 Nov 2004 17:37:57 +0000 (GMT) Received: from vt-pe2550-001.VANTAGE.vantage.com (sol.vantage.com [64.80.203.242]) by svr1.postgresql.org (Postfix) with ESMTP id 22E393A460A for ; Mon, 1 Nov 2004 17:37:55 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C4C039.84294ECE" Subject: shared_buffers and Shared Memory Segments Date: Mon, 1 Nov 2004 12:37:53 -0500 Message-ID: <4BAFBB6B9CC46F41B2AD7D9F4BBAF78501B27800@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: shared_buffers and Shared Memory Segments Thread-Index: AcTAOYQxicrKlfZKRvyVukFhxD9o8A== From: "Anjan Dave" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=HTML_60_70, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200411/6 X-Sequence-Number: 8960 This is a multi-part message in MIME format. ------_=_NextPart_001_01C4C039.84294ECE Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, =20 I am trying to understand the output of the 'ipcs' command during peak activity and how I can use it to possibly tune the shared_buffers... =20 Here's what I see right now: (ipcs -m) - (Host is RHAS 3.0) =20 ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x0052e2c1 1966080 postgres 600 92078080 322 =20 What is nattch? Is this the num of segments attached? Is it saying that about 92MB is used out of 512MB? =20 -Shared memory segment size is defined to be 512MB =20 =20 -Currently, shared_buffers are at 80MB (10240) =20 =20 Here's the 'top' output: =20 12:29:42 up 24 days, 15:04, 6 users, load average: 2.28, 1.07, 1.07 421 processes: 414 sleeping, 3 running, 4 zombie, 0 stopped CPU states: cpu user nice system irq softirq iowait idle total 83.6% 0.0% 40.8% 0.0% 7.6% 76.4% 190.0% cpu00 20.9% 0.0% 9.0% 0.3% 0.1% 22.5% 46.8% cpu01 19.2% 0.0% 10.6% 0.0% 7.3% 14.4% 48.3% cpu02 15.0% 0.0% 7.3% 0.0% 0.0% 8.6% 68.9% cpu03 28.6% 0.0% 14.0% 0.0% 0.1% 31.0% 26.0% Mem: 7973712k av, 7675856k used, 297856k free, 0k shrd, 149220k buff 3865444k actv, 2638404k in_d, 160092k in_c Swap: 4096532k av, 28k used, 4096504k free 6387092k cached =20 =20 Can I conclude anything from these outputs and the buffer setting? =20 =20 Appreciate any thoughts. =20 =20 Thanks, Anjan ------_=_NextPart_001_01C4C039.84294ECE Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hello,

 

I am trying to understand the output of the = ‘ipcs’ command during peak activity and how I can use it to possibly tune the shared_buffers…

 

Here’s what I see right now: (ipcs –m) = – (Host is RHAS 3.0)

 

------ Shared Memory Segments = --------

key        = shmid      owner      = perms      bytes      nattch     status

0x0052e2c1 1966080    postgres  = 600        92078080   = 322

 

What is nattch? Is this the num of segments attached? = Is it saying that about 92MB is used out of = 512MB?

 

-Shared memory segment size is defined to be = 512MB

 

 

-Currently, shared_buffers are at 80MB = (10240)

 

 

Here’s the ‘top’ = output:

 

12:29:42  up 24 days, 15:04,  6 = users,  load average: 2.28, 1.07, 1.07

421 processes: 414 sleeping, 3 running, 4 zombie, 0 = stopped

CPU states:  cpu    = user    nice  system    irq  = softirq  iowait    idle

         =   total   83.6%    0.0%   = 40.8%   0.0%     7.6%   76.4%  190.0%

         =   cpu00   20.9%    0.0%    = 9.0%   0.3%     0.1%   22.5%   46.8%

         =   cpu01   19.2%    0.0%   = 10.6%   0.0%     7.3%   14.4%   48.3%

         =   cpu02   15.0%    0.0%    = 7.3%   0.0%     0.0%    8.6%   68.9%

   =         cpu03   = 28.6%    0.0%   14.0%   = 0.0%     0.1%   31.0%   26.0%

Mem:  7973712k av, 7675856k used,  297856k = free,       0k shrd,  149220k buff

         =           3865444k actv, = 2638404k in_d,  160092k in_c

Swap: 4096532k av,      28k = used, 4096504k = free           &nb= sp;     6387092k cached

 

 

Can I conclude anything from these outputs and the = buffer setting?

 

 

Appreciate any thoughts.

 

 

Thanks,
Anjan

------_=_NextPart_001_01C4C039.84294ECE-- From pgsql-performance-owner@postgresql.org Mon Nov 1 18:50:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 11F703A460C for ; Mon, 1 Nov 2004 18:50:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 25746-06 for ; Mon, 1 Nov 2004 18:49:52 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id B4CB93A3B79 for ; Mon, 1 Nov 2004 18:49:52 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6591439; Mon, 01 Nov 2004 10:51:19 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: psql large RSS (1.6GB) Date: Mon, 1 Nov 2004 10:49:06 -0800 User-Agent: KMail/1.6.2 Cc: Tom Lane , Bruce Momjian , Gavin Sherry , Dustin Sallings , TTK Ciar References: <200411011404.iA1E4i407690@candle.pha.pa.us> <14203.1099324987@sss.pgh.pa.us> In-Reply-To: <14203.1099324987@sss.pgh.pa.us> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <200411011049.06770.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/7 X-Sequence-Number: 8961 Tom, > Far more useful would be some sort of streaming API to let the > application process the rows as they arrive, or at least fetch the rows > in small batches (the V3 protocol supports the latter even without any > explicit use of a cursor). =C2=A0I'm not sure if this can be bolted onto = the > existing libpq framework reasonably, but that's the direction I'd prefer > to go in. I think that TelegraphCQ incorporates this. However, I'm not sure whether= =20 it's a portable component; it may be too tied in to their streaming query=20 engine. They have talked about porting their "background query" patch for= =20 PSQL, though ... =2D-=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Nov 1 21:44:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 64CB73A469D for ; Mon, 1 Nov 2004 21:40:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77808-10 for ; Mon, 1 Nov 2004 21:40:33 +0000 (GMT) Received: from mail.atua.com.br (unknown [200.248.138.61]) by svr1.postgresql.org (Postfix) with ESMTP id 490D63A4696 for ; Mon, 1 Nov 2004 21:40:31 +0000 (GMT) Received: from [10.0.0.171] (ns2.atua.com.br [200.248.138.60]) by mail.atua.com.br (Postfix) with ESMTP id 1F2141EC324 for ; Mon, 1 Nov 2004 19:40:31 -0200 (BRST) Subject: Performance difference when using views From: Alvaro Nunes Melo To: Pgsql-Performance Content-Type: text/plain Message-Id: <1099345230.8204.30.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 01 Nov 2004 19:40:30 -0200 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/8 X-Sequence-Number: 8962 Hi, I have some views that are used to make some queries simplest. But when I use them there is a performance loss, because the query don't use indexes anymore. Below I'm sending the query with and without the view, its execution times, explains and the view's body. I didn't understood the why the performance is so different (20x in seconds, 1000x in page reads) if the queries are semantically identical. Shouldn't I use views in situations like this? Is there some way to use the view and the indexes? -------------- -- View body -------------- CREATE VIEW vw_test AS SELECT e.person_id, ci.city_id, ci.city_name, s.state_id, s.state_acronym FROM address a LEFT OUTER JOIN zip zp ON a.zip_code_id = zp.zip_code_id LEFT OUTER JOIN city ci ON ci.city_id = zp.city_id LEFT OUTER JOIN state s ON ci.state_id = s.state_id WHERE a.adress_type = 2; --------------------- -- Without the view --------------------- SELECT p.person_id, ci.city_id, ci.city_name, s.state_id, s.state_acronym FROM person p LEFT OUTER JOIN address e USING (person_id) LEFT OUTER JOIN zip zp ON a.zip_code_id = zp.zip_code_id LEFT OUTER JOIN city ci ON ci.city_id = zp.city_id LEFT OUTER JOIN state u ON ci.state_id = s.state_id WHERE a.adress_type = 2 AND p.person_id = 19257; person_id | city_id | city_name | state_id | state_acronym -----------+-----------+-----------+----------+--------------- 19257 | 70211 | JAGUARAO | 22 | RS (1 record) Time: 110,047 ms QUERY PLAN --------------------------------------------------------------------- Nested Loop Left Join (cost=0.00..20.04 rows=1 width=33) Join Filter: ("outer".state_id = "inner".state_id) -> Nested Loop Left Join (cost=0.00..18.43 rows=1 width=27) -> Nested Loop Left Join (cost=0.00..13.87 rows=1 width=8) -> Nested Loop (cost=0.00..10.75 rows=1 width=8) -> Index Scan using pk_person on person p (cost=0.00..5.41 rows=1 width=4) Index Cond: (person_id = 19257) -> Index Scan using un_address_adress_type on address e (cost=0.00..5.33 rows=1 width=8) Index Cond: (19257 = person_id) Filter: (adress_type = 2) -> Index Scan using pk_zip on zip zp (cost=0.00..3.11 rows=1 width=8) Index Cond: ("outer".zip_code_id = zp.zip_code_id) -> Index Scan using pk_city on city ci (cost=0.00..4.55 rows=1 width=23) Index Cond: (ci.city_id = "outer".city_id) -> Seq Scan on state u (cost=0.00..1.27 rows=27 width=10) (15 records) --------------------- -- With the view --------------------- SELECT p.person_id, t.city_id, t.city_name, t.state_id, t.state_acronym FROM person p LEFT OUTER JOIN vw_test t USING (person_id) WHERE p.person_id = 19257; person_id | city_id | city_name | state_id | state_acronym -----------+-----------+-----------+----------+-------------- 19257 | 70211 | JAGUARAO | 22 | RS (1 record) Time: 1982,743 ms QUERY PLAN --------------------------------------------------------------------- Nested Loop Left Join (cost=10921.71..28015.63 rows=1 width=33) Join Filter: ("outer".person_id = "inner".person_id) -> Index Scan using pk_person on person p (cost=0.00..5.41 rows=1 width=4) Index Cond: (person_id = 19257) -> Hash Left Join (cost=10921.71..27799.55 rows=16854 width=33) Hash Cond: ("outer".state_id = "inner".state_id) -> Hash Left Join (cost=10920.38..27545.40 rows=16854 width=27) Hash Cond: ("outer".city_id = "inner".city_id) -> Hash Left Join (cost=10674.20..26688.88 rows=16854 width=8) Hash Cond: ("outer".zip_code_id = "inner".zip_code_id) -> Seq Scan on address e (cost=0.00..1268.67 rows=16854 width=8) Filter: (adress_type = 2) -> Hash (cost=8188.36..8188.36 rows=387936 width=8) -> Seq Scan on zip zp (cost=0.00..8188.36 rows=387936 width=8) -> Hash (cost=164.94..164.94 rows=9694 width=23) -> Seq Scan on city ci (cost=0.00..164.94 rows=9694 width=23) -> Hash (cost=1.27..1.27 rows=27 width=10) -> Seq Scan on state u (cost=0.00..1.27 rows=27 width=10) (18 records) Best regards, -- +---------------------------------------------------+ | Alvaro Nunes Melo Atua Sistemas de Informacao | | al_nunes@atua.com.br www.atua.com.br | | UIN - 42722678 (54) 327-1044 | +---------------------------------------------------+ From pgsql-hackers-owner@postgresql.org Mon Nov 1 22:06:43 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AC94C3A46A0; Mon, 1 Nov 2004 22:06:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88560-04; Mon, 1 Nov 2004 22:06:20 +0000 (GMT) Received: from cmailm2.svr.pol.co.uk (cmailm2.svr.pol.co.uk [195.92.193.210]) by svr1.postgresql.org (Postfix) with ESMTP id F40503A4694; Mon, 1 Nov 2004 22:06:20 +0000 (GMT) Received: from modem-465.orangutan.dialup.pol.co.uk ([217.135.225.209] helo=[192.168.0.102]) by cmailm2.svr.pol.co.uk with esmtp (Exim 4.41) id 1COkJd-0001zY-Vt; Mon, 01 Nov 2004 22:06:19 +0000 Subject: Re: [PERFORM] [PATCHES] ARC Memory Usage analysis From: Simon Riggs To: josh@agliodbs.com Cc: pgsql-hackers@postgresql.org, "Thomas F.O'Connell" , PgSQL - Performance In-Reply-To: <200410261739.59814.josh@agliodbs.com> References: <1098471059.20926.49.camel@localhost.localdomain> <1098780555.6807.136.camel@localhost.localdomain> <74778BDA-27AC-11D9-B369-000D93AE0944@sitening.com> <200410261739.59814.josh@agliodbs.com> Content-Type: text/plain Organization: 2nd Quadrant Message-Id: <1099346638.2709.85.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Mon, 01 Nov 2004 22:03:58 +0000 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/48 X-Sequence-Number: 60620 On Wed, 2004-10-27 at 01:39, Josh Berkus wrote: > Thomas, > > > As a result, I was intending to inflate the value of > > effective_cache_size to closer to the amount of unused RAM on some of > > the machines I admin (once I've verified that they all have a unified > > buffer cache). Is that correct? > > Currently, yes. I now believe the answer to that is "no, that is not fully correct", following investigation into how to set that parameter correctly. > Right now, e_c_s is used just to inform the planner and make > index vs. table scan and join order decisions. Yes, I agree that is what e_c_s is used for. ...lets go deeper: effective_cache_size is used to calculate the number of I/Os required to index scan a table, which varies according to the size of the available cache (whether this be OS cache or shared_buffers). The reason to do this is because whether a table is in cache can make a very great difference to access times; *small* tables tend to be the ones that vary most significantly. PostgreSQL currently uses the Mackert and Lohman [1989] equation to assess how much of a table is in cache in a blocked DBMS with a finite cache. The Mackert and Lohman equation is accurate, as long as the parameter b is reasonably accurately set. [I'm discussing only the current behaviour here, not what it can or should or could be] If it is incorrectly set, then the equation will give the wrong answer for small tables. The same answer (i.e. same asymptotic behaviour) is returned for very large tables, but they are the ones we didn't worry about anyway. Getting the equation wrong means you will choose sub-optimal plans, potentially reducing your performance considerably. As I read it, effective_cache_size is equivalent to the parameter b, defined as (p.3) "minimum buffer size dedicated to a given scan". M&L they point out (p.3) "We...do not consider interactions of multiple users sharing the buffer for multiple file accesses". Either way, M&L aren't talking about "the total size of the cache", which we would interpret to mean shared_buffers + OS cache, in our effort to not forget the beneficial effect of the OS cache. They use the phrase "dedicated to a given scan".... AFAICS "effective_cache_size" should be set to a value that reflects how many other users of the cache there might be. If you know for certain you're the only user, set it according to the existing advice. If you know you aren't, then set it an appropriate factor lower. Setting that accurately on a system wide basis may clearly be difficult and setting it high will often be inappropriate. The manual is not clear as to how to set effective_cache_size. Other advice misses out the effect of the many scans/many tables issue and will give the wrong answer for many calculations, and thus produce incorrect plans for 8.0 (and earlier releases also). This is something that needs to be documented rather than a bug fix. It's a complex one, so I'll await all of your objections before I write a new doc patch. [Anyway, I do hope I've missed something somewhere in all that, though I've read their paper twice now. Fairly accessible, but requires interpretation to the PostgreSQL case. Mackert and Lohman [1989] "Index Scans using a finite LRU buffer: A validated I/O model"] > The problem which Simon is bringing up is part of a discussion about doing > *more* with the information supplied by e_c_s. He points out that it's not > really related to the *real* probability of any particular table being > cached. At least, if I'm reading him right. Yes, that was how Jan originally meant to discuss it, but not what I meant. Best regards, Simon Riggs From pgsql-performance-owner@postgresql.org Mon Nov 1 22:08:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 006F33A46A0 for ; Mon, 1 Nov 2004 22:08:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86659-10 for ; Mon, 1 Nov 2004 22:08:30 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 383453A469C for ; Mon, 1 Nov 2004 22:08:31 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA1M8SXd027482; Mon, 1 Nov 2004 17:08:28 -0500 (EST) To: Alvaro Nunes Melo Cc: Pgsql-Performance Subject: Re: Performance difference when using views In-reply-to: <1099345230.8204.30.camel@localhost> References: <1099345230.8204.30.camel@localhost> Comments: In-reply-to Alvaro Nunes Melo message dated "Mon, 01 Nov 2004 19:40:30 -0200" Date: Mon, 01 Nov 2004 17:08:28 -0500 Message-ID: <27481.1099346908@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/10 X-Sequence-Number: 8964 Alvaro Nunes Melo writes: > I have some views that are used to make some queries simplest. But when > I use them there is a performance loss, because the query don't use > indexes anymore. Below I'm sending the query with and without the view, > its execution times, explains and the view's body. It's not the same query, because you are implicitly changing the order of the LEFT JOINs when you group some of them into a subquery (view). Join order is significant for outer joins ... regards, tom lane From pgsql-performance-owner@postgresql.org Mon Nov 1 22:31:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 723883A4682 for ; Mon, 1 Nov 2004 22:31:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94707-07 for ; Mon, 1 Nov 2004 22:31:09 +0000 (GMT) Received: from cmailg4.svr.pol.co.uk (cmailg4.svr.pol.co.uk [195.92.195.174]) by svr1.postgresql.org (Postfix) with ESMTP id CB5EE3A4680 for ; Mon, 1 Nov 2004 22:31:11 +0000 (GMT) Received: from modem-465.orangutan.dialup.pol.co.uk ([217.135.225.209] helo=[192.168.0.102]) by cmailg4.svr.pol.co.uk with esmtp (Exim 4.41) id 1COkhh-0002vZ-Sm; Mon, 01 Nov 2004 22:31:10 +0000 Subject: Re: Performance difference when using views From: Simon Riggs To: Alvaro Nunes Melo Cc: Pgsql-Performance In-Reply-To: <1099345230.8204.30.camel@localhost> References: <1099345230.8204.30.camel@localhost> Content-Type: text/plain Organization: 2nd Quadrant Message-Id: <1099348130.2709.105.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Mon, 01 Nov 2004 22:28:50 +0000 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/11 X-Sequence-Number: 8965 On Mon, 2004-11-01 at 21:40, Alvaro Nunes Melo wrote: > Hi, > > I have some views that are used to make some queries simplest. But when > I use them there is a performance loss, because the query don't use > indexes anymore. Below I'm sending the query with and without the view, > its execution times, explains and the view's body. I didn't understood > the why the performance is so different (20x in seconds, 1000x in page > reads) if the queries are semantically identical. > > Shouldn't I use views in situations like this? Is there some way to use > the view and the indexes? > > -------------- > -- View body > -------------- > > CREATE VIEW vw_test AS > SELECT e.person_id, ci.city_id, ci.city_name, s.state_id, > s.state_acronym > FROM address a > LEFT OUTER JOIN zip zp ON a.zip_code_id = zp.zip_code_id > LEFT OUTER JOIN city ci ON ci.city_id = zp.city_id > LEFT OUTER JOIN state s ON ci.state_id = s.state_id > WHERE a.adress_type = 2; > > --------------------- > -- Without the view > --------------------- > > SELECT p.person_id, ci.city_id, ci.city_name, s.state_id, > s.state_acronym > FROM person p > LEFT OUTER JOIN address e USING (person_id) > LEFT OUTER JOIN zip zp ON a.zip_code_id = zp.zip_code_id > LEFT OUTER JOIN city ci ON ci.city_id = zp.city_id > LEFT OUTER JOIN state u ON ci.state_id = s.state_id > WHERE a.adress_type = 2 > AND p.person_id = 19257; > Try this.... SELECT p.person_id, ci.city_id, ci.city_name, s.state_id, s.state_acronym FROM person p LEFT OUTER JOIN ( address a LEFT OUTER JOIN zip zp ON a.zip_code_id = zp.zip_code_id LEFT OUTER JOIN city ci ON ci.city_id = zp.city_id LEFT OUTER JOIN state u ON ci.state_id = s.state_id ) USING (person_id) WHERE a.adress_type = 2 AND p.person_id = 19257; Which should return the same answer, and also hopefully the same plan. -- Best Regards, Simon Riggs From pgsql-performance-owner@postgresql.org Tue Nov 2 01:36:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C211A3A4786 for ; Tue, 2 Nov 2004 01:36:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40801-04 for ; Tue, 2 Nov 2004 01:36:12 +0000 (GMT) Received: from sue.samurai.com (sue.samurai.com [205.207.28.74]) by svr1.postgresql.org (Postfix) with ESMTP id 0FA5D3A4782 for ; Tue, 2 Nov 2004 01:36:13 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by sue.samurai.com (Postfix) with ESMTP id B2568197FB; Mon, 1 Nov 2004 20:36:13 -0500 (EST) Received: from sue.samurai.com ([127.0.0.1]) by localhost (sue.samurai.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 09240-01-9; Mon, 1 Nov 2004 20:36:10 -0500 (EST) Received: from [61.88.101.19] (unknown [61.88.101.19]) by sue.samurai.com (Postfix) with ESMTP id 71FCD197A7; Mon, 1 Nov 2004 20:36:09 -0500 (EST) Subject: Re: Speeding up Gist Index creations From: Neil Conway To: Josh Berkus Cc: pgsql-performance@postgresql.org, mallah@trade-india.com In-Reply-To: <200410311601.15408.josh@agliodbs.com> References: <46946.192.168.0.11.1099256590.squirrel@office1.trade-india.com> <200410311601.15408.josh@agliodbs.com> Content-Type: text/plain Message-Id: <1099359354.17405.150.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Tue, 02 Nov 2004 12:35:55 +1100 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/12 X-Sequence-Number: 8966 On Mon, 2004-11-01 at 11:01, Josh Berkus wrote: > > Gist indexes take a long time to create as compared > > to normal indexes is there any way to speed them up ? > > > > (for example by modifying sort_mem or something temporarily ) > > More sort_mem will indeed help. How so? sort_mem improves index creation for B+-tree because we implement bulk loading; there is no implementation of bulk loading for GiST, so I don't see how sort_mem will help. -Neil From pgsql-performance-owner@postgresql.org Tue Nov 2 05:59:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8939D3A4827 for ; Tue, 2 Nov 2004 05:59:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12384-10 for ; Tue, 2 Nov 2004 05:59:24 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 670563A47DB for ; Tue, 2 Nov 2004 05:59:24 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6593822; Mon, 01 Nov 2004 22:00:51 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: Speeding up Gist Index creations Date: Mon, 1 Nov 2004 21:58:35 -0800 User-Agent: KMail/1.6.2 Cc: Neil Conway , mallah@trade-india.com References: <46946.192.168.0.11.1099256590.squirrel@office1.trade-india.com> <200410311601.15408.josh@agliodbs.com> <1099359354.17405.150.camel@localhost.localdomain> In-Reply-To: <1099359354.17405.150.camel@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <200411012158.35549.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/13 X-Sequence-Number: 8967 Neil, > How so? sort_mem improves index creation for B+-tree because we > implement bulk loading; there is no implementation of bulk loading for > GiST, so I don't see how sort_mem will help. Ah, wasn't aware of that deficiency. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Nov 2 23:54:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F34923A4177 for ; Tue, 2 Nov 2004 23:53:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43966-05 for ; Tue, 2 Nov 2004 23:53:28 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id B4EDF3A4113 for ; Tue, 2 Nov 2004 23:53:27 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iA2NrMJ7045006 for ; Tue, 2 Nov 2004 23:53:22 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iA2Nq93o044564 for pgsql-performance@postgresql.org; Tue, 2 Nov 2004 23:52:09 GMT From: Martin Foster Organization: Ethereal Realms User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 X-Newsgroups: comp.databases.postgresql.performance Subject: Restricting Postgres Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Lines: 17 Message-ID: Date: Tue, 02 Nov 2004 23:52:12 GMT To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/14 X-Sequence-Number: 8968 Is there a way to restrict how much load a PostgreSQL server can take before dropping queries in order to safeguard the server? I was looking at the login.conf (5) man page and while it allows me to limit by processor time this seems to not fit my specific needs. Essentially, I am looking for a sort of functionality similar to what Sendmail and Apache have. Once the load of the system reaches a certain defined limit the daemon drops tasks until such a time that it can resume normal operation. While not necessarily common on my servers I have witnessed some fairly high load averages which may have led to the machine dropping outright. Any help on this matter would be appreciated. -- Martin Foster Creator/Designer Ethereal Realms martin@ethereal-realms.org From pgsql-performance-owner@postgresql.org Wed Nov 3 14:18:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5BFB03A4448 for ; Wed, 3 Nov 2004 14:17:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60503-02 for ; Wed, 3 Nov 2004 14:17:42 +0000 (GMT) Received: from smtp101.rog.mail.re2.yahoo.com (smtp101.rog.mail.re2.yahoo.com [206.190.36.79]) by svr1.postgresql.org (Postfix) with SMTP id AECCB3A4409 for ; Wed, 3 Nov 2004 14:17:44 +0000 (GMT) Received: from unknown (HELO phlogiston.dydns.org) (a.sullivan@rogers.com@65.49.125.184 with login) by smtp101.rog.mail.re2.yahoo.com with SMTP; 3 Nov 2004 14:17:44 -0000 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 4066A404B; Wed, 3 Nov 2004 09:17:43 -0500 (EST) Date: Wed, 3 Nov 2004 09:17:43 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Restricting Postgres Message-ID: <20041103141743.GA15499@phlogiston.dyndns.org> Mail-Followup-To: pgsql-performance@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6+20040722i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/15 X-Sequence-Number: 8969 On Tue, Nov 02, 2004 at 11:52:12PM +0000, Martin Foster wrote: > Is there a way to restrict how much load a PostgreSQL server can take > before dropping queries in order to safeguard the server? I was Well, you could limit the number of concurrent connections, and set the query timeout to a relatively low level. What that ought to mean is that, under heavy load, some queries will abort. A -- Andrew Sullivan | ajs@crankycanuck.ca When my information changes, I alter my conclusions. What do you do sir? --attr. John Maynard Keynes From pgsql-performance-owner@postgresql.org Wed Nov 3 17:31:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F3CA53A450F for ; Wed, 3 Nov 2004 17:31:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24876-02 for ; Wed, 3 Nov 2004 17:30:57 +0000 (GMT) Received: from fed1rmmtao05.cox.net (fed1rmmtao05.cox.net [68.230.241.34]) by svr1.postgresql.org (Postfix) with ESMTP id 15B233A44B6 for ; Wed, 3 Nov 2004 17:30:55 +0000 (GMT) Received: from CYGNUS ([68.228.61.13]) by fed1rmmtao05.cox.net (InterMail vM.6.01.04.00 201-2131-117-20041022) with ESMTP id <20041103173054.EJWF21506.fed1rmmtao05.cox.net@CYGNUS> for ; Wed, 3 Nov 2004 12:30:54 -0500 From: To: Subject: preloading indexes Date: Wed, 3 Nov 2004 10:30:47 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0006_01C4C190.30E98C00" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcTBytqc+F+Ugy7bRJCHLIsoClTAUQ== Message-Id: <20041103173054.EJWF21506.fed1rmmtao05.cox.net@CYGNUS> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_50_60, HTML_MESSAGE, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200411/16 X-Sequence-Number: 8970 This is a multi-part message in MIME format. ------=_NextPart_000_0006_01C4C190.30E98C00 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit I am working with some pretty convoluted queries that work very slowly the first time they're called but perform fine on the second call. I am fairly certain that these differences are due to the caching. Can someone point me in a direction that would allow me to pre-cache the critical indexes? ------=_NextPart_000_0006_01C4C190.30E98C00 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable

I am working with some pretty convoluted queries that = work very slowly the first time they’re called but perform fine on the = second call. I am fairly certain that these differences are due to the caching. = Can someone point me in a direction that would allow me to pre-cache the = critical indexes?

------=_NextPart_000_0006_01C4C190.30E98C00-- From pgsql-performance-owner@postgresql.org Wed Nov 3 17:59:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 21FF03A44F7 for ; Wed, 3 Nov 2004 17:59:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33060-06 for ; Wed, 3 Nov 2004 17:59:03 +0000 (GMT) Received: from neptune.lgu.ac.uk (neptune.lgu.ac.uk [140.97.30.6]) by svr1.postgresql.org (Postfix) with ESMTP id EFAAD3A4164 for ; Wed, 3 Nov 2004 17:59:02 +0000 (GMT) Received: from solent (cal42-234.lgu.ac.uk [140.97.42.234]) by neptune.lgu.ac.uk (8.12.10/8.12.10) with ESMTP id iA3HwoO6010071; Wed, 3 Nov 2004 17:58:51 GMT Reply-To: From: "Matt Clark" To: , Subject: Re: preloading indexes Date: Wed, 3 Nov 2004 17:59:02 -0000 Organization: Ymogen Ltd Message-ID: <004b01c4c1ce$cd969c80$8300a8c0@solent> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_004C_01C4C1CE.CD969C80" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 In-Reply-To: <20041103173054.EJWF21506.fed1rmmtao05.cox.net@CYGNUS> Importance: Normal X-LGU-MailScanner: Found to be clean X-MailScanner-From: matt@ymogen.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=HTML_50_60, HTML_FONTCOLOR_BLUE, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200411/17 X-Sequence-Number: 8971 This is a multi-part message in MIME format. ------=_NextPart_000_004C_01C4C1CE.CD969C80 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit The best way to get all the stuff needed by a query into RAM is to run the query. Is it more that you want to 'pin' the data in RAM so it doesn't get overwritten by other queries? -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of stuff@opensourceonline.com Sent: 03 November 2004 17:31 To: pgsql-performance@postgresql.org Subject: [PERFORM] preloading indexes I am working with some pretty convoluted queries that work very slowly the first time they're called but perform fine on the second call. I am fairly certain that these differences are due to the caching. Can someone point me in a direction that would allow me to pre-cache the critical indexes? ------=_NextPart_000_004C_01C4C1CE.CD969C80 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Message
The best way to get all the stuff needed by a = query into=20 RAM is to run the query.  Is it more that you want to 'pin' the = data in RAM=20 so it doesn't get overwritten by other=20 queries?
 
-----Original = Message-----
From:=20 pgsql-performance-owner@postgresql.org=20 [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of=20 stuff@opensourceonline.com
Sent: 03 November 2004=20 17:31
To: pgsql-performance@postgresql.org
Subject:=20 [PERFORM] preloading indexes

I am working with some = pretty=20 convoluted queries that work very slowly the first time they’re = called but=20 perform fine on the second call. I am fairly certain that these = differences=20 are due to the caching. Can someone point me in a direction that would = allow=20 me to pre-cache the critical=20 indexes?

------=_NextPart_000_004C_01C4C1CE.CD969C80-- From pgsql-performance-owner@postgresql.org Wed Nov 3 18:56:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B51C63A4537 for ; Wed, 3 Nov 2004 18:56:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49909-09 for ; Wed, 3 Nov 2004 18:56:47 +0000 (GMT) Received: from web52105.mail.yahoo.com (web52105.mail.yahoo.com [206.190.39.74]) by svr1.postgresql.org (Postfix) with SMTP id 6D2ED3A4536 for ; Wed, 3 Nov 2004 18:56:47 +0000 (GMT) Message-ID: <20041103185647.87443.qmail@web52105.mail.yahoo.com> Received: from [198.182.200.22] by web52105.mail.yahoo.com via HTTP; Wed, 03 Nov 2004 10:56:47 PST Date: Wed, 3 Nov 2004 10:56:47 -0800 (PST) From: patrick ~ Subject: vacuum analyze slows sql query To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/18 X-Sequence-Number: 8972 Greetings pgsql-performance :) Yesterday I posted to the pgsql-sql list about an issue with VACUUM while trying to track-down an issue with performance of a SQL SELECT statement invovling a stored function. It was suggested that I bring the discussion over to -performance. Instread of reposting the message here is a link to the original message followed by a brief summary: http://marc.theaimsgroup.com/?l=postgresql-sql&m=109945118928530&w=2 Summary: Our customer complains about web/php-based UI sluggishness accessing the data in db. I created a "stripped down" version of the tables in question to be able to post to the pgsql-sql list asking for hints as to how I can improve the SQL query. While doing this I noticed that if I 'createdb' and populate it with the "sanatized" data the query in question is quite fast; 618 rows returned in 864.522 ms. This was puzzling. Next I noticed that after a VACUUM the very same query would slow down to a crawl; 618 rows returned in 1080688.921 ms). This was reproduced on PostgreSQL 7.4.2 running on a Intel PIII 700Mhz, 512mb. This system is my /personal/ test system/sandbox. i.e., it isn't being stressed by any other processes. Thanks for reading, --patrick __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com From pgsql-performance-owner@postgresql.org Wed Nov 3 19:12:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D27EC3A45AD for ; Wed, 3 Nov 2004 19:12:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55969-10 for ; Wed, 3 Nov 2004 19:12:48 +0000 (GMT) Received: from fed1rmmtao07.cox.net (fed1rmmtao07.cox.net [68.230.241.32]) by svr1.postgresql.org (Postfix) with ESMTP id 3F4E23A1D9E for ; Wed, 3 Nov 2004 19:12:48 +0000 (GMT) Received: from CYGNUS ([68.228.61.13]) by fed1rmmtao07.cox.net (InterMail vM.6.01.04.00 201-2131-117-20041022) with ESMTP id <20041103191247.GFZT27576.fed1rmmtao07.cox.net@CYGNUS> for ; Wed, 3 Nov 2004 14:12:47 -0500 From: To: Subject: Re: preloading indexes Date: Wed, 3 Nov 2004 12:12:43 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0018_01C4C19E.6C735DB0" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcTBzUaXH/uXOnKFSV2A1bSnDRxRegAC5+rQ In-Reply-To: <004b01c4c1ce$cd969c80$8300a8c0@solent> Message-Id: <20041103191247.GFZT27576.fed1rmmtao07.cox.net@CYGNUS> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=HTML_50_60, HTML_FONTCOLOR_UNKNOWN, HTML_MESSAGE, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200411/19 X-Sequence-Number: 8973 This is a multi-part message in MIME format. ------=_NextPart_000_0018_01C4C19E.6C735DB0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit That's correct - I'd like to be able to keep particular indexes in RAM available all the time The best way to get all the stuff needed by a query into RAM is to run the query. Is it more that you want to 'pin' the data in RAM so it doesn't get overwritten by other queries? I am working with some pretty convoluted queries that work very slowly the first time they're called but perform fine on the second call. I am fairly certain that these differences are due to the caching. Can someone point me in a direction that would allow me to pre-cache the critical indexes? ------=_NextPart_000_0018_01C4C19E.6C735DB0 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Message

That’s correct – = I’d like to be able to keep particular indexes in RAM available all the = time

 

The best way to get all the stuff = needed by a query into RAM is to run the query.  Is it more that you want = to 'pin' the data in RAM so it doesn't get overwritten by other = queries?

 

I am working with some pretty convoluted queries that = work very slowly the first time they’re called but perform fine on the = second call. I am fairly certain that these differences are due to the caching. = Can someone point me in a direction that would allow me to pre-cache the = critical indexes?

------=_NextPart_000_0018_01C4C19E.6C735DB0-- From pgsql-performance-owner@postgresql.org Wed Nov 3 19:18:12 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E78C73A2B1B for ; Wed, 3 Nov 2004 19:18:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59399-01 for ; Wed, 3 Nov 2004 19:17:54 +0000 (GMT) Received: from neomail03.traderonline.com (email.traderonline.com [65.213.231.10]) by svr1.postgresql.org (Postfix) with ESMTP id BC01A3A1D9E for ; Wed, 3 Nov 2004 19:17:54 +0000 (GMT) Received: from [192.168.102.100] (24.229.184.154.res-cmts.nbh.ptd.net [24.229.184.154] (may be forged)) by neomail03.traderonline.com (8.12.10/8.12.8) with ESMTP id iA3IYu63027766; Wed, 3 Nov 2004 13:34:56 -0500 Message-ID: <41892EE0.3090703@ptd.net> Date: Wed, 03 Nov 2004 14:17:52 -0500 From: Doug Y User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: patrick ~ Cc: pgsql-performance@postgresql.org Subject: Re: vacuum analyze slows sql query References: <20041103185647.87443.qmail@web52105.mail.yahoo.com> In-Reply-To: <20041103185647.87443.qmail@web52105.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/20 X-Sequence-Number: 8974 Given that the plan doesn't change after an analyze, my guess would be that the first query is hitting cached data, then you vacuum and that chews though all the cache with its own data pushing the good data out of the cache so it has to be re-fetched from disk. If you run the select a 2nd time after the vacuum, what is the time? Not sure what your pkk_offer_has_pending_purch function does, that might be something to look at as well. I could be wrong, but thats the only thing that makes sense to me. ARC is supposed to help with that type of behavior in 8.0 patrick ~ wrote: > Greetings pgsql-performance :) > > Yesterday I posted to the pgsql-sql list about an issue with VACUUM > while trying to track-down an issue with performance of a SQL SELECT > statement invovling a stored function. It was suggested that I bring > the discussion over to -performance. > > Instread of reposting the message here is a link to the original > message followed by a brief summary: > > http://marc.theaimsgroup.com/?l=postgresql-sql&m=109945118928530&w=2 > > > Summary: > > Our customer complains about web/php-based UI sluggishness accessing > the data in db. I created a "stripped down" version of the tables > in question to be able to post to the pgsql-sql list asking for hints > as to how I can improve the SQL query. While doing this I noticed > that if I 'createdb' and populate it with the "sanatized" data the > query in question is quite fast; 618 rows returned in 864.522 ms. > This was puzzling. Next I noticed that after a VACUUM the very same > query would slow down to a crawl; 618 rows returned in 1080688.921 ms). > > This was reproduced on PostgreSQL 7.4.2 running on a Intel PIII 700Mhz, > 512mb. This system is my /personal/ test system/sandbox. i.e., it > isn't being stressed by any other processes. > > > Thanks for reading, > --patrick > From pgsql-performance-owner@postgresql.org Wed Nov 3 19:24:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 20B033A4546 for ; Wed, 3 Nov 2004 19:24:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59399-07 for ; Wed, 3 Nov 2004 19:23:50 +0000 (GMT) Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) by svr1.postgresql.org (Postfix) with ESMTP id 6183E3A1D9E for ; Wed, 3 Nov 2004 19:23:50 +0000 (GMT) Received: from modem-112.porcupine.dialup.pol.co.uk ([217.134.192.112] helo=[192.168.0.102]) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.14) id 1CPQjU-0002tN-LY; Wed, 03 Nov 2004 19:23:48 +0000 Subject: Re: Restricting Postgres From: Simon Riggs To: Martin Foster Cc: pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain Organization: 2nd Quadrant Message-Id: <1099509684.4320.2.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Wed, 03 Nov 2004 19:21:24 +0000 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/21 X-Sequence-Number: 8975 On Tue, 2004-11-02 at 23:52, Martin Foster wrote: > Is there a way to restrict how much load a PostgreSQL server can take > before dropping queries in order to safeguard the server? I was > looking at the login.conf (5) man page and while it allows me to limit > by processor time this seems to not fit my specific needs. > > Essentially, I am looking for a sort of functionality similar to what > Sendmail and Apache have. Once the load of the system reaches a > certain defined limit the daemon drops tasks until such a time that it > can resume normal operation. Sounds great... could you give more shape to the idea, so people can comment on it? What limit? Measured how? Normal operation is what? Drop what? How to tell? > > While not necessarily common on my servers I have witnessed some fairly > high load averages which may have led to the machine dropping outright. > Any help on this matter would be appreciated. You can limit the number of connections overall? -- Best Regards, Simon Riggs From pgsql-performance-owner@postgresql.org Wed Nov 3 19:36:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 06C2E3A2B1B for ; Wed, 3 Nov 2004 19:35:52 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65316-02 for ; Wed, 3 Nov 2004 19:35:36 +0000 (GMT) Received: from smtp102.rog.mail.re2.yahoo.com (smtp102.rog.mail.re2.yahoo.com [206.190.36.80]) by svr1.postgresql.org (Postfix) with SMTP id 99BEA3A45F0 for ; Wed, 3 Nov 2004 19:35:34 +0000 (GMT) Received: from unknown (HELO phlogiston.dydns.org) (a.sullivan@rogers.com@65.49.125.184 with login) by smtp102.rog.mail.re2.yahoo.com with SMTP; 3 Nov 2004 19:35:30 -0000 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id E8D24404B; Wed, 3 Nov 2004 14:35:28 -0500 (EST) Date: Wed, 3 Nov 2004 14:35:28 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: preloading indexes Message-ID: <20041103193528.GB16528@phlogiston.dyndns.org> Mail-Followup-To: pgsql-performance@postgresql.org References: <004b01c4c1ce$cd969c80$8300a8c0@solent> <20041103191247.GFZT27576.fed1rmmtao07.cox.net@CYGNUS> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041103191247.GFZT27576.fed1rmmtao07.cox.net@CYGNUS> User-Agent: Mutt/1.5.6+20040722i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/22 X-Sequence-Number: 8976 On Wed, Nov 03, 2004 at 12:12:43PM -0700, stuff@opensourceonline.com wrote: > That's correct - I'd like to be able to keep particular indexes in RAM > available all the time If these are queries that run frequently, then the relevant cache will probably remain populated[1]. If they _don't_ run frequently, why do you want to force the memory to be used to optimise something that is uncommon? But in any case, there's no mechanism to do this. A [1] there are in fact limits on the caching: if your data set is larger than memory, for instance, there's no way it will all stay cached. Also, VACUUM does nasty things to the cache. It is hoped that nastiness is fixed in 8.0. -- Andrew Sullivan | ajs@crankycanuck.ca The plural of anecdote is not data. --Roger Brinner From pgsql-performance-owner@postgresql.org Wed Nov 3 19:50:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AD4343A4583 for ; Wed, 3 Nov 2004 19:50:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 68146-10 for ; Wed, 3 Nov 2004 19:50:01 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 24E963A45ED for ; Wed, 3 Nov 2004 19:50:00 +0000 (GMT) Received: (qmail 21922 invoked from network); 3 Nov 2004 20:50:05 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 3 Nov 2004 20:50:05 +0100 Date: Wed, 03 Nov 2004 20:50:04 +0100 To: pgsql-performance@postgresql.org Subject: Re: preloading indexes References: <004b01c4c1ce$cd969c80$8300a8c0@solent> <20041103191247.GFZT27576.fed1rmmtao07.cox.net@CYGNUS> <20041103193528.GB16528@phlogiston.dyndns.org> From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <20041103193528.GB16528@phlogiston.dyndns.org> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/23 X-Sequence-Number: 8977 -- uh, you can always load a table in cache by doing a seq scan on it... like select count(1) from table or something... this doesn't work for indexes of course, but you can always look in the system catalogs, find the filename for the index, then just open() it from an external program and read it without caring for the data... it'll save you the seeks in the index... of course you'll have problems with file permissions etc, not mentioning security, locking, etc, etc, etc, is that worth the trouble ? On Wed, 3 Nov 2004 14:35:28 -0500, Andrew Sullivan wrote: > On Wed, Nov 03, 2004 at 12:12:43PM -0700, stuff@opensourceonline.com > wrote: >> That's correct - I'd like to be able to keep particular indexes in RAM >> available all the time > > If these are queries that run frequently, then the relevant cache > will probably remain populated[1]. If they _don't_ run frequently, why > do you want to force the memory to be used to optimise something that > is uncommon? But in any case, there's no mechanism to do this. > > A > > [1] there are in fact limits on the caching: if your data set is > larger than memory, for instance, there's no way it will all stay > cached. Also, VACUUM does nasty things to the cache. It is hoped > that nastiness is fixed in 8.0. > From pgsql-performance-owner@postgresql.org Wed Nov 3 19:56:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4F1613A45F0 for ; Wed, 3 Nov 2004 19:55:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71488-01 for ; Wed, 3 Nov 2004 19:55:19 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id D9CF03A2B87 for ; Wed, 3 Nov 2004 19:55:20 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA3JtHC4016199; Wed, 3 Nov 2004 14:55:18 -0500 (EST) To: stuff@opensourceonline.com Cc: pgsql-performance@postgresql.org Subject: Re: preloading indexes In-reply-to: <20041103173054.EJWF21506.fed1rmmtao05.cox.net@CYGNUS> References: <20041103173054.EJWF21506.fed1rmmtao05.cox.net@CYGNUS> Comments: In-reply-to message dated "Wed, 03 Nov 2004 10:30:47 -0700" Date: Wed, 03 Nov 2004 14:55:17 -0500 Message-ID: <16198.1099511717@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/24 X-Sequence-Number: 8978 writes: > I am working with some pretty convoluted queries that work very slowly the > first time they're called but perform fine on the second call. I am fairly > certain that these differences are due to the caching. Can someone point me > in a direction that would allow me to pre-cache the critical indexes? Buy more RAM. Also check your shared_buffers setting (but realize that more is not necessarily better). regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 3 20:13:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0BEBF3A2B87 for ; Wed, 3 Nov 2004 20:13:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77720-02 for ; Wed, 3 Nov 2004 20:12:59 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 091793A45FF for ; Wed, 3 Nov 2004 20:12:58 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA3KCwTD016374; Wed, 3 Nov 2004 15:12:58 -0500 (EST) To: patrick ~ Cc: pgsql-performance@postgresql.org Subject: Re: vacuum analyze slows sql query In-reply-to: <20041103185647.87443.qmail@web52105.mail.yahoo.com> References: <20041103185647.87443.qmail@web52105.mail.yahoo.com> Comments: In-reply-to patrick ~ message dated "Wed, 03 Nov 2004 10:56:47 -0800" Date: Wed, 03 Nov 2004 15:12:57 -0500 Message-ID: <16373.1099512777@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/25 X-Sequence-Number: 8979 patrick ~ writes: > that if I 'createdb' and populate it with the "sanatized" data the > query in question is quite fast; 618 rows returned in 864.522 ms. > This was puzzling. Next I noticed that after a VACUUM the very same > query would slow down to a crawl; 618 rows returned in 1080688.921 ms). The outer query is too simple to have more than one possible plan, so the issue is certainly a change in query plans inside the function. You need to be investigating what's happening inside that function. 7.1 doesn't have adequate tools for this, but in 7.4 you can use PREPARE and EXPLAIN ANALYZE EXECUTE to examine the query plans used for parameterized statements, which is what you've got here. My bet is that with ANALYZE stats present, the planner guesses wrong about which index to use; but without looking at EXPLAIN ANALYZE output there's no way to be sure. BTW, why the bizarrely complicated substitute for a NOT NULL test? ISTM you only need create function pkk_offer_has_pending_purch( integer ) returns bool as ' select p0.purchase_id is not null from pkk_purchase p0 where p0.offer_id = $1 and ( p0.pending = true or ( ( p0.expire_time > now() or p0.expire_time isnull ) and p0.cancel_date isnull ) ) limit 1 ' language 'sql' ; (Actually, seeing that pkk_purchase.purchase_id is defined as NOT NULL, I wonder why the function exists at all ... but I suppose you've "stripped" the function to the point of being nonsense.) regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 3 20:20:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 88D463A4645 for ; Wed, 3 Nov 2004 20:19:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76372-09 for ; Wed, 3 Nov 2004 20:19:48 +0000 (GMT) Received: from fed1rmmtao10.cox.net (fed1rmmtao10.cox.net [68.230.241.29]) by svr1.postgresql.org (Postfix) with ESMTP id 769C93A4633 for ; Wed, 3 Nov 2004 20:19:48 +0000 (GMT) Received: from CYGNUS ([68.228.61.13]) by fed1rmmtao10.cox.net (InterMail vM.6.01.04.00 201-2131-117-20041022) with ESMTP id <20041103201948.HWSQ12834.fed1rmmtao10.cox.net@CYGNUS> for ; Wed, 3 Nov 2004 15:19:48 -0500 From: To: Subject: Re: preloading indexes Date: Wed, 3 Nov 2004 13:19:43 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcTB3NTH2hFl89+5ReeTnb6kC4I0kAABVFqA In-Reply-To: <20041103193528.GB16528@phlogiston.dyndns.org> Message-Id: <20041103201948.HWSQ12834.fed1rmmtao10.cox.net@CYGNUS> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200411/26 X-Sequence-Number: 8980 The caching appears to disappear overnight. The environment is not in production yet so I'm the only one on it. Is there a time limit on the length of time in cache? I believe there is sufficient RAM, but maybe I need to look again. s -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Andrew Sullivan Sent: Wednesday, November 03, 2004 12:35 PM To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] preloading indexes On Wed, Nov 03, 2004 at 12:12:43PM -0700, stuff@opensourceonline.com wrote: > That's correct - I'd like to be able to keep particular indexes in RAM > available all the time If these are queries that run frequently, then the relevant cache will probably remain populated[1]. If they _don't_ run frequently, why do you want to force the memory to be used to optimise something that is uncommon? But in any case, there's no mechanism to do this. A [1] there are in fact limits on the caching: if your data set is larger than memory, for instance, there's no way it will all stay cached. Also, VACUUM does nasty things to the cache. It is hoped that nastiness is fixed in 8.0. -- Andrew Sullivan | ajs@crankycanuck.ca The plural of anecdote is not data. --Roger Brinner ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend From pgsql-performance-owner@postgresql.org Wed Nov 3 20:53:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0B4923A4665 for ; Wed, 3 Nov 2004 20:53:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89710-02 for ; Wed, 3 Nov 2004 20:53:10 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 930173A4657 for ; Wed, 3 Nov 2004 20:53:10 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA3Kr9Vt016806; Wed, 3 Nov 2004 15:53:10 -0500 (EST) To: stuff@opensourceonline.com Cc: pgsql-performance@postgresql.org Subject: Re: preloading indexes In-reply-to: <20041103201948.HWSQ12834.fed1rmmtao10.cox.net@CYGNUS> References: <20041103201948.HWSQ12834.fed1rmmtao10.cox.net@CYGNUS> Comments: In-reply-to message dated "Wed, 03 Nov 2004 13:19:43 -0700" Date: Wed, 03 Nov 2004 15:53:09 -0500 Message-ID: <16805.1099515189@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/27 X-Sequence-Number: 8981 writes: > The caching appears to disappear overnight. You've probably got cron jobs that run late at night and blow out your kernel disk cache by accessing a whole lot of non-Postgres stuff. (A nightly disk backup is one obvious candidate.) The most likely solution is to run some cron job a little later to exercise your database and thereby repopulate the cache with Postgres files before you get to work ;-) regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 3 20:53:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BA60C3A4675 for ; Wed, 3 Nov 2004 20:53:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89710-04 for ; Wed, 3 Nov 2004 20:53:18 +0000 (GMT) Received: from smtp101.rog.mail.re2.yahoo.com (smtp101.rog.mail.re2.yahoo.com [206.190.36.79]) by svr1.postgresql.org (Postfix) with SMTP id 111863A465B for ; Wed, 3 Nov 2004 20:53:19 +0000 (GMT) Received: from unknown (HELO phlogiston.dydns.org) (a.sullivan@rogers.com@65.49.125.184 with login) by smtp101.rog.mail.re2.yahoo.com with SMTP; 3 Nov 2004 20:53:18 -0000 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 7ACEC404C; Wed, 3 Nov 2004 15:53:16 -0500 (EST) Date: Wed, 3 Nov 2004 15:53:16 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: preloading indexes Message-ID: <20041103205316.GC16528@phlogiston.dyndns.org> Mail-Followup-To: pgsql-performance@postgresql.org References: <20041103193528.GB16528@phlogiston.dyndns.org> <20041103201948.HWSQ12834.fed1rmmtao10.cox.net@CYGNUS> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041103201948.HWSQ12834.fed1rmmtao10.cox.net@CYGNUS> User-Agent: Mutt/1.5.6+20040722i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/28 X-Sequence-Number: 8982 On Wed, Nov 03, 2004 at 01:19:43PM -0700, stuff@opensourceonline.com wrote: > The caching appears to disappear overnight. The environment is not in > production yet so I'm the only one on it. Are you vacuuming at night? It grovels through the entire database, and may bust your query out of the cache. Also, we'd need some more info about how you've tuned this thing. Maybe check out the archives first for some tuning pointers to help you. A -- Andrew Sullivan | ajs@crankycanuck.ca In the future this spectacle of the middle classes shocking the avant- garde will probably become the textbook definition of Postmodernism. --Brad Holland From pgsql-performance-owner@postgresql.org Wed Nov 3 20:56:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B61283A4654 for ; Wed, 3 Nov 2004 20:56:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88897-08 for ; Wed, 3 Nov 2004 20:56:13 +0000 (GMT) Received: from fed1rmmtao07.cox.net (fed1rmmtao07.cox.net [68.230.241.32]) by svr1.postgresql.org (Postfix) with ESMTP id 9BAA43A4631 for ; Wed, 3 Nov 2004 20:56:13 +0000 (GMT) Received: from CYGNUS ([68.228.61.13]) by fed1rmmtao07.cox.net (InterMail vM.6.01.04.00 201-2131-117-20041022) with ESMTP id <20041103205613.ITAC27576.fed1rmmtao07.cox.net@CYGNUS> for ; Wed, 3 Nov 2004 15:56:13 -0500 From: To: Subject: Re: preloading indexes Date: Wed, 3 Nov 2004 13:56:10 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcTB5ZvfMkt3/5WtRKOhKCEbGAJquAAAdAJg In-Reply-To: <16805.1099515189@sss.pgh.pa.us> Message-Id: <20041103205613.ITAC27576.fed1rmmtao07.cox.net@CYGNUS> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200411/29 X-Sequence-Number: 8983 Thanks - this is what I was afraid of, but I may have to do this Is there a good way to monitor what's in the cache? j writes: > The caching appears to disappear overnight. You've probably got cron jobs that run late at night and blow out your kernel disk cache by accessing a whole lot of non-Postgres stuff. (A nightly disk backup is one obvious candidate.) The most likely solution is to run some cron job a little later to exercise your database and thereby repopulate the cache with Postgres files before you get to work ;-) regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 3 22:00:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F3A893A45E9 for ; Wed, 3 Nov 2004 21:53:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06100-09 for ; Wed, 3 Nov 2004 21:53:38 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id DC5BF3A1D8A for ; Wed, 3 Nov 2004 21:53:40 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iA3LrZJ7009604 for ; Wed, 3 Nov 2004 21:53:35 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iA3LPiHX000466 for pgsql-performance@postgresql.org; Wed, 3 Nov 2004 21:25:44 GMT Message-ID: <41894CD9.8090308@ethereal-realms.org> From: Martin Foster Organization: Ethereal Realms User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Restricting Postgres References: <1099509684.4320.2.camel@localhost.localdomain> In-Reply-To: <1099509684.4320.2.camel@localhost.localdomain> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Lines: 98 Date: Wed, 03 Nov 2004 21:25:45 GMT To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/30 X-Sequence-Number: 8984 Simon Riggs wrote: > On Tue, 2004-11-02 at 23:52, Martin Foster wrote: > >>Is there a way to restrict how much load a PostgreSQL server can take >>before dropping queries in order to safeguard the server? I was >>looking at the login.conf (5) man page and while it allows me to limit >>by processor time this seems to not fit my specific needs. >> >>Essentially, I am looking for a sort of functionality similar to what >>Sendmail and Apache have. Once the load of the system reaches a >>certain defined limit the daemon drops tasks until such a time that it >>can resume normal operation. > > > Sounds great... could you give more shape to the idea, so people can > comment on it? > > What limit? Measured how? Normal operation is what? > > Drop what? How to tell? > > Let's use the example in Apache, there is the Apache::LoadAvgLimit mod_perl module which allows one to limit based on the system load averages. Here is an example of the configuration one would find: PerlInitHandler Apache::LoadAvgLimit PerlSetVar LoadAvgLimit_1 3.00 PerlSetVar LoadAvgLimit_5 2.00 PerlSetVar LoadAvgLimit_15 1.50 PerlSetVar LoadAvgRetryAfter 120 The end state is simple, once the load average moves above 3.00 for the 1 minute average the web server will not process the CGI scripts or mod_perl applications under that directory. Instead it will return a 503 error and save the system from being crushed by ever increasing load averages. Only once the load average is below the defined limits will the server process requests as normal. This is not necessarily the nicest or cleanest way or doing things, but it does allow the Apache web server to prevent a collapse. There are ways of restricting the size of files, number of concurrent processes and even memory being used by a daemon. This can be done through ulimit or the login.conf file if your system supports it. However, there is no way to restrict based on load averages, only processor time which is ineffective for a perpetually running daemon like PostgreSQL has. >>While not necessarily common on my servers I have witnessed some fairly >>high load averages which may have led to the machine dropping outright. >> Any help on this matter would be appreciated. > > > You can limit the number of connections overall? > Limiting concurrent connections is not always the solution to the problem. Problems can occur when there is a major spike in activity that would be considered abnormal, due to outside conditions. For example using Apache::DBI or pgpool the DBMS may be required to spawn a great deal of child processed in a short order of time. This in turn can cause a major spike in processor load and if unchecked by running as high demand queries the system can literally increase in load until the server buckles. I've seen this behavior before when restarting the web server during heavy loads. Apache goes from zero connections to a solid 120, causing PostgreSQL to spawn that many children in a short order of time just to keep up with the demand. PostgreSQL undertakes a penalty when spawning a new client and accepting a connection, this slows takes resources at every level to accomplish. However clients on the web server are hitting the server at an accelerated rate because of the slowed response, leading to even more demand being placed on both machines. In most cases the processor will be taxed and the load average high enough to cause even a noticeable delay when using a console, however it will generally recover... slowly or in rare cases crash outright. In such a circumstance, having the database server refuse queries when the sanity of the system is concerned might come in handy for such a circumstance. Of course, I am not blaming PostgreSQL, there are probably some instabilities in the AMD64 port of FreeBSD 5.2.1 for dual processor systems that lead to an increased chance of failure instead of recovery. However, if there was a way to prevent the process from reaching those limits, it may avoid the problem altogether. Martin Foster Creator/Designer Ethereal Realms martin@ethereal-realms.org From pgsql-performance-owner@postgresql.org Wed Nov 3 22:23:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B4A913A1D9E for ; Wed, 3 Nov 2004 22:23:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16305-06 for ; Wed, 3 Nov 2004 22:22:58 +0000 (GMT) Received: from web52104.mail.yahoo.com (web52104.mail.yahoo.com [206.190.39.73]) by svr1.postgresql.org (Postfix) with SMTP id 12D7A3A4675 for ; Wed, 3 Nov 2004 22:22:57 +0000 (GMT) Message-ID: <20041103222257.73682.qmail@web52104.mail.yahoo.com> Received: from [198.182.200.22] by web52104.mail.yahoo.com via HTTP; Wed, 03 Nov 2004 14:22:57 PST Date: Wed, 3 Nov 2004 14:22:57 -0800 (PST) From: patrick ~ Subject: Re: vacuum analyze slows sql query To: pgsql-performance@postgresql.org Cc: Greg Stark In-Reply-To: <16373.1099512777@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/31 X-Sequence-Number: 8985 Here is a fresh run with 'explain analyze' run before and after the VACUUM statement: -- begin % dropdb pkk DROP DATABASE % createdb pkk CREATE DATABASE % psql pkk < pkk_db.sql ERROR: function pkk_offer_has_pending_purch(integer) does not exist ERROR: function pkk_offer_has_pending_purch2(integer) does not exist ERROR: table "pkk_billing" does not exist ERROR: table "pkk_purchase" does not exist ERROR: table "pkk_offer" does not exist NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pkk_offer_pkey" for table "pkk_offer" CREATE TABLE NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pkk_purchase_pkey" for table "pkk_purchase" CREATE TABLE CREATE INDEX CREATE INDEX CREATE INDEX CREATE TABLE CREATE INDEX CREATE FUNCTION CREATE FUNCTION % zcat pkk.20041028_00.sql.gz | psql pkk SET SET SET SET % psql pkk pkk=# select offer_id, pkk_offer_has_pending_purch( offer_id ) from pkk_offer ; (618 rows) Time: 877.348 ms pkk=# explain analyze select offer_id, pkk_offer_has_pending_purch( offer_id ) from pkk_offer ; QUERY PLAN ----------------------------------------------------------------------------------------------------------- Seq Scan on pkk_offer (cost=0.00..22.50 rows=1000 width=4) (actual time=1.291..845.485 rows=618 loops=1) Total runtime: 849.475 ms (2 rows) Time: 866.613 ms pkk=# vacuum analyze ; VACUUM Time: 99344.399 ms pkk=# explain analyze select offer_id, pkk_offer_has_pending_purch( offer_id ) from pkk_offer ; QUERY PLAN ----------------------------------------------------------------------------------------------------------------- Seq Scan on pkk_offer (cost=0.00..13.72 rows=618 width=4) (actual time=3636.401..1047412.851 rows=618 loops=1) Total runtime: 1047415.525 ms (2 rows) Time: 1047489.477 ms -- end Tom, The reason of the extra "case" part in the function is to ensure non-null fields on the result. I tried your version as well and i get similar performance results: -- begin pkk=# create function toms_pending_purch( integer ) returns bool as 'select p0.purchase_id is not null from pkk_purchase p0 where p0.offer_id = $1 and ( p0.pending = true or ( ( p0.expire_time > now() or p0.expire_time isnull ) and p0.cancel_date isnull ) ) limit 1 ' language 'sql' ; CREATE FUNCTION Time: 2.496 ms pkk=# select offer_id, toms_pending_purch( offer_id ) from pkk_offer ; (618 rows) Time: 1052339.506 ms -- end Right now, I'm studying the document section on PREPARE and will attempt to play around with it. I was asked (in a prior post) whether running the statement a second time after the VACUUM improves in performance. It does not. After the VACUUM the statement remains slow. Thanks for your help, --patrick --- Tom Lane wrote: > patrick ~ writes: > > that if I 'createdb' and populate it with the "sanatized" data the > > query in question is quite fast; 618 rows returned in 864.522 ms. > > This was puzzling. Next I noticed that after a VACUUM the very same > > query would slow down to a crawl; 618 rows returned in 1080688.921 ms). > > The outer query is too simple to have more than one possible plan, > so the issue is certainly a change in query plans inside the function. > You need to be investigating what's happening inside that function. > 7.1 doesn't have adequate tools for this, but in 7.4 you can use > PREPARE and EXPLAIN ANALYZE EXECUTE to examine the query plans used > for parameterized statements, which is what you've got here. > > My bet is that with ANALYZE stats present, the planner guesses wrong > about which index to use; but without looking at EXPLAIN ANALYZE output > there's no way to be sure. > > BTW, why the bizarrely complicated substitute for a NOT NULL test? > ISTM you only need > > create function > pkk_offer_has_pending_purch( integer ) > returns bool > as ' > select p0.purchase_id is not null > from pkk_purchase p0 > where p0.offer_id = $1 > and ( p0.pending = true > or ( ( p0.expire_time > now() > or p0.expire_time isnull ) > and p0.cancel_date isnull ) ) > limit 1 > ' language 'sql' ; > > (Actually, seeing that pkk_purchase.purchase_id is defined as NOT NULL, > I wonder why the function exists at all ... but I suppose you've > "stripped" the function to the point of being nonsense.) > > regards, tom lane __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com From pgsql-performance-owner@postgresql.org Wed Nov 3 23:26:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C1AB73A4697 for ; Wed, 3 Nov 2004 23:26:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33013-08 for ; Wed, 3 Nov 2004 23:25:52 +0000 (GMT) Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu [129.255.60.186]) by svr1.postgresql.org (Postfix) with ESMTP id 0C3383A4692 for ; Wed, 3 Nov 2004 23:25:52 +0000 (GMT) Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id iA3NPa303792; Wed, 3 Nov 2004 17:25:36 -0600 Message-ID: <418968E7.40700@johnmeinel.com> Date: Wed, 03 Nov 2004 17:25:27 -0600 From: John A Meinel User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Martin Foster Cc: pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <1099509684.4320.2.camel@localhost.localdomain> <41894CD9.8090308@ethereal-realms.org> In-Reply-To: <41894CD9.8090308@ethereal-realms.org> X-Enigmail-Version: 0.86.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig92F99F0CDAA06D9B7EFDBEB4" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/32 X-Sequence-Number: 8986 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig92F99F0CDAA06D9B7EFDBEB4 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Martin Foster wrote: > Simon Riggs wrote: > >> On Tue, 2004-11-02 at 23:52, Martin Foster wrote: [...] > I've seen this behavior before when restarting the web server during > heavy loads. Apache goes from zero connections to a solid 120, > causing PostgreSQL to spawn that many children in a short order of time > just to keep up with the demand. > But wouldn't limiting the number of concurrent connections do this at the source. If you tell it that "You can at most have 20 connections" you would never have postgres spawn 120 children. I'm not sure what apache does if it can't get a DB connection, but it seems exactly like what you want. Now, if you expected to have 50 clients that all like to just sit on open connections, you could leave the number of concurrent connections high. But if your only connect is from the webserver, where all of them are designed to be short connections, then leave the max low. The other possibility is having the webserver use connection pooling, so it uses a few long lived connections. But even then, you could limit it to something like 10-20, not 120. John =:-> --------------enig92F99F0CDAA06D9B7EFDBEB4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBiWjrJdeBCYSNAAMRApthAJ4tBFarzA2vq5aQDkBrqOUpUjvthgCgoMGp uBrVH14BtjhKmWVyE3HoR64= =+Jts -----END PGP SIGNATURE----- --------------enig92F99F0CDAA06D9B7EFDBEB4-- From pgsql-performance-owner@postgresql.org Wed Nov 3 23:36:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8F6383A46A8 for ; Wed, 3 Nov 2004 23:36:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37299-04 for ; Wed, 3 Nov 2004 23:35:52 +0000 (GMT) Received: from fep3.cogeco.net (smtp.cogeco.net [216.221.81.25]) by svr1.postgresql.org (Postfix) with ESMTP id 582E43A4697 for ; Wed, 3 Nov 2004 23:35:54 +0000 (GMT) Received: from [127.0.0.1] (d226-34-9.home.cgocable.net [24.226.34.9]) by fep3.cogeco.net (Postfix) with ESMTP id 63D3D117A; Wed, 3 Nov 2004 18:35:54 -0500 (EST) Message-ID: <41896B58.80209@ethereal-realms.org> Date: Wed, 03 Nov 2004 18:35:52 -0500 From: Martin Foster Organization: Ethereal Realms User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 To: John A Meinel Cc: pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <1099509684.4320.2.camel@localhost.localdomain> <41894CD9.8090308@ethereal-realms.org> <418968E7.40700@johnmeinel.com> In-Reply-To: <418968E7.40700@johnmeinel.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/33 X-Sequence-Number: 8987 John A Meinel wrote: > Martin Foster wrote: > >> Simon Riggs wrote: >> >>> On Tue, 2004-11-02 at 23:52, Martin Foster wrote: > > [...] > >> I've seen this behavior before when restarting the web server during >> heavy loads. Apache goes from zero connections to a solid 120, >> causing PostgreSQL to spawn that many children in a short order of >> time just to keep up with the demand. >> > > But wouldn't limiting the number of concurrent connections do this at > the source. If you tell it that "You can at most have 20 connections" > you would never have postgres spawn 120 children. > I'm not sure what apache does if it can't get a DB connection, but it > seems exactly like what you want. > > Now, if you expected to have 50 clients that all like to just sit on > open connections, you could leave the number of concurrent connections > high. > > But if your only connect is from the webserver, where all of them are > designed to be short connections, then leave the max low. > > The other possibility is having the webserver use connection pooling, so > it uses a few long lived connections. But even then, you could limit it > to something like 10-20, not 120. > > John > =:-> > I have a dual processor system that can support over 150 concurrent connections handling normal traffic and load. Now suppose I setup Apache to spawn all of it's children instantly, what will happen is that as this happens the PostgreSQL server will also receive 150 attempts at connection. This will spawn 150 children in a short order of time and as this takes place clients can connect and start requesting information not allowing the machine to settle down to a normal traffic. That spike when initiated can cripple the machine or even the webserver if a deadlocked transaction is introduced. Because on the webserver side a slowdown in the database means that it will just get that many more connection attempts pooled from the clients. As they keep clicking and hitting reload over and over to get a page load, that server starts to buckle hitting unbelievably high load averages. When the above happened once, I lost the ability to type on a console because of a 60+ (OpenBSD) load average on a single processor system. The reason why Apache now drops a 503 Service Unavailable when loads get too high. It's that spike I worry about and it can happen for whatever reason. It could just as easily be triggered by a massive concurrent request for processing of an expensive query done in DDOS fashion. This may not affect the webserver at all, at least immediately, but the same problem can effect can come into effect. Limiting connections help, but it's not the silver bullet and limits your ability to support more connections because of that initial spike. The penalty for forking a new child is hardly unexecpected, even Apache will show the same effect when restarted in a high traffic time. Martin Foster Creator/Designer Ethereal Realms martin@ethereal-realms.org From pgsql-performance-owner@postgresql.org Thu Nov 4 00:52:15 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 97C293A472F for ; Thu, 4 Nov 2004 00:51:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53492-09 for ; Thu, 4 Nov 2004 00:51:24 +0000 (GMT) Received: from mail.academyoflearning.ca (s64-180-138-192.bc.hsia.telus.net [64.180.138.192]) by svr1.postgresql.org (Postfix) with ESMTP id CB12A3A470C for ; Thu, 4 Nov 2004 00:51:25 +0000 (GMT) Received: from ipso.snappymail.ca (d207-81-249-35.bchsia.telus.net [207.81.249.35]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by mail.academyoflearning.ca (Postfix) with ESMTP id E220E3E2FE; Wed, 3 Nov 2004 16:50:43 -0800 (PST) Subject: Re: preloading indexes From: Mike Benoit To: Tom Lane Cc: stuff@opensourceonline.com, pgsql-performance@postgresql.org In-Reply-To: <16805.1099515189@sss.pgh.pa.us> References: <20041103201948.HWSQ12834.fed1rmmtao10.cox.net@CYGNUS> <16805.1099515189@sss.pgh.pa.us> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-W5g7jrTRFmZFmIHJ+oeF" Date: Wed, 03 Nov 2004 16:50:42 -0800 Message-Id: <1099529442.18904.4.camel@ipso.snappymail.ca> Mime-Version: 1.0 X-Mailer: Evolution 2.0.1-1mdk X-snappymail-MailScanner-Information: Please contact the ISP for more information X-snappymail-MailScanner: Found to be clean X-snappymail-MailScanner-SpamCheck: not spam, SpamAssassin (score=-0.141, required 5, AWL -0.14, BAYES_44 -0.00) X-MailScanner-From: ipso@snappymail.ca X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/34 X-Sequence-Number: 8988 --=-W5g7jrTRFmZFmIHJ+oeF Content-Type: text/plain Content-Transfer-Encoding: quoted-printable If your running Linux, and kernel 2.6.x, you can try playing with the: /proc/sys/vm/swappiness setting. My understanding is that: echo "0" > /proc/sys/vm/swappiness Will try to keep all in-use application memory from being swapped out when other processes query the disk a lot. Although, since PostgreSQL utilizes the disk cache quite a bit, this may not help you.=20 On Wed, 2004-11-03 at 15:53 -0500, Tom Lane wrote: > writes: > > The caching appears to disappear overnight. >=20 > You've probably got cron jobs that run late at night and blow out your > kernel disk cache by accessing a whole lot of non-Postgres stuff. > (A nightly disk backup is one obvious candidate.) The most likely > solution is to run some cron job a little later to exercise your > database and thereby repopulate the cache with Postgres files before > you get to work ;-) >=20 > regards, tom lane >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if you= r > joining column's datatypes do not match --=20 Mike Benoit --=-W5g7jrTRFmZFmIHJ+oeF Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBBiXzhMhKjsejwBhgRAmZJAJ0W7Fb0+noueiw8SDr0KuH4AII7WgCfY4rR 5YniXISTkAExdNzEb3LFSfY= =Pcfb -----END PGP SIGNATURE----- --=-W5g7jrTRFmZFmIHJ+oeF-- From pgsql-performance-owner@postgresql.org Thu Nov 4 07:51:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E467B3A3CD5 for ; Thu, 4 Nov 2004 07:51:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47889-06 for ; Thu, 4 Nov 2004 07:51:03 +0000 (GMT) Received: from smtp.ops.co.at (ops004.ops.co.at [194.152.182.4]) by svr1.postgresql.org (Postfix) with ESMTP id 7CF943A4863 for ; Thu, 4 Nov 2004 07:51:03 +0000 (GMT) Received: by smtp.ops.co.at (Postfix, from userid 65534) id 07D6423C0AC; Thu, 4 Nov 2004 08:50:59 +0100 (CET) Received: from [172.27.1.101] (ts1.int.ops.co.at [172.27.1.101]) by smtp.ops.co.at (Postfix) with ESMTP id F256023C0AB for ; Thu, 4 Nov 2004 08:50:56 +0100 (CET) Message-ID: <4189E086.5060400@ops.co.at> Date: Thu, 04 Nov 2004 08:55:50 +0100 From: Mario Ivankovits User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: index not used if using IN or OR Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/35 X-Sequence-Number: 8989 Hello ! Sorry if this has been discussed before, it is just hard to find in the archives using the words "or" or "in" :-o I use postgres-8.0 beta4 for windows. I broke down my problem to a very simple table - two columns "primary_key" and "secondary_key". Creates and Insert you will find below. If I query the _empty_ freshly created table I get the following explain result: select * from tt where seckey = 1; Index Scan using seckey_key on tt (cost=0.00..17.07 rows=5 width=12) Index Cond: (seckey = 1) If I use "OR" (or IN) things get worse: select * from tt where seckey = 1 or seckey = 2 Seq Scan on tt (cost=0.00..0.00 rows=1 width=12) Filter: ((seckey = 1) OR (seckey = 2)) Note the "Seq Scan" instead of using the index. After populating the table with 8920 records and "analyze" the scenario gets even worser: select * from tt where seckey = 1; Seq Scan on tt (cost=0.00..168.50 rows=1669 width=12) (actual time=0.000..15.000 rows=1784 loops=1) Filter: (seckey = 1) Total runtime: 31.000 ms Now also this simple query uses a "Seq Scan". Now the questions are: a) Why is the index not used if I use "OR" or "IN" b) Why is the index not used after "analyze" ? Any help is very appreciated! Thanks, Mario // The table and data CREATE TABLE tt ( pkey int4 NOT NULL DEFAULT nextval('public."tt_PKEY_seq"'::text), seckey int8, CONSTRAINT pkey_key PRIMARY KEY (pkey) ) WITHOUT OIDS; CREATE INDEX seckey_key ON tt USING btree (seckey); // inserted many-many times insert into tt values (default, 1); insert into tt values (default, 2); insert into tt values (default, 3); insert into tt values (default, 4); insert into tt values (default, 5); From pgsql-performance-owner@postgresql.org Thu Nov 4 08:30:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7503E3A44A3 for ; Thu, 4 Nov 2004 08:30:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57276-09 for ; Thu, 4 Nov 2004 08:30:33 +0000 (GMT) Received: from neptune.lgu.ac.uk (neptune.lgu.ac.uk [140.97.30.6]) by svr1.postgresql.org (Postfix) with ESMTP id 2AE643A446D for ; Thu, 4 Nov 2004 08:30:32 +0000 (GMT) Received: from solent (cal42-234.lgu.ac.uk [140.97.42.234]) by neptune.lgu.ac.uk (8.12.10/8.12.10) with ESMTP id iA48TRO6018310; Thu, 4 Nov 2004 08:29:27 GMT Reply-To: From: "Matt Clark" To: "'Martin Foster'" , "'John A Meinel'" Cc: Subject: Re: Restricting Postgres Date: Thu, 4 Nov 2004 08:29:39 -0000 Organization: Ymogen Ltd Message-ID: <009701c4c248$6d5298e0$8300a8c0@solent> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 In-Reply-To: <41896B58.80209@ethereal-realms.org> Importance: Normal X-LGU-MailScanner: Found to be clean X-MailScanner-From: matt@ymogen.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/36 X-Sequence-Number: 8990 > I have a dual processor system that can support over 150 concurrent > connections handling normal traffic and load. Now suppose I setup > Apache to spawn all of it's children instantly, what will ... > This will spawn 150 children in a short order of time and as > this takes "Doctor, it hurts when I do this!" "Well, don't do that then..." Sorry, couldn't resist ;-) Our Apache/PG driven website also needs to be able to deal with occasional large peaks, so what we do is: StartServers 15 # Don't create too many children initially MinSpareServers 10 # Always have at least 10 spares lying around MaxSpareServers 20 # But no more than 20 MaxClients 150 # Up to 150 - the default 256 is too much for our RAM So on server restart 15 Apache children are created, then one new child every second up to a maximum of 150. Apache's 'ListenBackLog' is around 500 by default, so there's plenty of scope for queuing inbound requests while we wait for sufficient children to be spawned. In addition we (as _every_ high load site should) run Squid as an accelerator, which dramatically increases the number of client connections that can be handled. Across 2 webservers at peak times we've had 50,000 concurrently open http & https client connections to Squid, with 150 Apache children doing the work that squid can't (i.e. all the dynamic stuff), and PG (on a separate box of course) whipping through nearly 800 mixed selects, inserts and updates per second - and then had to restart Apache on one of the servers for a config change... Not a problem :-) One little tip - if you run squid on the same machine as apache, and use a dual-proc box, then because squid is single-threaded it will _never_ take more than half the CPU - nicely self balancing in a way. M From pgsql-performance-owner@postgresql.org Thu Nov 4 08:32:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 403853A3C13 for ; Thu, 4 Nov 2004 08:32:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57626-09 for ; Thu, 4 Nov 2004 08:32:20 +0000 (GMT) Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by svr1.postgresql.org (Postfix) with ESMTP id 302973A3ADA for ; Thu, 4 Nov 2004 08:32:21 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 4.42) id 1CPd2Z-000GqU-7r; Thu, 04 Nov 2004 08:32:21 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 5052017BE6; Thu, 4 Nov 2004 08:32:10 +0000 (GMT) Message-ID: <4189E908.2000104@archonet.com> Date: Thu, 04 Nov 2004 08:32:08 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mario Ivankovits Cc: pgsql-performance@postgresql.org Subject: Re: index not used if using IN or OR References: <4189E086.5060400@ops.co.at> In-Reply-To: <4189E086.5060400@ops.co.at> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/37 X-Sequence-Number: 8991 Mario Ivankovits wrote: > Hello ! > > Sorry if this has been discussed before, it is just hard to find in the > archives using the words "or" or "in" :-o > > I use postgres-8.0 beta4 for windows. > I broke down my problem to a very simple table - two columns > "primary_key" and "secondary_key". Creates and Insert you will find below. > > If I query the _empty_ freshly created table I get the following explain > result: > > select * from tt where seckey = 1; > Index Scan using seckey_key on tt (cost=0.00..17.07 rows=5 width=12) > Index Cond: (seckey = 1) > > If I use "OR" (or IN) things get worse: > > select * from tt where seckey = 1 or seckey = 2 > Seq Scan on tt (cost=0.00..0.00 rows=1 width=12) > Filter: ((seckey = 1) OR (seckey = 2)) > > Note the "Seq Scan" instead of using the index. But as you said, your table is *empty* - why would an index be faster? Try running EXPLAIN ANALYSE on these queries and look at the actual times. > After populating the table with 8920 records and "analyze" the scenario > gets even worser: > > select * from tt where seckey = 1; > Seq Scan on tt (cost=0.00..168.50 rows=1669 width=12) (actual > time=0.000..15.000 rows=1784 loops=1) > Filter: (seckey = 1) > Total runtime: 31.000 ms > > Now also this simple query uses a "Seq Scan". Well, it thinks it's going to be returning 1669 rows. If that's roughly right, then scanning the table probably is faster. Run the queries again with EXPLAIN ANALYSE. Also try issuing set enable_seqscan=false; This will force the planner to use any indexes it finds. Compare the times with and without, and don't forget to account for the effects of caching. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Thu Nov 4 11:01:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EB8513A44E5 for ; Thu, 4 Nov 2004 11:01:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08800-02 for ; Thu, 4 Nov 2004 11:00:55 +0000 (GMT) Received: from mail.logi-track.com (www.logi-track.com [213.239.193.212]) by svr1.postgresql.org (Postfix) with ESMTP id B7A623A4526 for ; Thu, 4 Nov 2004 11:00:54 +0000 (GMT) Received: from kingfisher.intern.logi-track.com (J0972.j.pppool.de [85.74.9.114]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logi-track.com (Postfix) with ESMTP id 5D3E93016D; Thu, 4 Nov 2004 12:00:52 +0100 (CET) Received: from kingfisher.intern.logi-track.com (localhost [127.0.0.1]) by kingfisher.intern.logi-track.com (Postfix) with SMTP id E0AAB165E4C; Thu, 4 Nov 2004 12:00:47 +0100 (CET) Date: Thu, 4 Nov 2004 12:00:47 +0100 From: Markus Schaber Cc: Subject: Re: Anything to be gained from a 'Postgres Filesystem'? Message-ID: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> In-Reply-To: References: Organization: logi-track ag, =?ISO-8859-15?Q?z=FCrich?= X-Mailer: Sylpheed-Claws 0.9.12b (GTK+ 1.2.10; i386-pc-linux-gnu) X-Face: Nx5T&>Nj$VrVPv}sC3IL&)TqHHOKCz/|)R$i"*r@w0{*I6w; UNU_hdl1J4NI_m{IMztq=>cmM}1gCLbAF+9\#CGkG8}Y{x%SuQ>1#t:; Z(|\qdd[i]HStki~#w1$TPF}:0w-7"S\Ev|_a$K wrote: > (I'm not sure if it's a good idea to create a PG-specific FS in your > OS of choice, but it's certainly gonna be easier than getting FS code > inside of PG) I don't think PG really needs a specific FS. I rather think that PG could profit from some functionality that's missing in traditional UN*X file systems. posix_fadvise(2) may be a candidate. Read/Write bareers another pone, as well asn syncing a bunch of data in different files with a single call (so that the OS can determine the best write order). I can also imagine some interaction with the FS journalling system (to avoid duplicate efforts). We should create a list of those needs, and then communicate those to the kernel/fs developers. Then we (as well as other apps) can make use of those features where they are available, and use the old way everywhere else. Maybe Reiser4 is a step into the right way, and maybe even a postgres plugin for Reiser4 will be worth the effort. Maybe XFS/JFS etc. already have such capabilities. Maybe that's completely wrong. cheers, Markus --=20 markus schaber | dipl. informatiker logi-track ag | rennweg 14-16 | ch 8001 z=FCrich phone +41-43-888 62 52 | fax +41-43-888 62 53 mailto:schabios@logi-track.com | www.logi-track.com From pgsql-performance-owner@postgresql.org Thu Nov 4 12:21:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3ABE73A45FD for ; Thu, 4 Nov 2004 12:21:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31563-10 for ; Thu, 4 Nov 2004 12:21:27 +0000 (GMT) Received: from cmailm3.svr.pol.co.uk (cmailm3.svr.pol.co.uk [195.92.193.19]) by svr1.postgresql.org (Postfix) with ESMTP id 682F73A44C1 for ; Thu, 4 Nov 2004 12:21:29 +0000 (GMT) Received: from modem-3697.lynx.dialup.pol.co.uk ([217.135.206.113] helo=[192.168.0.102]) by cmailm3.svr.pol.co.uk with esmtp (Exim 4.41) id 1CPgcL-0003n7-6S; Thu, 04 Nov 2004 12:21:30 +0000 Subject: Re: Restricting Postgres From: Simon Riggs To: Martin Foster Cc: pgsql-performance@postgresql.org In-Reply-To: <41894CD9.8090308@ethereal-realms.org> References: <1099509684.4320.2.camel@localhost.localdomain> <41894CD9.8090308@ethereal-realms.org> Content-Type: text/plain Organization: 2nd Quadrant Message-Id: <1099570740.4320.196.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Thu, 04 Nov 2004 12:19:00 +0000 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/39 X-Sequence-Number: 8993 On Wed, 2004-11-03 at 21:25, Martin Foster wrote: > Simon Riggs wrote: > > On Tue, 2004-11-02 at 23:52, Martin Foster wrote: > > > >>Is there a way to restrict how much load a PostgreSQL server can take > >>before dropping queries in order to safeguard the server? I was > >>looking at the login.conf (5) man page and while it allows me to limit > >>by processor time this seems to not fit my specific needs. > >> > >>Essentially, I am looking for a sort of functionality similar to what > >>Sendmail and Apache have. Once the load of the system reaches a > >>certain defined limit the daemon drops tasks until such a time that it > >>can resume normal operation. > > > > > > Sounds great... could you give more shape to the idea, so people can > > comment on it? > > > > What limit? Measured how? Normal operation is what? > > > > Drop what? How to tell? > > > > > > Let's use the example in Apache, there is the Apache::LoadAvgLimit > mod_perl module which allows one to limit based on the system load > averages. Here is an example of the configuration one would find: > > > PerlInitHandler Apache::LoadAvgLimit > PerlSetVar LoadAvgLimit_1 3.00 > PerlSetVar LoadAvgLimit_5 2.00 > PerlSetVar LoadAvgLimit_15 1.50 > PerlSetVar LoadAvgRetryAfter 120 > > > The end state is simple, once the load average moves above 3.00 for the > 1 minute average the web server will not process the CGI scripts or > mod_perl applications under that directory. Instead it will return a > 503 error and save the system from being crushed by ever increasing load > averages. > > Only once the load average is below the defined limits will the server > process requests as normal. This is not necessarily the nicest or > cleanest way or doing things, but it does allow the Apache web server to > prevent a collapse. > > There are ways of restricting the size of files, number of concurrent > processes and even memory being used by a daemon. This can be done > through ulimit or the login.conf file if your system supports it. > However, there is no way to restrict based on load averages, only > processor time which is ineffective for a perpetually running daemon > like PostgreSQL has. > All workloads are not created equally, so mixing them can be tricky. This will be better in 8.0 because seq scans don't spoil the cache. Apache is effectively able to segregate the workloads because each workload is "in a directory". SQL isn't stored anywhere for PostgreSQL to say "just those ones please", so defining which statements are in which workload is the tricky part. PostgreSQL workload management could look at userid, tables, processor load (?) and estimated cost to decide what to do. There is a TODO item on limiting numbers of connections per userid/group, in addition to the max number of sessions per server. Perhaps the easiest way would be to have the Apache workloads segregated by PostgreSQL userid, then limit connections to each. > For example using Apache::DBI or pgpool the DBMS may be required to > spawn a great deal of child processed in a short order of time. This > in turn can cause a major spike in processor load and if unchecked by > running as high demand queries the system can literally increase in load > until the server buckles. > That's been nicely covered off by John and Matt on the other threads, so you're sorted out for now and doesn't look like a bug in PostgreSQL. > Of course, I am not blaming PostgreSQL, there are probably some > instabilities in the AMD64 port of FreeBSD 5.2.1 for dual processor > systems that lead to an increased chance of failure instead of recovery. Good! -- Best Regards, Simon Riggs From pgsql-performance-owner@postgresql.org Thu Nov 4 12:29:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E1D8A3A3E68 for ; Thu, 4 Nov 2004 12:29:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36329-01 for ; Thu, 4 Nov 2004 12:29:04 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id AAB163A3E2E for ; Thu, 4 Nov 2004 12:29:04 +0000 (GMT) Received: (qmail 29952 invoked from network); 4 Nov 2004 13:29:17 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 4 Nov 2004 13:29:17 +0100 Date: Thu, 04 Nov 2004 13:29:19 +0100 To: pgsql-performance@postgresql.org Subject: Re: Anything to be gained from a 'Postgres Filesystem'? References: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/40 X-Sequence-Number: 8994 > posix_fadvise(2) may be a candidate. Read/Write bareers another pone, as > well asn syncing a bunch of data in different files with a single call > (so that the OS can determine the best write order). I can also imagine > some interaction with the FS journalling system (to avoid duplicate > efforts). There is also the fact that syncing after every transaction could be changed to syncing every N transactions (N fixed or depending on the data size written by the transactions) which would be more efficient than the current behaviour with a sleep. HOWEVER suppressing the sleep() would lead to postgres returning from the COMMIT while it is in fact not synced, which somehow rings a huge alarm bell somewhere. What about read order ? This could be very useful for SELECT queries involving indexes, which in case of a non-clustered table lead to random seeks in the table. There's fadvise to tell the OS to readahead on a seq scan (I think the OS detects it anyway), but if there was a system call telling the OS "in the next seconds I'm going to read these chunks of data from this file (gives a list of offsets and lengths), could you put them in your cache in the most efficient order without seeking too much, so that when I read() them in random order, they will be in the cache already ?". This would be an asynchronous call which would return immediately, just queuing up the data somewhere in the kernel, and maybe sending a signal to the application when a certain percentage of the data has been cached. PG could take advantage of this with not much code changes, simply by putting a fifo between the index scan and the tuple fetches, to wait the time necessary for the OS to have enough reads to cluster them efficiently. On very large tables this would maybe not gain much, but on tables which are explicitely clustered, or naturally clustered like accessing an index on a serial primary key in order, it could be interesting. Just a thought. From pgsql-performance-owner@postgresql.org Thu Nov 4 13:10:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 23C2E3A47D4 for ; Thu, 4 Nov 2004 13:10:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49305-02 for ; Thu, 4 Nov 2004 13:10:42 +0000 (GMT) Received: from fep2.cogeco.net (smtp.cogeco.net [216.221.81.25]) by svr1.postgresql.org (Postfix) with ESMTP id 848423A46D5 for ; Thu, 4 Nov 2004 13:10:44 +0000 (GMT) Received: from [127.0.0.1] (d226-34-9.home.cgocable.net [24.226.34.9]) by fep2.cogeco.net (Postfix) with ESMTP id 50FC326FB; Thu, 4 Nov 2004 08:10:44 -0500 (EST) Message-ID: <418A2A4E.6030409@ethereal-realms.org> Date: Thu, 04 Nov 2004 08:10:38 -0500 From: Martin Foster Organization: Ethereal Realms User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Matt Clark Cc: pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <009701c4c248$6d5298e0$8300a8c0@solent> In-Reply-To: <009701c4c248$6d5298e0$8300a8c0@solent> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/41 X-Sequence-Number: 8995 Matt Clark wrote: >>I have a dual processor system that can support over 150 concurrent >>connections handling normal traffic and load. Now suppose I setup >>Apache to spawn all of it's children instantly, what will > > ... > >>This will spawn 150 children in a short order of time and as >>this takes > > > "Doctor, it hurts when I do this!" > "Well, don't do that then..." > > Sorry, couldn't resist ;-) > > Our Apache/PG driven website also needs to be able to deal with occasional > large peaks, so what we do is: > > StartServers 15 # Don't create too many children initially > MinSpareServers 10 # Always have at least 10 spares lying around > MaxSpareServers 20 # But no more than 20 > MaxClients 150 # Up to 150 - the default 256 is too much for our > RAM > > > So on server restart 15 Apache children are created, then one new child > every second up to a maximum of 150. > > Apache's 'ListenBackLog' is around 500 by default, so there's plenty of > scope for queuing inbound requests while we wait for sufficient children to > be spawned. > > In addition we (as _every_ high load site should) run Squid as an > accelerator, which dramatically increases the number of client connections > that can be handled. Across 2 webservers at peak times we've had 50,000 > concurrently open http & https client connections to Squid, with 150 Apache > children doing the work that squid can't (i.e. all the dynamic stuff), and > PG (on a separate box of course) whipping through nearly 800 mixed selects, > inserts and updates per second - and then had to restart Apache on one of > the servers for a config change... Not a problem :-) > > One little tip - if you run squid on the same machine as apache, and use a > dual-proc box, then because squid is single-threaded it will _never_ take > more than half the CPU - nicely self balancing in a way. > > M > I've heard of the merits of Squid in the use as a reverse proxy. However, well over 99% of my traffic is dynamic, hence why I may be experiencing behavior that people normally do not expect. As I have said before in previous threads, the scripts are completely database driven and at the time the database averaged 65 queries per second under MySQL before a migration, while the webserver was averaging 2 to 4. Martin Foster Creator/Designer Ethereal Realms martin@ethereal-realms.org From pgsql-performance-owner@postgresql.org Thu Nov 4 13:17:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 90A7F3A47DB for ; Thu, 4 Nov 2004 13:17:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49152-07 for ; Thu, 4 Nov 2004 13:17:20 +0000 (GMT) Received: from fep3.cogeco.net (smtp.cogeco.net [216.221.81.25]) by svr1.postgresql.org (Postfix) with ESMTP id DBBB33A477A for ; Thu, 4 Nov 2004 13:17:23 +0000 (GMT) Received: from [127.0.0.1] (d226-34-9.home.cgocable.net [24.226.34.9]) by fep3.cogeco.net (Postfix) with ESMTP id 02559F96; Thu, 4 Nov 2004 08:17:22 -0500 (EST) Message-ID: <418A2BE2.70609@ethereal-realms.org> Date: Thu, 04 Nov 2004 08:17:22 -0500 From: Martin Foster Organization: Ethereal Realms User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Simon Riggs , pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <1099509684.4320.2.camel@localhost.localdomain> <41894CD9.8090308@ethereal-realms.org> <1099570740.4320.196.camel@localhost.localdomain> In-Reply-To: <1099570740.4320.196.camel@localhost.localdomain> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/42 X-Sequence-Number: 8996 Simon Riggs wrote > > > All workloads are not created equally, so mixing them can be tricky. > This will be better in 8.0 because seq scans don't spoil the cache. > > Apache is effectively able to segregate the workloads because each > workload is "in a directory". SQL isn't stored anywhere for PostgreSQL > to say "just those ones please", so defining which statements are in > which workload is the tricky part. > > PostgreSQL workload management could look at userid, tables, processor > load (?) and estimated cost to decide what to do. > > There is a TODO item on limiting numbers of connections per > userid/group, in addition to the max number of sessions per server. > > Perhaps the easiest way would be to have the Apache workloads segregated > by PostgreSQL userid, then limit connections to each. > Apache has a global setting for load average limits, the above was just a module which extended the capability. It might also make sense to have limitations set on schema's which can be used in a similar way to Apache directories. While for most people the database protecting itself against a sudden surge of high traffic would be undesirable. It can help those who run dynamically driven sites and get slammed by Slashdot for example. Martin Foster Creator/Designer Ethereal Realms martin@ethereal-realms.org From pgsql-performance-owner@postgresql.org Thu Nov 4 14:02:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D38163A44D6 for ; Thu, 4 Nov 2004 14:02:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65901-04 for ; Thu, 4 Nov 2004 14:02:16 +0000 (GMT) Received: from smtp103.rog.mail.re2.yahoo.com (smtp103.rog.mail.re2.yahoo.com [206.190.36.81]) by svr1.postgresql.org (Postfix) with SMTP id B2A773A44BC for ; Thu, 4 Nov 2004 14:02:18 +0000 (GMT) Received: from unknown (HELO phlogiston.dydns.org) (a.sullivan@rogers.com@65.49.125.184 with login) by smtp103.rog.mail.re2.yahoo.com with SMTP; 4 Nov 2004 14:02:18 -0000 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 8A12E4048; Thu, 4 Nov 2004 09:02:17 -0500 (EST) Date: Thu, 4 Nov 2004 09:02:17 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: preloading indexes Message-ID: <20041104140217.GB23219@phlogiston.dyndns.org> Mail-Followup-To: pgsql-performance@postgresql.org References: <20041103193528.GB16528@phlogiston.dyndns.org> <20041103201948.HWSQ12834.fed1rmmtao10.cox.net@CYGNUS> <20041103205316.GC16528@phlogiston.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041103205316.GC16528@phlogiston.dyndns.org> User-Agent: Mutt/1.5.6+20040722i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/43 X-Sequence-Number: 8997 On Wed, Nov 03, 2004 at 03:53:16PM -0500, Andrew Sullivan wrote: > and may bust your query out of the cache. Also, we'd need some more Uh, the data you're querying, of course. Queries themselves aren't cached. A -- Andrew Sullivan | ajs@crankycanuck.ca I remember when computers were frustrating because they *did* exactly what you told them to. That actually seems sort of quaint now. --J.D. Baldwin From pgsql-performance-owner@postgresql.org Thu Nov 4 14:53:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 100C33A4520 for ; Thu, 4 Nov 2004 14:52:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84127-09 for ; Thu, 4 Nov 2004 14:52:06 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id E37DC3A3FC0 for ; Thu, 4 Nov 2004 14:52:09 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA4Eq3Dg025182; Thu, 4 Nov 2004 09:52:03 -0500 (EST) To: Mario Ivankovits Cc: pgsql-performance@postgresql.org Subject: Re: index not used if using IN or OR In-reply-to: <4189E086.5060400@ops.co.at> References: <4189E086.5060400@ops.co.at> Comments: In-reply-to Mario Ivankovits message dated "Thu, 04 Nov 2004 08:55:50 +0100" Date: Thu, 04 Nov 2004 09:52:03 -0500 Message-ID: <25181.1099579923@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/44 X-Sequence-Number: 8998 Mario Ivankovits writes: > After populating the table with 8920 records and "analyze" the scenario > gets even worser: > select * from tt where seckey = 1; > Seq Scan on tt (cost=0.00..168.50 rows=1669 width=12) (actual > time=0.000..15.000 rows=1784 loops=1) > Filter: (seckey = 1) > Total runtime: 31.000 ms > Now also this simple query uses a "Seq Scan". Which is exactly what it *should* do, considering that it is selecting 1784 out of 8920 records. Indexscans only win for small selectivities --- the rule of thumb is that retrieving more than about 1% of the records should use a seqscan. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 4 16:23:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F3C633A48D3 for ; Thu, 4 Nov 2004 16:23:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 21305-07 for ; Thu, 4 Nov 2004 16:23:49 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 793673A48D1 for ; Thu, 4 Nov 2004 16:23:48 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iA4GNmJ9023994 for ; Thu, 4 Nov 2004 16:23:48 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iA4G43oO017358 for pgsql-performance@postgresql.org; Thu, 4 Nov 2004 16:04:03 GMT From: Chris Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Anything to be gained from a 'Postgres Filesystem'? Date: Thu, 04 Nov 2004 10:47:31 -0500 Organization: cbbrowne Computing Inc Lines: 33 Message-ID: <60bred39bg.fsf@dba2.int.libertyrms.com> References: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Cancel-Lock: sha1:S5wKdTs6GNyQ4yoKCVRcJH2vTes= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/46 X-Sequence-Number: 9000 lists@boutiquenumerique.com (Pierre-Fr�d�ric Caillaud) writes: >> posix_fadvise(2) may be a candidate. Read/Write bareers another pone, as >> well asn syncing a bunch of data in different files with a single call >> (so that the OS can determine the best write order). I can also imagine >> some interaction with the FS journalling system (to avoid duplicate >> efforts). > > There is also the fact that syncing after every transaction > could be changed to syncing every N transactions (N fixed or > depending on the data size written by the transactions) which would > be more efficient than the current behaviour with a sleep. HOWEVER > suppressing the sleep() would lead to postgres returning from the > COMMIT while it is in fact not synced, which somehow rings a huge > alarm bell somewhere. > > What about read order ? > This could be very useful for SELECT queries involving > indexes, which in case of a non-clustered table lead to random seeks > in the table. Another thing that would be valuable would be to have some way to say: "Read this data; don't bother throwing other data out of the cache to stuff this in." Something like a "read_uncached()" call... That would mean that a seq scan or a vacuum wouldn't force useful data out of cache. -- let name="cbbrowne" and tld="cbbrowne.com" in String.concat "@" [name;tld];; http://www.ntlug.org/~cbbrowne/linuxxian.html A VAX is virtually a computer, but not quite. From pgsql-general-owner@postgresql.org Thu Nov 4 16:00:59 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 784443A48C5 for ; Thu, 4 Nov 2004 16:00:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15446-02 for ; Thu, 4 Nov 2004 16:00:53 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.198]) by svr1.postgresql.org (Postfix) with ESMTP id 882843A48C1 for ; Thu, 4 Nov 2004 16:00:52 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a41so272350rng for ; Thu, 04 Nov 2004 08:00:40 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=MVFZETZSspNYNb+GiX9BlAQvrGwGuZbuelqqqXdihmVLmuXtJpsb6Hmgmcl1D2TeGSG7Lk4FlAwsb0x7fhrIGhGpSALOaJAu9vU3A3ZC0yeRhuS+j2YWgKlLYeDroRIMiPZYB/M3wYq5urbqtt3BVANUrN/8H9PWzWGKVOmmdfo= Received: by 10.38.218.39 with SMTP id q39mr647762rng; Thu, 04 Nov 2004 08:00:40 -0800 (PST) Received: by 10.38.165.10 with HTTP; Thu, 4 Nov 2004 08:00:38 -0800 (PST) Message-ID: Date: Thu, 4 Nov 2004 10:00:38 -0600 From: Kevin Barnard Reply-To: Kevin Barnard To: Martin Foster Subject: Re: [PERFORM] Restricting Postgres Cc: PostgreSQL In-Reply-To: <418A2BE2.70609@ethereal-realms.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <1099509684.4320.2.camel@localhost.localdomain> <41894CD9.8090308@ethereal-realms.org> <1099570740.4320.196.camel@localhost.localdomain> <418A2BE2.70609@ethereal-realms.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/124 X-Sequence-Number: 68205 I am generally interested in a good solution for this. So far our solution has been to increase the hardware to the point of allowing 800 connections to the DB. I don't have the mod loaded for Apache, but we haven't had too many problems there. The site is split pretty good between dynamic and non-dynamic, it's largely Flash with several plugins to the DB. However we still can and have been slammed and up to point of the 800 connections. What I don't get is why not use pgpool? This should eliminate the rapid fire forking of postgres instanaces in the DB server. I'm assuming you app can safely handle a failure to connect to the DB (i.e. exceed number of DB connections). If not it should be fairly simple to send a 503 header when it's unable to get the connection. On Thu, 04 Nov 2004 08:17:22 -0500, Martin Foster wrote: > Apache has a global setting for load average limits, the above was just > a module which extended the capability. It might also make sense to > have limitations set on schema's which can be used in a similar way to > Apache directories. > > While for most people the database protecting itself against a sudden > surge of high traffic would be undesirable. It can help those who run > dynamically driven sites and get slammed by Slashdot for example. > > > > Martin Foster > Creator/Designer Ethereal Realms > martin@ethereal-realms.org > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > From pgsql-performance-owner@postgresql.org Thu Nov 4 16:15:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 523673A47BB for ; Thu, 4 Nov 2004 16:15:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19256-03 for ; Thu, 4 Nov 2004 16:15:13 +0000 (GMT) Received: from fep4.cogeco.net (smtp.cogeco.net [216.221.81.25]) by svr1.postgresql.org (Postfix) with ESMTP id A520E3A4893 for ; Thu, 4 Nov 2004 16:15:12 +0000 (GMT) Received: from [127.0.0.1] (d226-34-9.home.cgocable.net [24.226.34.9]) by fep4.cogeco.net (Postfix) with ESMTP id 2357C279E; Thu, 4 Nov 2004 11:15:12 -0500 (EST) Message-ID: <418A5590.5090006@ethereal-realms.org> Date: Thu, 04 Nov 2004 11:15:12 -0500 From: Martin Foster Organization: Ethereal Realms User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kevin Barnard Cc: PostgreSQL Performance Subject: Re: Restricting Postgres References: <1099509684.4320.2.camel@localhost.localdomain> <41894CD9.8090308@ethereal-realms.org> <1099570740.4320.196.camel@localhost.localdomain> <418A2BE2.70609@ethereal-realms.org> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/45 X-Sequence-Number: 8999 Kevin Barnard wrote: > I am generally interested in a good solution for this. So far our > solution has been to increase the hardware to the point of allowing > 800 connections to the DB. > > I don't have the mod loaded for Apache, but we haven't had too many > problems there. The site is split pretty good between dynamic and > non-dynamic, it's largely Flash with several plugins to the DB. > However we still can and have been slammed and up to point of the 800 > connections. > > What I don't get is why not use pgpool? This should eliminate the > rapid fire forking of postgres instanaces in the DB server. I'm > assuming you app can safely handle a failure to connect to the DB > (i.e. exceed number of DB connections). If not it should be fairly > simple to send a 503 header when it's unable to get the connection. > Note, that I am not necessarily looking for a PostgreSQL solution to the matter. Just a way to prevent the database from killing off the server it sits on, but looking at the load averages. I have attempted to make use of pgpool and have had some very poor performance. There were constant error messages being sounded, load averages on that machine seemed to skyrocket and it just seemed to not be suited for my needs. Apache::DBI overall works better to what I require, even if it is not a pool per sey. Now if pgpool supported variable rate pooling like Apache does with it's children, it might help to even things out. That and you'd still get the spike if you have to start the webserver and database server at or around the same time. Martin Foster Creator/Designer Ethereal Realms martin@ethereal-realms.org From pgsql-performance-owner@postgresql.org Thu Nov 4 16:34:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C34733A48A7 for ; Thu, 4 Nov 2004 16:33:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24825-08 for ; Thu, 4 Nov 2004 16:33:48 +0000 (GMT) Received: from neptune.lgu.ac.uk (neptune.lgu.ac.uk [140.97.30.6]) by svr1.postgresql.org (Postfix) with ESMTP id E30053A48CF for ; Thu, 4 Nov 2004 16:33:46 +0000 (GMT) Received: from solent (cal42-234.lgu.ac.uk [140.97.42.234]) by neptune.lgu.ac.uk (8.12.10/8.12.10) with ESMTP id iA4GXKO6022007; Thu, 4 Nov 2004 16:33:21 GMT Reply-To: From: "Matt Clark" To: "'Martin Foster'" , "'Kevin Barnard'" Cc: "'PostgreSQL Performance'" Subject: Re: Restricting Postgres Date: Thu, 4 Nov 2004 16:33:33 -0000 Organization: Ymogen Ltd Message-ID: <002e01c4c28c$06e83df0$8300a8c0@solent> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 In-Reply-To: <418A5590.5090006@ethereal-realms.org> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Importance: Normal X-LGU-MailScanner: Found to be clean X-MailScanner-From: matt@ymogen.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/47 X-Sequence-Number: 9001 > Apache::DBI overall works better to what I require, even if > it is not a > pool per sey. Now if pgpool supported variable rate pooling like > Apache does with it's children, it might help to even things > out. That > and you'd still get the spike if you have to start the webserver and > database server at or around the same time. I still don't quite get it though - you shouldn't be getting more than one child per second being launched by Apache, so that's only one PG postmaster per second, which is really a trivial load. That is unless you have 'StartServers' set high, in which case the 'obvious' answer is to lower it. Are you launching multiple DB connections per Apache process as well? From pgsql-performance-owner@postgresql.org Mon Nov 8 03:10:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CD0ED3A4426 for ; Thu, 4 Nov 2004 16:36:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28274-01 for ; Thu, 4 Nov 2004 16:36:19 +0000 (GMT) Received: from ms-smtp-02.tampabay.rr.com (ms-smtp-02-smtplb.tampabay.rr.com [65.32.5.132]) by svr1.postgresql.org (Postfix) with ESMTP id 8BC5C3A48B9 for ; Thu, 4 Nov 2004 16:36:16 +0000 (GMT) Received: from MATTSPC (222-60.26-24.tampabay.rr.com [24.26.60.222]) by ms-smtp-02.tampabay.rr.com (8.12.10/8.12.7) with ESMTP id iA4GZoZn028054; Thu, 4 Nov 2004 11:35:50 -0500 (EST) Message-Id: <200411041635.iA4GZoZn028054@ms-smtp-02.tampabay.rr.com> From: "Matthew Nuzum" To: "'Martin Foster'" , "'Matt Clark'" Cc: Subject: Re: Restricting Postgres Date: Thu, 4 Nov 2004 11:37:42 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.6353 In-reply-to: <418A2A4E.6030409@ethereal-realms.org> X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-index: AcTCcOLGQIUdvRKOQSSwR+DvSVzkdAAGShsA X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/131 X-Sequence-Number: 9085 Matt - Very interesting information about squid effectiveness, thanks. Martin, You mean your site had no images? No CSS files? No JavaScript files? Nearly everything is dynamic? I've found that our CMS spends more time sending a 23KB image to a dial up user than it does generating and serving dynamic content. This means that if you have a "light" squid process who caches and serves your images and static content from it's cache then your apache processes can truly focus on only the dynamic data. Case in point: A first time visitor hits your home page. A dynamic page is generated (in about 1 second) and served (taking 2 more seconds) which contains links to 20 additional files (images, styles and etc). Then expensive apache processes are used to serve each of those 20 files, which takes an additional 14 seconds. Your precious application server processes have now spent 14 seconds serving stuff that could have been served by an upstream cache. I am all for using upstream caches and SSL accelerators to take the load off of application servers. My apache children often take 16 or 20MB of RAM each. Why spend all of that on a 1.3KB image? Just food for thought. There are people who use proxying in apache to redirect expensive tasks to other servers that are dedicated to just one heavy challenge. In that case you likely do have 99% dynamic content. Matthew Nuzum | Makers of "Elite Content Management System" www.followers.net | View samples of Elite CMS in action matt@followers.net | http://www.followers.net/portfolio/ -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Martin Foster Matt Clark wrote: > In addition we (as _every_ high load site should) run Squid as an > accelerator, which dramatically increases the number of client connections > that can be handled. Across 2 webservers at peak times we've had 50,000 > concurrently open http & https client connections to Squid, with 150 Apache > children doing the work that squid can't (i.e. all the dynamic stuff), and > PG (on a separate box of course) whipping through nearly 800 mixed selects, > inserts and updates per second - and then had to restart Apache on one of > the servers for a config change... Not a problem :-) > > One little tip - if you run squid on the same machine as apache, and use a > dual-proc box, then because squid is single-threaded it will _never_ take > more than half the CPU - nicely self balancing in a way. > > M > I've heard of the merits of Squid in the use as a reverse proxy. However, well over 99% of my traffic is dynamic, hence why I may be experiencing behavior that people normally do not expect. As I have said before in previous threads, the scripts are completely database driven and at the time the database averaged 65 queries per second under MySQL before a migration, while the webserver was averaging 2 to 4. Martin Foster Creator/Designer Ethereal Realms martin@ethereal-realms.org From pgsql-performance-owner@postgresql.org Thu Nov 4 16:48:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0F2563A48FA for ; Thu, 4 Nov 2004 16:46:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29956-08 for ; Thu, 4 Nov 2004 16:46:44 +0000 (GMT) Received: from neptune.lgu.ac.uk (neptune.lgu.ac.uk [140.97.30.6]) by svr1.postgresql.org (Postfix) with ESMTP id 785CC3A48E0 for ; Thu, 4 Nov 2004 16:46:38 +0000 (GMT) Received: from solent (cal42-234.lgu.ac.uk [140.97.42.234]) by neptune.lgu.ac.uk (8.12.10/8.12.10) with ESMTP id iA4GkCO6022962; Thu, 4 Nov 2004 16:46:12 GMT Reply-To: From: "Matt Clark" To: "'Matthew Nuzum'" , "'Martin Foster'" Cc: Subject: Re: Restricting Postgres Date: Thu, 4 Nov 2004 16:46:25 -0000 Organization: Ymogen Ltd Message-ID: <003001c4c28d$d2f16830$8300a8c0@solent> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 In-Reply-To: <200411041635.iA4GZoZn028054@ms-smtp-02.tampabay.rr.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Importance: Normal X-LGU-MailScanner: Found to be clean X-MailScanner-From: matt@ymogen.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/48 X-Sequence-Number: 9002 > Case in point: A first time visitor hits your home page. A > dynamic page is generated (in about 1 second) and served > (taking 2 more seconds) which contains links to 20 additional The gain from an accelerator is actually even more that that, as it takes essentially zero seconds for Apache to return the generated content (which in the case of a message board could be quite large) to Squid, which can then feed it slowly to the user, leaving Apache free again to generate another page. When serving dialup users large dynamic pages this can be a _huge_ gain. I think Martin's pages (dimly recalling another thread) take a pretty long time to generate though, so he may not see quite such a significant gain. From pgsql-performance-owner@postgresql.org Thu Nov 4 17:26:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9B1B43A4897 for ; Thu, 4 Nov 2004 17:25:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46327-03 for ; Thu, 4 Nov 2004 17:25:05 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 81AFC3A488A for ; Thu, 4 Nov 2004 17:25:02 +0000 (GMT) Received: (qmail 8213 invoked from network); 4 Nov 2004 18:25:13 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 4 Nov 2004 18:25:13 +0100 To: pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <003001c4c28d$d2f16830$8300a8c0@solent> Message-ID: Date: Thu, 04 Nov 2004 18:25:16 +0100 From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <003001c4c28d$d2f16830$8300a8c0@solent> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/49 X-Sequence-Number: 9003 Myself, I like a small Apache with few modules serving static files (no dynamic content, no db connections), and with a mod_proxy on a special path directed to another Apache which generates the dynamic pages (few processes, persistent connections...) You get the best of both, static files do not hog DB connections, and the second apache sends generated pages very fast to the first which then trickles them down to the clients. >> Case in point: A first time visitor hits your home page. A >> dynamic page is generated (in about 1 second) and served >> (taking 2 more seconds) which contains links to 20 additional > > The gain from an accelerator is actually even more that that, as it takes > essentially zero seconds for Apache to return the generated content > (which > in the case of a message board could be quite large) to Squid, which can > then feed it slowly to the user, leaving Apache free again to generate > another page. When serving dialup users large dynamic pages this can be > a > _huge_ gain. > > I think Martin's pages (dimly recalling another thread) take a pretty > long > time to generate though, so he may not see quite such a significant gain. > > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if > your > joining column's datatypes do not match > From pgsql-performance-owner@postgresql.org Thu Nov 4 17:59:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EE5B13A48F4 for ; Thu, 4 Nov 2004 17:59:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59335-08 for ; Thu, 4 Nov 2004 17:59:27 +0000 (GMT) Received: from fep3.cogeco.net (smtp.cogeco.net [216.221.81.25]) by svr1.postgresql.org (Postfix) with ESMTP id DAC7C3A48F0 for ; Thu, 4 Nov 2004 17:59:26 +0000 (GMT) Received: from [127.0.0.1] (d226-34-9.home.cgocable.net [24.226.34.9]) by fep3.cogeco.net (Postfix) with ESMTP id 73C9433ED; Thu, 4 Nov 2004 12:59:25 -0500 (EST) Message-ID: <418A6DFD.8010803@ethereal-realms.org> Date: Thu, 04 Nov 2004 12:59:25 -0500 From: Martin Foster Organization: Ethereal Realms User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Matt Clark Cc: Matthew Nuzum , PostgreSQL Performance Subject: Re: Restricting Postgres References: <003001c4c28d$d2f16830$8300a8c0@solent> In-Reply-To: <003001c4c28d$d2f16830$8300a8c0@solent> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/50 X-Sequence-Number: 9004 Matt Clark wrote: >>Case in point: A first time visitor hits your home page. A >>dynamic page is generated (in about 1 second) and served >>(taking 2 more seconds) which contains links to 20 additional > > > The gain from an accelerator is actually even more that that, as it takes > essentially zero seconds for Apache to return the generated content (which > in the case of a message board could be quite large) to Squid, which can > then feed it slowly to the user, leaving Apache free again to generate > another page. When serving dialup users large dynamic pages this can be a > _huge_ gain. > > I think Martin's pages (dimly recalling another thread) take a pretty long > time to generate though, so he may not see quite such a significant gain. > > Correct the 75% of all hits are on a script that can take anywhere from a few seconds to a half an hour to complete. The script essentially auto-flushes to the browser so they get new information as it arrives creating the illusion of on demand generation. A squid proxy would probably cause severe problems when dealing with a script that does not complete output for a variable rate of time. As for images, CSS, javascript and such the site makes use of it, but in the grand scheme of things the amount of traffic they tie up is literally inconsequential. Though I will probably move all of that onto another server just to allow the main server the capabilities of dealing with almost exclusively dynamic content. Martin Foster Creator/Designer Ethereal Realms martin@ethereal-realms.org From pgsql-performance-owner@postgresql.org Thu Nov 4 18:05:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BBCBF3A3E73 for ; Thu, 4 Nov 2004 18:04:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60293-10 for ; Thu, 4 Nov 2004 18:04:01 +0000 (GMT) Received: from fep6.cogeco.net (smtp.cogeco.net [216.221.81.25]) by svr1.postgresql.org (Postfix) with ESMTP id 803D33A2BA9 for ; Thu, 4 Nov 2004 18:04:01 +0000 (GMT) Received: from [127.0.0.1] (d226-34-9.home.cgocable.net [24.226.34.9]) by fep6.cogeco.net (Postfix) with ESMTP id 9707D640; Thu, 4 Nov 2004 13:04:00 -0500 (EST) Message-ID: <418A6F10.2030309@ethereal-realms.org> Date: Thu, 04 Nov 2004 13:04:00 -0500 From: Martin Foster Organization: Ethereal Realms User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Matt Clark , PostgreSQL Performance Subject: Re: Restricting Postgres References: <002e01c4c28c$06e83df0$8300a8c0@solent> In-Reply-To: <002e01c4c28c$06e83df0$8300a8c0@solent> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/51 X-Sequence-Number: 9005 Matt Clark wrote: >>Apache::DBI overall works better to what I require, even if >>it is not a >>pool per sey. Now if pgpool supported variable rate pooling like >>Apache does with it's children, it might help to even things >>out. That >>and you'd still get the spike if you have to start the webserver and >>database server at or around the same time. > > > I still don't quite get it though - you shouldn't be getting more than one > child per second being launched by Apache, so that's only one PG postmaster > per second, which is really a trivial load. That is unless you have > 'StartServers' set high, in which case the 'obvious' answer is to lower it. > Are you launching multiple DB connections per Apache process as well? > I have start servers set to a fairly high limit. However this would make little different overall if I restarted the webservers to load in new modules during a high load time. When I am averaging 145 concurrent connections before a restart, I can expect that many request to hit the server once Apache begins to respond. As a result, it will literally cause a spike on both machines as new connections are initiated at a high rate. In my case I don't always have the luxury of waiting till 0300 just to test a change. Again, not necessarily looking for a PostgreSQL solution. I am looking for a method that would allow the database or the OS itself to protect the system it's hosted on. If both the database and the apache server were on the same machine this type of scenario would be unstable to say the least. Martin Foster Creator/Designer Ethereal Realms martin@ethereal-realms.org From pgsql-performance-owner@postgresql.org Thu Nov 4 18:22:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F387F3A48DB for ; Thu, 4 Nov 2004 18:20:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66734-07 for ; Thu, 4 Nov 2004 18:20:36 +0000 (GMT) Received: from neptune.lgu.ac.uk (neptune.lgu.ac.uk [140.97.30.6]) by svr1.postgresql.org (Postfix) with ESMTP id 5C7243A48EC for ; Thu, 4 Nov 2004 18:20:35 +0000 (GMT) Received: from solent (cal42-234.lgu.ac.uk [140.97.42.234]) by neptune.lgu.ac.uk (8.12.10/8.12.10) with ESMTP id iA4IK5O6027673; Thu, 4 Nov 2004 18:20:05 GMT Reply-To: From: "Matt Clark" To: "'Martin Foster'" Cc: "'Matthew Nuzum'" , "'PostgreSQL Performance'" Subject: Re: Restricting Postgres Date: Thu, 4 Nov 2004 18:20:18 -0000 Organization: Ymogen Ltd Message-ID: <003301c4c29a$f052d910$8300a8c0@solent> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 In-Reply-To: <418A6DFD.8010803@ethereal-realms.org> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Importance: Normal X-LGU-MailScanner: Found to be clean X-MailScanner-From: matt@ymogen.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/52 X-Sequence-Number: 9006 > Correct the 75% of all hits are on a script that can take=20 > anywhere from=20 > a few seconds to a half an hour to complete. The script=20 > essentially=20 > auto-flushes to the browser so they get new information as it arrives=20 > creating the illusion of on demand generation. This is more like a streaming data server, which is a very different = beast from a webserver, and probably better suited to the job. Usually either multithreaded or single-process using select() (just like Squid). You = could probably build one pretty easily. Using a 30MB Apache process to serve = one client for half an hour seems like a hell of a waste of RAM. > A squid proxy would probably cause severe problems when=20 > dealing with a=20 > script that does not complete output for a variable rate of time. No, it's fine, squid gives it to the client as it gets it, but can = receive from the server faster. From pgsql-performance-owner@postgresql.org Thu Nov 4 19:08:08 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8AA493A4491 for ; Thu, 4 Nov 2004 19:06:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80988-06 for ; Thu, 4 Nov 2004 19:06:16 +0000 (GMT) Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) by svr1.postgresql.org (Postfix) with ESMTP id DF7953A3E0A for ; Thu, 4 Nov 2004 19:06:16 +0000 (GMT) Received: from modem-2125.lemur.dialup.pol.co.uk ([217.135.136.77] helo=[192.168.0.102]) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.14) id 1CPmw2-00069s-Mc; Thu, 04 Nov 2004 19:06:14 +0000 Subject: Re: Anything to be gained from a 'Postgres Filesystem'? From: Simon Riggs To: Chris Browne Cc: pgsql-performance@postgresql.org In-Reply-To: <60bred39bg.fsf@dba2.int.libertyrms.com> References: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> <60bred39bg.fsf@dba2.int.libertyrms.com> Content-Type: text/plain Organization: 2nd Quadrant Message-Id: <1099595027.4320.663.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Thu, 04 Nov 2004 19:03:47 +0000 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/53 X-Sequence-Number: 9007 On Thu, 2004-11-04 at 15:47, Chris Browne wrote: > Another thing that would be valuable would be to have some way to say: > > "Read this data; don't bother throwing other data out of the cache > to stuff this in." > > Something like a "read_uncached()" call... > > That would mean that a seq scan or a vacuum wouldn't force useful data > out of cache. ARC does almost exactly those two things in 8.0. Seq scans do get put in cache, but in a way that means they don't spoil the main bulk of the cache. -- Best Regards, Simon Riggs From pgsql-performance-owner@postgresql.org Thu Nov 4 19:20:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 165EE3A493C for ; Thu, 4 Nov 2004 19:20:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85420-06 for ; Thu, 4 Nov 2004 19:20:06 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id 06D123A492B for ; Thu, 4 Nov 2004 19:20:06 +0000 (GMT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1CPn9Q-0004v0-00 for ; Thu, 04 Nov 2004 20:20:04 +0100 Date: Thu, 4 Nov 2004 20:20:04 +0100 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Anything to be gained from a 'Postgres Filesystem'? Message-ID: <20041104192004.GA18793@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> <60bred39bg.fsf@dba2.int.libertyrms.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <60bred39bg.fsf@dba2.int.libertyrms.com> X-Operating-System: Linux 2.6.8.1 on a i686 User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/54 X-Sequence-Number: 9008 On Thu, Nov 04, 2004 at 10:47:31AM -0500, Chris Browne wrote: > Another thing that would be valuable would be to have some way to say: > > "Read this data; don't bother throwing other data out of the cache > to stuff this in." > > Something like a "read_uncached()" call... You mean, like, open(filename, O_DIRECT)? :-) /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Thu Nov 4 19:34:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C4A1D3A4943 for ; Thu, 4 Nov 2004 19:34:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91741-05 for ; Thu, 4 Nov 2004 19:34:15 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id BCA563A4923 for ; Thu, 4 Nov 2004 19:34:15 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA4JY8aK028209; Thu, 4 Nov 2004 14:34:08 -0500 (EST) To: Simon Riggs Cc: Chris Browne , pgsql-performance@postgresql.org Subject: Re: Anything to be gained from a 'Postgres Filesystem'? In-reply-to: <1099595027.4320.663.camel@localhost.localdomain> References: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> <60bred39bg.fsf@dba2.int.libertyrms.com> <1099595027.4320.663.camel@localhost.localdomain> Comments: In-reply-to Simon Riggs message dated "Thu, 04 Nov 2004 19:03:47 +0000" Date: Thu, 04 Nov 2004 14:34:08 -0500 Message-ID: <28208.1099596848@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/55 X-Sequence-Number: 9009 Simon Riggs writes: > On Thu, 2004-11-04 at 15:47, Chris Browne wrote: >> Something like a "read_uncached()" call... >> >> That would mean that a seq scan or a vacuum wouldn't force useful data >> out of cache. > ARC does almost exactly those two things in 8.0. But only for Postgres' own shared buffers. The kernel cache still gets trashed, because we have no way to suggest to the kernel that it not hang onto the data read in. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 4 20:31:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2C8A33A496E for ; Thu, 4 Nov 2004 20:31:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09871-07 for ; Thu, 4 Nov 2004 20:30:53 +0000 (GMT) Received: from fep4.cogeco.net (smtp.cogeco.net [216.221.81.25]) by svr1.postgresql.org (Postfix) with ESMTP id 59FD73A492F for ; Thu, 4 Nov 2004 20:30:54 +0000 (GMT) Received: from [127.0.0.1] (d226-34-9.home.cgocable.net [24.226.34.9]) by fep4.cogeco.net (Postfix) with ESMTP id 8ACB452C; Thu, 4 Nov 2004 15:30:34 -0500 (EST) Message-ID: <418A915B.5060600@ethereal-realms.org> Date: Thu, 04 Nov 2004 15:30:19 -0500 From: Martin Foster Organization: Ethereal Realms User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Matt Clark , PostgreSQL Performance Subject: Re: Restricting Postgres References: <003301c4c29a$f052d910$8300a8c0@solent> In-Reply-To: <003301c4c29a$f052d910$8300a8c0@solent> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/57 X-Sequence-Number: 9011 Matt Clark wrote: >>Correct the 75% of all hits are on a script that can take >>anywhere from >>a few seconds to a half an hour to complete. The script >>essentially >>auto-flushes to the browser so they get new information as it arrives >>creating the illusion of on demand generation. > > > This is more like a streaming data server, which is a very different beast > from a webserver, and probably better suited to the job. Usually either > multithreaded or single-process using select() (just like Squid). You could > probably build one pretty easily. Using a 30MB Apache process to serve one > client for half an hour seems like a hell of a waste of RAM. > These are CGI scripts at the lowest level, nothing more and nothing less. While I could probably embed a small webserver directly into the perl scripts and run that as a daemon, it would take away the portability that the scripts currently offer. This should be my last question on the matter, does squid report the proper IP address of the client themselves? That's a critical requirement for the scripts. Martin Foster Creator/Designer Ethereal Realms martin@ethereal-realms.org From pgsql-performance-owner@postgresql.org Thu Nov 4 20:30:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5ADA33A48D8 for ; Thu, 4 Nov 2004 20:30:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11047-05 for ; Thu, 4 Nov 2004 20:30:18 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id B98D53A4893 for ; Thu, 4 Nov 2004 20:30:18 +0000 (GMT) Received: (qmail 13684 invoked from network); 4 Nov 2004 21:30:31 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 4 Nov 2004 21:30:31 +0100 To: pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <003301c4c29a$f052d910$8300a8c0@solent> Message-ID: Date: Thu, 04 Nov 2004 21:30:35 +0100 From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <003301c4c29a$f052d910$8300a8c0@solent> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/56 X-Sequence-Number: 9010 On Thu, 4 Nov 2004 18:20:18 -0000, Matt Clark wrote: >> Correct the 75% of all hits are on a script that can take >> anywhere from >> a few seconds to a half an hour to complete. The script >> essentially >> auto-flushes to the browser so they get new information as it arrives >> creating the illusion of on demand generation. Er, do you mean that : 1- You have a query that runs for half an hour and you spoon feed the results to the client ? (argh) 2- Your script looks for new data every few seconds, sends a packet, then sleeps, and loops ? If it's 2 I have a readymade solution for you, just ask. From pgsql-performance-owner@postgresql.org Thu Nov 4 20:43:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 46EBE3A4985 for ; Thu, 4 Nov 2004 20:43:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13182-10 for ; Thu, 4 Nov 2004 20:43:15 +0000 (GMT) Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) by svr1.postgresql.org (Postfix) with ESMTP id E694F3A4980 for ; Thu, 4 Nov 2004 20:43:16 +0000 (GMT) Received: from modem-462.lion.dialup.pol.co.uk ([217.135.161.206] helo=[192.168.0.102]) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.14) id 1CPoRs-0002UZ-MR; Thu, 04 Nov 2004 20:43:12 +0000 Subject: Re: Anything to be gained from a 'Postgres Filesystem'? From: Simon Riggs To: Tom Lane Cc: Chris Browne , pgsql-performance@postgresql.org In-Reply-To: <28208.1099596848@sss.pgh.pa.us> References: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> <60bred39bg.fsf@dba2.int.libertyrms.com> <1099595027.4320.663.camel@localhost.localdomain> <28208.1099596848@sss.pgh.pa.us> Content-Type: text/plain Organization: 2nd Quadrant Message-Id: <1099600845.5682.3.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Thu, 04 Nov 2004 20:40:45 +0000 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/58 X-Sequence-Number: 9012 On Thu, 2004-11-04 at 19:34, Tom Lane wrote: > Simon Riggs writes: > > On Thu, 2004-11-04 at 15:47, Chris Browne wrote: > >> Something like a "read_uncached()" call... > >> > >> That would mean that a seq scan or a vacuum wouldn't force useful data > >> out of cache. > > > ARC does almost exactly those two things in 8.0. > > But only for Postgres' own shared buffers. The kernel cache still gets > trashed, because we have no way to suggest to the kernel that it not > hang onto the data read in. I guess a difference in viewpoints. I'm inclined to give most of the RAM to PostgreSQL, since as you point out, the kernel is out of our control. That way, we can do what we like with it - keep it or not, as we choose. -- Best Regards, Simon Riggs From pgsql-performance-owner@postgresql.org Thu Nov 4 21:01:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A65263A4958 for ; Thu, 4 Nov 2004 20:46:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16324-05 for ; Thu, 4 Nov 2004 20:45:57 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id BAC363A493F for ; Thu, 4 Nov 2004 20:45:58 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA4KjprA029578; Thu, 4 Nov 2004 15:45:51 -0500 (EST) To: Simon Riggs Cc: Chris Browne , pgsql-performance@postgresql.org Subject: Re: Anything to be gained from a 'Postgres Filesystem'? In-reply-to: <1099600845.5682.3.camel@localhost.localdomain> References: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> <60bred39bg.fsf@dba2.int.libertyrms.com> <1099595027.4320.663.camel@localhost.localdomain> <28208.1099596848@sss.pgh.pa.us> <1099600845.5682.3.camel@localhost.localdomain> Comments: In-reply-to Simon Riggs message dated "Thu, 04 Nov 2004 20:40:45 +0000" Date: Thu, 04 Nov 2004 15:45:51 -0500 Message-ID: <29577.1099601151@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/59 X-Sequence-Number: 9013 Simon Riggs writes: > On Thu, 2004-11-04 at 19:34, Tom Lane wrote: >> But only for Postgres' own shared buffers. The kernel cache still gets >> trashed, because we have no way to suggest to the kernel that it not >> hang onto the data read in. > I guess a difference in viewpoints. I'm inclined to give most of the RAM > to PostgreSQL, since as you point out, the kernel is out of our control. > That way, we can do what we like with it - keep it or not, as we choose. That's always been a Bad Idea for three or four different reasons, of which ARC will eliminate no more than one. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 4 21:03:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E68B83A4940 for ; Thu, 4 Nov 2004 20:46:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17230-03 for ; Thu, 4 Nov 2004 20:46:04 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id 0981F3A496B for ; Thu, 4 Nov 2004 20:46:04 +0000 (GMT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1CPoUd-0005BB-00 for ; Thu, 04 Nov 2004 21:46:03 +0100 Date: Thu, 4 Nov 2004 21:46:03 +0100 From: "Steinar H. Gunderson" To: PostgreSQL Performance Subject: Re: Restricting Postgres Message-ID: <20041104204603.GC19625@uio.no> Mail-Followup-To: PostgreSQL Performance References: <003301c4c29a$f052d910$8300a8c0@solent> <418A915B.5060600@ethereal-realms.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <418A915B.5060600@ethereal-realms.org> X-Operating-System: Linux 2.6.8.1 on a i686 User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/60 X-Sequence-Number: 9014 On Thu, Nov 04, 2004 at 03:30:19PM -0500, Martin Foster wrote: > This should be my last question on the matter, does squid report the > proper IP address of the client themselves? That's a critical > requirement for the scripts. AFAIK it's in some header; I believe they're called "X-Forwarded-For". If you're using caching, your script will obviously be called fewer times than usual, though, so be careful about relying too much on side effects. :-) (This is, of course, exactly the same if the client side uses a caching proxy. Saying anything more is impossible without knowing exactly what you are doing, though :-) ) /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Thu Nov 4 21:06:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9B4FC3A4949 for ; Thu, 4 Nov 2004 21:02:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23007-03 for ; Thu, 4 Nov 2004 21:02:23 +0000 (GMT) Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk [217.27.240.154]) by svr1.postgresql.org (Postfix) with ESMTP id D82E23A497C for ; Thu, 4 Nov 2004 21:02:23 +0000 (GMT) Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP id 087DFA312C; Thu, 4 Nov 2004 21:02:22 +0000 (GMT) Message-ID: <418A986B.5040806@ymogen.net> Date: Thu, 04 Nov 2004 21:00:27 +0000 From: Matt Clark User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Martin Foster Cc: PostgreSQL Performance Subject: Re: Restricting Postgres References: <003301c4c29a$f052d910$8300a8c0@solent> <418A915B.5060600@ethereal-realms.org> In-Reply-To: <418A915B.5060600@ethereal-realms.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/62 X-Sequence-Number: 9016 > These are CGI scripts at the lowest level, nothing more and nothing > less. While I could probably embed a small webserver directly into > the perl scripts and run that as a daemon, it would take away the > portability that the scripts currently offer. If they're CGI *scripts* then they just use the CGI environment, not Apache, so a daemon that accepts the inbound connections, then compiles the scripts a-la Apache::Registry, but puts each in a separate thread would be, er, relatively easy for someone better at multithreaded stuff than me. > > This should be my last question on the matter, does squid report the > proper IP address of the client themselves? That's a critical > requirement for the scripts. > In the X-Forwarded-For header. Not that you can be sure you're seeing the true client IP anyway if they've gone through an ISP proxy beforehand. From pgsql-performance-owner@postgresql.org Thu Nov 4 21:06:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C0C713A495F for ; Thu, 4 Nov 2004 21:03:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23657-04 for ; Thu, 4 Nov 2004 21:03:45 +0000 (GMT) Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk [217.27.240.154]) by svr1.postgresql.org (Postfix) with ESMTP id 494123A4978 for ; Thu, 4 Nov 2004 21:03:47 +0000 (GMT) Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP id 9E08CA312C; Thu, 4 Nov 2004 21:03:46 +0000 (GMT) Message-ID: <418A98C0.9010107@ymogen.net> Date: Thu, 04 Nov 2004 21:01:52 +0000 From: Matt Clark User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Cc: pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <003301c4c29a$f052d910$8300a8c0@solent> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/61 X-Sequence-Number: 9015 > 1- You have a query that runs for half an hour and you spoon feed > the results to the client ? > (argh) > > 2- Your script looks for new data every few seconds, sends a > packet, then sleeps, and loops ? > > If it's 2 I have a readymade solution for you, just ask. > I'm guessing (2) - PG doesn't give the results of a query in a stream. From pgsql-performance-owner@postgresql.org Thu Nov 4 21:11:08 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2469C3A4915 for ; Thu, 4 Nov 2004 21:06:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22462-10 for ; Thu, 4 Nov 2004 21:06:03 +0000 (GMT) Received: from mail.atua.com.br (unknown [200.248.138.61]) by svr1.postgresql.org (Postfix) with ESMTP id DFC283A4961 for ; Thu, 4 Nov 2004 21:06:03 +0000 (GMT) Received: from [10.0.0.171] (ns2.atua.com.br [200.248.138.60]) by mail.atua.com.br (Postfix) with ESMTP id AA99F1EC3FE for ; Thu, 4 Nov 2004 19:06:01 -0200 (BRST) Subject: Better Hardware, worst Results From: Alvaro Nunes Melo To: Pgsql-Performance Content-Type: text/plain Message-Id: <1099602361.7775.15.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Thu, 04 Nov 2004 19:06:01 -0200 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/63 X-Sequence-Number: 9017 Hi, I have a very tricky situation here. A client bought a Dell dual-machine to be used as Database Server, and we have a cheaper machine used in development. With identical databases, configuration parameters and running the same query, our machine is almost 3x faster. I tried to increase the shared_buffers and other parameters, but the result is still the same. I would like to know what can I do to check what can be "holding" the Dell server (HD, memory, etc). Both machines run Debian Linux. I'll post configuration details below, so you'll can figure my scenario better. ==> Dell PowerEdge: HD: SCSI processor : 0 vendor_id : GenuineIntel cpu family : 15 model : 2 model name : Intel(R) Xeon(TM) CPU 2.80GHz stepping : 9 cpu MHz : 2791.292 cache size : 512 KB processor : 1 vendor_id : GenuineIntel cpu family : 15 model : 2 model name : Intel(R) Xeon(TM) CPU 2.80GHz stepping : 9 cpu MHz : 2791.292 cache size : 512 KB # free -m total used free shared buffers cached Mem: 1010 996 14 0 98 506 ==> Other machine: HD: IDE processor : 0 vendor_id : GenuineIntel cpu family : 15 model : 2 model name : Intel(R) Pentium(R) 4 CPU 2.26GHz stepping : 5 cpu MHz : 2262.166 cache size : 512 KB #free -m total used free shared buffers cached Mem: 439 434 4 0 16 395 -- +---------------------------------------------------+ | Alvaro Nunes Melo Atua Sistemas de Informacao | | al_nunes@atua.com.br www.atua.com.br | | UIN - 42722678 (54) 327-1044 | +---------------------------------------------------+ From pgsql-performance-owner@postgresql.org Thu Nov 4 21:18:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3CB7B3A499A for ; Thu, 4 Nov 2004 21:18:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27841-07 for ; Thu, 4 Nov 2004 21:18:03 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id DEC643A49AE for ; Thu, 4 Nov 2004 21:18:03 +0000 (GMT) Received: from [134.22.69.212] (dyn-69-212.tor.dsl.tht.net [134.22.69.212]) by tht.net (Postfix) with ESMTP id BD11676AAE; Thu, 4 Nov 2004 16:18:07 -0500 (EST) Subject: Re: Better Hardware, worst Results From: Rod Taylor To: Alvaro Nunes Melo Cc: Pgsql-Performance In-Reply-To: <1099602361.7775.15.camel@localhost> References: <1099602361.7775.15.camel@localhost> Content-Type: text/plain Message-Id: <1099602998.1647.711.camel@home> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Thu, 04 Nov 2004 16:16:38 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/64 X-Sequence-Number: 9018 On Thu, 2004-11-04 at 16:06, Alvaro Nunes Melo wrote: > Hi, > > I have a very tricky situation here. A client bought a Dell dual-machine > to be used as Database Server, and we have a cheaper machine used in > development. With identical databases, configuration parameters and > running the same query, our machine is almost 3x faster. Please send an explain analyze from both. From pgsql-performance-owner@postgresql.org Thu Nov 4 21:46:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 341493A4915 for ; Thu, 4 Nov 2004 21:46:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36549-09 for ; Thu, 4 Nov 2004 21:46:18 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 487463A4893 for ; Thu, 4 Nov 2004 21:46:18 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA4LkDvF004848; Thu, 4 Nov 2004 16:46:14 -0500 (EST) To: Alvaro Nunes Melo Cc: Pgsql-Performance Subject: Re: Better Hardware, worst Results In-reply-to: <1099602361.7775.15.camel@localhost> References: <1099602361.7775.15.camel@localhost> Comments: In-reply-to Alvaro Nunes Melo message dated "Thu, 04 Nov 2004 19:06:01 -0200" Date: Thu, 04 Nov 2004 16:46:13 -0500 Message-ID: <4847.1099604773@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/65 X-Sequence-Number: 9019 Alvaro Nunes Melo writes: > I have a very tricky situation here. A client bought a Dell dual-machine > to be used as Database Server, and we have a cheaper machine used in > development. With identical databases, configuration parameters and > running the same query, our machine is almost 3x faster. > ==> Dell PowerEdge: > HD: SCSI > ==> Other machine: > HD: IDE I'll bet a nickel that the IDE drive is lying about write completion, thereby gaining a significant performance boost at the cost of probable data corruption during a power failure. SCSI drives generally tell the truth about this, but consumer-grade IDE gear is usually configured to lie. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 4 22:00:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F00283A499E for ; Thu, 4 Nov 2004 22:00:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41792-06 for ; Thu, 4 Nov 2004 21:59:56 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id BE6DA3A49A4 for ; Thu, 4 Nov 2004 21:59:56 +0000 (GMT) Received: (qmail 16256 invoked from network); 4 Nov 2004 23:00:10 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 4 Nov 2004 23:00:10 +0100 Date: Thu, 04 Nov 2004 23:00:14 +0100 To: pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <003301c4c29a$f052d910$8300a8c0@solent> <418A98C0.9010107@ymogen.net> From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <418A98C0.9010107@ymogen.net> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/66 X-Sequence-Number: 9020 > I'm guessing (2) - PG doesn't give the results of a query in a stream. In 1- I was thinking about a cursor... but I think his problem is more like 2- In that case one can either code a special purpose server or use the following hack : In your webpage include an iframe with a Javascript to refresh it every five seconds. The iframe fetches a page from the server which brings in the new data in form of generated JavaScript which writes in the parent window. Thus, you get a very short request every 5 seconds to fetch new data, and it is displayed in the client's window very naturally. I've used this technique for another application and find it very cool. It's for selection lists, often you'll see a list of things to be checked or not, which makes a big form that people forget to submit. Thus I've replaced the checkboxes with clickable zones which trigger the loading of a page in a hidden iframe, which does appropriate modifications in the database, and updates the HTML in the parent page, changing texts here and there... it feels a bit like it's not a webpage but rather a standard GUI. Very neat. Changes are recorded without needing a submit button... I should write a framework for making that easy to do. I did not use a frame because frames suck, but iframes are convenient. Yeah, it does not work with Lynx... it needs JavaScript... but it works well. From pgsql-performance-owner@postgresql.org Thu Nov 4 22:33:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 213B23A4920 for ; Thu, 4 Nov 2004 22:33:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50431-10 for ; Thu, 4 Nov 2004 22:33:13 +0000 (GMT) Received: from msgdirector2.onetel.net.uk (msgdirector2.onetel.net.uk [212.67.96.149]) by svr1.postgresql.org (Postfix) with ESMTP id C47923A48D1 for ; Thu, 4 Nov 2004 22:33:13 +0000 (GMT) Received: from bolek.coachhouse ([213.78.163.63]) by msgdirector2.onetel.net.uk (MOS 3.4.6-GR) with ESMTP id CAL08191; Thu, 4 Nov 2004 22:33:10 GMT Received: (Exim 3.36) #1 (Debian)) protocol: esmtp id 1CPqA5-0004Hg-00 ; Thu, 04 Nov 2004 22:32:57 +0000 Message-ID: <418AAE19.3030609@numerixtechnology.de> Date: Thu, 04 Nov 2004 22:32:57 +0000 From: T E Schmitz Reply-To: mailreg@numerixtechnology.de User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: appropriate indexing Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.4 tagged_above=0.0 required=5.0 tests=LINES_OF_YELLING, LINES_OF_YELLING_2, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/67 X-Sequence-Number: 9021 Hello, I am seeking some advice on appropriate indexing. I think I have a rough idea where to place my indices but would be grateful for some tips from more experienced people. The following example shows what is probably the most complex query of the application. A few points to give you a rough indicator about the DB: - application is more query than update intensive - each table has a surrogate PK (serial) - access of tables ITEM and PRODUCT always involves join on BRAND, MODEL, TYPE - CATEGORY,SECTION,CONDITION are pretty much static and have no more than 30 rows - PRODUCT table will eventually contain a few thousand records - ITEM table will, grow, grow, grow (sold items are not deleted) - PRODUCT_FK, TYPE_FK, MODEL_FK, BRAND_FK are never NULL - PRODUCT_LENS... columns are only NOT NULL where CATEGORY_PK=2 - ITEM.STATUS = available, sold, reserved ..., never NULL - ITEM.KIND = secondhand, commission, new, never NULL ============================================= My understanding is: - index the FK columns used for joins - index columns typically used in WHERE clause - index on e.g. PRODUCT.CATEGORY_FK prevents seq scan of CATEGORY - as CATEGORY contains few rows it's not worth indexing CATEGORY_FK Questions: - Does the order of the JOIN clauses make a difference? - Does the order of the WHERE clauses make a difference? ============================================= SELECT BRAND.BRAND_NAME, MODEL.MODEL_NAME, TYPE.TYPE_NAME, ITEM.RETAIL_PRICE, CONDITION.ABBREVIATION FROM ITEM LEFT JOIN PRODUCT ON ITEM.PRODUCT_FK=PRODUCT.PRODUCT_PK LEFT JOIN TYPE ON PRODUCT.TYPE_FK=TYPE.TYPE_PK LEFT JOIN MODEL ON TYPE.MODEL_FK=MODEL.MODEL_PK LEFT JOIN BRAND ON MODEL.BRAND_FK=BRAND.BRAND_PK LEFT JOIN CATEGORY ON PRODUCT.CATEGORY_FK=CATEGORY.CATEGORY_PK LEFT JOIN SECTION SECTION ON PRODUCT.SECTION_USED_FK=SECTION.SECTION_PK LEFT JOIN CONDITION ON ITEM.CONDITION_FK=CONDITION.CONDITION_PK WHERE PRODUCT.SECTION_USED_FK IS NOT NULL AND ITEM.STATUS=1 and (ITEM.KIND=2 or ITEM.KIND=3) ORDER BY SECTION.POSITION, CATEGORY.POSITION, PRODUCT.LENS_FOCAL_LEN_FROM,PRODUCT.LENS_FOCAL_LEN_TO IS NOT NULL, PRODUCT.LENS_FOCAL_LEN_TO, PRODUCT.LENS_SPEED_FROM,PRODUCT.LENS_SPEED_TO, TYPE.TYPE_NAME, CONDITION.POSITION I'd appreciate a few pointers based on this example. Thanks in advance. -- Regards/Gru�, Tarlika Elisabeth Schmitz From pgsql-performance-owner@postgresql.org Thu Nov 4 22:39:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A02BE3A48D1 for ; Thu, 4 Nov 2004 22:39:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54517-02 for ; Thu, 4 Nov 2004 22:39:10 +0000 (GMT) Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk [217.27.240.154]) by svr1.postgresql.org (Postfix) with ESMTP id 9696B3A499C for ; Thu, 4 Nov 2004 22:39:11 +0000 (GMT) Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP id 80172A33CB; Thu, 4 Nov 2004 22:39:11 +0000 (GMT) Message-ID: <418AAF12.8030307@ymogen.net> Date: Thu, 04 Nov 2004 22:37:06 +0000 From: Matt Clark User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Cc: pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <003301c4c29a$f052d910$8300a8c0@solent> <418A98C0.9010107@ymogen.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/68 X-Sequence-Number: 9022 > > In your webpage include an iframe with a Javascript to refresh it > every five seconds. The iframe fetches a page from the server which > brings in the new data in form of generated JavaScript which writes > in the parent window. Thus, you get a very short request every 5 > seconds to fetch new data, and it is displayed in the client's window > very naturally. > > ... Yup. If you go the JS route then you can do even better by using JS to load data into JS objects in the background and manipulate the page content directly, no need for even an Iframe. Ignore the dullards who have JS turned off - it's essential for modern web apps, and refusing JS conflicts absolutely with proper semantic markup. http://developer.apple.com/internet/webcontent/xmlhttpreq.html is a good starting point. It's clear that this discussion has moved way away from PG! Although in the context of DB backed web apps I guess in remains a bit on-topic... M From pgsql-performance-owner@postgresql.org Thu Nov 4 22:41:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B3F4D3A49B0 for ; Thu, 4 Nov 2004 22:41:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54878-05 for ; Thu, 4 Nov 2004 22:40:51 +0000 (GMT) Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk [217.27.240.154]) by svr1.postgresql.org (Postfix) with ESMTP id 2E9013A49AA for ; Thu, 4 Nov 2004 22:40:53 +0000 (GMT) Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP id 65A76A33CB; Thu, 4 Nov 2004 22:40:52 +0000 (GMT) Message-ID: <418AAF81.5040108@ymogen.net> Date: Thu, 04 Nov 2004 22:38:57 +0000 From: Matt Clark User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: mailreg@numerixtechnology.de Cc: pgsql-performance@postgresql.org Subject: Re: appropriate indexing References: <418AAE19.3030609@numerixtechnology.de> In-Reply-To: <418AAE19.3030609@numerixtechnology.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/69 X-Sequence-Number: 9023 > - ITEM table will, grow, grow, grow (sold items are not deleted) > WHERE PRODUCT.SECTION_USED_FK IS NOT NULL AND ITEM.STATUS=1 and > (ITEM.KIND=2 or ITEM.KIND=3) > Partial index on item.status ? From pgsql-performance-owner@postgresql.org Thu Nov 4 22:42:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 87AB73A499C for ; Thu, 4 Nov 2004 22:42:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 54275-05 for ; Thu, 4 Nov 2004 22:42:04 +0000 (GMT) Received: from mail.atua.com.br (unknown [200.248.138.61]) by svr1.postgresql.org (Postfix) with ESMTP id 0CDBE3A48D1 for ; Thu, 4 Nov 2004 22:42:04 +0000 (GMT) Received: by mail.atua.com.br (Postfix, from userid 33) id C7CE11EC3DB; Thu, 4 Nov 2004 20:42:03 -0200 (BRST) Received: from hostere-145.tpo.com.br (hostere-145.tpo.com.br [200.174.191.145]) by webmail.atua.com.br (IMP) with HTTP for ; Thu, 4 Nov 2004 20:42:03 -0200 Message-ID: <1099608123.418ab03ba292f@webmail.atua.com.br> Date: Thu, 4 Nov 2004 20:42:03 -0200 From: al_nunes@atua.com.br To: pgsql-performance@postgresql.org Subject: Re: Better Hardware, worst Results References: <1099602361.7775.15.camel@localhost> <1099602998.1647.711.camel@home> In-Reply-To: <1099602998.1647.711.camel@home> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.3 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200411/70 X-Sequence-Number: 9024 Citando Rod Taylor : > Please send an explain analyze from both. I'm sendin three explains. In the first the Dell machine didn't use existing indexes, so I turn enable_seqscan off (this is the second explain). The total cost decreased, but the total time not. The third explain refers to the cheaper (and faster) machine. The last thing is the query itself. Nested Loop (cost=9008.68..13596.97 rows=1 width=317) (actual time=9272.803..65287.304 rows=2604 loops=1) -> Hash Join (cost=9008.68..13590.91 rows=1 width=319) (actual time=9243.294..10560.330 rows=2604 loops=1) Hash Cond: ("outer".cd_tipo_pagamento = "inner".cd_tipo_pagamento) -> Hash Join (cost=9007.59..13589.81 rows=1 width=317) (actual time=9243.149..10529.765 rows=2604 loops=1) Hash Cond: ("outer".cd_condicao = "inner".cd_condicao) -> Nested Loop (cost=9006.46..13588.62 rows=8 width=315) (actual time=9243.083..10497.385 rows=2604 loops=1) -> Merge Join (cost=9006.46..13540.44 rows=8 width=290) (actual time=9242.962..10405.245 rows=2604 loops=1) Merge Cond: ("outer".cd_pessoa = "inner".cd_pessoa) -> Nested Loop Left Join (cost=4658.37..9183.72 rows=375 width=286) (actual time=9210.101..10327.003 rows=23392 loops=1) -> Merge Left Join (cost=4658.37..6924.15 rows=375 width=274) (actual time=9209.952..9981.475 rows=23392 loops=1) Merge Cond: ("outer".cd_pessoa = "inner".cd_pessoa) -> Merge Left Join (cost=3366.00..5629.19 rows=375 width=255) (actual time=9158.705..9832.781 rows=23392 loops=1) Merge Cond: ("outer".cd_pessoa = "inner".cd_pessoa) -> Nested Loop Left Join (cost=2073.63..4334.24 rows=375 width=236) (actual time=8679.698..9152.213 rows=23392 loops= 1) -> Merge Left Join (cost=2073.63..2075.94 rows=375 width=44) (actual time=8679.557..8826.898 rows=23392 loops=1 ) Merge Cond: ("outer".cd_pessoa = "inner".cd_pessoa) -> Sort (cost=1727.15..1728.09 rows=375 width=40) (actual time=8580.391..8611.842 rows=23392 loops=1) Sort Key: p.cd_pessoa -> Seq Scan on pessoa p (cost=0.00..1711.12 rows=375 width=40) (actual time=0.371..8247.028 rows=50 412 loops=1) Filter: (cliente_liberado(cd_pessoa) = 1) -> Sort (cost=346.47..346.69 rows=85 width=8) (actual time=99.121..120.706 rows=16470 loops=1) Sort Key: e.cd_pessoa -> Seq Scan on endereco e (cost=0.00..343.75 rows=85 width=8) (actual time=0.070..30.558 rows=16858 loops=1) Filter: (id_tipo_endereco = 2) -> Index Scan using pk_pessoa_juridica on pessoa_juridica pj (cost=0.00..6.01 rows=1 width=196) (actual time=0. 007..0.008 rows=1 loops=23392) Index Cond: (pj.cd_pessoa = "outer".cd_pessoa) -> Sort (cost=1292.37..1293.18 rows=325 width=23) (actual time=478.963..522.701 rows=33659 loops=1) Sort Key: t.cd_pessoa -> Seq Scan on telefone t (cost=0.00..1278.81 rows=325 width=23) (actual time=0.039..120.256 rows=59572 loops=1 ) Filter: (id_principal = 1::smallint) -> Sort (cost=1292.37..1293.18 rows=325 width=23) (actual time=51.205..53.662 rows=3422 loops=1) Sort Key: tf.cd_pessoa -> Seq Scan on telefone tf (cost=0.00..1278.81 rows=325 width=23) (actual time=0.024..43.192 rows=3885 loops=1) Filter: (id_tipo = 4::smallint) -> Index Scan using pk_cep on cep c (cost=0.00..6.01 rows=1 width=20) (actual time=0.007..0.009 rows=1 loops=23392) Index Cond: (c.cd_cep = "outer".cd_cep) -> Sort (cost=4348.08..4351.89 rows=1524 width=4) (actual time=13.182..18.069 rows=2619 loops=1) Sort Key: cgv.cd_pessoa -> Index Scan using idx_cliente_grupo_vendedor_cd_vendedor on cliente_grupo_vendedor cgv (cost=0.00..4267.51 rows=1524 width=4) ( actual time=0.114..8.986 rows=2619 loops=1) Index Cond: (cd_vendedor = 577) -> Index Scan using pk_cliente_financeiro on cliente_financeiro cf (cost=0.00..6.01 rows=1 width=25) (actual time=0.018..0.021 rows=1 loops=2 604) Index Cond: ("outer".cd_pessoa = cf.cd_pessoa) -> Hash (cost=1.11..1.11 rows=11 width=6) (actual time=0.029..0.029 rows=0 loops=1) -> Seq Scan on condicao_pagamento cp (cost=0.00..1.11 rows=11 width=6) (actual time=0.006..0.024 rows=11 loops=1) -> Hash (cost=1.07..1.07 rows=7 width=6) (actual time=0.114..0.114 rows=0 loops=1) -> Seq Scan on tipo_pagamento tp (cost=0.00..1.07 rows=7 width=6) (actual time=0.095..0.106 rows=7 loops=1) -> Index Scan using pk_cliente on cliente cl (cost=0.00..6.01 rows=1 width=10) (actual time=0.013..0.017 rows=1 loops=2604) Index Cond: ("outer".cd_pessoa = cl.cd_pessoa) Total runtime: 65298.215 ms (49 registros) ************************* Nested Loop (cost=5155.51..19320.20 rows=1 width=317) (actual time=480.311..62530.121 rows=2604 loops=1) -> Nested Loop (cost=5155.51..19314.14 rows=1 width=319) (actual time=445.146..7385.369 rows=2604 loops=1) -> Hash Join (cost=5155.51..19309.45 rows=1 width=317) (actual time=429.995..7307.799 rows=2604 loops=1) Hash Cond: ("outer".cd_tipo_pagamento = "inner".cd_tipo_pagamento) -> Nested Loop (cost=5149.42..19303.31 rows=8 width=315) (actual time=365.722..7208.785 rows=2604 loops=1) -> Merge Join (cost=5149.42..19255.13 rows=8 width=290) (actual time=365.551..7112.292 rows=2604 loops=1) Merge Cond: ("outer".cd_pessoa = "inner".cd_pessoa) -> Nested Loop Left Join (cost=801.33..14898.41 rows=375 width=286) (actual time=180.146..7026.597 rows=23392 loops=1) -> Merge Left Join (cost=801.33..12638.83 rows=375 width=274) (actual time=180.087..6620.025 rows=23392 loops=1) Merge Cond: ("outer".cd_pessoa = "inner".cd_pessoa) -> Merge Left Join (cost=801.33..9709.38 rows=375 width=255) (actual time=179.964..6443.147 rows=23392 loops=1) Merge Cond: ("outer".cd_pessoa = "inner".cd_pessoa) -> Nested Loop Left Join (cost=801.33..6779.94 rows=375 width=236) (actual time=178.106..6131.000 rows=23392 loops=1) -> Merge Left Join (cost=801.33..4521.63 rows=375 width=44) (actual time=177.883..5737.847 rows=23392 loops=1) Merge Cond: ("outer".cd_pessoa = "inner".cd_pessoa) -> Index Scan using pk_pessoa on pessoa p (cost=0.00..3718.93 rows=375 width=40) (actual time=41.851..543 1.143 rows=23392 loops=1) Filter: (cliente_liberado(cd_pessoa) = 1) -> Sort (cost=801.33..801.55 rows=85 width=8) (actual time=135.988..166.175 rows=16470 loops=1) Sort Key: e.cd_pessoa -> Index Scan using idx_endereco_cd_cep on endereco e (cost=0.00..798.61 rows=85 width=8) (actual t ime=8.121..61.640 rows=16858 loops=1) Filter: (id_tipo_endereco = 2) -> Index Scan using pk_pessoa_juridica on pessoa_juridica pj (cost=0.00..6.01 rows=1 width=196) (actual time=0. 009..0.010 rows=1 loops=23392) Index Cond: (pj.cd_pessoa = "outer".cd_pessoa) -> Index Scan using idx_telefone_cd_pessoa_id_principal on telefone t (cost=0.00..2927.68 rows=325 width=23) (actual time=1.840..106.496 rows=33659 loops=1) Filter: (id_principal = 1::smallint) -> Index Scan using idx_telefone_cd_pessoa_id_principal on telefone tf (cost=0.00..2927.68 rows=325 width=23) (actual time= 0.056..67.089 rows=3422 loops=1) Filter: (id_tipo = 4::smallint) -> Index Scan using pk_cep on cep c (cost=0.00..6.01 rows=1 width=20) (actual time=0.010..0.011 rows=1 loops=23392) Index Cond: (c.cd_cep = "outer".cd_cep) -> Sort (cost=4348.08..4351.89 rows=1524 width=4) (actual time=14.178..18.668 rows=2619 loops=1) Sort Key: cgv.cd_pessoa -> Index Scan using idx_cliente_grupo_vendedor_cd_vendedor on cliente_grupo_vendedor cgv (cost=0.00..4267.51 rows=1524 width=4) ( actual time=0.177..9.557 rows=2619 loops=1) Index Cond: (cd_vendedor = 577) -> Index Scan using pk_cliente_financeiro on cliente_financeiro cf (cost=0.00..6.01 rows=1 width=25) (actual time=0.019..0.022 rows=1 loops=2 604) Index Cond: ("outer".cd_pessoa = cf.cd_pessoa) -> Hash (cost=6.08..6.08 rows=7 width=6) (actual time=64.025..64.025 rows=0 loops=1) -> Index Scan using pk_tipo_pagamento on tipo_pagamento tp (cost=0.00..6.08 rows=7 width=6) (actual time=63.991..64.007 rows=7 loops=1) -> Index Scan using pk_condicao_pagamento on condicao_pagamento cp (cost=0.00.. Index Cond: (cp.cd_condicao = "outer".cd_condicao) -> Index Scan using pk_cliente on cliente cl (cost=0.00..6.01 rows=1 width=10) (actual time=0.013..0.017 rows=1 loops=2604) Index Cond: ("outer".cd_pessoa = cl.cd_pessoa) Total runtime: 62536.845 ms (42 registros) 4.68 rows=1 width=6) (actual time=0.014..0.016 rows=1 loops=2604) ************************* Hash Join (cost=2.23..11191.77 rows=9 width=134) (actual time=341.708..21868.167 rows=2604 loops=1) Hash Cond: ("outer".cd_condicao = "inner".cd_condicao) -> Hash Join (cost=1.09..11190.16 rows=9 width=132) (actual time=329.205..19758.764 rows=2604 loops=1) Hash Cond: ("outer".cd_tipo_pagamento = "inner".cd_tipo_pagamento) -> Nested Loop (cost=0.00..11188.94 rows=9 width=130) (actual time=329.086..19727.477 rows=2604 loops=1) -> Merge Join (cost=0.00..9190.52 rows=245 width=138) (actual time=7.860..18543.354 rows=24380 loops=1) Merge Cond: ("outer".cd_pessoa = "inner".cd_pessoa) -> Merge Join (cost=0.00..11686.19 rows=245 width=128) (actual time=7.692..17802.380 rows=24380 loops=1) Merge Cond: ("outer".cd_pessoa = "inner".cd_pessoa) -> Nested Loop Left Join (cost=0.00..14123.02 rows=375 width=106) (actual time=7.513..17071.221 rows=70931 loops=1) -> Merge Left Join (cost=0.00..12973.12 rows=375 width=94) (actual time=7.297..16005.974 rows=70931 loops=1) Merge Cond: ("outer".cd_pessoa = "inner".cd_pessoa) -> Merge Left Join (cost=0.00..10076.90 rows=375 width=82) (actual time=7.161..15391.752 rows=70931 loops=1) Merge Cond: ("outer".cd_pessoa = "inner".cd_pessoa) -> Nested Loop Left Join (cost=0.00..7040.30 rows=375 width=70) (actual time=6.990..14516.256 rows=47998 loops=1) -> Nested Loop Left Join (cost=0.00..5401.41 rows=375 width=37) (actual time=6.839..13504.771 rows=47998 loops= 1) -> Index Scan using pk_pessoa on pessoa p (cost=0.00..3398.09 rows=375 width=33) (actual time=6.599..1234 7.532 rows=47998 loops=1) Filter: (cliente_liberado(cd_pessoa) = 1) -> Index Scan using un_endereco_id_tipo_endereco on endereco e (cost=0.00..5.33 rows=1 width=8) (actual t ime=0.015..0.016 rows=0 loops=47998) Index Cond: (e.cd_pessoa = "outer".cd_pessoa) Filter: (id_tipo_endereco = 2) -> Index Scan using pk_pessoa_juridica on pessoa_juridica pj (cost=0.00..4.36 rows=1 width=37) (actual time=0.0 12..0.013 rows=0 loops=47998) Index Cond: (pj.cd_pessoa = "outer".cd_pessoa) -> Index Scan using idx_telefone_cd_pessoa_id_principal on telefone t (cost=0.00..2884.52 rows=59265 width=16) (actua l time=0.146..260.008 rows=58128 loops=1) Filter: (id_principal = 1::smallint) -> Index Scan using idx_telefone_cd_pessoa_id_principal on telefone tf (cost=0.00..2884.52 rows=4217 width=16) (actual time =0.053..159.212 rows=3600 loops=1) Filter: (id_tipo = 4::smallint) -> Index Scan using pk_cep on cep c (cost=0.00..3.05 rows=1 width=20) (actual time=0.006..0.007 rows=0 loops=70931) Index Cond: (c.cd_cep = "outer".cd_cep) -> Index Scan using pk_cliente_financeiro on cliente_financeiro cf (cost=0.00..1806.88 rows=48765 width=22) (actual time=0.146..175.468 rows=48765 loops=1) -> Index Scan using pk_cliente on cliente cl (cost=0.00..1387.01 rows=48805 width=10) (actual time=0.135..179.715 rows=48804 loops=1) -> Index Scan using idx_cliente_grupo_vendedor_cd_pessoa on cliente_grupo_vendedor cgv (cost=0.00..8.14 rows=1 width=4) (actual time=0.042..0.043 r ows=0 loops=24380) Index Cond: (cgv.cd_pessoa = "outer".cd_pessoa) Filter: (cd_vendedor = 577) -> Hash (cost=1.07..1.07 rows=7 width=6) (actual time=0.059..0.059 rows=0 loops=1) -> Seq Scan on tipo_pagamento tp (cost=0.00..1.07 rows=7 width=6) (actual time=0.033..0.047 rows=7 loops=1) -> Hash (cost=1.11..1.11 rows=11 width=6) (actual time=0.096..0.096 rows=0 loops=1) -> Seq Scan on condicao_pagamento cp (cost=0.00..1.11 rows=11 width=6) (actual time=0.054..0.079 rows=11 loops=1) Total runtime: 21873.236 ms (39 rows) SELECT p.cd_pessoa, obtem_cnpj_cpf(p.cd_pessoa) AS nr_cnpj_cpf, p.nm_pessoa, COALESCE(pj.nm_fantasia, p.nm_pessoa), obtem_endereco(obtem_endereco_comercial(p.cd_pessoa)) AS ds_endereco, obtem_bairro(obtem_endereco_comercial(p.cd_pessoa)) AS ds_bairro, c.cd_cidade, c.nr_cep, pj.nr_ie, '0' || t.nr_telefone, '0' || tf.nr_telefone, cf.cd_tipo_pagamento, cf.cd_condicao, cp.nr_dias, cl.cd_atividade, tp.nr_hierarquia, '0', REPLACE(cf.pr_taxa_financeira, '.', ',') AS pr_taxa_financeira, TO_CHAR(p.dt_nascimento, 'DDMMYYYY') AS dt_nascimento, cl.nr_checkouts, CASE WHEN cf.id_confianca = 1 THEN 'A' WHEN cf.id_confianca = 2 THEN 'B' WHEN cf.id_confianca = 3 THEN 'C' WHEN cf.id_confianca = 4 THEN 'D' END AS id_confianca, '' AS id_cadastro FROM pessoa p LEFT OUTER JOIN endereco e ON e.cd_pessoa = p.cd_pessoa AND e.id_tipo_endereco = 2 LEFT OUTER JOIN pessoa_juridica pj ON pj.cd_pessoa = p.cd_pessoa LEFT OUTER JOIN telefone t ON t.cd_pessoa = p.cd_pessoa AND t.id_principal = '1' LEFT OUTER JOIN telefone tf ON tf.cd_pessoa = p.cd_pessoa AND tf.id_tipo = '4' LEFT OUTER JOIN cep c ON c.cd_cep = e.cd_cep JOIN cliente cl ON cl.cd_pessoa = p.cd_pessoa JOIN cliente_financeiro cf ON cf.cd_pessoa = cl.cd_pessoa JOIN cliente_grupo_vendedor cgv ON cgv.cd_pessoa = p.cd_pessoa JOIN condicao_pagamento cp ON cp.cd_condicao = cf.cd_condicao JOIN tipo_pagamento tp ON tp.cd_tipo_pagamento = cf.cd_tipo_pagamento WHERE cgv.cd_vendedor = '577' AND cliente_liberado(p.cd_pessoa) = 1; -- +---------------------------------------------------+ | Alvaro Nunes Melo Atua Sistemas de Informacao | | al_nunes@atua.com.br www.atua.com.br | | UIN - 42722678 (54) 327-1044 | +---------------------------------------------------+ ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. Atua Sistemas de Informa��o - http://www.atua.com.br From pgsql-performance-owner@postgresql.org Thu Nov 4 23:00:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CF81C3A4987 for ; Thu, 4 Nov 2004 23:00:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58428-06 for ; Thu, 4 Nov 2004 22:59:56 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 64C113A4654 for ; Thu, 4 Nov 2004 22:59:55 +0000 (GMT) Received: from [134.22.69.212] (dyn-69-212.tor.dsl.tht.net [134.22.69.212]) by tht.net (Postfix) with ESMTP id 7659D76D26; Thu, 4 Nov 2004 17:59:58 -0500 (EST) Subject: Re: Better Hardware, worst Results From: Rod Taylor To: al_nunes@atua.com.br Cc: Postgresql Performance In-Reply-To: <1099608123.418ab03ba292f@webmail.atua.com.br> References: <1099602361.7775.15.camel@localhost> <1099602998.1647.711.camel@home> <1099608123.418ab03ba292f@webmail.atua.com.br> Content-Type: text/plain Message-Id: <1099609109.1647.727.camel@home> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Thu, 04 Nov 2004 17:58:29 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/72 X-Sequence-Number: 9026 On Thu, 2004-11-04 at 17:42, al_nunes@atua.com.br wrote: > Citando Rod Taylor : > > Please send an explain analyze from both. > I'm sendin three explains. In the first the Dell machine didn't use existing > indexes, so I turn enable_seqscan off (this is the second explain). The total > cost decreased, but the total time not. The third explain refers to the cheaper > (and faster) machine. The last thing is the query itself. All 3 plans have crappy estimates. Run ANALYZE in production, then send another explain analyze (as an attachment please, to avoid linewrap). From pgsql-performance-owner@postgresql.org Thu Nov 4 22:59:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4473C3A49B0 for ; Thu, 4 Nov 2004 22:58:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60112-05 for ; Thu, 4 Nov 2004 22:58:53 +0000 (GMT) Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk [217.27.240.154]) by svr1.postgresql.org (Postfix) with ESMTP id BBBA23A49B1 for ; Thu, 4 Nov 2004 22:58:55 +0000 (GMT) Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP id 82CD0A4111; Thu, 4 Nov 2004 22:58:55 +0000 (GMT) Message-ID: <418AB42F.3080505@ymogen.net> Date: Thu, 04 Nov 2004 22:58:55 +0000 From: Matt Clark User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: al_nunes@atua.com.br Cc: pgsql-performance@postgresql.org Subject: Re: Better Hardware, worst Results References: <1099602361.7775.15.camel@localhost> <1099602998.1647.711.camel@home> <1099608123.418ab03ba292f@webmail.atua.com.br> In-Reply-To: <1099608123.418ab03ba292f@webmail.atua.com.br> Content-Type: multipart/alternative; boundary="------------080506050205060805090403" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=HTML_20_30, HTML_MESSAGE, HTML_TITLE_EMPTY X-Spam-Level: * X-Archive-Number: 200411/71 X-Sequence-Number: 9025 This is a multi-part message in MIME format. --------------080506050205060805090403 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit al_nunes@atua.com.br wrote: >Citando Rod Taylor : > > >>Please send an explain analyze from both. >> >> >I'm sendin three explains. In the first the Dell machine didn't use existing >indexes, so I turn enable_seqscan off (this is the second explain). The total >cost decreased, but the total time not. The third explain refers to the cheaper >(and faster) machine. The last thing is the query itself. > > > Nested Loop (cost=9008.68..13596.97 rows=1 width=317) (actual >time=9272.803..65287.304 rows=2604 loops=1) > Nested Loop (cost=5155.51..19320.20 rows=1 width=317) (actual >time=480.311..62530.121 rows=2604 loops=1) > Hash Join (cost=2.23..11191.77 rows=9 width=134) (actual >time=341.708..21868.167 rows=2604 loops=1) > > > Well the plan is completely different on the dev machine. Therefore either the PG version or the postgresql.conf is different. No other possible answer. M --------------080506050205060805090403 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit

al_nunes@atua.com.br wrote:
Citando Rod Taylor <pg@rbt.ca>:
  
Please send an explain analyze from both.
    
I'm sendin three explains. In the first the Dell machine didn't use existing
indexes, so I turn enable_seqscan off (this is the second explain). The total
cost decreased, but the total time not. The third explain refers to the cheaper
(and faster) machine. The last thing is the query itself.


 Nested Loop  (cost=9008.68..13596.97 rows=1 width=317) (actual
time=9272.803..65287.304 rows=2604 loops=1)
 Nested Loop  (cost=5155.51..19320.20 rows=1 width=317) (actual
time=480.311..62530.121 rows=2604 loops=1)
 Hash Join  (cost=2.23..11191.77 rows=9 width=134) (actual
time=341.708..21868.167 rows=2604 loops=1)

  
Well the plan is completely different on the dev machine.  Therefore either the PG version or the postgresql.conf is different.  No other possible answer.

M
--------------080506050205060805090403-- From pgsql-performance-owner@postgresql.org Thu Nov 4 23:09:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1B6B33A47BE for ; Thu, 4 Nov 2004 23:09:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61900-09 for ; Thu, 4 Nov 2004 23:09:00 +0000 (GMT) Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk [217.27.240.154]) by svr1.postgresql.org (Postfix) with ESMTP id 813033A499D for ; Thu, 4 Nov 2004 23:09:01 +0000 (GMT) Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP id 3015BA33CB; Thu, 4 Nov 2004 23:09:00 +0000 (GMT) Message-ID: <418AB68B.90005@ymogen.net> Date: Thu, 04 Nov 2004 23:08:59 +0000 From: Matt Clark User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Rod Taylor Cc: al_nunes@atua.com.br, Postgresql Performance Subject: Re: Better Hardware, worst Results References: <1099602361.7775.15.camel@localhost> <1099602998.1647.711.camel@home> <1099608123.418ab03ba292f@webmail.atua.com.br> <1099609109.1647.727.camel@home> In-Reply-To: <1099609109.1647.727.camel@home> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/74 X-Sequence-Number: 9028 >All 3 plans have crappy estimates. > >Run ANALYZE in production, then send another explain analyze (as an >attachment please, to avoid linewrap). > > > Er, no other possible answer except Rod's :-) From pgsql-performance-owner@postgresql.org Thu Nov 4 23:03:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5A8F63A49C4 for ; Thu, 4 Nov 2004 23:03:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60196-05 for ; Thu, 4 Nov 2004 23:03:14 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id ED3333A4987 for ; Thu, 4 Nov 2004 23:03:15 +0000 (GMT) Received: (qmail 15588 invoked by uid 500); 4 Nov 2004 23:14:29 -0000 Date: Thu, 4 Nov 2004 17:14:29 -0600 From: Bruno Wolff III To: Matt Clark Cc: =?iso-8859-1?Q?Pierre-Fr=E9d=E9ric?= Caillaud , pgsql-performance@postgresql.org Subject: Re: Restricting Postgres Message-ID: <20041104231429.GA15541@wolff.to> Mail-Followup-To: Matt Clark , =?iso-8859-1?Q?Pierre-Fr=E9d=E9ric?= Caillaud , pgsql-performance@postgresql.org References: <003301c4c29a$f052d910$8300a8c0@solent> <418A98C0.9010107@ymogen.net> <418AAF12.8030307@ymogen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <418AAF12.8030307@ymogen.net> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/73 X-Sequence-Number: 9027 On Thu, Nov 04, 2004 at 22:37:06 +0000, Matt Clark wrote: > >... > > Yup. If you go the JS route then you can do even better by using JS to > load data into JS objects in the background and manipulate the page > content directly, no need for even an Iframe. Ignore the dullards who > have JS turned off - it's essential for modern web apps, and refusing JS > conflicts absolutely with proper semantic markup. Javascript is too powerful to turn for any random web page. It is only essential for web pages because people write their web pages to only work with javascript. From pgsql-performance-owner@postgresql.org Thu Nov 4 23:23:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4AF3B3A4893 for ; Thu, 4 Nov 2004 23:21:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64348-09 for ; Thu, 4 Nov 2004 23:21:30 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 69C713A4654 for ; Thu, 4 Nov 2004 23:21:31 +0000 (GMT) Received: (qmail 18663 invoked from network); 5 Nov 2004 00:21:44 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 5 Nov 2004 00:21:44 +0100 To: "Matt Clark" Cc: pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <003301c4c29a$f052d910$8300a8c0@solent> <418A98C0.9010107@ymogen.net> <418AAF12.8030307@ymogen.net> Message-ID: Date: Fri, 05 Nov 2004 00:21:48 +0100 From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <418AAF12.8030307@ymogen.net> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/76 X-Sequence-Number: 9030 check this marvelus piece of 5 minutes of work : http://boutiquenumerique.com/test/iframe_feed.html > Yup. If you go the JS route then you can do even better by using JS to > load data into JS objects in the background and manipulate the page > content directly, no need for even an Iframe. Ignore the dullards who > have JS turned off - it's essential for modern web apps, and refusing JS > conflicts absolutely with proper semantic markup. > > http://developer.apple.com/internet/webcontent/xmlhttpreq.html is a good > starting point. Didn't know this existed ! Very, very cool. I have to check this out more in depth. A note though : you'll have to turn off HTTP persistent connections in your server (not in your proxy) or youre back to square one. > > It's clear that this discussion has moved way away from PG! Although in > the context of DB backed web apps I guess in remains a bit on-topic... I find it very on-topic as - it's a way to help this guy solve his "pg problem" which was iin fact a design problem - it's the future of database driven web apps (no more reloading the whole page !) I think in the future there will be a good bit of presentation login in the client... From pgsql-performance-owner@postgresql.org Thu Nov 4 23:23:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9583E3A4987 for ; Thu, 4 Nov 2004 23:22:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65725-06 for ; Thu, 4 Nov 2004 23:22:21 +0000 (GMT) Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk [217.27.240.154]) by svr1.postgresql.org (Postfix) with ESMTP id 6F5BE3A4983 for ; Thu, 4 Nov 2004 23:22:23 +0000 (GMT) Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP id F0E68A33CB; Thu, 4 Nov 2004 23:22:22 +0000 (GMT) Message-ID: <418AB9AE.1010009@ymogen.net> Date: Thu, 04 Nov 2004 23:22:22 +0000 From: Matt Clark User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bruno Wolff III Cc: =?ISO-8859-1?Q?Pierre-Fr=E9d=E9ric_Caillaud?= , pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <003301c4c29a$f052d910$8300a8c0@solent> <418A98C0.9010107@ymogen.net> <418AAF12.8030307@ymogen.net> <20041104231429.GA15541@wolff.to> In-Reply-To: <20041104231429.GA15541@wolff.to> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200411/75 X-Sequence-Number: 9029 >Javascript is too powerful to turn for any random web page. It is only >essential for web pages because people write their web pages to only >work with javascript. > > Hmm... I respectfully disagree. It is so powerful that it is impossible to ignore when implementing a sophisticated app. And it is not dangerous to the user so long as they have a popup blocker. Commercially, I can ignore the people who turn it off, and I can gain a huge benefit from knowing that 95% of people have it turned on, because it gives my users a hugely better experience than the equivalent XHTML only page (which I deliver, and which works, but which is a fairly depressing experience compared to the JS enabled version). It is _amazing_ how much crud you can take out of a page if you let JS do the dynamic stuff (with CSS still in full control of the styling). Nice, clean, semantically sensible XHTML, that can be transformed for multiple devices - it's great. An example: /previews/foo.wmv But we want it to appear in a popup when viewed in certain devices.... Easy - Attach an 'onclick' event handler (or just set the target attribute) when the device has a suitable screen & media player, but leave the markup clean for the rest of the world. From pgsql-performance-owner@postgresql.org Thu Nov 4 23:33:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1076A3A4983 for ; Thu, 4 Nov 2004 23:33:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69273-04 for ; Thu, 4 Nov 2004 23:32:56 +0000 (GMT) Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk [217.27.240.154]) by svr1.postgresql.org (Postfix) with ESMTP id A9A3D3A47BE for ; Thu, 4 Nov 2004 23:32:57 +0000 (GMT) Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP id CF259A312C; Thu, 4 Nov 2004 23:32:57 +0000 (GMT) Message-ID: <418ABC29.8090601@ymogen.net> Date: Thu, 04 Nov 2004 23:32:57 +0000 From: Matt Clark User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Cc: pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <003301c4c29a$f052d910$8300a8c0@solent> <418A98C0.9010107@ymogen.net> <418AAF12.8030307@ymogen.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/77 X-Sequence-Number: 9031 > > A note though : you'll have to turn off HTTP persistent > connections in your server (not in your proxy) or youre back to > square one. > I hadn't considered that. On the client side it would seem to be up to the client whether to use a persistent connection or not. If it does, then yeah, a request every 5 seconds would still just hold open a server. One more reason to use a proxy I s'pose. >> >> It's clear that this discussion has moved way away from PG! Although >> in the context of DB backed web apps I guess in remains a bit >> on-topic... > > > I find it very on-topic as > - it's a way to help this guy solve his "pg problem" which was iin > fact a design problem > - it's the future of database driven web apps (no more reloading > the whole page !) > > I think in the future there will be a good bit of presentation > login in the client... Not if Bruno has his way ;-) From pgsql-performance-owner@postgresql.org Thu Nov 4 23:36:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1920B3A49C4 for ; Thu, 4 Nov 2004 23:35:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69068-06 for ; Thu, 4 Nov 2004 23:35:43 +0000 (GMT) Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk [217.27.240.154]) by svr1.postgresql.org (Postfix) with ESMTP id 31B3B3A4983 for ; Thu, 4 Nov 2004 23:35:46 +0000 (GMT) Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP id 0C447A312C; Thu, 4 Nov 2004 23:35:46 +0000 (GMT) Message-ID: <418ABCD1.7020407@ymogen.net> Date: Thu, 04 Nov 2004 23:35:45 +0000 From: Matt Clark User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Cc: pgsql-performance@postgresql.org Subject: Re: Restricting Postgres References: <003301c4c29a$f052d910$8300a8c0@solent> <418A98C0.9010107@ymogen.net> <418AAF12.8030307@ymogen.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/78 X-Sequence-Number: 9032 Pierre-Fr�d�ric Caillaud wrote: > > check this marvelus piece of 5 minutes of work : > http://boutiquenumerique.com/test/iframe_feed.html > cela m'a fait le sourire :-) (apologies for bad french) M From pgsql-performance-owner@postgresql.org Fri Nov 5 02:55:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4EA4C3A2BB9 for ; Fri, 5 Nov 2004 02:53:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17518-10 for ; Fri, 5 Nov 2004 02:53:54 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id DB7A43A2BCF for ; Fri, 5 Nov 2004 02:53:57 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iA52rmJD020570 for ; Fri, 5 Nov 2004 02:53:54 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iA52o0wa019712 for pgsql-performance@postgresql.org; Fri, 5 Nov 2004 02:50:00 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Anything to be gained from a 'Postgres Filesystem'? Date: Thu, 04 Nov 2004 21:05:36 -0500 Organization: cbbrowne Computing Inc Lines: 30 Message-ID: References: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> <60bred39bg.fsf@dba2.int.libertyrms.com> <1099595027.4320.663.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Cancel-Lock: sha1:6uXmyIDDY5ACBmluA/ABI0QWUAg= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/81 X-Sequence-Number: 9035 After a long battle with technology, simon@2ndquadrant.com (Simon Riggs), an earthling, wrote: > On Thu, 2004-11-04 at 15:47, Chris Browne wrote: > >> Another thing that would be valuable would be to have some way to say: >> >> "Read this data; don't bother throwing other data out of the cache >> to stuff this in." >> >> Something like a "read_uncached()" call... >> >> That would mean that a seq scan or a vacuum wouldn't force useful >> data out of cache. > > ARC does almost exactly those two things in 8.0. > > Seq scans do get put in cache, but in a way that means they don't > spoil the main bulk of the cache. We're not talking about the same cache. ARC does these exact things for _shared memory_ cache, and is the obvious inspiration. But it does more or less nothing about the way OS file buffer cache is managed, and the handling of _that_ would be the point of modifying OS filesystem semantics. -- select 'cbbrowne' || '@' || 'linuxfinances.info'; http://www3.sympatico.ca/cbbrowne/oses.html Have you ever considered beating yourself with a cluestick? From pgsql-performance-owner@postgresql.org Fri Nov 5 02:54:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 794963A2BCA for ; Fri, 5 Nov 2004 02:53:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20230-02 for ; Fri, 5 Nov 2004 02:53:54 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id D8AAB3A2BCB for ; Fri, 5 Nov 2004 02:53:57 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iA52rmJ9020570 for ; Fri, 5 Nov 2004 02:53:51 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iA52o0fj019763 for pgsql-performance@postgresql.org; Fri, 5 Nov 2004 02:50:00 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Anything to be gained from a 'Postgres Filesystem'? Date: Thu, 04 Nov 2004 21:29:04 -0500 Organization: cbbrowne Computing Inc Lines: 50 Message-ID: References: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Cancel-Lock: sha1:TAKilw0uTYjqo4LvF77ALqtS3S8= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/79 X-Sequence-Number: 9033 In an attempt to throw the authorities off his trail, schabios@logi-track.com (Markus Schaber) transmitted: > We should create a list of those needs, and then communicate those > to the kernel/fs developers. Then we (as well as other apps) can > make use of those features where they are available, and use the old > way everywhere else. Which kernel/fs developers did you have in mind? The ones working on Linux? Or FreeBSD? Or DragonflyBSD? Or Solaris? Or AIX? Please keep in mind that many of the PostgreSQL developers are BSD folk that aren't particularly interested in creating bleeding edge Linux capabilities. Furthermore, I'd think long and hard before jumping into such a _spectacularly_ bleeding edge kind of project. The reason why you would want this would be if you needed to get some margin of performance. I can't see wanting that without also wanting some _assurance_ of system reliability, at which point I also want things like vendor support. If you've ever contacted Red Hat Software, you'd know that they very nearly refuse to provide support for any filesystem other than ext3. Use anything else and they'll make noises about not being able to assure you of anything at all. If you need high performance, you'd also want to use interesting sorts of hardware. Disk arrays, RAID controllers, that sort of thing. Vendors of such things don't particularly want to talk to you unless you're using a "supported" Linux distribution and a "supported" filesystem. Jumping into a customized filesystem that neither hardware nor software vendors would remotely consider supporting just doesn't look like a viable strategy to me. > Maybe Reiser4 is a step into the right way, and maybe even a > postgres plugin for Reiser4 will be worth the effort. Maybe XFS/JFS > etc. already have such capabilities. Maybe that's completely wrong. The capabilities tend to be redundant. They tend to implement vaguely similar transactional capabilities to what databases have to implement. The similarities are not close enough to eliminate either variety of "commit" as redundant. -- "cbbrowne","@","linuxfinances.info" http://linuxfinances.info/info/linux.html Rules of the Evil Overlord #128. "I will not employ robots as agents of destruction if there is any possible way that they can be re-programmed or if their battery packs are externally mounted and easily removable." From pgsql-performance-owner@postgresql.org Fri Nov 5 02:55:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BA5363A2B49 for ; Fri, 5 Nov 2004 02:53:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20230-01 for ; Fri, 5 Nov 2004 02:53:52 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 3DB813A2B37 for ; Fri, 5 Nov 2004 02:53:55 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iA52rmJ7020570 for ; Fri, 5 Nov 2004 02:53:48 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iA52nb3e019644 for pgsql-performance@postgresql.org; Fri, 5 Nov 2004 02:49:38 GMT From: Martin Foster Organization: Ethereal Realms User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Restricting Postgres References: <003301c4c29a$f052d910$8300a8c0@solent> <418A98C0.9010107@ymogen.net> <418AAF12.8030307@ymogen.net> <418ABCD1.7020407@ymogen.net> In-Reply-To: <418ABCD1.7020407@ymogen.net> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit Lines: 52 Message-ID: Date: Fri, 05 Nov 2004 02:49:42 GMT To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/80 X-Sequence-Number: 9034 Matt Clark wrote: > > > Pierre-Fr�d�ric Caillaud wrote: > >> >> check this marvelus piece of 5 minutes of work : >> http://boutiquenumerique.com/test/iframe_feed.html >> > cela m'a fait le sourire :-) > > (apologies for bad french) > > M > > Javascript is not an option for the scripts, one of the mandates of the project is to support as many different client setups as possible and we have encountered everything from WebTV to the latest Firefox release. It's a chat/roleplay community and not everyone will invest in new equipment. Now, it would seem to me that there is a trade off between a JS push system and a constant ever-present process. With the traditional method as I use it, a client will incur the initial penalty of going through authentication, pulling the look and feel of the realms, sites and simply poll one table from that point on. Now on the other hand, you have one user making a call for new posts every x amount of seconds. This means every X seconds the penalty for authentication and design would kick in, increasing overall the load. The current scripts can also by dynamically adapted to slow things down based on heavy load or quiet realms that bring little posts in. It's much harder to expect Javascript solutions to work perfectly every time and not be modified by some proxy. Unfortunately, we are getting way off track. I'm looking for a way to protect the PostgreSQL server, either from PostgreSQL or some sort of external script which pools load average once in a while to make that determination. Now is there an administrative command in PostgreSQL that will cause it to move into some sort of maintenance mode? For me that could be exceedingly useful as it would still allow for an admin connection to be made and run a VACUUM FULL and such. Martin Foster Creator/Designer Ethereal Realms martin@ethereal-realms.org From pgsql-performance-owner@postgresql.org Fri Nov 5 04:29:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 53C4D3A2B3C for ; Fri, 5 Nov 2004 04:29:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42832-05 for ; Fri, 5 Nov 2004 04:29:02 +0000 (GMT) Received: from sue.samurai.com (sue.samurai.com [205.207.28.74]) by svr1.postgresql.org (Postfix) with ESMTP id 301093A1D92 for ; Fri, 5 Nov 2004 04:29:02 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by sue.samurai.com (Postfix) with ESMTP id A3EF419861; Thu, 4 Nov 2004 23:29:01 -0500 (EST) Received: from sue.samurai.com ([127.0.0.1]) by localhost (sue.samurai.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 64966-01-9; Thu, 4 Nov 2004 23:29:00 -0500 (EST) Received: from [61.88.101.19] (unknown [61.88.101.19]) by sue.samurai.com (Postfix) with ESMTP id 973921985B; Thu, 4 Nov 2004 23:28:59 -0500 (EST) Subject: Re: Anything to be gained from a 'Postgres Filesystem'? From: Neil Conway To: "Steinar H. Gunderson" Cc: pgsql-performance@postgresql.org In-Reply-To: <20041104192004.GA18793@uio.no> References: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> <60bred39bg.fsf@dba2.int.libertyrms.com> <20041104192004.GA18793@uio.no> Content-Type: text/plain Message-Id: <1099628919.10449.39.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 05 Nov 2004 15:28:39 +1100 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/82 X-Sequence-Number: 9036 On Fri, 2004-11-05 at 06:20, Steinar H. Gunderson wrote: > You mean, like, open(filename, O_DIRECT)? :-) This disables readahead (at least on Linux), which is certainly not we want: for the very case where we don't want to keep the data in cache for a while (sequential scans, VACUUM), we also want aggressive readahead. -Neil From pgsql-performance-owner@postgresql.org Fri Nov 5 04:34:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 46E0C3A3B09 for ; Fri, 5 Nov 2004 04:34:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45100-02 for ; Fri, 5 Nov 2004 04:33:58 +0000 (GMT) Received: from sue.samurai.com (sue.samurai.com [205.207.28.74]) by svr1.postgresql.org (Postfix) with ESMTP id EB9D43A1D85 for ; Fri, 5 Nov 2004 04:33:57 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by sue.samurai.com (Postfix) with ESMTP id 0E9BA19811; Thu, 4 Nov 2004 23:33:57 -0500 (EST) Received: from sue.samurai.com ([127.0.0.1]) by localhost (sue.samurai.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 65205-01-8; Thu, 4 Nov 2004 23:33:53 -0500 (EST) Received: from [61.88.101.19] (unknown [61.88.101.19]) by sue.samurai.com (Postfix) with ESMTP id CA09D19801; Thu, 4 Nov 2004 23:33:52 -0500 (EST) Subject: Re: Anything to be gained from a 'Postgres Filesystem'? From: Neil Conway To: =?ISO-8859-1?Q?Pierre-Fr=E9d=E9ric?= Caillaud Cc: pgsql-performance@postgresql.org In-Reply-To: References: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> Content-Type: text/plain; charset=iso-8859-1 Message-Id: <1099629212.10449.45.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 05 Nov 2004 15:33:32 +1100 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/83 X-Sequence-Number: 9037 On Thu, 2004-11-04 at 23:29, Pierre-Fr�d�ric Caillaud wrote: > There is also the fact that syncing after every transaction could be > changed to syncing every N transactions (N fixed or depending on the data > size written by the transactions) which would be more efficient than the > current behaviour with a sleep. Uh, which "sleep" are you referring to? Also, how would interacting with the filesystem's journal effect how often we need to force-write the WAL to disk? (ISTM we need to sync _something_ to disk when a transaction commits in order to maintain the WAL invariant.) > There's fadvise to tell the OS to readahead on a seq scan (I think the OS > detects it anyway) Not perfectly, though; also, Linux will do a more aggressive readahead if you tell it to do so via posix_fadvise(). > if there was a system call telling the OS "in the > next seconds I'm going to read these chunks of data from this file (gives > a list of offsets and lengths), could you put them in your cache in the > most efficient order without seeking too much, so that when I read() them > in random order, they will be in the cache already ?". http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html POSIX_FADV_WILLNEED Specifies that the application expects to access the specified data in the near future. -Neil From pgsql-performance-owner@postgresql.org Fri Nov 5 04:42:03 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EF4873A3B0F for ; Fri, 5 Nov 2004 04:35:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44762-06 for ; Fri, 5 Nov 2004 04:35:31 +0000 (GMT) Received: from sue.samurai.com (sue.samurai.com [205.207.28.74]) by svr1.postgresql.org (Postfix) with ESMTP id 815F43A3B2B for ; Fri, 5 Nov 2004 04:35:31 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by sue.samurai.com (Postfix) with ESMTP id E262919801; Thu, 4 Nov 2004 23:35:30 -0500 (EST) Received: from sue.samurai.com ([127.0.0.1]) by localhost (sue.samurai.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 65242-01-8; Thu, 4 Nov 2004 23:35:29 -0500 (EST) Received: from [61.88.101.19] (unknown [61.88.101.19]) by sue.samurai.com (Postfix) with ESMTP id CBBC7197B8; Thu, 4 Nov 2004 23:35:28 -0500 (EST) Subject: Re: Anything to be gained from a 'Postgres Filesystem'? From: Neil Conway To: Chris Browne Cc: pgsql-performance@postgresql.org In-Reply-To: <60bred39bg.fsf@dba2.int.libertyrms.com> References: <20041104120047.62810c8f@kingfisher.intern.logi-track.com> <60bred39bg.fsf@dba2.int.libertyrms.com> Content-Type: text/plain Message-Id: <1099629308.10449.48.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 05 Nov 2004 15:35:08 +1100 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/84 X-Sequence-Number: 9038 On Fri, 2004-11-05 at 02:47, Chris Browne wrote: > Another thing that would be valuable would be to have some way to say: > > "Read this data; don't bother throwing other data out of the cache > to stuff this in." This is similar, although not exactly the same thing: http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html POSIX_FADV_NOREUSE Specifies that the application expects to access the specified data once and then not reuse it thereafter. -Neil From pgsql-performance-owner@postgresql.org Fri Nov 5 05:05:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 84B6D3A3B14 for ; Fri, 5 Nov 2004 05:05:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49650-09 for ; Fri, 5 Nov 2004 05:05:32 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id DD14F3A3B13 for ; Fri, 5 Nov 2004 05:05:32 +0000 (GMT) Received: (qmail 22765 invoked by uid 500); 5 Nov 2004 05:16:46 -0000 Date: Thu, 4 Nov 2004 23:16:46 -0600 From: Bruno Wolff III To: Matt Clark Cc: =?iso-8859-1?Q?Pierre-Fr=E9d=E9ric?= Caillaud , pgsql-performance@postgresql.org Subject: Re: Restricting Postgres Message-ID: <20041105051646.GA22486@wolff.to> Mail-Followup-To: Matt Clark , =?iso-8859-1?Q?Pierre-Fr=E9d=E9ric?= Caillaud , pgsql-performance@postgresql.org References: <003301c4c29a$f052d910$8300a8c0@solent> <418A98C0.9010107@ymogen.net> <418AAF12.8030307@ymogen.net> <418ABC29.8090601@ymogen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <418ABC29.8090601@ymogen.net> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/85 X-Sequence-Number: 9039 On Thu, Nov 04, 2004 at 23:32:57 +0000, Matt Clark wrote: > > > > I think in the future there will be a good bit of presentation > >login in the client... > > Not if Bruno has his way ;-) Sure there will, but it will be controlled by the client, perhaps taking suggestions from the style sheet pointed to by the document. Running foreign code from random or even semi-random places is a recipe for becoming a spam server. See examples from Microsoft such as their spreadsheet and office software. Documents really need to be passive data, not active code. If the client and the server have a special trust relationship, then running code supplied by the server makes sense. So you might use javascript within a business where the IT department runs the server and the employees run clients. However, encouraging people to browse the internet with javascript enabled is a bad idea. From pgsql-performance-owner@postgresql.org Fri Nov 5 07:17:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4FD023A3B61 for ; Fri, 5 Nov 2004 07:16:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85600-01 for ; Fri, 5 Nov 2004 07:16:21 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.200]) by svr1.postgresql.org (Postfix) with ESMTP id 01E063A3B2D for ; Fri, 5 Nov 2004 07:16:21 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a41so23570rng for ; Thu, 04 Nov 2004 23:16:20 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=JRt2n8iXT6GOxihPlH7jhqb0qBnZ+L+c7DfOUT8HS5S2KUP/hdeGZ7xzmvPWmwOW2ZBYem46Pq48x5o2ta6pxr1KHdlwlzNXHxWbZH9Eos8p8p7UJhwZZoWaaSJkYQaoxNeUy3YXa8IGNqCJmIxBqc7GjaNAAr4NeSkrYJI9E08= Received: by 10.38.152.67 with SMTP id z67mr134293rnd; Thu, 04 Nov 2004 23:16:20 -0800 (PST) Received: by 10.38.149.52 with HTTP; Thu, 4 Nov 2004 23:16:20 -0800 (PST) Message-ID: <2989532e0411042316566b35f4@mail.gmail.com> Date: Fri, 5 Nov 2004 12:46:20 +0530 From: Antony Paul Reply-To: Antony Paul To: pgsql-performance@postgresql.org Subject: Checking = with timestamp field is slow Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200411/86 X-Sequence-Number: 9040 Hi all, I have a table which have more than 200000 records. I need to get the records which matches like this where today::date = '2004-11-05'; This is the only condition in the query. There is a btree index on the column today. Is there any way to optimise it. rgds Antony Paul From pgsql-performance-owner@postgresql.org Fri Nov 5 08:15:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 00A073A3BD7 for ; Fri, 5 Nov 2004 08:14:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 00306-03 for ; Fri, 5 Nov 2004 08:14:24 +0000 (GMT) Received: from laughter.local (unknown [61.115.206.98]) by svr1.postgresql.org (Postfix) with ESMTP id D1B223A3B07 for ; Fri, 5 Nov 2004 08:14:25 +0000 (GMT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by laughter.local (Postfix) with ESMTP id F197635F98E; Fri, 5 Nov 2004 17:14:01 +0900 (JST) In-Reply-To: <2989532e0411042316566b35f4@mail.gmail.com> References: <2989532e0411042316566b35f4@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: pgsql-performance@postgresql.org From: Michael Glaesemann Subject: Re: Checking = with timestamp field is slow Date: Fri, 5 Nov 2004 17:14:01 +0900 To: Antony Paul X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/87 X-Sequence-Number: 9041 On Nov 5, 2004, at 4:16 PM, Antony Paul wrote: > where today::date = '2004-11-05'; > > This is the only condition in the query. There is a btree index on the > column today. > Is there any way to optimise it. I'm sure others out there have better ideas, but you might want to try where current_date = date '2004-11-05' Might not make a difference at all, but perhaps PostgreSQL is coercing both values to timestamp or some other type as you're only providing a string to compare to a date. Then again, it might make no difference at all. My 1 cent. Michael Glaesemann grzm myrealbox com From pgsql-performance-owner@postgresql.org Fri Nov 5 08:33:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D95D03A3B78 for ; Fri, 5 Nov 2004 08:33:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04424-05 for ; Fri, 5 Nov 2004 08:33:10 +0000 (GMT) Received: from laughter.local (unknown [61.115.206.98]) by svr1.postgresql.org (Postfix) with ESMTP id EE7B03A3B28 for ; Fri, 5 Nov 2004 08:33:11 +0000 (GMT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by laughter.local (Postfix) with ESMTP id 614FD35FA3A; Fri, 5 Nov 2004 17:32:50 +0900 (JST) In-Reply-To: References: <2989532e0411042316566b35f4@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <4704C044-2F05-11D9-BE4A-000A95C88220@myrealbox.com> Content-Transfer-Encoding: 7bit Cc: Antony Paul , pgsql-performance@postgresql.org From: Michael Glaesemann Subject: Re: Checking = with timestamp field is slow Date: Fri, 5 Nov 2004 17:32:49 +0900 To: Michael Glaesemann X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/88 X-Sequence-Number: 9042 On Nov 5, 2004, at 5:14 PM, Michael Glaesemann wrote: > > On Nov 5, 2004, at 4:16 PM, Antony Paul wrote: >> where today::date = '2004-11-05'; >> >> This is the only condition in the query. There is a btree index on the >> column today. >> Is there any way to optimise it. > > I'm sure others out there have better ideas, but you might want to try > > where current_date = date '2004-11-05' Ach! just re-read that. today is one of your columns! Try where today::date = date '2004-11-05' From pgsql-performance-owner@postgresql.org Fri Nov 5 08:34:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D207F3A3BD9 for ; Fri, 5 Nov 2004 08:34:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03672-09 for ; Fri, 5 Nov 2004 08:34:14 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 367643A3B54 for ; Fri, 5 Nov 2004 08:34:14 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id iA58Y2GR014746 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Nov 2004 01:34:04 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id iA58Y2V3045072; Fri, 5 Nov 2004 01:34:02 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id iA58Y1xn045071; Fri, 5 Nov 2004 01:34:01 -0700 (MST) (envelope-from mfuhr) Date: Fri, 5 Nov 2004 01:34:01 -0700 From: Michael Fuhr To: Antony Paul Cc: pgsql-performance@postgresql.org Subject: Re: Checking = with timestamp field is slow Message-ID: <20041105083401.GA44953@winnie.fuhr.org> References: <2989532e0411042316566b35f4@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2989532e0411042316566b35f4@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/89 X-Sequence-Number: 9043 On Fri, Nov 05, 2004 at 12:46:20PM +0530, Antony Paul wrote: > I have a table which have more than 200000 records. I need to get > the records which matches like this > > where today::date = '2004-11-05'; > > This is the only condition in the query. There is a btree index on the > column today. Is there any way to optimise it. Is the today column a TIMESTAMP as the subject implies? If so then your queries probably aren't using the index because you're changing the type to something that's not indexed. Your queries should speed up if you create an index on DATE(today): CREATE INDEX foo_date_today_idx ON foo (DATE(today)); After creating the new index, use WHERE DATE(today) = '2004-11-05' in your queries. EXPLAIN ANALYZE should show that the index is being used. -- Michael Fuhr http://www.fuhr.org/~mfuhr/ From pgsql-performance-owner@postgresql.org Fri Nov 5 08:48:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5ED4A3A2B21 for ; Fri, 5 Nov 2004 08:48:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10450-02 for ; Fri, 5 Nov 2004 08:48:23 +0000 (GMT) Received: from usbb-lacimss2.unisys.com (usbb-lacimss2.unisys.com [192.63.108.52]) by svr1.postgresql.org (Postfix) with ESMTP id 312003A202A for ; Fri, 5 Nov 2004 08:48:21 +0000 (GMT) Received: from USBB-LACGW3.na.uis.unisys.com ([129.224.98.43]unverified) by usbb-lacimss2 with InterScan Messaging Security Suite; Fri, 05 Nov 2004 03:51:43 -0500 Received: from USBB-LACGW3.na.uis.unisys.com ([129.224.98.44]) by USBB-LACGW3.na.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.211); Fri, 5 Nov 2004 03:48:02 -0500 Received: from gbmk-eugw2.eu.uis.unisys.com ([129.221.133.27]) by USBB-LACGW3.na.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.211); Fri, 5 Nov 2004 03:48:02 -0500 Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by gbmk-eugw2.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.47); Fri, 5 Nov 2004 08:48:01 +0000 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable Subject: Re: Restricting Postgres Date: Fri, 5 Nov 2004 09:48:00 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Restricting Postgres Thread-Index: AcTC44lyVhIEywiZSq2njqNHfZrCEgAMBWrA From: "Leeuw van der, Tim" To: "Martin Foster" , X-OriginalArrivalTime: 05 Nov 2004 08:48:01.0488 (UTC) FILETIME=[283A2D00:01C4C314] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/90 X-Sequence-Number: 9044 To what extent would your problems be solved by having a 2nd server, a = replication system (such as slony-1, but there are others), and some = sort of load-balancer in front of it? The load-balancing could be as = simple as round-robin DNS server, perhaps... Then when you need to do maintenance such a vacuum full, you can = temporarily take 1 server out of the load-balancer (I hope) and do = maintenance, and then the other. I don't know what that does to replication, but I would venture that = replication systems should be designed to handle a node going offline. Load balancing could also help to protect against server-overload and 1 = server toppling over. Of course, I don't know to what extent having another piece of hardware = is an option, for you. cheers, --Tim -----Original Message----- From: pgsql-performance-owner@postgresql.org = [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Martin = Foster Sent: Friday, November 05, 2004 3:50 AM To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Restricting Postgres [...] Now is there an administrative command in PostgreSQL that will cause it=20 to move into some sort of maintenance mode? For me that could be=20 exceedingly useful as it would still allow for an admin connection to be = made and run a VACUUM FULL and such. Martin Foster Creator/Designer Ethereal Realms martin@ethereal-realms.org ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Fri Nov 5 08:49:17 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 16D133A3AED for ; Fri, 5 Nov 2004 08:49:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09185-03 for ; Fri, 5 Nov 2004 08:49:08 +0000 (GMT) Received: from mail1.catalyst.net.nz (godel.catalyst.net.nz [202.49.159.12]) by svr1.postgresql.org (Postfix) with ESMTP id A6B1F3A3BC1 for ; Fri, 5 Nov 2004 08:49:08 +0000 (GMT) Received: from 222-152-154-34.jetstream.xtra.co.nz ([222.152.154.34] helo=lamb.mcmillan.net.nz) by mail1.catalyst.net.nz with asmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1CPzmJ-0006S8-7Y; Fri, 05 Nov 2004 21:49:03 +1300 Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) by lamb.mcmillan.net.nz (Postfix) with ESMTP id 4680DAD985AF; Fri, 5 Nov 2004 21:49:00 +1300 (NZDT) Subject: Re: Checking = with timestamp field is slow From: Andrew McMillan To: Antony Paul Cc: pgsql-performance@postgresql.org In-Reply-To: <2989532e0411042316566b35f4@mail.gmail.com> References: <2989532e0411042316566b35f4@mail.gmail.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-oaLdnswM0Iu9PCXFLzSs" Date: Fri, 05 Nov 2004 21:48:59 +1300 Message-Id: <1099644539.7326.346.camel@lamb.mcmillan.net.nz> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/91 X-Sequence-Number: 9045 --=-oaLdnswM0Iu9PCXFLzSs Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, 2004-11-05 at 12:46 +0530, Antony Paul wrote: > Hi all, > I have a table which have more than 200000 records. I need to get > the records which matches like this >=20 > where today::date =3D '2004-11-05'; >=20 > This is the only condition in the query. There is a btree index on the > column today. > Is there any way to optimise it. Hi Antony, I take it your field is called "today" (seems dodgy, but these things happen...). Anywa, have you tried indexing on the truncated value? create index xyz_date on xyz( today::date ); analyze xyz; That's one way. It depends on how many of those 200,000 rows are on each date too, as to whether it will get used by your larger query. Regards, Andrew. ------------------------------------------------------------------------- Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St DDI: +64(4)803-2201 MOB: +64(272)DEBIAN OFFICE: +64(4)499-2267 When in doubt, tell the truth. -- Mark Twain ------------------------------------------------------------------------- --=-oaLdnswM0Iu9PCXFLzSs Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQBBiz57jJA0f48GgBIRAj/MAKC9Pxsc6aRaXomhw/czj3MunJSA+wCgrMV9 LPIveQnVUx/reyz6DenTnzg= =GCx8 -----END PGP SIGNATURE----- --=-oaLdnswM0Iu9PCXFLzSs-- From pgsql-performance-owner@postgresql.org Fri Nov 5 09:13:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AA5FD3A3BFE for ; Fri, 5 Nov 2004 09:13:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17565-01 for ; Fri, 5 Nov 2004 09:13:11 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id BA6CD3A3B75 for ; Fri, 5 Nov 2004 09:13:12 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id iA59D6gN014786 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Nov 2004 02:13:08 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id iA59D6ot045308; Fri, 5 Nov 2004 02:13:06 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id iA59D6oK045307; Fri, 5 Nov 2004 02:13:06 -0700 (MST) (envelope-from mfuhr) Date: Fri, 5 Nov 2004 02:13:06 -0700 From: Michael Fuhr To: Michael Glaesemann Cc: Antony Paul , pgsql-performance@postgresql.org Subject: Re: Checking = with timestamp field is slow Message-ID: <20041105091306.GA45244@winnie.fuhr.org> References: <2989532e0411042316566b35f4@mail.gmail.com> <4704C044-2F05-11D9-BE4A-000A95C88220@myrealbox.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4704C044-2F05-11D9-BE4A-000A95C88220@myrealbox.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/92 X-Sequence-Number: 9046 On Fri, Nov 05, 2004 at 05:32:49PM +0900, Michael Glaesemann wrote: > > On Nov 5, 2004, at 5:14 PM, Michael Glaesemann wrote: > > > > >On Nov 5, 2004, at 4:16 PM, Antony Paul wrote: > >>where today::date = '2004-11-05'; > >> > >>This is the only condition in the query. There is a btree index on the > >>column today. > >>Is there any way to optimise it. > > > >I'm sure others out there have better ideas, but you might want to try > > > >where current_date = date '2004-11-05' > > Ach! just re-read that. today is one of your columns! Try > > where today::date = date '2004-11-05' Casting '2004-11-05' to DATE shouldn't be necessary, at least not in 7.4.5. test=> EXPLAIN ANALYZE SELECT * FROM foo WHERE today::DATE = '2004-11-05'; QUERY PLAN -------------------------------------------------------------------------------------------------- Seq Scan on foo (cost=0.00..268.00 rows=50 width=16) (actual time=0.592..50.854 rows=1 loops=1) Filter: ((today)::date = '2004-11-05'::date) As you can see, '2004-11-05' is already cast to DATE. The sequential scan is happening because there's no index on today::DATE. test=> CREATE INDEX foo_date_idx ON foo (DATE(today)); CREATE INDEX test=> EXPLAIN ANALYZE SELECT * FROM foo WHERE DATE(today) = '2004-11-05'; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------- Index Scan using foo_date_idx on foo (cost=0.00..167.83 rows=50 width=16) (actual time=0.051..0.061 rows=1 loops=1) Index Cond: (date(today) = '2004-11-05'::date) -- Michael Fuhr http://www.fuhr.org/~mfuhr/ From pgsql-performance-owner@postgresql.org Fri Nov 5 12:55:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 98F003A3C51 for ; Fri, 5 Nov 2004 12:54:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91206-03 for ; Fri, 5 Nov 2004 12:53:56 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 456703A3C3E for ; Fri, 5 Nov 2004 12:53:58 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iA5CrtJ7092419 for ; Fri, 5 Nov 2004 12:53:55 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iA5Co20Y091199 for pgsql-performance@postgresql.org; Fri, 5 Nov 2004 12:50:02 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Checking = with timestamp field is slow Date: Fri, 05 Nov 2004 07:47:54 -0500 Organization: cbbrowne Computing Inc Lines: 21 Message-ID: References: <2989532e0411042316566b35f4@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Cancel-Lock: sha1:s5VTkhBAHnD6cjO0VHLAIcYbZyU= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=MAILTO_TO_SPAM_ADDR X-Spam-Level: * X-Archive-Number: 200411/93 X-Sequence-Number: 9047 After a long battle with technology, antonypaul24@gmail.com (Antony Paul), an earthling, wrote: > Hi all, > I have a table which have more than 200000 records. I need to get > the records which matches like this > > where today::date = '2004-11-05'; > > This is the only condition in the query. There is a btree index on the > column today. > Is there any way to optimise it. How about changing the criterion to: where today between '2004-11-05' and '2004-11-06'; That ought to make use of the index on "today". -- "cbbrowne","@","ntlug.org" http://www.ntlug.org/~cbbrowne/sgml.html "People need to quit pretending they can invent THE interface and walk away from it, like some Deist fantasy." -- Michael Peck From pgsql-performance-owner@postgresql.org Fri Nov 5 14:39:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3F6DF3A3CC0 for ; Fri, 5 Nov 2004 14:39:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30681-04 for ; Fri, 5 Nov 2004 14:39:13 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.198]) by svr1.postgresql.org (Postfix) with ESMTP id EC77F3A3C95 for ; Fri, 5 Nov 2004 14:39:16 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 58so58594wri for ; Fri, 05 Nov 2004 06:39:16 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=OGBvXYMkJYEYLsk4Lm7Vzl2EBLK4kTP3/IEt5HCDiJndzGvSF/r+ZL5Ez4TbWfxAUDUfmlGcvrv1ZIstLT73dPB4K70KMat5XOveQ9NkKjEcK3kynE3jiw3OiWMpD5YES2HCqwSj670w6HqAJlvDpxaVdeK0mBGv2k++gMYEBRU= Received: by 10.54.21.71 with SMTP id 71mr22982wru; Fri, 05 Nov 2004 06:39:16 -0800 (PST) Received: by 10.54.43.36 with HTTP; Fri, 5 Nov 2004 06:39:16 -0800 (PST) Message-ID: <88f1825a041105063955367088@mail.gmail.com> Date: Fri, 5 Nov 2004 09:39:16 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: pgsql-performance@postgresql.org Subject: Strange (?) Index behavior? Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/94 X-Sequence-Number: 9048 Hey people, long while since I posted here, but I'm having an index issue that looks on the surface to be a little strange. I have a text field that I'm trying to query on in a table with millions of rows. Stupid I know, but a fairly common stupid thing to try to do. For some reason it's a requirement that partial wildcard searches are done on this field, such as "SELECT ... WHERE field LIKE 'A%'" I thought an interesting way to do this would be to simply create partial indexes for each letter on that field, and it works when the query matches the WHERE clause in the index exactly like above. The problem is thus: Say I have an index.. CREATE INDEX column_idx_a ON table (column) WHERE column LIKE 'A%' It seems to me that a query saying "SELECT column FROM table WHERE column LIKE 'AA%';" should be just as fast or very close to the first case up above. However, explain tells me that this query is not using the index above, which is what's not making sense to me. Does the planner not realize that 'AA%' will always fall between 'A%' and 'B', and thus that using the index would be the best way to go, or am I missing something else that's preventing this from working? From pgsql-performance-owner@postgresql.org Fri Nov 5 15:06:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4DEED3A3C89 for ; Fri, 5 Nov 2004 15:06:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41631-02 for ; Fri, 5 Nov 2004 15:06:36 +0000 (GMT) Received: from neptune.lgu.ac.uk (neptune.lgu.ac.uk [140.97.30.6]) by svr1.postgresql.org (Postfix) with ESMTP id B51793A3C75 for ; Fri, 5 Nov 2004 15:06:38 +0000 (GMT) Received: from solent (cal42-234.lgu.ac.uk [140.97.42.234]) by neptune.lgu.ac.uk (8.12.10/8.12.10) with ESMTP id iA5F6IO6028795; Fri, 5 Nov 2004 15:06:19 GMT Reply-To: From: "Matt Clark" To: "'Allen Landsidel'" , Subject: Re: Strange (?) Index behavior? Date: Fri, 5 Nov 2004 15:06:32 -0000 Organization: Ymogen Ltd Message-ID: <007a01c4c349$092cdae0$8300a8c0@solent> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 In-Reply-To: <88f1825a041105063955367088@mail.gmail.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Importance: Normal X-LGU-MailScanner: Found to be clean X-MailScanner-From: matt@ymogen.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/95 X-Sequence-Number: 9049 > For some reason it's a requirement that partial wildcard > searches are done on this field, such as "SELECT ... WHERE > field LIKE 'A%'" > > I thought an interesting way to do this would be to simply > create partial indexes for each letter on that field, and it > works when the query matches the WHERE clause in the index > exactly like above. The problem is thus: I thought PG could use an ordinary index for 'like' conditions with just a terminating '%'? My other thought is that like 'A%' should grab about 1/26th of the table anyway (if the initial character distribution is random), and so a sequential scan might be the best plan anyway... M From pgsql-performance-owner@postgresql.org Fri Nov 5 15:09:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 871F33A3B5F for ; Fri, 5 Nov 2004 15:09:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41189-04 for ; Fri, 5 Nov 2004 15:09:24 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 09A373A3B2A for ; Fri, 5 Nov 2004 15:09:27 +0000 (GMT) Received: from [134.22.69.212] (dyn-69-212.tor.dsl.tht.net [134.22.69.212]) by tht.net (Postfix) with ESMTP id 5E50376D74; Fri, 5 Nov 2004 10:09:04 -0500 (EST) Subject: Re: Strange (?) Index behavior? From: Rod Taylor To: Allen Landsidel Cc: Postgresql Performance In-Reply-To: <88f1825a041105063955367088@mail.gmail.com> References: <88f1825a041105063955367088@mail.gmail.com> Content-Type: text/plain Message-Id: <1099667258.1647.827.camel@home> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 05 Nov 2004 10:07:38 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/96 X-Sequence-Number: 9050 > It seems to me that a query saying "SELECT column FROM table WHERE > column LIKE 'AA%';" should be just as fast or very close to the first > case up above. However, explain tells me that this query is not using > the index above, which is what's not making sense to me. It looks for an exact expression match, and doesn't know about values which are equal. You can provide both clauses. WHERE column LIKE 'A%' and column LIKE 'AA%'; From pgsql-performance-owner@postgresql.org Fri Nov 5 15:32:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 269A63A3D1A for ; Fri, 5 Nov 2004 15:32:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50069-08 for ; Fri, 5 Nov 2004 15:32:40 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.201]) by svr1.postgresql.org (Postfix) with ESMTP id 510123A3CA7 for ; Fri, 5 Nov 2004 15:32:43 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 58so60137wri for ; Fri, 05 Nov 2004 07:32:44 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=Y3Fd8sVRdzRup6A0r84AEXTCOQ4WVoNWhLbYLlTS6POJvUKcu9uwzLiJpgpzKJ+V/EHjqyQECh112h1aMezy7a1QyIN0z+ibBe/2FLkhtdQ4nPLt+DKWu4H2kIAfv5UibQMw7e+6DWKuwR6elxG47uh2QJjPOh/PWcNBiNLPhis= Received: by 10.54.21.71 with SMTP id 71mr26832wru; Fri, 05 Nov 2004 07:32:44 -0800 (PST) Received: by 10.54.43.36 with HTTP; Fri, 5 Nov 2004 07:32:43 -0800 (PST) Message-ID: <88f1825a041105073245010974@mail.gmail.com> Date: Fri, 5 Nov 2004 10:32:43 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: Postgresql Performance Subject: Re: Strange (?) Index behavior? In-Reply-To: <1099667258.1647.827.camel@home> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105063955367088@mail.gmail.com> <1099667258.1647.827.camel@home> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/97 X-Sequence-Number: 9051 On Fri, 05 Nov 2004 10:07:38 -0500, Rod Taylor wrote: > > It seems to me that a query saying "SELECT column FROM table WHERE > > column LIKE 'AA%';" should be just as fast or very close to the first > > case up above. However, explain tells me that this query is not using > > the index above, which is what's not making sense to me. > > It looks for an exact expression match, and doesn't know about values > which are equal. > > You can provide both clauses. > > WHERE column LIKE 'A%' and column LIKE 'AA%'; I see. That's not really optimal either however as you can probably see already.. adding AB, AC, AD...AZ is likely to be pretty bogus and at the least is time consuming. Matt Clark was right that it will use a standard index, which is in fact what it's doing right now in the "SELECT column WHERE column LIKE 'AA%';" case.. however as I said, the table has millions of rows -- currently about 76 million, so even a full index scan is fairly slow. The machine isn't all that hot performance wise either, a simple dual 800 P3 with a single 47GB Seagate SCSI. The only redeeming factor is that it has 2GB of memory, which I'm trying to make the most of with these indexes. So assuming this partial index situation isn't going to change (it seems like it would be a fairly simple fix for someone that knows the pg code however) I'm wondering if a subselect may speed things up any, so I'm going to investigate that next. Perhaps.. SELECT column FROM (SELECT column FROM table WHERE column LIKE 'A%') AS sq WHERE column LIKE 'AA%'; The query planner thinks this will be pretty fast indeed, and does use the index I am after. OS is, of course, FreeBSD. From pgsql-performance-owner@postgresql.org Fri Nov 5 15:38:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EFE503A3D18 for ; Fri, 5 Nov 2004 15:34:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50397-10 for ; Fri, 5 Nov 2004 15:34:10 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 3CD3B3A3D28 for ; Fri, 5 Nov 2004 15:34:13 +0000 (GMT) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-class: urn:content-classes:message Subject: postgresql amd-64 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Fri, 5 Nov 2004 10:33:38 -0500 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7518@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: postgresql amd-64 Thread-Index: AcTDTNFJDztlvixxTeudjm2PQZ22gw== From: "Merlin Moncure" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/98 X-Sequence-Number: 9052 Does anybody have any experiences with postgresql 7.4+ running on amd-64 in 64 bit mode? Specifically, does it run quicker and if so do the performance benefits justify the extra headaches running 64 bit linux? Right now I'm building a dual Opteron 246 with 4 gig ddr400. =20 Merlin From pgsql-performance-owner@postgresql.org Fri Nov 5 16:54:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 45CAE3A3CF0 for ; Fri, 5 Nov 2004 16:54:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83257-04 for ; Fri, 5 Nov 2004 16:54:04 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.204]) by svr1.postgresql.org (Postfix) with ESMTP id 4C4593A3ACB for ; Fri, 5 Nov 2004 16:54:03 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 58so62895wri for ; Fri, 05 Nov 2004 08:54:03 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=SfORcWKfMxUphITcAQWsWS5Xmyi8+gUSxCESfPoHhtQXCI8tRdPm1VMsPYWtWBm5AmgqDuedCGsnLHbgYAJHdFm9rJtL6Um9Z10J41QSfkFHNSjHrSSRzmLf+umlCdSJOKmcsdHWhQ3cGIvNxmypASNWaG9+1qbQxOEwiDUrVJM= Received: by 10.54.21.14 with SMTP id 14mr83788wru; Fri, 05 Nov 2004 08:54:02 -0800 (PST) Received: by 10.54.43.36 with HTTP; Fri, 5 Nov 2004 08:54:02 -0800 (PST) Message-ID: <88f1825a0411050854417e1198@mail.gmail.com> Date: Fri, 5 Nov 2004 11:54:02 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: Postgresql Performance Subject: Re: Strange (?) Index behavior? In-Reply-To: <88f1825a041105073245010974@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105063955367088@mail.gmail.com> <1099667258.1647.827.camel@home> <88f1825a041105073245010974@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/99 X-Sequence-Number: 9053 On Fri, 5 Nov 2004 10:32:43 -0500, Allen Landsidel wrote: > On Fri, 05 Nov 2004 10:07:38 -0500, Rod Taylor wrote: > > > > > It seems to me that a query saying "SELECT column FROM table WHERE > > > column LIKE 'AA%';" should be just as fast or very close to the first > > > case up above. However, explain tells me that this query is not using > > > the index above, which is what's not making sense to me. > > > > It looks for an exact expression match, and doesn't know about values > > which are equal. > > > > You can provide both clauses. > > > > WHERE column LIKE 'A%' and column LIKE 'AA%'; > > I see. That's not really optimal either however as you can probably > see already.. adding AB, AC, AD...AZ is likely to be pretty bogus and > at the least is time consuming. I see now that you mean to add that to the SELECT clause and not the index, my mistake. > Perhaps.. SELECT column FROM (SELECT column FROM table WHERE column > LIKE 'A%') AS sq WHERE column LIKE 'AA%'; > > The query planner thinks this will be pretty fast indeed, and does use > the index I am after. This was indeed pretty fast. About 7 seconds, as was modifying the WHERE as suggested above. -Allen From pgsql-performance-owner@postgresql.org Fri Nov 5 17:46:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 48A4E3A3E44 for ; Fri, 5 Nov 2004 17:45:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02927-05 for ; Fri, 5 Nov 2004 17:45:46 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id C5F453A3E33 for ; Fri, 5 Nov 2004 17:45:45 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id iA5HjYNo000223 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Nov 2004 10:45:37 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id iA5HjYtr000807; Fri, 5 Nov 2004 10:45:34 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id iA5HjY2n000806; Fri, 5 Nov 2004 10:45:34 -0700 (MST) (envelope-from mfuhr) Date: Fri, 5 Nov 2004 10:45:34 -0700 From: Michael Fuhr To: Christopher Browne Cc: pgsql-performance@postgresql.org Subject: Re: Checking = with timestamp field is slow Message-ID: <20041105174534.GA685@winnie.fuhr.org> References: <2989532e0411042316566b35f4@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/101 X-Sequence-Number: 9055 On Fri, Nov 05, 2004 at 07:47:54AM -0500, Christopher Browne wrote: > > How about changing the criterion to: > > where today between '2004-11-05' and '2004-11-06'; > > That ought to make use of the index on "today". Yes it should, but it'll also return records that have a "today" value of '2004-11-06 00:00:00' since "x BETWEEN y AND z" is equivalent to "x >= y AND x <= z". Try this instead: WHERE today >= '2004-11-05' AND today < '2004-11-06' In another post I suggested creating an index on DATE(today). The above query should make that unnecessary, although in 8.0 such an index would be used in queries like this: WHERE today IN ('2004-09-01', '2004-10-01', '2004-11-01'); -- Michael Fuhr http://www.fuhr.org/~mfuhr/ From pgsql-performance-owner@postgresql.org Fri Nov 5 17:42:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4FE463A3E14 for ; Fri, 5 Nov 2004 17:40:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99998-07 for ; Fri, 5 Nov 2004 17:40:48 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 1326C3A3E03 for ; Fri, 5 Nov 2004 17:40:47 +0000 (GMT) Received: (qmail 15874 invoked by uid 500); 5 Nov 2004 17:51:59 -0000 Date: Fri, 5 Nov 2004 11:51:59 -0600 From: Bruno Wolff III To: Allen Landsidel Cc: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? Message-ID: <20041105175159.GB8855@wolff.to> Mail-Followup-To: Allen Landsidel , pgsql-performance@postgresql.org References: <88f1825a041105063955367088@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <88f1825a041105063955367088@mail.gmail.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/100 X-Sequence-Number: 9054 On Fri, Nov 05, 2004 at 09:39:16 -0500, Allen Landsidel wrote: > > For some reason it's a requirement that partial wildcard searches are > done on this field, such as "SELECT ... WHERE field LIKE 'A%'" > > I thought an interesting way to do this would be to simply create > partial indexes for each letter on that field, and it works when the > query matches the WHERE clause in the index exactly like above. The > problem is thus: That may not help much except for prefixes that have a below average number of occurences. If you are going to be select 1/26 of the records, you are probably going to do about as well with a sequential scan as an index scan. Just having a normal index on the column will work if the database locale is C. In 7.4 you can create an index usable by LIKE even in the database locale isn't C, but I don't remember the exact syntax. You will be better off having just one index rather than 26 partial indexes. From pgsql-performance-owner@postgresql.org Fri Nov 5 17:56:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 124E63A3D50 for ; Fri, 5 Nov 2004 17:56:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06804-08 for ; Fri, 5 Nov 2004 17:56:49 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.193]) by svr1.postgresql.org (Postfix) with ESMTP id 690BC3A3D27 for ; Fri, 5 Nov 2004 17:56:48 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 58so64856wri for ; Fri, 05 Nov 2004 09:56:47 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=e60T/GclOvtHi7IRipWBaHn7EzFOAJDsqnpsP7+MQXktq8ELC1NxLcMW2OTJ82fFxqhl5PkxKSiUdbgIYH97aKJJg1YJu26DpoRsAPtTZDN9NPN3YFM8ZWOMC5VQTjwlwBBigT2Ti+OG3dkjZlfQK6eF1BTYqszyBA+rHaLnzEk= Received: by 10.54.21.14 with SMTP id 14mr89096wru; Fri, 05 Nov 2004 09:56:47 -0800 (PST) Received: by 10.54.43.36 with HTTP; Fri, 5 Nov 2004 09:56:47 -0800 (PST) Message-ID: <88f1825a041105095631064cb0@mail.gmail.com> Date: Fri, 5 Nov 2004 12:56:47 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-Reply-To: <20041105175159.GB8855@wolff.to> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105063955367088@mail.gmail.com> <20041105175159.GB8855@wolff.to> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/102 X-Sequence-Number: 9056 On Fri, 5 Nov 2004 11:51:59 -0600, Bruno Wolff III wrote: > On Fri, Nov 05, 2004 at 09:39:16 -0500, > Allen Landsidel wrote: > > > > For some reason it's a requirement that partial wildcard searches are > > done on this field, such as "SELECT ... WHERE field LIKE 'A%'" > > > > I thought an interesting way to do this would be to simply create > > partial indexes for each letter on that field, and it works when the > > query matches the WHERE clause in the index exactly like above. The > > problem is thus: > > That may not help much except for prefixes that have a below average > number of occurences. If you are going to be select 1/26 of the records, > you are probably going to do about as well with a sequential scan as an > index scan. The thing isn't that I want 1/26th of the records since the distribution is not exactly equal among different letters, but more importantly, there are about 76million rows currently, and for some reason I am being told by the people with the pointy hair that a query like "select foo,bar from table where foo like 'abc%';" is not an uncommon type of query to run. I don't know why it's common and to be honest, I'm afraid to ask. ;) With that many rows, and a normal index on the field, postgres figures the best option for say "I%" is not an index scan, but a sequential scan on the table, with a filter -- quite obviously this is slow as heck, and yes, I've run analyze several times and in fact have the vacuum analyze automated. With the partial index the index scan is used and the cost drops from 0..2million to 0..9000 -- a vast improvement. So I'm going to go with the partial indexes, and have a total of 36 of them -- A-Z and 0-9. > Just having a normal index on the column will work if the database locale > is C. In 7.4 you can create an index usable by LIKE even in the database > locale isn't C, but I don't remember the exact syntax. You will be better > off having just one index rather than 26 partial indexes. I haven't written a line of C in years, and it was never my strong suit, so despite all my years doing development and sysadminning, the locale stuff is still something of a mystery to me. The locale though is C, the default, and will for the time being at least be storing only ascii strings -- no unicode, other character sets, or anything funky like that. -Allen From pgsql-performance-owner@postgresql.org Fri Nov 5 18:10:02 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 612FF3A3E1A for ; Fri, 5 Nov 2004 18:09:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08549-07 for ; Fri, 5 Nov 2004 18:09:28 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.197]) by svr1.postgresql.org (Postfix) with ESMTP id AC05A3A3D6B for ; Fri, 5 Nov 2004 18:09:27 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a41so97259rng for ; Fri, 05 Nov 2004 10:09:27 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=gUELQeBjk24efWyMLNana4c8JBG28oed0gPVNRYMt7gvWiAoB2DMjHWPoS7+vBd7lRjI8lkAT2rYWlBFPI6Sojq8E+v2kP+h1GxnC9ckBUvqeoVMOJiZ3GzsiHW8Pbbxkfzlj4+q0VbECPHcuet54qFILSfN5b2UZiv/XG+HOL8= Received: by 10.38.207.79 with SMTP id e79mr474043rng; Fri, 05 Nov 2004 10:09:26 -0800 (PST) Received: by 10.38.165.32 with HTTP; Fri, 5 Nov 2004 10:09:26 -0800 (PST) Message-ID: <27c475ec0411051009460dd9d0@mail.gmail.com> Date: Fri, 5 Nov 2004 13:09:26 -0500 From: Matt Nuzum Reply-To: matt@followers.net To: Postgresql Performance Subject: What is the difference between these? Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/103 X-Sequence-Number: 9057 To me, these three queries seem identical... why doesn't the first one (simplest to understand and write) go the same speed as the third one? I'll I'm trying to do is get statistics for one day (in this case, today) summarized. Table has ~25M rows. I'm using postgres 7.3.? on rh linux 7.3 (note that i think the difference between the first two might just be related to the data being in memory for the second query). EXPLAIN ANALYZE select count(distinct sessionid) from usage_access where atime > date_trunc('day', now()); QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=933439.69..933439.69 rows=1 width=4) (actual time=580350.43..580350.43 rows=1 loops=1) -> Seq Scan on usage_access (cost=0.00..912400.11 rows=8415831 width=4) (actual time=580164.48..580342.21 rows=2964 loops=1) Filter: (atime > date_trunc('day'::text, now())) Total runtime: 580350.65 msec (4 rows) EXPLAIN ANALYZE select count(distinct sessionid) from (select * from usage_access where atime > date_trunc('day', now())) as temp; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=933439.69..933439.69 rows=1 width=4) (actual time=348012.85..348012.85 rows=1 loops=1) -> Seq Scan on usage_access (cost=0.00..912400.11 rows=8415831 width=4) (actual time=347960.53..348004.68 rows=2964 loops=1) Filter: (atime > date_trunc('day'::text, now())) Total runtime: 348013.10 msec (4 rows) EXPLAIN ANALYZE select count(distinct sessionid) from usage_access where atime between date_trunc('day', now()) and date_trunc('day', now()) + '1 day'::interval; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=89324.98..89324.98 rows=1 width=4) (actual time=27.84..27.84 rows=1 loops=1) -> Index Scan using usage_access_atime on usage_access (cost=0.00..89009.39 rows=126237 width=4) (actual time=0.51..20.37 rows=2964 loops=1) Index Cond: ((atime >= date_trunc('day'::text, now())) AND (atime <= (date_trunc('day'::text, now()) + '1 day'::interval))) Total runtime: 28.11 msec (4 rows) -- Matthew Nuzum | Makers of "Elite Content Management System" www.followers.net | View samples of Elite CMS in action matt@followers.net | http://www.followers.net/portfolio/ From pgsql-performance-owner@postgresql.org Fri Nov 5 18:23:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 896483A3BE0 for ; Fri, 5 Nov 2004 18:23:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13979-10 for ; Fri, 5 Nov 2004 18:23:21 +0000 (GMT) Received: from mail.3gstech.com (ns1.mcdownloads.com [216.239.132.98]) by svr1.postgresql.org (Postfix) with ESMTP id 9A7123A3E07 for ; Fri, 5 Nov 2004 18:23:21 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.3gstech.com (Postfix) with ESMTP id 7FC81A16FC5; Fri, 5 Nov 2004 10:23:20 -0800 (PST) Received: from mail.3gstech.com ([127.0.0.1]) by localhost (fungus [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 08201-03; Fri, 5 Nov 2004 10:23:20 -0800 (PST) Received: from [216.239.128.141] (daniel.omnis.com [216.239.128.141]) by mail.3gstech.com (Postfix) with ESMTP id 656E8A16FC4; Fri, 5 Nov 2004 10:23:20 -0800 (PST) Message-ID: <418BC518.2050909@omnis.com> Date: Fri, 05 Nov 2004 10:23:20 -0800 From: Daniel Ceregatti Organization: Omnis Network User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040916 MultiZilla/1.6.3.1a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Merlin Moncure Cc: pgsql-performance@postgresql.org Subject: Re: postgresql amd-64 References: <6EE64EF3AB31D5448D0007DD34EEB3412A7518@Herge.rcsinc.local> In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A7518@Herge.rcsinc.local> X-Enigmail-Version: 0.86.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/104 X-Sequence-Number: 9058 I have two dual opteron 248's with 4g of ram each, 6x36G 15k rpm ultra 320 scsi disks in hardware raid 5, and they are by far the fastest machines I've user used. As far as this "headache" of using 64 bit Linux, I've experienced no such thing. I'm using gentoo on both machines, which are dedicated for postgres 7.4 and replicated with slony. They're both quite fast and reliable. One machine even runs a secondary instance of pg, pg 8 beta4 in this case, for development, which also runs quite well. Daniel Merlin Moncure wrote: >Does anybody have any experiences with postgresql 7.4+ running on amd-64 >in 64 bit mode? Specifically, does it run quicker and if so do the >performance benefits justify the extra headaches running 64 bit linux? > >Right now I'm building a dual Opteron 246 with 4 gig ddr400. > >Merlin > >---------------------------(end of broadcast)--------------------------- >TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html > > -- Daniel Ceregatti - Programmer Omnis Network, LLC The forest is safe because a lion lives therein and the lion is safe because it lives in a forest. Likewise the friendship of persons rests on mutual help. -- Laukikanyay. From pgsql-performance-owner@postgresql.org Fri Nov 5 18:26:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E26023A3E36 for ; Fri, 5 Nov 2004 18:26:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16979-01 for ; Fri, 5 Nov 2004 18:26:01 +0000 (GMT) Received: from web52107.mail.yahoo.com (web52107.mail.yahoo.com [206.190.39.76]) by svr1.postgresql.org (Postfix) with SMTP id 2DB443A3E27 for ; Fri, 5 Nov 2004 18:26:01 +0000 (GMT) Message-ID: <20041105182600.18215.qmail@web52107.mail.yahoo.com> Received: from [198.182.200.22] by web52107.mail.yahoo.com via HTTP; Fri, 05 Nov 2004 10:26:00 PST Date: Fri, 5 Nov 2004 10:26:00 -0800 (PST) From: patrick ~ Subject: Re: vacuum analyze slows sql query To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/105 X-Sequence-Number: 9059 Just wanted to know if there were any insights after looking at requested 'explain analyze select ...'? Thanks, --patrick __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com From pgsql-performance-owner@postgresql.org Fri Nov 5 18:34:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 183643A2B27 for ; Fri, 5 Nov 2004 18:34:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17885-08 for ; Fri, 5 Nov 2004 18:34:19 +0000 (GMT) Received: from neptune.lgu.ac.uk (neptune.lgu.ac.uk [140.97.30.6]) by svr1.postgresql.org (Postfix) with ESMTP id D30453A202A for ; Fri, 5 Nov 2004 18:34:18 +0000 (GMT) Received: from solent (cal42-234.lgu.ac.uk [140.97.42.234]) by neptune.lgu.ac.uk (8.12.10/8.12.10) with ESMTP id iA5IYAO6009354; Fri, 5 Nov 2004 18:34:10 GMT Reply-To: From: "Matt Clark" To: "'Allen Landsidel'" , Subject: Re: Strange (?) Index behavior? Date: Fri, 5 Nov 2004 18:34:23 -0000 Organization: Ymogen Ltd Message-ID: <008401c4c366$127d5260$8300a8c0@solent> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 In-Reply-To: <88f1825a041105095631064cb0@mail.gmail.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Importance: Normal X-LGU-MailScanner: Found to be clean X-MailScanner-From: matt@ymogen.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/106 X-Sequence-Number: 9060 > With that many rows, and a normal index on the field,=20 > postgres figures the best option for say "I%" is not an index=20 > scan, but a sequential scan on the table, with a filter --=20 > quite obviously this is slow as heck, and yes, I've run=20 > analyze several times and in fact have the vacuum analyze automated. Ah, so "like 'I%'" uses a very slow seq scan, but "like 'ABC%'" uses an ordinary index OK? If so then... The planner would usually assume (from what Tom usually says) that 1/26 selectivity isn't worth doing an index scan for, but in your case it's = wrong (maybe because the rows are very big?) You may be able to get the planner to go for an index scan on "like = 'I%'" by tweaking the foo_cost variables in postgresql.conf=20 Or you could have the app rewrite "like 'I%'" to "like 'IA%' or like = 'IB%' ... ", or do that as a stored proc. > With the partial index the index scan is used and the cost=20 > drops from 0..2million to 0..9000 -- a vast improvement. So there are really only 9000 rows out of 76 million starting with 'I'? = How about combining some techniques - you could create an index on the first = two chars of the field (should be selective enough to give an index scan), select from that, and select the actual data with the like clause. CREATE INDEX idx_firstletters ON table (substr(field, 1, 2)); CREATE INDEX idx_all ON table (field); SELECT field FROM (SELECT field FROM table WHERE substr(field, 1, 2) =3D = 'DE') AS approx WHERE field LIKE 'DE%'; Any good? From pgsql-performance-owner@postgresql.org Fri Nov 5 19:44:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9659A3A3E69 for ; Fri, 5 Nov 2004 19:44:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38319-04 for ; Fri, 5 Nov 2004 19:44:24 +0000 (GMT) Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) by svr1.postgresql.org (Postfix) with ESMTP id B5A2F3A3E53 for ; Fri, 5 Nov 2004 19:44:24 +0000 (GMT) Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] helo=[192.168.0.66]) by outbound.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.42) id 1CQA0V-000Peg-Ka; Fri, 05 Nov 2004 14:44:24 -0500 Message-ID: <418BD811.7020706@zeut.net> Date: Fri, 05 Nov 2004 14:44:17 -0500 From: "Matthew T. O'Connor" Organization: Terrie O'Connor Realtors User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: matt@followers.net Cc: Postgresql Performance Subject: Re: What is the difference between these? References: <27c475ec0411051009460dd9d0@mail.gmail.com> In-Reply-To: <27c475ec0411051009460dd9d0@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mail-Handler: MailHop Outbound by DynDNS.org X-Originating-IP: 67.80.199.173 X-Report-Abuse-To: abuse@dyndns.org (see http://www.mailhop.org/outbound/abuse.html for abuse reporting information) X-MHO-User: zeut X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/107 X-Sequence-Number: 9061 Matt Nuzum wrote: >To me, these three queries seem identical... why doesn't the first one >(simplest to understand and write) go the same speed as the third one? > > If you look at the explain output, you will notice that only the 3rd query is using an Index Scan, where as the 1st and 2nd are doing a sequential scan over the entire table of 25M rows. My guess is that the problem is related to outdated statistics on the atime column. If you notice the 1st and 2nd queries estimate 8.4M rows returned at which point a seq scan is the right choice, but the 3rd query using the between statement only estimates 127k rows which make the Index a better option. All of these queries only return 2964 rows so it looks like your stats are out of date. Try running an analyze command right before doing any of these queries and see what happens. >I'll I'm trying to do is get statistics for one day (in this case, >today) summarized. Table has ~25M rows. I'm using postgres 7.3.? on >rh linux 7.3 (note that i think the difference between the first two >might just be related to the data being in memory for the second >query). > > > EXPLAIN ANALYZE > select count(distinct sessionid) from usage_access where atime > >date_trunc('day', now()); > QUERY PLAN >---------------------------------------------------------------------------------------------------------------------------------- > Aggregate (cost=933439.69..933439.69 rows=1 width=4) (actual >time=580350.43..580350.43 rows=1 loops=1) > -> Seq Scan on usage_access (cost=0.00..912400.11 rows=8415831 >width=4) (actual time=580164.48..580342.21 rows=2964 loops=1) > Filter: (atime > date_trunc('day'::text, now())) > Total runtime: 580350.65 msec >(4 rows) > > > EXPLAIN ANALYZE > select count(distinct sessionid) from (select * from usage_access >where atime > date_trunc('day', now())) as temp; > QUERY PLAN >---------------------------------------------------------------------------------------------------------------------------------- > Aggregate (cost=933439.69..933439.69 rows=1 width=4) (actual >time=348012.85..348012.85 rows=1 loops=1) > -> Seq Scan on usage_access (cost=0.00..912400.11 rows=8415831 >width=4) (actual time=347960.53..348004.68 rows=2964 loops=1) > Filter: (atime > date_trunc('day'::text, now())) > Total runtime: 348013.10 msec >(4 rows) > > > EXPLAIN ANALYZE > select count(distinct sessionid) from usage_access where atime >between date_trunc('day', now()) and date_trunc('day', now()) + '1 >day'::interval; > QUERY PLAN >-------------------------------------------------------------------------------------------------------------------------------------------------- > Aggregate (cost=89324.98..89324.98 rows=1 width=4) (actual >time=27.84..27.84 rows=1 loops=1) > -> Index Scan using usage_access_atime on usage_access >(cost=0.00..89009.39 rows=126237 width=4) (actual time=0.51..20.37 >rows=2964 loops=1) > Index Cond: ((atime >= date_trunc('day'::text, now())) AND >(atime <= (date_trunc('day'::text, now()) + '1 day'::interval))) > Total runtime: 28.11 msec >(4 rows) > > > From pgsql-performance-owner@postgresql.org Fri Nov 5 19:58:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 990F43A3D33 for ; Fri, 5 Nov 2004 19:57:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41904-04 for ; Fri, 5 Nov 2004 19:57:49 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7FCB63A3E6B for ; Fri, 5 Nov 2004 19:57:50 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA5JveOe010899; Fri, 5 Nov 2004 14:57:41 -0500 (EST) To: Allen Landsidel Cc: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-reply-to: <88f1825a041105095631064cb0@mail.gmail.com> References: <88f1825a041105063955367088@mail.gmail.com> <20041105175159.GB8855@wolff.to> <88f1825a041105095631064cb0@mail.gmail.com> Comments: In-reply-to Allen Landsidel message dated "Fri, 05 Nov 2004 12:56:47 -0500" Date: Fri, 05 Nov 2004 14:57:40 -0500 Message-ID: <10898.1099684660@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/108 X-Sequence-Number: 9062 Allen Landsidel writes: > With that many rows, and a normal index on the field, postgres figures > the best option for say "I%" is not an index scan, but a sequential > scan on the table, with a filter -- quite obviously this is slow as > heck, and yes, I've run analyze several times and in fact have the > vacuum analyze automated. > With the partial index the index scan is used and the cost drops from > 0..2million to 0..9000 -- a vast improvement. Hmm. This suggests to me that you're using a non-C locale and so a plain index *can't* be used for a LIKE query. Can you force it to use an indexscan by setting enable_seqscan = false? If not then you've got a locale problem. As someone else pointed out, this can be worked around by creating an index with the right operator class. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Nov 5 20:33:17 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 303793A3E76 for ; Fri, 5 Nov 2004 20:32:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51111-06 for ; Fri, 5 Nov 2004 20:32:32 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9DD673A3E5F for ; Fri, 5 Nov 2004 20:32:31 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA5KWSYa011492; Fri, 5 Nov 2004 15:32:29 -0500 (EST) To: matt@followers.net Cc: Postgresql Performance Subject: Re: What is the difference between these? In-reply-to: <27c475ec0411051009460dd9d0@mail.gmail.com> References: <27c475ec0411051009460dd9d0@mail.gmail.com> Comments: In-reply-to Matt Nuzum message dated "Fri, 05 Nov 2004 13:09:26 -0500" Date: Fri, 05 Nov 2004 15:32:28 -0500 Message-ID: <11491.1099686748@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/109 X-Sequence-Number: 9063 Matt Nuzum writes: > To me, these three queries seem identical... why doesn't the first one > (simplest to understand and write) go the same speed as the third one? This is the standard problem that the planner has to guess about the selectivity of inequalities involving non-constants (like now()). The guesses are set up so that a one-sided inequality will use a seqscan while a range constraint will use an indexscan. See the pgsql-performance archives for other ways of persuading it that an indexscan is a good idea. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Nov 5 20:36:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2EC6A3A3E1D for ; Fri, 5 Nov 2004 20:36:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52599-01 for ; Fri, 5 Nov 2004 20:36:28 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.206]) by svr1.postgresql.org (Postfix) with ESMTP id D25D43A3C1E for ; Fri, 5 Nov 2004 20:36:28 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 58so70103wri for ; Fri, 05 Nov 2004 12:36:28 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=DXWH6pIgaJVBgDXyEyTcoDj5zUVLWcmca4T9On7+uLP9P0KOZ1d4hUVZZxTHIlV+rVmd+mx5wxB/DQumEUXllAdbIUzuU5d2qE0KYmbjNk3B08pRezwCbssK6QZqaTATrcLgUb/RhcsR3g3zrBdpdG0R8onvIv5Qahr6+5KXGiE= Received: by 10.54.21.61 with SMTP id 61mr80683wru; Fri, 05 Nov 2004 12:36:28 -0800 (PST) Received: by 10.54.43.36 with HTTP; Fri, 5 Nov 2004 12:36:28 -0800 (PST) Message-ID: <88f1825a0411051236497f6bbf@mail.gmail.com> Date: Fri, 5 Nov 2004 15:36:28 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-Reply-To: <10898.1099684660@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105063955367088@mail.gmail.com> <20041105175159.GB8855@wolff.to> <88f1825a041105095631064cb0@mail.gmail.com> <10898.1099684660@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/110 X-Sequence-Number: 9064 On Fri, 05 Nov 2004 14:57:40 -0500, Tom Lane wrote: > Allen Landsidel writes: > > With that many rows, and a normal index on the field, postgres figures > > the best option for say "I%" is not an index scan, but a sequential > > scan on the table, with a filter -- quite obviously this is slow as > > heck, and yes, I've run analyze several times and in fact have the > > vacuum analyze automated. > > With the partial index the index scan is used and the cost drops from > > 0..2million to 0..9000 -- a vast improvement. > > Hmm. This suggests to me that you're using a non-C locale and so a > plain index *can't* be used for a LIKE query. Can you force it to use > an indexscan by setting enable_seqscan = false? If not then you've got > a locale problem. As someone else pointed out, this can be worked > around by creating an index with the right operator class. Tom, disabling seqscan does cause it to use the index. With seqscan enabled however, "AB%" will use the index, but "A%" will not. The estimated cost for the query is much higher without the partial indexes than it is with them, and the actual runtime of the query is definitely longer without the partial indexes. The locale is set in the postgresql.conf file as per default, with.. # These settings are initialized by initdb -- they may 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 -Allen From pgsql-performance-owner@postgresql.org Fri Nov 5 21:00:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 05DFD3A202A for ; Fri, 5 Nov 2004 21:00:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59326-04 for ; Fri, 5 Nov 2004 21:00:15 +0000 (GMT) Received: from vsmtp3.tin.it (vsmtp3alice.tin.it [212.216.176.143]) by svr1.postgresql.org (Postfix) with ESMTP id 35C513A3E7A for ; Fri, 5 Nov 2004 21:00:16 +0000 (GMT) Received: from angus.tin.it (82.51.70.133) by vsmtp3.tin.it (7.0.027) id 4183C0F6002CD462 for pgsql-performance@postgresql.org; Fri, 5 Nov 2004 22:00:17 +0100 Message-Id: <6.1.2.0.2.20041105220007.03401ec0@box.tin.it> X-Sender: angusgb@box.tin.it (Unverified) X-Mailer: QUALCOMM Windows Eudora Version 6.1.2.0 Date: Fri, 05 Nov 2004 22:00:16 +0100 To: "Postgresql Performance" From: Gabriele Bartolini Subject: Question regarding the file system Mime-Version: 1.0 Content-Type: multipart/mixed; x-avg-checked=avg-ok-68BC2236; boundary="=======1C6B1C17=======" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/111 X-Sequence-Number: 9065 --=======1C6B1C17======= Content-Type: text/plain; x-avg-checked=avg-ok-68BC2236; charset=us-ascii; format=flowed Content-Transfer-Encoding: 8bit Hi guys, I have been given a dual PIII with 768MB RAM and I am going to install PostgreSQL on it, for data warehousing reasons. I have also been given four 160 Ultra SCSI disks (36MB each) with a RAID controller (Adaptec 2100). I am going to use a RAID5 architecture (this gives me approximately 103 GB of data) and install a Debian Linux on it: this machine will be dedicated exclusively to PostgreSQL. I was wondering which file system you suggest me: ext3 or reiserfs? Also, I was thinking of using the 2.6.x kernel which offers a faster thread support: will PostgreSQL gain anything from it or should I stick with 2.4.x? Thank you very much, -Gabriele -- Gabriele Bartolini: Web Programmer, ht://Dig & IWA/HWG Member, ht://Check maintainer Current Location: Prato, Toscana, Italia angusgb@tin.it | http://www.prato.linux.it/~gbartolini | ICQ#129221447 > "Leave every hope, ye who enter!", Dante Alighieri, Divine Comedy, The Inferno --=======1C6B1C17======= Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-68BC2236 Content-Disposition: inline --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.788 / Virus Database: 533 - Release Date: 01/11/2004 --=======1C6B1C17=======-- From pgsql-performance-owner@postgresql.org Fri Nov 5 21:03:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 782853A3E83 for ; Fri, 5 Nov 2004 21:02:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60742-01 for ; Fri, 5 Nov 2004 21:02:45 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.196]) by svr1.postgresql.org (Postfix) with ESMTP id E3ED23A3E39 for ; Fri, 5 Nov 2004 21:02:46 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 58so70875wri for ; Fri, 05 Nov 2004 13:02:43 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=XqaLFQnXPiv8BEB5fij9ovPGHDoKr70wtdrnVGl/5ZR0tvdc6c4aji1BNCJaNcYxAqFwXh7vxhARmB8YMXRwhyj6Z3xuEDo80nZzbn7BM0aIqrKpfm6NLrwS3Eut/+/EEUDu2UN8nygPACeIDvvlu5rsPbp/t0AX4UNVaXaJhI8= Received: by 10.54.21.71 with SMTP id 71mr54360wru; Fri, 05 Nov 2004 13:02:43 -0800 (PST) Received: by 10.54.43.36 with HTTP; Fri, 5 Nov 2004 13:02:43 -0800 (PST) Message-ID: <88f1825a04110513028759dd3@mail.gmail.com> Date: Fri, 5 Nov 2004 16:02:43 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-Reply-To: <008401c4c366$127d5260$8300a8c0@solent> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105095631064cb0@mail.gmail.com> <008401c4c366$127d5260$8300a8c0@solent> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/112 X-Sequence-Number: 9066 On Fri, 5 Nov 2004 18:34:23 -0000, Matt Clark wrote: > > With that many rows, and a normal index on the field, > > postgres figures the best option for say "I%" is not an index > > scan, but a sequential scan on the table, with a filter -- > > quite obviously this is slow as heck, and yes, I've run > > analyze several times and in fact have the vacuum analyze automated. > > Ah, so "like 'I%'" uses a very slow seq scan, but "like 'ABC%'" uses an > ordinary index OK? If so then... That is correct. > The planner would usually assume (from what Tom usually says) that 1/26 > selectivity isn't worth doing an index scan for, but in your case it's wrong > (maybe because the rows are very big?) The rows aren't big, it's a text field, a few ints, and a few timestamps. That's all. The text field is the one we're querying on here and lengthwise it's typically not over 32 chars. > You may be able to get the planner to go for an index scan on "like 'I%'" by > tweaking the foo_cost variables in postgresql.conf That's true but I'd rather not, there are times when the seqscan will have a faster net result (for other queries) and I'd rather not have them suffer. > Or you could have the app rewrite "like 'I%'" to "like 'IA%' or like 'IB%' > ... ", or do that as a stored proc. Holy cow. Yeah that seems a little outrageous. It would be cleaner looking in "\d table" than having all these indexes at the cost of having one very ugly query. > > With the partial index the index scan is used and the cost > > drops from 0..2million to 0..9000 -- a vast improvement. > > So there are really only 9000 rows out of 76 million starting with 'I'? How > about combining some techniques - you could create an index on the first two > chars of the field (should be selective enough to give an index scan), > select from that, and select the actual data with the like clause. I was talking about the cost, not the number of rows. About 74,000 rows are returned but the query only takes about 8 seconds to run. -- with the partial index in place. > CREATE INDEX idx_firstletters ON table (substr(field, 1, 2)); > CREATE INDEX idx_all ON table (field); > SELECT field FROM (SELECT field FROM table WHERE substr(field, 1, 2) = 'DE') > AS approx WHERE field LIKE 'DE%'; That looks like a pretty slick way to create an index, I didn't know there was such a way to do it.. but It appears that this will not work with queries where the WHERE clause wants to find substrings longer than 2 characters. I will give it a try and see how it goes though I think I'm fairly "settled" on creating all the other indexes, unless there is some specific reason I shouldn't -- they are used in all cases where the substring is >= 1 character, so long as I make sure the first where clause (or inner select in a subquery) is the most ambiguous from an index standpoint. Going back to the initial problem -- having only one large, complete index on the table (no partial indexes) the query "SELECT field FROM table WHERE field LIKE 'A%';" does not use the index. The query "SELECT field FROM table WHERE field LIKE 'AB%';" however, does use the single large index if it exists. Adding the partial index "CREATE INDEX idx_table_substrfield_A ON table (field) WHERE field LIKE 'A%';" causes all queries with substrings of any length to do index scans.provided I issue the query as: SELECT field FROM table WHERE field LIKE 'A%' AND field LIKE 'AB%'; -- or even -- SELECT field FROM table WHERE field LIKE 'A%'; The latter query, without the partial index described, does a sequential scan on the table itself instead of an index scan. -Allen From pgsql-performance-owner@postgresql.org Fri Nov 5 21:10:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C1D303A3E77 for ; Fri, 5 Nov 2004 21:09:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62285-04 for ; Fri, 5 Nov 2004 21:09:03 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6286F3A202A for ; Fri, 5 Nov 2004 21:09:03 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA5L8ub1012856; Fri, 5 Nov 2004 16:08:56 -0500 (EST) To: Allen Landsidel Cc: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-reply-to: <88f1825a0411051236497f6bbf@mail.gmail.com> References: <88f1825a041105063955367088@mail.gmail.com> <20041105175159.GB8855@wolff.to> <88f1825a041105095631064cb0@mail.gmail.com> <10898.1099684660@sss.pgh.pa.us> <88f1825a0411051236497f6bbf@mail.gmail.com> Comments: In-reply-to Allen Landsidel message dated "Fri, 05 Nov 2004 15:36:28 -0500" Date: Fri, 05 Nov 2004 16:08:56 -0500 Message-ID: <12855.1099688936@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/113 X-Sequence-Number: 9067 Allen Landsidel writes: > With seqscan enabled however, "AB%" will use the index, but "A%" will not. > The estimated cost for the query is much higher without the partial > indexes than it is with them, and the actual runtime of the query is > definitely longer without the partial indexes. OK. This suggests that the planner is drastically misestimating the selectivity of the 'A%' clause, which seems odd to me since in principle it could get that fairly well from the ANALYZE histogram. But it could well be that you need to increase the resolution of the histogram --- see ALTER TABLE SET STATISTICS. Did you ever show us EXPLAIN ANALYZE results for this query? regards, tom lane From pgsql-performance-owner@postgresql.org Fri Nov 5 21:18:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2F25C3A3E39 for ; Fri, 5 Nov 2004 21:17:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63467-06 for ; Fri, 5 Nov 2004 21:17:44 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id C5FF53A3C1E for ; Fri, 5 Nov 2004 21:17:44 +0000 (GMT) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-class: urn:content-classes:message Subject: Re: postgresql amd-64 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Fri, 5 Nov 2004 16:17:02 -0500 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A751B@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] postgresql amd-64 Thread-Index: AcTDZIg+dSFJcchRSqajPm29eCZpJQAFq83A From: "Merlin Moncure" To: "Daniel Ceregatti" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/114 X-Sequence-Number: 9068 > I have two dual opteron 248's with 4g of ram each, 6x36G 15k rpm ultra > 320 scsi disks in hardware raid 5, and they are by far the fastest > machines I've user used. As far as this "headache" of using 64 bit > Linux, I've experienced no such thing. I'm using gentoo on both > machines, which are dedicated for postgres 7.4 and replicated with > slony. They're both quite fast and reliable. One machine even runs a > secondary instance of pg, pg 8 beta4 in this case, for development, > which also runs quite well. Good, I'll give it a shot and see what I come up with...thx. Merlin From pgsql-performance-owner@postgresql.org Fri Nov 5 22:40:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 734563A3EFF for ; Fri, 5 Nov 2004 22:40:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86129-06 for ; Fri, 5 Nov 2004 22:40:21 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.197]) by svr1.postgresql.org (Postfix) with ESMTP id F1C5A3A3EFC for ; Fri, 5 Nov 2004 22:40:23 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 58so73477wri for ; Fri, 05 Nov 2004 14:40:23 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=f6UoWK9lucmTChDB4KfizDyDbLr7ZKiGIjtII+07rv4Dfh4VE8rYNhTkteCeyfxSN5Td0aO3J2Im4JWXLSJEgyJI79ptDDd86k5URUrddUnKObV0vwzIrfAk/VHN/zthXxIjmJ9L6k5bJACP22u0KAsQSSJ3aelATOD07HC4VNI= Received: by 10.54.21.71 with SMTP id 71mr61281wru; Fri, 05 Nov 2004 14:40:23 -0800 (PST) Received: by 10.54.43.36 with HTTP; Fri, 5 Nov 2004 14:40:23 -0800 (PST) Message-ID: <88f1825a04110514407ef8a11b@mail.gmail.com> Date: Fri, 5 Nov 2004 17:40:23 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-Reply-To: <88f1825a04110514392aa65f4b@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105063955367088@mail.gmail.com> <20041105175159.GB8855@wolff.to> <88f1825a041105095631064cb0@mail.gmail.com> <10898.1099684660@sss.pgh.pa.us> <88f1825a0411051236497f6bbf@mail.gmail.com> <12855.1099688936@sss.pgh.pa.us> <88f1825a04110514392aa65f4b@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/115 X-Sequence-Number: 9069 On Fri, 05 Nov 2004 16:08:56 -0500, Tom Lane wrote: > Allen Landsidel writes: > > With seqscan enabled however, "AB%" will use the index, but "A%" will not. > > > The estimated cost for the query is much higher without the partial > > indexes than it is with them, and the actual runtime of the query is > > definitely longer without the partial indexes. > > OK. This suggests that the planner is drastically misestimating > the selectivity of the 'A%' clause, which seems odd to me since in > principle it could get that fairly well from the ANALYZE histogram. > But it could well be that you need to increase the resolution of the > histogram --- see ALTER TABLE SET STATISTICS. I will look into this. > > Did you ever show us EXPLAIN ANALYZE results for this query? No, I didn't. I am running it now without the partial index on to give you the results but it's (the 'A%' problem query) been running pretty much since I got this message (an hour ago) and is still not finished. The EXPLAIN results without the ANALYZE will have to suffice until it's done, I can readd the index, and run it again, so you have both to compare to. First two queries run where both the main index, and the 'A%' index exist: -- QUERY 1 search=# explain search-# SELECT test_name FROM test WHERE test_name LIKE 'A%'; QUERY PLAN ------------------------------------------------------------------------------------------- Index Scan using test_name_idx_a on "test" (cost=0.00..8605.88 rows=391208 width=20) Index Cond: ((test_name >= 'A'::text) AND (test_name < 'B'::text)) Filter: (test_name ~~ 'A%'::text) (3 rows) Time: 16.507 ms -- QUERY 2 search=# explain search-# SELECT test_name FROM test WHERE test_name LIKE 'A%' AND test_name LIKE 'AB%'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------- Index Scan using test_name_idx_a on "test" (cost=0.00..113.79 rows=28 width=20) Index Cond: ((test_name >= 'A'::text) AND (test_name < 'B'::text) AND (test_name >= 'AB'::text) AND (test_name < 'AC'::text)) Filter: ((test_name ~~ 'A%'::text) AND (test_name ~~ 'AB%'::text)) (3 rows) Time: 3.197 ms Ok, now the same two queries after a DROP INDEX test_name_idx_a; search=# explain search-# SELECT test_name FROM test WHERE test_name LIKE 'A%'; QUERY PLAN ----------------------------------------------------------------------------------------------- Index Scan using test_name_unique on "test" (cost=0.00..1568918.66 rows=391208 width=20) Index Cond: ((test_name >= 'A'::text) AND (test_name < 'B'::text)) Filter: (test_name ~~ 'A%'::text) (3 rows) Time: 2.470 ms search=# explain search-# SELECT test_name FROM test WHERE test_name LIKE 'AB%'; QUERY PLAN ------------------------------------------------------------------------------------------- Index Scan using test_name_unique on "test" (cost=0.00..20379.49 rows=5081 width=20) Index Cond: ((test_name >= 'AB'::text) AND (test_name < 'AC'::text)) Filter: (test_name ~~ 'AB%'::text) (3 rows) Time: 2.489 ms ------------------ Copying just the costs you can see the vast difference... Index Scan using test_name_unique on "test" (cost=0.00..1568918.66 rows=391208 width=20) Index Scan using test_name_unique on "test" (cost=0.00..20379.49 rows=5081 width=20) vs Index Scan using test_name_idx_a on "test" (cost=0.00..8605.88 rows=391208 width=20) Index Scan using test_name_idx_a on "test" (cost=0.00..113.79 rows=28 width=20) Lastly no, neither of these row guesstimates is correct.. I'll get back and tell you how much they're off by if it's important, once this query is done. The odd thing is it used the index scan here each time -- that has not always been the case with the main unique index, it's trying to make a liar out of me heh. I'm used to the estimates and plan changing from one vacuum analyze to the next, even without any inserts or updates between.. the index scan is always used however when I have the partial indexes in place, and something like.. CREATE TEMP TABLE t1 AS SELECT field FROM table WHERE field LIKE 'A%' AND field LIKE 'AA%'; runs in 6-8 seconds as well, with a bit under 100k records. -Allen From pgsql-performance-owner@postgresql.org Fri Nov 5 23:13:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7AA213A3EC7 for ; Fri, 5 Nov 2004 23:13:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95693-01 for ; Fri, 5 Nov 2004 23:13:47 +0000 (GMT) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by svr1.postgresql.org (Postfix) with ESMTP id 9A0B03A3BDD for ; Fri, 5 Nov 2004 23:13:48 +0000 (GMT) Received: (from markw@localhost) by mail.osdl.org (8.11.6/8.11.6) id iA5NDjD27083; Fri, 5 Nov 2004 15:13:45 -0800 Date: Fri, 5 Nov 2004 15:13:45 -0800 From: Mark Wong To: testperf-general@pgfoundry.org, pgsql-performance@postgresql.org Subject: ia64 results with dbt2 and 8.0beta4 Message-ID: <20041105151345.A12593@osdl.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/116 X-Sequence-Number: 9070 Hi everyone, Some more data I've collected, trying to best tune dbt-2 with 8.0beta4. Was hoping for some suggestions, explanations for what I'm seeing, etc. A review of hardware I've got: 4 x 1.5Ghz Itanium 2 16GB memory 84 15K RPM disks (6 controlers, 12 channels) Physical Database table layout (using LVM2 for tables using more than 1 disk): - warehouse 2 disks - district 2 disks - order_line 2 disks - customer 4 disks - stock 12 disks - log 12 disks - orders 2 disks - new_order 2 disks - history 1 disk - item 1 disk - index1 1 disk - index2 1 disk All these tests are using a 500 warehouse database. Test 1: http://www.osdl.org/projects/dbt2dev/results/dev4-010/188/ Metric: 3316 DB parameter changes from default: bgwriter_percent | 10 checkpoint_timeout | 300 checkpoint_segments | 800 checkpoint_timeout | 1800 default_statistics_target | 1000 max_connections | 140 stats_block_level | on stats_command_string | on stats_row_level | on wal_buffers | 128 wal_sync_method | fsync work_mem | 2048 Test 2: http://www.osdl.org/projects/dbt2dev/results/dev4-010/189/ Metric: 3261 -1.7% decrease Test 1 DB parameter changes from Test 1: shared_buffers | 60000 Noted changes: The block read for the customer table decreases significantly according to the database. Test 3: http://www.osdl.org/projects/dbt2dev/results/dev4-010/190/ Metric: 3261 0% change from Test 2 DB parameter changes from Test 2: effective_cache_size | 220000 Noted changes: No apparent changes according to the charts. Test 4: http://www.osdl.org/projects/dbt2dev/results/dev4-010/191/ Metric: 3323 1.9 increase from Test 3 DB parameter changes from Test 3: checkpoint_segments | 1024 effective_cache_size | 1000 Noted Changes: The increased checkpoint_segments smothed out the throughput and other i/o related stats. Test 5: http://www.osdl.org/projects/dbt2dev/results/dev4-010/192/ Metric: 3149 -5% decrease from Test 4 DB parameter changes from Test 4: shared_buffers | 80000 Noted changes: The graphs are starting to jump around a bit. I figure 80,000 shared_buffers is too much. Test 6: http://www.osdl.org/projects/dbt2dev/results/dev4-010/193/ Metric: 3277 4% increase from Test 5 DB parameter changes from Test 5: random_page_cost | 2 shared_buffers | 60000 Noted changes: Reducing the shared_buffers to the smoother performance found in Test 4 seemed to have disrupted by decreasing the random_page_cost to 2. From pgsql-performance-owner@postgresql.org Sat Nov 6 00:14:48 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8419C3A3F00 for ; Sat, 6 Nov 2004 00:14:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07735-06 for ; Sat, 6 Nov 2004 00:14:26 +0000 (GMT) Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk [217.27.240.154]) by svr1.postgresql.org (Postfix) with ESMTP id 1B8E53A3EBB for ; Sat, 6 Nov 2004 00:14:28 +0000 (GMT) Received: from [82.68.132.233] (82-68-132-233.dsl.in-addr.zen.co.uk [82.68.132.233]) by bayswater1.ymogen.net (Postfix) with ESMTP id 7DF83A436D; Sat, 6 Nov 2004 00:14:26 +0000 (GMT) Message-ID: <418C1757.70909@ymogen.net> Date: Sat, 06 Nov 2004 00:14:15 +0000 From: Matt Clark User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Allen Landsidel Cc: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? References: <88f1825a041105095631064cb0@mail.gmail.com> <008401c4c366$127d5260$8300a8c0@solent> <88f1825a04110513028759dd3@mail.gmail.com> In-Reply-To: <88f1825a04110513028759dd3@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/117 X-Sequence-Number: 9071 >>So there are really only 9000 rows out of 76 million starting with 'I'? How >>about combining some techniques - you could create an index on the first two >>chars of the field (should be selective enough to give an index scan), >>select from that, and select the actual data with the like clause. >> >> > >I was talking about the cost, not the number of rows. About 74,000 >rows are returned but the query only takes about 8 seconds to run. -- > > Well, 74000/76000000 ~= 0.1%, way less than 1/26, so no surprise that an indexscan is better, and also no surprise that the planner can't know that I is such an uncommon initial char. >with the partial index in place. > > > >>CREATE INDEX idx_firstletters ON table (substr(field, 1, 2)); >>CREATE INDEX idx_all ON table (field); >>SELECT field FROM (SELECT field FROM table WHERE substr(field, 1, 2) = 'DE') >>AS approx WHERE field LIKE 'DE%'; >> >> > >That looks like a pretty slick way to create an index, I didn't know >there was such a way to do it.. but It appears that this will not work >with queries where the WHERE clause wants to find substrings longer >than 2 characters. > > I don't see why not, it just uses the functional index to grap the 1/(ascii_chars^2) of the rows that are of obvious interest, and then uses the standard index to filter that set.. Where it won't work is where you just want one initial char! Which is why I suggested the silly query rewrite... >Going back to the initial problem -- having only one large, complete >index on the table (no partial indexes) the query "SELECT field FROM >table WHERE field LIKE 'A%';" does not use the index. The query >"SELECT field FROM table WHERE field LIKE 'AB%';" however, does use >the single large index if it exists. > > > If you were planning the query, what would you do? Assuming we're talking about A-Z as possible first chars, and assuming we don't know the distribution of those chars, then we have to assume 1/26 probability of each char, so a seq scan makes sense. Whereas like 'JK%' should only pull 1/500 rows. >Adding the partial index "CREATE INDEX idx_table_substrfield_A ON >table (field) WHERE field LIKE 'A%';" causes all queries with >substrings of any length to do index scans.provided I issue the query >as: > >SELECT field FROM table WHERE field LIKE 'A%' AND field LIKE 'AB%'; > -- or even -- >SELECT field FROM table WHERE field LIKE 'A%'; > >The latter query, without the partial index described, does a >sequential scan on the table itself instead of an index scan. > > Yes, because (I assume, Tom will no doubt clarify/correct), by creating the partial indices you create a lot more information about the distribution of the first char - either that, or the planner simply always uses an exactly matching partial index if available. I _think_ that creating 26 partial indexes on '?%' is essentially the same thing as creating one functional index on substr(field,1,1), just messier, unless the partial indexes cause the planner to do something special... M From pgsql-performance-owner@postgresql.org Sat Nov 6 00:27:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3C27F3A3F09 for ; Sat, 6 Nov 2004 00:26:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10307-09 for ; Sat, 6 Nov 2004 00:26:49 +0000 (GMT) Received: from web52107.mail.yahoo.com (web52107.mail.yahoo.com [206.190.39.76]) by svr1.postgresql.org (Postfix) with SMTP id 200B13A3F0C for ; Sat, 6 Nov 2004 00:26:51 +0000 (GMT) Message-ID: <20041106002649.19809.qmail@web52107.mail.yahoo.com> Received: from [198.182.200.22] by web52107.mail.yahoo.com via HTTP; Fri, 05 Nov 2004 16:26:49 PST Date: Fri, 5 Nov 2004 16:26:49 -0800 (PST) From: patrick ~ Subject: Re: vacuum analyze slows sql query To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/118 X-Sequence-Number: 9072 Looking around at the pg_ tables and some PostgreSQL online docs prompted by another post/reply on this list regarding ALERT TABLE SET STATISTICS i found out that prior to a VACUUM the following select (taken from the online docs) shows: pkk=# select relname, relkind, reltuples, relpages from pg_class where relname like 'pkk_%'; relname | relkind | reltuples | relpages -------------------+---------+-----------+---------- pkk_billing | r | 1000 | 10 pkk_offer | r | 1000 | 10 pkk_offer_pkey | i | 1000 | 1 pkk_purchase | r | 1000 | 10 pkk_purchase_pkey | i | 1000 | 1 (5 rows) Time: 1097.263 ms and after a VACUUM: pkk=# vacuum analyze ; VACUUM Time: 100543.359 ms it shows: pkk=# select relname, relkind, reltuples, relpages from pg_class where relname like 'pkk_%'; relname | relkind | reltuples | relpages -------------------+---------+-------------+---------- pkk_billing | r | 714830 | 4930 pkk_offer | r | 618 | 6 pkk_offer_pkey | i | 618 | 4 pkk_purchase | r | 1.14863e+06 | 8510 pkk_purchase_pkey | i | 1.14863e+06 | 8214 (5 rows) Time: 3.868 ms Further, I notice that if I were to delete rows from the pg_statistic table I get the db in a state where the query is fast again: pkk=# explain analyze select offer_id, pkk_offer_has_pending_purch( offer_id ) from pkk_offer ; QUERY PLAN ----------------------------------------------------------------------------------------------------------------- Seq Scan on pkk_offer (cost=0.00..13.72 rows=618 width=4) (actual time=2415.739..1065709.092 rows=618 loops=1) Total runtime: 1065711.651 ms (2 rows) Time: 1065713.446 ms pkk=# delete from pg_statistic where pg_statistic.starelid = pg_class.oid and pg_class.relname like 'pkk_%'; DELETE 11 Time: 3.368 ms pkk=# select offer_id, pkk_offer_has_pending_purch( offer_id ) from pkk_offer ; (618 rows) Time: 876.377 ms pkk=# explain analyze select offer_id, pkk_offer_has_pending_purch( offer_id ) from pkk_offer ; QUERY PLAN ---------------------------------------------------------------------------------------------------------- Seq Scan on pkk_offer (cost=0.00..13.72 rows=618 width=4) (actual time=1.329..846.786 rows=618 loops=1) Total runtime: 848.170 ms (2 rows) Time: 849.958 ms Now, I'm sure someone (a PostgreSQL developer most likely) is about to shoot me for doing such a thing :-) But, however *ugly, wrong, sacrilege* this may be, if this is the only solution...err workaround I have that will help me i must resort to it. The only two questions I have about this are: 1. Is this really the only solution left for me? 2. Am I in anyway screwing the db doing this? Best regards, --patrick __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com From pgsql-performance-owner@postgresql.org Sat Nov 6 03:03:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2AFE03A3F0B for ; Sat, 6 Nov 2004 03:02:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46318-02 for ; Sat, 6 Nov 2004 03:01:47 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.203]) by svr1.postgresql.org (Postfix) with ESMTP id 0D3B83A3F7C for ; Sat, 6 Nov 2004 03:01:50 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 64so73706wri for ; Fri, 05 Nov 2004 19:01:44 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=bR42RQN0EwjcLaXSjx4DnA/4aJ52jgvty/HEqMuvOBP4fgmFESYp7h3RkVXn1+mpqDyBOFfXuvQjc5GwV215ZdjxXbxn6fphiZo+aoqRtpMncdYVZ1iHsGIfrOIPvWJuRO33tFz05uTbPpuhjxeE7N7slEsJfcRUdKziudYl7S0= Received: by 10.54.13.48 with SMTP id 48mr74727wrm; Fri, 05 Nov 2004 19:01:44 -0800 (PST) Received: by 10.54.50.36 with HTTP; Fri, 5 Nov 2004 19:01:44 -0800 (PST) Message-ID: <77b69d21041105190148253fb1@mail.gmail.com> Date: Sat, 6 Nov 2004 08:31:44 +0530 From: "Vishal Kashyap @ [Sai Hertz And Control Systems]" Reply-To: "Vishal Kashyap @ [Sai Hertz And Control Systems]" To: Merlin Moncure Subject: Re: postgresql amd-64 Cc: Daniel Ceregatti , pgsql-performance@postgresql.org In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A751B@Herge.rcsinc.local> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <6EE64EF3AB31D5448D0007DD34EEB3412A751B@Herge.rcsinc.local> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/119 X-Sequence-Number: 9073 Merlin, > Good, I'll give it a shot and see what I come up with...thx. > Do share your experience with us. -- With Best Regards, Vishal Kashyap. Did you know SaiPACS is one and only PACS Management tool. http://saihertz.com From pgsql-performance-owner@postgresql.org Sat Nov 6 04:04:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 078203A3F9E for ; Sat, 6 Nov 2004 04:04:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58084-02 for ; Sat, 6 Nov 2004 04:04:37 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2817A3A3F8F for ; Sat, 6 Nov 2004 04:04:36 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA644N4d025493; Fri, 5 Nov 2004 23:04:24 -0500 (EST) To: Matt Clark Cc: Allen Landsidel , pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-reply-to: <418C1757.70909@ymogen.net> References: <88f1825a041105095631064cb0@mail.gmail.com> <008401c4c366$127d5260$8300a8c0@solent> <88f1825a04110513028759dd3@mail.gmail.com> <418C1757.70909@ymogen.net> Comments: In-reply-to Matt Clark message dated "Sat, 06 Nov 2004 00:14:15 +0000" Date: Fri, 05 Nov 2004 23:04:23 -0500 Message-ID: <25492.1099713863@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/120 X-Sequence-Number: 9074 Matt Clark writes: > Well, 74000/76000000 ~= 0.1%, way less than 1/26, so no surprise that an > indexscan is better, and also no surprise that the planner can't know > that I is such an uncommon initial char. But it *can* know that, at least given adequate ANALYZE statistics. I'm pretty convinced that the basic answer to Allen's problem is to increase the histogram size. How large he needs to make it is not clear --- obviously his data distribution is not uniform, but I don't have a fix on how badly non-uniform. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Nov 6 04:08:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A1FA13A3F07 for ; Sat, 6 Nov 2004 04:07:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56698-07 for ; Sat, 6 Nov 2004 04:06:57 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9AECE3A3E86 for ; Sat, 6 Nov 2004 04:06:56 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA646pU3025528; Fri, 5 Nov 2004 23:06:52 -0500 (EST) To: patrick ~ Cc: pgsql-performance@postgresql.org Subject: Re: vacuum analyze slows sql query In-reply-to: <20041106002649.19809.qmail@web52107.mail.yahoo.com> References: <20041106002649.19809.qmail@web52107.mail.yahoo.com> Comments: In-reply-to patrick ~ message dated "Fri, 05 Nov 2004 16:26:49 -0800" Date: Fri, 05 Nov 2004 23:06:51 -0500 Message-ID: <25527.1099714011@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/121 X-Sequence-Number: 9075 patrick ~ writes: > 1. Is this really the only solution left for me? You still haven't followed the suggestions that were given to you (ie, find out what is happening with the plan for the query inside the problematic function). regards, tom lane From pgsql-performance-owner@postgresql.org Sat Nov 6 06:18:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CB55F3A3FB0 for ; Sat, 6 Nov 2004 06:18:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86309-09 for ; Sat, 6 Nov 2004 06:18:51 +0000 (GMT) Received: from web52102.mail.yahoo.com (web52102.mail.yahoo.com [206.190.39.71]) by svr1.postgresql.org (Postfix) with SMTP id DCEFC3A4002 for ; Sat, 6 Nov 2004 06:18:51 +0000 (GMT) Message-ID: <20041106061850.5463.qmail@web52102.mail.yahoo.com> Received: from [66.92.62.216] by web52102.mail.yahoo.com via HTTP; Fri, 05 Nov 2004 22:18:50 PST Date: Fri, 5 Nov 2004 22:18:50 -0800 (PST) From: patrick ~ Subject: Re: vacuum analyze slows sql query To: Tom Lane Cc: pgsql-performance@postgresql.org In-Reply-To: <25527.1099714011@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/122 X-Sequence-Number: 9076 Hi Tom, -performance@, I apologize if I didn't follow through with the PREPARE and EXECUTE. I assume that is what you are refering to. After reading the PostgreSQL docs on PREPARE statement I realized two things: a) PREPARE is only session long and b) that I can not (at least I haven't figured out how) PREPARE a statement which would mimic my original select statement which I could EXECUTE over all rows of pkk_offer table. Best I could do is either: PREPARE pkk_01 ( interger ) select $1, pkk_offer_has_pending_purch( $1 ) from pkk_offer ; or PREPARE pkk_00 ( integer ) In the former case the EXPLAIN ANALYZE doesn't give enough data (it is the same as w/o the PREPARE statement). In the latter case, I can only execute it with one offer_id at at time. Is this sufficient? If so, here are the results before and after VACUUM ANALYZE: pkk=# explain analyze execute pkk_00( 795 ) ; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Result (cost=8.57..8.58 rows=1 width=0) (actual time=0.095..0.096 rows=1 loops=1) InitPlan -> Limit (cost=0.00..8.57 rows=1 width=4) (actual time=0.083..0.084 rows=1 loops=1) -> Index Scan using pur_offer_id_idx on pkk_purchase p0 (cost=0.00..17.13 rows=2 width=4) (actual time=0.079..0.079 rows=1 loops=1) Index Cond: (offer_id = $1) Filter: ((((expire_time)::timestamp with time zone > now()) OR (expire_time IS NULL) OR (pending = true)) AND ((cancel_date IS NULL) OR (pending = true))) Total runtime: 0.238 ms (7 rows) pkk=# VACUUM ANALYZE ; VACUUM Time: 97105.589 ms pkk=# explain analyze execute pkk_00( 795 ) ; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Result (cost=8.57..8.58 rows=1 width=0) (actual time=0.329..0.330 rows=1 loops=1) InitPlan -> Limit (cost=0.00..8.57 rows=1 width=4) (actual time=0.311..0.312 rows=1 loops=1) -> Index Scan using pur_offer_id_idx on pkk_purchase p0 (cost=0.00..17.13 rows=2 width=4) (actual time=0.307..0.307 rows=1 loops=1) Index Cond: (offer_id = $1) Filter: ((((expire_time)::timestamp with time zone > now()) OR (expire_time IS NULL) OR (pending = true)) AND ((cancel_date IS NULL) OR (pending = true))) Total runtime: 0.969 ms (7 rows) Time: 16.252 ms In both before and after "Index Scan" is used on pur_offer_id_idx. So, unless I'm missing something obvious here I am at a loss. I went as far as doing the EXPLAIN ANALYZE EXECUTE pkk_00( offer_id ) for each offer_id in pkk_offer table one at a time (not manually but by scripting it). All instances use "Index Scan". I only noticed a couple that had quite large "actual times" like this following: pkk=# explain analyze execute pkk_00( 2312 ) ; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Result (cost=8.57..8.58 rows=1 width=0) (actual time=21.279..21.282 rows=1 loops=1) InitPlan -> Limit (cost=0.00..8.57 rows=1 width=4) (actual time=21.256..21.258 rows=1 loops=1) -> Index Scan using pur_offer_id_idx on pkk_purchase p0 (cost=0.00..17.13 rows=2 width=4) (actual time=21.249..21.249 rows=1 loops=1) Index Cond: (offer_id = $1) Filter: ((((expire_time)::timestamp with time zone > now()) OR (expire_time IS NULL) OR (pending = true)) AND ((cancel_date IS NULL) OR (pending = true))) Total runtime: 21.435 ms (7 rows) Time: 22.541 ms Which makes sense when you look at the number of entries this offer_id has in pkk_purchase table vs offer_id = 795: pkk=# select offer_id, count(*) from pkk_purchase where offer_id in ( 795, 2312 ) group by offer_id ; offer_id | count ----------+------- 795 | 4 2312 | 1015 (2 rows) Time: 21.118 ms --patrick --- Tom Lane wrote: > patrick ~ writes: > > 1. Is this really the only solution left for me? > > You still haven't followed the suggestions that were given to you > (ie, find out what is happening with the plan for the query inside > the problematic function). > > regards, tom lane __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com From pgsql-performance-owner@postgresql.org Sat Nov 6 06:39:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 060C83A3FF2 for ; Sat, 6 Nov 2004 06:39:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92720-03 for ; Sat, 6 Nov 2004 06:38:59 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id BA85A3A3C13 for ; Sat, 6 Nov 2004 06:38:58 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA66cwH6026774; Sat, 6 Nov 2004 01:38:58 -0500 (EST) To: patrick ~ Cc: pgsql-performance@postgresql.org Subject: Re: vacuum analyze slows sql query In-reply-to: <20041106061850.5463.qmail@web52102.mail.yahoo.com> References: <20041106061850.5463.qmail@web52102.mail.yahoo.com> Comments: In-reply-to patrick ~ message dated "Fri, 05 Nov 2004 22:18:50 -0800" Date: Sat, 06 Nov 2004 01:38:58 -0500 Message-ID: <26773.1099723138@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/123 X-Sequence-Number: 9077 patrick ~ writes: > PREPARE pkk_00 ( integer ) ; Sat, 6 Nov 2004 07:27:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03273-06 for ; Sat, 6 Nov 2004 07:27:26 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.207]) by svr1.postgresql.org (Postfix) with ESMTP id F318D3A2B0B for ; Sat, 6 Nov 2004 07:27:26 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 58so80488wri for ; Fri, 05 Nov 2004 23:27:25 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=GrbC+gbJ4S+MfWdBIxHXIj8Ez/FpKNXAz1Wq05xEiG0mYJsWDyEpv1w4q9UHOyfImav2LTTnXvQkbJzdLOJnfUpIaoI5JznKuFwZlmIvefx2GQDlUw/GlDADaBbsF2Gl98W90I6OiwRCFrr78mfB8vq9yIN1U+C7ZucLfON4NX4= Received: by 10.54.21.14 with SMTP id 14mr131514wru; Fri, 05 Nov 2004 23:27:25 -0800 (PST) Received: by 10.54.43.36 with HTTP; Fri, 5 Nov 2004 23:27:25 -0800 (PST) Message-ID: <88f1825a04110523276f83653b@mail.gmail.com> Date: Sat, 6 Nov 2004 02:27:25 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: Tom Lane Subject: Re: Strange (?) Index behavior? Cc: Matt Clark , pgsql-performance@postgresql.org In-Reply-To: <25492.1099713863@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105095631064cb0@mail.gmail.com> <008401c4c366$127d5260$8300a8c0@solent> <88f1825a04110513028759dd3@mail.gmail.com> <418C1757.70909@ymogen.net> <25492.1099713863@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/124 X-Sequence-Number: 9078 On Fri, 05 Nov 2004 23:04:23 -0500, Tom Lane wrote: > Matt Clark writes: > > Well, 74000/76000000 ~= 0.1%, way less than 1/26, so no surprise that an > > indexscan is better, and also no surprise that the planner can't know > > that I is such an uncommon initial char. > > But it *can* know that, at least given adequate ANALYZE statistics. > I'm pretty convinced that the basic answer to Allen's problem is to > increase the histogram size. How large he needs to make it is not > clear --- obviously his data distribution is not uniform, but I don't > have a fix on how badly non-uniform. > Tom just an update, it's now 2am.. several hours since I started that EXPLAIN ANALYZE and it still hasn't finished, so I've aborted it. I will do the example with the more precise substring instead to illustrate the performance differences, both with and without the substring index and report back here. I'm also interested in something someone else posted, namely that the 36 indexes I have, "A%" through "Z%" and "0%" through "9%" could be replaced with a single index like: "CREATE INDEX idx_table_field_substr ON table substr(field, 1, 1);" I'm wondering, histogram and other information aside, will this function as well (or better) than creating all the individual indexes? From pgsql-admin-owner@postgresql.org Sat Nov 6 19:52:31 2004 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0B4303A3D02 for ; Sat, 6 Nov 2004 19:52:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45297-05 for ; Sat, 6 Nov 2004 19:52:16 +0000 (GMT) Received: from web52706.mail.yahoo.com (web52706.mail.yahoo.com [206.190.39.157]) by svr1.postgresql.org (Postfix) with SMTP id 3D3593A3D6C for ; Sat, 6 Nov 2004 19:52:16 +0000 (GMT) Message-ID: <20041106195215.91282.qmail@web52706.mail.yahoo.com> Received: from [168.243.73.4] by web52706.mail.yahoo.com via HTTP; Sat, 06 Nov 2004 11:52:15 PST Date: Sat, 6 Nov 2004 11:52:15 -0800 (PST) From: Carlos Lopez Subject: poor performance in migrated database To: pgsql-performance@postgresql.org, pgsql-admin@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/47 X-Sequence-Number: 15432 I have migrated a database from MS SQL to a postgresSQL database, but when running it, the results are very slow (and unusable) which is the only reason we don't entirely move to postgresSQL. The problem is that there are many nested views which normally join tables by using two fields, one character and other integer. The biggest table has about 300k records (isn't it too little for having performance problems?) What could be the poor performance reason? the server is a dual itanium (intel 64bits) processor with 6Gb of RAM and a 36Gb Raid 5 scsi hdds of 15k rpm. If someone has the time and wants to check the structure, I have a copy of everything at http://www.micredito.com.sv/.carlos/materiales.sql.bz2 it is a pgsqldump made with postgres 7.4 Thanks in advance for your help. Carlos Lopez Linares. ===== ___ Ing. Carlos L�pez Linares IT Consultant Quieres aprender linux? visita http://www.aprende-linux.com.sv __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com From pgsql-admin-owner@postgresql.org Sat Nov 6 20:11:58 2004 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A214B3A3E8B for ; Sat, 6 Nov 2004 20:11:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48860-08 for ; Sat, 6 Nov 2004 20:11:35 +0000 (GMT) Received: from main.gmane.org (main.gmane.org [80.91.229.2]) by svr1.postgresql.org (Postfix) with ESMTP id 15CE03A3E19 for ; Sat, 6 Nov 2004 20:11:37 +0000 (GMT) Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1CQWuO-0007PU-00 for ; Sat, 06 Nov 2004 21:11:36 +0100 Received: from 62.79.119.132.adsl.vbr.tiscali.dk ([62.79.119.132]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 06 Nov 2004 21:11:36 +0100 Received: from troels by 62.79.119.132.adsl.vbr.tiscali.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 06 Nov 2004 21:11:36 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-admin@postgresql.org From: Troels Arvin Subject: Re: poor performance in migrated database Date: Sat, 06 Nov 2004 21:07:06 +0100 Lines: 26 Message-ID: References: <20041106195215.91282.qmail@web52706.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 62.79.119.132.adsl.vbr.tiscali.dk User-Agent: Pan/0.14.2.91 (As She Crawled Across the Table) Cc: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/48 X-Sequence-Number: 15433 On Sat, 06 Nov 2004 11:52:15 -0800, Carlos Lopez wrote: > I have migrated a database from MS SQL to a > postgresSQL database, but when running it, the results > are very slow (and unusable) which is the only reason > we don't entirely move to postgresSQL. Have you run ANALYZE lately? (See manual.) Do you know how to use EXPLAIN? (See manual.) If so: Please post an example query which is slow, and the corresponding output from EXPLAIN. Have you tried turning your random_page_cost a bit down? (My experience its value should generally be lessened.) Have you read http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html ? > The biggest table has about 300k records (isn't it too > little for having performance problems?) That should be no problem. -- Greetings from Troels Arvin, Copenhagen, Denmark From pgsql-admin-owner@postgresql.org Sat Nov 6 20:31:51 2004 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B80913A3E19 for ; Sat, 6 Nov 2004 20:31:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55410-05 for ; Sat, 6 Nov 2004 20:31:40 +0000 (GMT) Received: from main.gmane.org (main.gmane.org [80.91.229.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4928F3A3D16 for ; Sat, 6 Nov 2004 20:31:40 +0000 (GMT) Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1CQXDo-0008MI-00 for ; Sat, 06 Nov 2004 21:31:40 +0100 Received: from 62.79.119.132.adsl.vbr.tiscali.dk ([62.79.119.132]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 06 Nov 2004 21:31:36 +0100 Received: from troels by 62.79.119.132.adsl.vbr.tiscali.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 06 Nov 2004 21:31:36 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-admin@postgresql.org From: Troels Arvin Subject: Re: poor performance in migrated database Date: Sat, 06 Nov 2004 21:26:15 +0100 Lines: 25 Message-ID: References: <20041106195215.91282.qmail@web52706.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 62.79.119.132.adsl.vbr.tiscali.dk User-Agent: Pan/0.14.2.91 (As She Crawled Across the Table) Cc: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/49 X-Sequence-Number: 15434 On Sat, 06 Nov 2004 11:52:15 -0800, Carlos Lopez wrote: > I have migrated a database from MS SQL to a postgresSQL database, but > when running it, the results are very slow (and unusable) which is the > only reason we don't entirely move to postgresSQL. Have you run ANALYZE lately? (See manual.) Do you know how to use EXPLAIN? (See manual.) If so: Please post an example query which is slow, and the corresponding output from EXPLAIN. Have you tried turning your random_page_cost a bit down? (My experience its value should generally be lessened.) Have you read http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html ? > The biggest table has about 300k records (isn't it too little for having > performance problems?) That should be no problem. -- Greetings from Troels Arvin, Copenhagen, Denmark From pgsql-admin-owner@postgresql.org Sat Nov 6 21:41:54 2004 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D7CAB3A3F1F; Sat, 6 Nov 2004 21:41:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 78535-05; Sat, 6 Nov 2004 21:41:44 +0000 (GMT) Received: from cmailg4.svr.pol.co.uk (cmailg4.svr.pol.co.uk [195.92.195.174]) by svr1.postgresql.org (Postfix) with ESMTP id 825A13A3FC9; Sat, 6 Nov 2004 21:41:45 +0000 (GMT) Received: from modem-978.leopard.dialup.pol.co.uk ([217.135.147.210] helo=[192.168.0.102]) by cmailg4.svr.pol.co.uk with esmtp (Exim 4.41) id 1CQYJd-0004Ip-Fv; Sat, 06 Nov 2004 21:41:45 +0000 Subject: Re: [PERFORM] poor performance in migrated database From: Simon Riggs To: Carlos Lopez Cc: pgsql-performance@postgresql.org, pgsql-admin@postgresql.org In-Reply-To: <20041106195215.91282.qmail@web52706.mail.yahoo.com> References: <20041106195215.91282.qmail@web52706.mail.yahoo.com> Content-Type: text/plain Organization: 2nd Quadrant Message-Id: <1099777150.6942.393.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Sat, 06 Nov 2004 21:39:10 +0000 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/50 X-Sequence-Number: 15435 On Sat, 2004-11-06 at 19:52, Carlos Lopez wrote: > The problem is that there are many nested views which > normally join tables by using two fields, one > character and other integer. PostgreSQL has difficulty with some multi-column situations, even though in general it has a particularly good query optimizer. If the first column is poorly selective, yet the addition of the second column makes the combination very highly selective then PostgreSQL may not be able to realise this, ANALYZE or not. ANALYZE doesn't have anywhere to store multi-column selectivity statistics. EXPLAIN ANALYZE will show you whether this is the case. It seems likely that the estimated cardinality of certain joins is incorrect. -- Best Regards, Simon Riggs From pgsql-admin-owner@postgresql.org Sat Nov 6 21:58:29 2004 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9172E3A3E19 for ; Sat, 6 Nov 2004 21:58:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80668-09 for ; Sat, 6 Nov 2004 21:57:54 +0000 (GMT) Received: from mpls-qmqp-02.inet.qwest.net (mpls-qmqp-02.inet.qwest.net [63.231.195.113]) by svr1.postgresql.org (Postfix) with SMTP id 2DEDB3A3EC8 for ; Sat, 6 Nov 2004 21:57:53 +0000 (GMT) Received: (qmail 88295 invoked by uid 0); 6 Nov 2004 20:35:22 -0000 Received: from mpls-pop-10.inet.qwest.net (63.231.195.10) by mpls-qmqp-02.inet.qwest.net with QMQP; 6 Nov 2004 20:35:22 -0000 Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) by mpls-pop-10.inet.qwest.net with SMTP; 6 Nov 2004 21:57:52 -0000 Date: Sat, 06 Nov 2004 16:00:15 -0700 Message-Id: <1099782015.1310.39.camel@localhost.localdomain> From: "Scott Marlowe" To: "Carlos Lopez" Cc: pgsql-performance@postgresql.org, pgsql-admin@postgresql.org Subject: Re: [PERFORM] poor performance in migrated database In-Reply-To: <20041106195215.91282.qmail@web52706.mail.yahoo.com> References: <20041106195215.91282.qmail@web52706.mail.yahoo.com> Content-Type: text/plain Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/51 X-Sequence-Number: 15436 On Sat, 2004-11-06 at 12:52, Carlos Lopez wrote: > I have migrated a database from MS SQL to a > postgresSQL database, but when running it, the results > are very slow (and unusable) which is the only reason > we don't entirely move to postgresSQL. > The problem is that there are many nested views which > normally join tables by using two fields, one > character and other integer. If you are joining on different type fields, you might find the query planner encouraged to use the indexes if you cast one field to the other field's type. If that's possible. From pgsql-performance-owner@postgresql.org Sun Nov 7 11:04:25 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 426713A4302 for ; Sun, 7 Nov 2004 11:04:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58868-04 for ; Sun, 7 Nov 2004 11:04:16 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.203]) by svr1.postgresql.org (Postfix) with ESMTP id 8A7443A42FE for ; Sun, 7 Nov 2004 11:04:17 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a41so231731rng for ; Sun, 07 Nov 2004 03:04:17 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=sswucMpS0F9FYMa0VH8qxKmYNgEnTeByEMwSF3xHLinoJ1wTMdPep9i14GURS6vZ00XnZD6Du/k8ELzT0dilZjle+worR0h+JrJDAt/7jWJi7TjPOS8shKPPkVyWbgcLCba7xTnfXOrvZmzL/cvJdHgkM/eam5Jwe+P6xXCRgK4= Received: by 10.38.149.79 with SMTP id w79mr947235rnd; Sun, 07 Nov 2004 03:04:16 -0800 (PST) Received: by 10.38.59.73 with HTTP; Sun, 7 Nov 2004 03:04:16 -0800 (PST) Message-ID: <8c88543604110703044cf70e15@mail.gmail.com> Date: Sun, 7 Nov 2004 19:04:16 +0800 From: Ang Chin Han Reply-To: Ang Chin Han To: pgsql-performance@postgresql.org Subject: DISTINCT and GROUP BY: possible performance enhancement? Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/129 X-Sequence-Number: 9083 Is SELECT DISTINCT foo, bar FROM baz; equivalent to SELECT foo, bar from baz GROUP BY foo, bar; ? In the former case, pgsql >= 7.4 does not use HashAgg, but uses it for the latter case. In many circumstances, esp. for large amount of data in the table baz, the second case is an order of a magnitude faster. For example (pgsql8b4): regress=# explain analyze select distinct four from tenk1; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------- Unique (cost=1109.39..1159.39 rows=4 width=4) (actual time=90.017..106.936 rows=4 loops=1) -> Sort (cost=1109.39..1134.39 rows=10000 width=4) (actual time=90.008..95.589 rows=10000 loops=1) Sort Key: four -> Seq Scan on tenk1 (cost=0.00..445.00 rows=10000 width=4) (actual time=0.027..45.454 rows=10000 loops=1) Total runtime: 110.927 ms (5 rows) regress=# explain analyze select distinct four from tenk1 group by four; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------- Unique (cost=470.04..470.06 rows=4 width=4) (actual time=47.487..47.498 rows=4 loops=1) -> Sort (cost=470.04..470.05 rows=4 width=4) (actual time=47.484..47.486 rows=4 loops=1) Sort Key: four -> HashAggregate (cost=470.00..470.00 rows=4 width=4) (actual time=47.444..47.451 rows=4 loops=1) -> Seq Scan on tenk1 (cost=0.00..445.00 rows=10000 width=4) (actual time=0.013..31.068 rows=10000 loops=1) Total runtime: 47.822 ms (6 rows) If they're equivalent, can we have pgsql use HashAgg for DISTINCTs? Yes, I've read planner.c's comments on "Executor doesn't support hashed aggregation with DISTINCT aggregates.", but I believe using HashAgg is better if the product of the columns' n_distinct statistic is way less than the number of expected rows. From pgsql-performance-owner@postgresql.org Mon Nov 8 02:12:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9FD553A3E66 for ; Mon, 8 Nov 2004 02:12:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73885-10 for ; Mon, 8 Nov 2004 02:12:40 +0000 (GMT) Received: from millenium.mst.co.jp (unknown [210.230.185.241]) by svr1.postgresql.org (Postfix) with ESMTP id 54F273A3E4A for ; Mon, 8 Nov 2004 02:12:42 +0000 (GMT) Received: from mst1x5r347kymb (lc12114 [192.168.1.114]) by millenium.mst.co.jp (8.11.6p2/3.7W) with SMTP id iA82CdZ15080; Mon, 8 Nov 2004 11:12:39 +0900 Message-ID: <014501c4c538$88d66950$7201a8c0@mst1x5r347kymb> From: "Iain" To: "Daniel Ceregatti" , "Merlin Moncure" Cc: References: <6EE64EF3AB31D5448D0007DD34EEB3412A7518@Herge.rcsinc.local> <418BC518.2050909@omnis.com> Subject: Re: postgresql amd-64 Date: Mon, 8 Nov 2004 11:13:22 +0900 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/130 X-Sequence-Number: 9084 I'm hoping I'll have the opportunity to build a similar machine soon and am wondering about the choice of 64 bit distributions. Gentoo is obviously a possibility but I'm also condsidering Debian. There is also a 64 compile of redhat sources somewhere around, but I can't remember what they call it offhand. If anyone has opinions about that, I'd be happy to hear. regards Iain ----- Original Message ----- From: "Daniel Ceregatti" To: "Merlin Moncure" Cc: Sent: Saturday, November 06, 2004 3:23 AM Subject: Re: [PERFORM] postgresql amd-64 >I have two dual opteron 248's with 4g of ram each, 6x36G 15k rpm ultra > 320 scsi disks in hardware raid 5, and they are by far the fastest > machines I've user used. As far as this "headache" of using 64 bit > Linux, I've experienced no such thing. I'm using gentoo on both > machines, which are dedicated for postgres 7.4 and replicated with > slony. They're both quite fast and reliable. One machine even runs a > secondary instance of pg, pg 8 beta4 in this case, for development, > which also runs quite well. > > Daniel > > Merlin Moncure wrote: > >>Does anybody have any experiences with postgresql 7.4+ running on amd-64 >>in 64 bit mode? Specifically, does it run quicker and if so do the >>performance benefits justify the extra headaches running 64 bit linux? >> >>Right now I'm building a dual Opteron 246 with 4 gig ddr400. >> >>Merlin >> >>---------------------------(end of broadcast)--------------------------- >>TIP 5: Have you checked our extensive FAQ? >> >> http://www.postgresql.org/docs/faqs/FAQ.html >> >> > > -- > > Daniel Ceregatti - Programmer > Omnis Network, LLC > > The forest is safe because a lion lives therein and the lion is safe > because > it lives in a forest. Likewise the friendship of persons rests on mutual > help. > -- Laukikanyay. > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match From pgsql-performance-owner@postgresql.org Mon Nov 8 07:36:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 78EBC3A3B81 for ; Mon, 8 Nov 2004 07:36:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63803-02 for ; Mon, 8 Nov 2004 07:36:31 +0000 (GMT) Received: from millenium.mst.co.jp (unknown [210.230.185.241]) by svr1.postgresql.org (Postfix) with ESMTP id 09E673A2B4A for ; Mon, 8 Nov 2004 07:36:30 +0000 (GMT) Received: from mst1x5r347kymb (lc12114 [192.168.1.114]) by millenium.mst.co.jp (8.11.6p2/3.7W) with SMTP id iA87aOZ16331; Mon, 8 Nov 2004 16:36:24 +0900 Message-ID: <006001c4c565$b19642c0$7201a8c0@mst1x5r347kymb> From: "Iain" To: "Andrew McMillan" Cc: References: <6EE64EF3AB31D5448D0007DD34EEB3412A7518@Herge.rcsinc.local> <418BC518.2050909@omnis.com> <014501c4c538$88d66950$7201a8c0@mst1x5r347kymb> <1099885867.18830.3.camel@lamb.mcmillan.net.nz> Subject: Re: postgresql amd-64 Date: Mon, 8 Nov 2004 16:36:38 +0900 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-2022-jp"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/133 X-Sequence-Number: 9087 Hi Andrew, I had never heard of Ubuntu before, thanks for the tip. regards iain ----- Original Message ----- From: "Andrew McMillan" To: "Iain" Sent: Monday, November 08, 2004 12:51 PM Subject: Re: [PERFORM] postgresql amd-64 On Mon, 2004-11-08 at 11:13 +0900, Iain wrote: > I'm hoping I'll have the opportunity to build a similar machine soon and > am > wondering about the choice of 64 bit distributions. > > Gentoo is obviously a possibility but I'm also condsidering Debian. There > is > also a 64 compile of redhat sources somewhere around, but I can't remember > what they call it offhand. > > If anyone has opinions about that, I'd be happy to hear. Hi Iain, We are using Debian on a few dual-Opteron systems and a number of AMD64 desktop systems and it is working fine. We are also using Ubuntu, which can be installed with the "Custom" options for a server, is Debian based, and includes PostgreSQL in the basic supported package set. Due to the better security support for AMD64 in Ubuntu we are likely to migrate our server environments to that, at least until there is a more officially support AMD64 port for Debian. Cheers, Andrew. ------------------------------------------------------------------------- Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St DDI: +64(4)803-2201 MOB: +64(272)DEBIAN OFFICE: +64(4)499-2267 Don't get to bragging. ------------------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Mon Nov 8 10:40:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9A5F03A2BCC for ; Mon, 8 Nov 2004 10:40:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16811-08 for ; Mon, 8 Nov 2004 10:40:06 +0000 (GMT) Received: from postfix.snow.erlang.no (snow.uninett.no [158.38.61.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5B9693A3D1E for ; Mon, 8 Nov 2004 10:40:07 +0000 (GMT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by postfix.snow.erlang.no (Postfix) with ESMTP id 9F17118D264 for ; Mon, 8 Nov 2004 11:40:05 +0100 (CET) Mime-Version: 1.0 (Apple Message framework v619) Content-Transfer-Encoding: quoted-printable Message-Id: <8A4F8F3E-3172-11D9-9835-000393BAA290@uninett.no> Content-Type: text/plain; charset=UTF-8; delsp=yes; format=fixed To: pgsql-performance@postgresql.org From: =?ISO-8859-1?Q?Andreas_=C5kre_Solberg?= Subject: Postgresql is using seqscan when is should use indexes. Date: Mon, 8 Nov 2004 11:40:00 +0100 X-Pgp-Rfc2646-Fix: 1 X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/134 X-Sequence-Number: 9088 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 We have two tables, dst_port_hour and dst_port_day, which should be =20 very similar, they both have about 50.000.000 rows. In both tables we =20= have an index for period_id. We run postgresql 7.4.5 on a dedicated Debian server, with dual Intel =20= Xeon 3GHz and 4GB memory. The problem is that on the dst_port_day table, postgresql is using =20 seqscan, and not the index when it should. Forcing the use of the index =20= by setting enable_seqscan to false, makes the query lighthening fast. =20= When using seqscan, the query takes several minutes. The planner =20 calculates the cost for Index scan to be much more than sequence scan. Why is our query planner misbehaving? Here are the exaplain analyze output with and without index-force: SET enable_seqscan=3Dfalse; stager=3D> explain analyze SELECT cur.portnr FROM dst_port_day cur = WHERE =20 cur.period_id=3D'2779' GROUP BY cur.portnr ORDER BY SUM(cur.octets) = DESC =20 LIMIT 5; = =20 QUERY PLAN - = ------------------------------------------------------------------------=20= - = ------------------------------------------------------------------------=20= - --------------------------------- Limit (cost=3D2022664.62..2022664.63 rows=3D5 width=3D12) (actual =20 time=3D831.772..831.816 rows=3D5 loops=3D1) -> Sort (cost=3D2022664.62..2022664.82 rows=3D80 width=3D12) = (actual =20 time=3D831.761..831.774 rows=3D5 loops=3D1) Sort Key: sum(octets) -> HashAggregate (cost=3D2022661.89..2022662.09 rows=3D80 =20= width=3D12) (actual time=3D587.036..663.991 rows=3D16396 loops=3D1) -> Index Scan using dst_port_day_period_id_key on =20 dst_port_day cur (cost=3D0.00..2019931.14 rows=3D546150 width=3D12) = (actual =20 time=3D0.038..303.801 rows=3D48072 loops=3D1) Index Cond: (period_id =3D 2779) Total runtime: 836.362 ms (7 rows) SET enable_seqscan=3Dtrue; stager=3D> explain analyze SELECT cur.portnr FROM dst_port_day cur =20 WHERE cur.period_id=3D'2779' GROUP BY cur.portnr ORDER BY =20 SUM(cur.octets) DESC LIMIT 5; =20= QUERY PLAN - = ------------------------------------------------------------------------=20= - = ------------------------------------------------------------------------=20= - ------ Limit (cost=3D1209426.88..1209426.89 rows=3D5 width=3D12) (actual =20 time=3D299053.006..299053.053 rows=3D5 loops=3D1) -> Sort (cost=3D1209426.88..1209427.08 rows=3D80 width=3D12) = (actual =20 time=3D299052.995..299053.008 rows=3D5 loops=3D1) Sort Key: sum(octets) -> HashAggregate (cost=3D1209424.15..1209424.35 rows=3D80 =20= width=3D12) (actual time=3D298803.273..298881.020 rows=3D16396 loops=3D1) -> Seq Scan on dst_port_day cur (cost=3D0.00..1206693.40= =20 rows=3D546150 width=3D12) (actual time=3D298299.508..298526.544 = rows=3D48072 =20 loops=3D1) Filter: (period_id =3D 2779) Total runtime: 299057.643 ms (7 rows) - --=20 Andreas =C3=85kre Solberg, UNINETT AS Testnett Contact info and Public PGP Key available on: http://andreas.solweb.no/?account=3DWork -----BEGIN PGP SIGNATURE----- Version: PGP 8.1 Comment: My public key is available at http://andreas.solweb.no iQA/AwUBQY9NBPyFPYEtpdl2EQKIcwCgpPEkZ3PQKWNf6JWP6tQ4eFBPEngAoKTT 4eGkB0NVyIg0surd1LJdFD7+ =3DbYtH -----END PGP SIGNATURE----- From pgsql-performance-owner@postgresql.org Mon Nov 8 11:40:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0E9003A3BC7 for ; Mon, 8 Nov 2004 11:40:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38721-03 for ; Mon, 8 Nov 2004 11:40:33 +0000 (GMT) Received: from mxc.pcnet.ro (unknown [82.137.16.32]) by svr1.postgresql.org (Postfix) with ESMTP id AB2223A23D0 for ; Mon, 8 Nov 2004 11:40:34 +0000 (GMT) Received: from aldratech.com (aldratech.com.pcnet.ro [213.154.158.58] (may be forged)) by mxc.pcnet.ro (8.12.10/8.12.10) with ESMTP id iA8Bdu4r004202 for ; Mon, 8 Nov 2004 13:39:56 +0200 Received: from [192.168.0.6] ([192.168.0.6]) by aldratech.com for with eXtremail; Mon, 8 Nov 2004 13:40:32 +2GMT Message-ID: <418F5B2F.3010600@aldratech.com> Date: Mon, 08 Nov 2004 13:40:31 +0200 From: Radu-Adrian Popescu Reply-To: radu.popescu@aldratech.com Organization: Aldratech Ltd. User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.3) Gecko/20040921 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Iain Cc: pgsql-performance@postgresql.org Subject: Re: postgresql amd-64 References: <6EE64EF3AB31D5448D0007DD34EEB3412A7518@Herge.rcsinc.local> <418BC518.2050909@omnis.com> <014501c4c538$88d66950$7201a8c0@mst1x5r347kymb> In-Reply-To: <014501c4c538$88d66950$7201a8c0@mst1x5r347kymb> Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg=sha1; boundary="------------ms030806070509080706090408" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/135 X-Sequence-Number: 9089 This is a cryptographically signed message in MIME format. --------------ms030806070509080706090408 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Iain wrote: > I'm hoping I'll have the opportunity to build a similar machine soon and > am wondering about the choice of 64 bit distributions. > > Gentoo is obviously a possibility but I'm also condsidering Debian. > There is also a 64 compile of redhat sources somewhere around, but I > can't remember what they call it offhand. > RedHat's community OS is now called Fedora: http://fedora.redhat.com/ There's been two AMD64 releases of this OS, Fedora Core 1 and Fedora Core 2. Core 3 is just around the corner. I've been running FC2 x86_64 with kernel 2.6 as a desktop system for quite some time now, with PostgreSQL 7.4.2 / 64bit installed. I find Fedora to be a really good Linux distro, continuing and improving upon the fine tradition of RedHat's releases. You can also get RedHat's commercial releases on AMD64; according to http://www.redhat.com/software/rhel/features/ you can also get a EM64T release. > If anyone has opinions about that, I'd be happy to hear. -- Radu-Adrian Popescu CSA, DBA, Developer Aldrapay MD Aldratech Ltd. +40213212243 --------------ms030806070509080706090408 Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIJDTCC AuEwggJKoAMCAQICAw0/VDANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UE ChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNv bmFsIEZyZWVtYWlsIElzc3VpbmcgQ0EwHhcNMDQxMDE4MTEwNjM0WhcNMDUxMDE4MTEwNjM0 WjBMMR8wHQYDVQQDExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSkwJwYJKoZIhvcNAQkBFhpy YWR1LnBvcGVzY3VAYWxkcmF0ZWNoLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC ggEBAM+UjztouTxkdmm0OFNJxUGs2UpnbgswyyR0EmZYGpPnge2EjGIbnxgCsgtId466dmqw OokdKo7xf/XNzhYxR3NluUf6SsQhd8lVWt8ATHFchGEs5iHZAEcsbu2hzkrVTbrgfcer8+r/ WUlrEiMC1tJBXKQFxqVDZiLDrfGs+yxm0HSwnHE9DFrNFUpcqvZ0haBs4DA52AQw6rOxZaza eoDVXETwOHKp5K4igmC7Fu1tyA63g7RMn7dDtZ9r6U86FfN6RAOJ0SVvvlRWq31Z8ziLNtKO EytsMpVPlVL1Hhx86S5gqweU9YaXsZ3jfHXkMo8tpN33hplgBtPcjwToLnUCAwEAAaM3MDUw JQYDVR0RBB4wHIEacmFkdS5wb3Blc2N1QGFsZHJhdGVjaC5jb20wDAYDVR0TAQH/BAIwADAN BgkqhkiG9w0BAQQFAAOBgQBq9KdN3dCGQ2TgIrAjyWeDihQMsVMdfAVymKpOz/SDwsvnVP0N 9PDFr3MAcKql/ZodgVm4GylYyQVALIT6UcsjBd38kRRaLZhwB4zyp1s22uYsc3e7cnMgFs2F 2210Tv0WMMeRbRiMK6JCskLFxNg6N7w072+z/IOxcFpH3ZPBPzCCAuEwggJKoAMCAQICAw0/ VDANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1 bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElz c3VpbmcgQ0EwHhcNMDQxMDE4MTEwNjM0WhcNMDUxMDE4MTEwNjM0WjBMMR8wHQYDVQQDExZU aGF3dGUgRnJlZW1haWwgTWVtYmVyMSkwJwYJKoZIhvcNAQkBFhpyYWR1LnBvcGVzY3VAYWxk cmF0ZWNoLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM+UjztouTxkdmm0 OFNJxUGs2UpnbgswyyR0EmZYGpPnge2EjGIbnxgCsgtId466dmqwOokdKo7xf/XNzhYxR3Nl uUf6SsQhd8lVWt8ATHFchGEs5iHZAEcsbu2hzkrVTbrgfcer8+r/WUlrEiMC1tJBXKQFxqVD ZiLDrfGs+yxm0HSwnHE9DFrNFUpcqvZ0haBs4DA52AQw6rOxZazaeoDVXETwOHKp5K4igmC7 Fu1tyA63g7RMn7dDtZ9r6U86FfN6RAOJ0SVvvlRWq31Z8ziLNtKOEytsMpVPlVL1Hhx86S5g qweU9YaXsZ3jfHXkMo8tpN33hplgBtPcjwToLnUCAwEAAaM3MDUwJQYDVR0RBB4wHIEacmFk dS5wb3Blc2N1QGFsZHJhdGVjaC5jb20wDAYDVR0TAQH/BAIwADANBgkqhkiG9w0BAQQFAAOB gQBq9KdN3dCGQ2TgIrAjyWeDihQMsVMdfAVymKpOz/SDwsvnVP0N9PDFr3MAcKql/ZodgVm4 GylYyQVALIT6UcsjBd38kRRaLZhwB4zyp1s22uYsc3e7cnMgFs2F2210Tv0WMMeRbRiMK6JC skLFxNg6N7w072+z/IOxcFpH3ZPBPzCCAz8wggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAw gdExCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUg VG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcxKDAmBgNVBAsTH0NlcnRpZmljYXRp b24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFp bCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxAdGhhd3RlLmNvbTAeFw0w MzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxU aGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwg RnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAxKY8VXNV +065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B1OVQCjDXAmNaLIkVcI7dyfAr hVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/ p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8 MDowOKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVtYWls Q0EuY3JsMAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJpdmF0ZUxh YmVsMi0xMzgwDQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOWlJ1/ TCG4+DYfqi2fNi/A9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amc OY6MIE9lX5Xa9/eH1sYITq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8xggM7MIID NwIBATBpMGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5 KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQID DT9UMAkGBSsOAwIaBQCgggGnMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcN AQkFMQ8XDTA0MTEwODExNDAzMVowIwYJKoZIhvcNAQkEMRYEFN7mJj/8vhjVicFfDAOxH804 THPhMFIGCSqGSIb3DQEJDzFFMEMwCgYIKoZIhvcNAwcwDgYIKoZIhvcNAwICAgCAMA0GCCqG SIb3DQMCAgFAMAcGBSsOAwIHMA0GCCqGSIb3DQMCAgEoMHgGCSsGAQQBgjcQBDFrMGkwYjEL MAkGA1UEBhMCWkExJTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAq BgNVBAMTI1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBAgMNP1QwegYLKoZI hvcNAQkQAgsxa6BpMGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGlu ZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNzdWlu ZyBDQQIDDT9UMA0GCSqGSIb3DQEBAQUABIIBAK212GgKvsZC0tKgmfEtMu5rwd/h3Te45n5c emCVgqIwDFFN4uJwRyg8MrgGTd52eCwcvwLxVFzxe/bpFGCrVjwDf7twgRiAUMdSNbBCXSD9 99Z3BA5us0wXUcbdAe04jc1iLIiojjA69/MnoYC1+s8/wVrMmCQlOuxWScNEdSyUce/Xqx1K l5CcJzt6QuVRlfSUSUV2UoPDv5IwESJS9HCaWhA/T7NjT9wIYLR5fCeGs5zGfpxWkwOEIV91 nAWQtbcSBtfZukGVzrlEpTczdQDAe20cFiZgmWvnAJfOysC1+TGCkCa2oidCUQ4+IAGV9Gwx E/YjkdsFRt7iiB7YVukAAAAAAAA= --------------ms030806070509080706090408-- From pgsql-performance-owner@postgresql.org Mon Nov 8 11:47:01 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1CF103A3E0F for ; Mon, 8 Nov 2004 11:46:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37257-10 for ; Mon, 8 Nov 2004 11:46:51 +0000 (GMT) Received: from mail.atua.com.br (unknown [200.248.138.61]) by svr1.postgresql.org (Postfix) with ESMTP id 07EBD3A3D0A for ; Mon, 8 Nov 2004 11:46:52 +0000 (GMT) Received: from [10.0.0.171] (ns2.atua.com.br [200.248.138.60]) by mail.atua.com.br (Postfix) with ESMTP id 38BFF1EC2BC for ; Mon, 8 Nov 2004 09:46:51 -0200 (BRST) Subject: Re: Better Hardware, worst Results From: Alvaro Nunes Melo To: Pgsql-Performance In-Reply-To: <1099609109.1647.727.camel@home> References: <1099602361.7775.15.camel@localhost> <1099602998.1647.711.camel@home> <1099608123.418ab03ba292f@webmail.atua.com.br> <1099609109.1647.727.camel@home> Content-Type: text/plain; charset=iso-8859-1 Message-Id: <1099914410.4314.8.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 08 Nov 2004 09:46:51 -0200 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/136 X-Sequence-Number: 9090 Em Qui, 2004-11-04 �s 20:58, Rod Taylor escreveu: > All 3 plans have crappy estimates. > > Run ANALYZE in production, then send another explain analyze (as an > attachment please, to avoid linewrap). First of all, I'd like to apoligize for taking so long to post a new position. After this, I apologize again because the problem was in my query. It used some functions that for some reason made the Dell machine have a greater cost than our house-made machine. After correcting this functions, the results were faster in the Dell machine. The last apologize is for the linewrapped explains. In our brazilian PostgreSQL mailing list, attachments are not allowed, so I send them as inline text. Thanks to everyone who spent some time to help me solving this problem. -- +---------------------------------------------------+ | Alvaro Nunes Melo Atua Sistemas de Informacao | | al_nunes@atua.com.br www.atua.com.br | | UIN - 42722678 (54) 327-1044 | +---------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Nov 8 12:07:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 91E793A3C95 for ; Mon, 8 Nov 2004 12:07:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45180-03 for ; Mon, 8 Nov 2004 12:07:04 +0000 (GMT) Received: from mail.pws.com.au (mail.pws.com.au [210.23.138.139]) by svr1.postgresql.org (Postfix) with SMTP id 8B2353A3AC3 for ; Mon, 8 Nov 2004 12:07:05 +0000 (GMT) Received: (qmail 18236 invoked by uid 0); 8 Nov 2004 23:07:01 +1100 Received: from cpe-203-45-44-212.vic.bigpond.net.au (HELO wizzard.pws.com.au) (russell@pws.com.au@203.45.44.212) by mail.pws.com.au with SMTP; 8 Nov 2004 23:07:01 +1100 From: Russell Smith To: Andreas =?utf-8?q?=C3=85kre_Solberg?= Subject: Re: Postgresql is using seqscan when is should use indexes. Date: Mon, 8 Nov 2004 23:04:04 +1100 User-Agent: KMail/1.7 Cc: pgsql-performance@postgresql.org References: <8A4F8F3E-3172-11D9-9835-000393BAA290@uninett.no> In-Reply-To: <8A4F8F3E-3172-11D9-9835-000393BAA290@uninett.no> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200411082304.04359.mr-russ@pws.com.au> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/137 X-Sequence-Number: 9091 On Mon, 8 Nov 2004 09:40 pm, Andreas =C3=85kre Solberg wrote: > We have two tables, dst_port_hour and dst_port_day, which should be > very similar, they both have about 50.000.000 rows. In both tables we > have an index for period_id. >=20 > We run postgresql 7.4.5 on a dedicated Debian server, with dual Intel > Xeon 3GHz and 4GB memory. >=20 > The problem is that on the dst_port_day table, postgresql is using > seqscan, and not the index when it should. Forcing the use of the index > by setting enable_seqscan to false, makes the query lighthening fast. > When using seqscan, the query takes several minutes. The planner > calculates the cost for Index scan to be much more than sequence scan. >=20 > Why is our query planner misbehaving? >=20 > Here are the exaplain analyze output with and without index-force: >=20 >=20 > SET enable_seqscan=3Dfalse; >=20 > stager=3D> explain analyze SELECT cur.portnr FROM dst_port_day cur WHERE > cur.period_id=3D'2779' GROUP BY cur.portnr ORDER BY SUM(cur.octets) DESC > LIMIT 5; >=20 dst_port_day cur (cost=3D0.00..2019931.14 rows=3D546150 width=3D12) (actua= l time=3D0.038..303.801 rows=3D48072 loops=3D1) The guess of the number of rows returned by the index scan is out by a fact= or of 10. 500k rows is greater than 1% of the rows, so I think the planner is likely to choose a sequence scan at thi= s amount, unless you have tuned things like random page cost. What is the selectivity like on that column? Have you analyzed recently? If so, you should probably increase the statistics on that column See ALTER TABLE SET STATISTICS in the manual. > QUERY PLAN > -------------------------------------------------------------------------= =2D------------------------------------------------------------------------= =2D------------------------------ > Limit (cost=3D2022664.62..2022664.63 rows=3D5 width=3D12) (actual time= =3D831.772..831.816 rows=3D5 loops=3D1) > -> Sort (cost=3D2022664.62..2022664.82 rows=3D80 width=3D12) (actua= l time=3D831.761..831.774 rows=3D5 loops=3D1) > Sort Key: sum(octets) > -> HashAggregate (cost=3D2022661.89..2022662.09 rows=3D80 wid= th=3D12) (actual time=3D587.036..663.991 rows=3D16396 loops=3D1) > -> Index Scan using dst_port_day_period_id_key on dst_po= rt_day cur (cost=3D0.00..2019931.14 rows=3D546150 width=3D12) (actual time= =3D0.038..303.801 rows=3D48072 loops=3D1) > Index Cond: (period_id =3D 2779) > Total runtime: 836.362 ms > (7 rows) >=20 >=20 >=20 > SET enable_seqscan=3Dtrue; >=20 > stager=3D> explain analyze SELECT cur.portnr FROM dst_port_day cur WHER= E cur.period_id=3D'2779' GROUP BY cur.portnr ORDER BY SUM(cur.octets) DESC= LIMIT 5; >=20 > QUERY PLAN > -------------------------------------------------------------------------= =2D------------------------------------------------------------------------= =2D--- > Limit (cost=3D1209426.88..1209426.89 rows=3D5 width=3D12) (actual time= =3D299053.006..299053.053 rows=3D5 loops=3D1) > -> Sort (cost=3D1209426.88..1209427.08 rows=3D80 width=3D12) (actua= l time=3D299052.995..299053.008 rows=3D5 loops=3D1) > Sort Key: sum(octets) > -> HashAggregate (cost=3D1209424.15..1209424.35 rows=3D80 wid= th=3D12) (actual time=3D298803.273..298881.020 rows=3D16396 loops=3D1) > -> Seq Scan on dst_port_day cur (cost=3D0.00..1206693.4= 0 rows=3D546150 width=3D12) (actual time=3D298299.508..298526.544 rows=3D48= 072 loops=3D1) > Filter: (period_id =3D 2779) > Total runtime: 299057.643 ms > (7 rows) >=20 Regards Russell Smith From pgsql-performance-owner@postgresql.org Mon Nov 8 12:26:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E37103A3E1A for ; Mon, 8 Nov 2004 12:26:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48525-10 for ; Mon, 8 Nov 2004 12:26:24 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.205]) by svr1.postgresql.org (Postfix) with ESMTP id 624193A2B4A for ; Mon, 8 Nov 2004 12:26:26 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a36so291082rnf for ; Mon, 08 Nov 2004 04:26:09 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=kLvxk1RRebwd/NBUgIj6TRqAn28brfRSLSNFArWDu86Yp4EA42fhJFFsxJGVXc8b4fcCnRYKSBbfb6EWOLSQKAkcLwxCfMvfAx0Ieqj9YYEa2ASyXDnxSwAXUx0UNnrghYLdmwAG6S8eaQk9YSLFAoii0wPf9YTZzWIi4sB88Ro= Received: by 10.38.82.50 with SMTP id f50mr274550rnb; Mon, 08 Nov 2004 04:26:09 -0800 (PST) Received: by 10.38.163.22 with HTTP; Mon, 8 Nov 2004 04:26:09 -0800 (PST) Message-ID: <758d5e7f04110804263efdf475@mail.gmail.com> Date: Mon, 8 Nov 2004 13:26:09 +0100 From: Dawid Kuroczko Reply-To: Dawid Kuroczko To: pgsql-performance@postgresql.org Subject: ext3 journalling type Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200411/138 X-Sequence-Number: 9092 The ext3fs allows to selet type of journalling to be used with filesystem. Journalling pretty much "mirrors" the work of WAL logging by PostgreSQL... I wonder which type of journalling is best for PgSQL in terms of performance. Choices include: journal All data is committed into the journal prior to being written into the main file system. ordered This is the default mode. All data is forced directly out to the main file system prior to its metadata being committed to the journal. writeback Data ordering is not preserved - data may be written into the main file system after its metadata has been commit- ted to the journal. This is rumoured to be the highest- throughput option. It guarantees internal file system integrity, however it can allow old data to appear in files after a crash and journal recovery. Am I right to assume that "writeback" is both fastest and at the same time as safe to use as ordered? Maybe any of you did some benchmarks? Regards, Dawid From pgsql-performance-owner@postgresql.org Mon Nov 8 13:20:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 803763A3E62 for ; Mon, 8 Nov 2004 13:20:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70973-01 for ; Mon, 8 Nov 2004 13:20:44 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id AE42F3A3C84 for ; Mon, 8 Nov 2004 13:20:46 +0000 (GMT) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-class: urn:content-classes:message Subject: Re: postgresql amd-64 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Mon, 8 Nov 2004 08:20:11 -0500 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A751D@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] postgresql amd-64 Thread-Index: AcTDrPN0zfIYyifySp65dYvEEQkyuAB51RHw From: "Merlin Moncure" To: "Vishal Kashyap @ [Sai Hertz And Control Systems]" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/139 X-Sequence-Number: 9093 > > Good, I'll give it a shot and see what I come up with...thx. > > > Do share your experience with us. Will do. I have to ship the server on Friday, and the parts are on order. If they come today, I'll have time to test Gentoo, Redhat 32/64, and win32 by then. If I can't get it built until tomorrow, unfortunately the Gentoo test will have to be skipped. The win32 test is forced because our clients prefer win32 and I have to justify any platform change with a reasonable performance advantage. I have to compile and install a lot of software (including subversion, which I'm using to manage our application binaries), and I'm wary of 64 bit library issues which will hold me up. Any major roadblocks and I'll be forced to drop the test. When I'm finished I'll throw a link to this list, probably Friday. Merlin From pgsql-performance-owner@postgresql.org Mon Nov 8 14:05:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 66E483A3E68 for ; Mon, 8 Nov 2004 14:05:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85836-03 for ; Mon, 8 Nov 2004 14:04:55 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 415963A3E63 for ; Mon, 8 Nov 2004 14:04:56 +0000 (GMT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id iA8E4jK27330; Mon, 8 Nov 2004 09:04:45 -0500 (EST) From: Bruce Momjian Message-Id: <200411081404.iA8E4jK27330@candle.pha.pa.us> Subject: Re: ext3 journalling type In-Reply-To: <758d5e7f04110804263efdf475@mail.gmail.com> To: Dawid Kuroczko Date: Mon, 8 Nov 2004 09:04:45 -0500 (EST) Cc: pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/140 X-Sequence-Number: 9094 Dawid Kuroczko wrote: > The ext3fs allows to selet type of journalling to be used with > filesystem. Journalling pretty much "mirrors" the work of WAL > logging by PostgreSQL... I wonder which type of journalling > is best for PgSQL in terms of performance. > Choices include: > journal > All data is committed into the journal prior to being > written into the main file system. > ordered > This is the default mode. All data is forced directly > out to the main file system prior to its metadata being > committed to the journal. > writeback > Data ordering is not preserved - data may be written into > the main file system after its metadata has been commit- > ted to the journal. This is rumoured to be the highest- > throughput option. It guarantees internal file system > integrity, however it can allow old data to appear in > files after a crash and journal recovery. > > Am I right to assume that "writeback" is both fastest and at the same > time as safe to use as ordered? Maybe any of you did some benchmarks? Yes. I have seen benchmarks that say writeback is fastest but I don't have any numbers handy. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Mon Nov 8 15:14:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A816C3A3F22 for ; Mon, 8 Nov 2004 15:14:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07960-09 for ; Mon, 8 Nov 2004 15:14:11 +0000 (GMT) Received: from neptune.lgu.ac.uk (neptune.lgu.ac.uk [140.97.30.6]) by svr1.postgresql.org (Postfix) with ESMTP id B80133A3F0C for ; Mon, 8 Nov 2004 15:14:13 +0000 (GMT) Received: from solent (cal42-234.lgu.ac.uk [140.97.42.234]) by neptune.lgu.ac.uk (8.12.10/8.12.10) with ESMTP id iA8FDkO6000515; Mon, 8 Nov 2004 15:13:46 GMT Reply-To: From: "Matt Clark" To: "'Dawid Kuroczko'" , Subject: Re: ext3 journalling type Date: Mon, 8 Nov 2004 15:14:04 -0000 Organization: Ymogen Ltd Message-ID: <000d01c4c5a5$96202020$8300a8c0@solent> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Importance: Normal In-Reply-To: <758d5e7f04110804263efdf475@mail.gmail.com> X-LGU-MailScanner: Found to be clean X-MailScanner-From: matt@ymogen.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/141 X-Sequence-Number: 9095 > Am I right to assume that "writeback" is both fastest and at=20 > the same time as safe to use as ordered? Maybe any of you=20 > did some benchmarks? It should be fastest because it is the least overhead, and safe because postgres does it's own write-order guaranteeing through fsync(). You = should also mount the FS with the 'noatime' option. But.... For some workloads, there are tests showing that = 'data=3Djournal' can be the fastest! This is because although the data is written twice = (once to the journal, and then to its real location on disk) in this mode data is written _sequentially_ to the journal, and later written out to its destination, which may be at a quieter time. There's a discussion (based around 7.2) here: http://www.kerneltraffic.org/kernel-traffic/kt20020401_160.txt M From pgsql-performance-owner@postgresql.org Mon Nov 8 16:30:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C09213A3E5A for ; Mon, 8 Nov 2004 16:30:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34639-10 for ; Mon, 8 Nov 2004 16:30:22 +0000 (GMT) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by svr1.postgresql.org (Postfix) with ESMTP id BF6B63A3F0C for ; Mon, 8 Nov 2004 16:30:18 +0000 (GMT) Received: (from markw@localhost) by mail.osdl.org (8.11.6/8.11.6) id iA8GTxN05745; Mon, 8 Nov 2004 08:29:59 -0800 Date: Mon, 8 Nov 2004 08:29:59 -0800 From: Mark Wong To: Dawid Kuroczko Cc: pgsql-performance@postgresql.org Subject: Re: ext3 journalling type Message-ID: <20041108082959.A3950@osdl.org> References: <758d5e7f04110804263efdf475@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <758d5e7f04110804263efdf475@mail.gmail.com>; from qnex42@gmail.com on Mon, Nov 08, 2004 at 01:26:09PM +0100 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/142 X-Sequence-Number: 9096 I have some data here, no detailed analyses though: http://www.osdl.org/projects/dbt2dev/results/fs/ Mark On Mon, Nov 08, 2004 at 01:26:09PM +0100, Dawid Kuroczko wrote: > The ext3fs allows to selet type of journalling to be used with > filesystem. Journalling pretty much "mirrors" the work of WAL > logging by PostgreSQL... I wonder which type of journalling > is best for PgSQL in terms of performance. > Choices include: > journal > All data is committed into the journal prior to being > written into the main file system. > ordered > This is the default mode. All data is forced directly > out to the main file system prior to its metadata being > committed to the journal. > writeback > Data ordering is not preserved - data may be written into > the main file system after its metadata has been commit- > ted to the journal. This is rumoured to be the highest- > throughput option. It guarantees internal file system > integrity, however it can allow old data to appear in > files after a crash and journal recovery. > > Am I right to assume that "writeback" is both fastest and at the same > time as safe to use as ordered? Maybe any of you did some benchmarks? > > Regards, > Dawid > From pgsql-performance-owner@postgresql.org Mon Nov 8 17:39:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 229663A3B0B for ; Mon, 8 Nov 2004 17:39:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59663-09 for ; Mon, 8 Nov 2004 17:39:17 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 8873E3A3F9C for ; Mon, 8 Nov 2004 17:39:16 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6631312; Mon, 08 Nov 2004 09:40:42 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org, Subject: Re: ext3 journalling type Date: Mon, 8 Nov 2004 09:38:56 -0800 User-Agent: KMail/1.6.2 Cc: "'Dawid Kuroczko'" References: <000d01c4c5a5$96202020$8300a8c0@solent> In-Reply-To: <000d01c4c5a5$96202020$8300a8c0@solent> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <200411080938.56212.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/143 X-Sequence-Number: 9097 Matt, > It should be fastest because it is the least overhead, and safe because > postgres does it's own write-order guaranteeing through fsync(). =A0You > should also mount the FS with the 'noatime' option. This, of course, assumes that PostgreSQL is the only thing on the partition= =2E =20 Which is a good idea in general, but not to be taken for granted ... =2D-=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Nov 8 17:45:08 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0474F3A3E5A for ; Mon, 8 Nov 2004 17:45:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61008-08 for ; Mon, 8 Nov 2004 17:44:52 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 389FE3A3F4D for ; Mon, 8 Nov 2004 17:44:53 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6631340; Mon, 08 Nov 2004 09:46:19 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: Question regarding the file system Date: Mon, 8 Nov 2004 09:44:33 -0800 User-Agent: KMail/1.6.2 Cc: Gabriele Bartolini References: <6.1.2.0.2.20041105220007.03401ec0@box.tin.it> In-Reply-To: <6.1.2.0.2.20041105220007.03401ec0@box.tin.it> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <200411080944.33311.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/144 X-Sequence-Number: 9098 Gabriele, > I have been given a dual PIII with 768MB RAM and I am going to install > PostgreSQL on it, for data warehousing reasons. I have also been given four > 160 Ultra SCSI disks (36MB each) with a RAID controller (Adaptec 2100). I > am going to use a RAID5 architecture (this gives me approximately 103 GB of > data) and install a Debian Linux on it: this machine will be dedicated > exclusively to PostgreSQL. FWIW, RAID5 with < 5 disks is probably the worst-performing disk setup for PG with most kinds of DB applications. However, with 4 disks you don't have a lot of other geometries available. If the database will fit on one disk, I might suggest doing RAID 1 for 2 of the disks, and having two single disks, one with the OS and swap, and one with the database log. If you're doing Debian, make sure to get a current version of PG from Debian Unstable. > I was wondering which file system you suggest me: ext3 or reiserfs? These seem to be equivalent in data=writeback mode for most database applications. Use whichever you find easier to install & maintain. > Also, I was thinking of using the 2.6.x kernel which offers a faster thread > support: will PostgreSQL gain anything from it or should I stick with > 2.4.x? PostgreSQL won't gain anything from the thread support (unless you're using a threaded front-end app with thread-safe ecpg). But it will gain from several other improvements in 2.6, especially better scheduling and VM support. Use 2.6. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Nov 8 18:57:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5A9B33A3E5A for ; Mon, 8 Nov 2004 18:57:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84654-08 for ; Mon, 8 Nov 2004 18:57:05 +0000 (GMT) Received: from web52103.mail.yahoo.com (web52103.mail.yahoo.com [206.190.39.72]) by svr1.postgresql.org (Postfix) with SMTP id ABF673A1EC0 for ; Mon, 8 Nov 2004 18:57:04 +0000 (GMT) Message-ID: <20041108185702.99883.qmail@web52103.mail.yahoo.com> Received: from [198.182.200.22] by web52103.mail.yahoo.com via HTTP; Mon, 08 Nov 2004 10:57:02 PST Date: Mon, 8 Nov 2004 10:57:02 -0800 (PST) From: patrick ~ Subject: Re: vacuum analyze slows sql query To: Tom Lane Cc: pgsql-performance@postgresql.org In-Reply-To: <26773.1099723138@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/145 X-Sequence-Number: 9099 Sorry for the late reply. Was feeling a bit under the weather this weekend and didn't get a chance to look at this. --- Tom Lane wrote: > patrick ~ writes: > > PREPARE pkk_00 ( integer ) ) > > This is what you want to do, but not quite like that. The PREPARE > determines the plan and so VACUUMing and re-EXECUTing is going to show > the same plan. What we need to look at is > - standing start > PREPARE pkk_00 ... > EXPLAIN ANALYZE EXECUTE pkk_00 ... > VACUUM ANALYZE; > PREPARE pkk_01 ... > EXPLAIN ANALYZE EXECUTE pkk_01 ... But of course! I feel a bit silly now. This is what I get after following Tom's directions: pkk=# prepare pkk_00 ( integer ) as select ... PREPARE Time: 1.753 ms pkk=# execute pkk_00( 241 ); case ------ f (1 row) Time: 0.788 ms pkk=# explain analyze execute pkk_00( 241 ); QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Result (cost=10.73..10.74 rows=1 width=0) (actual time=0.067..0.068 rows=1 loops=1) InitPlan -> Limit (cost=0.00..10.73 rows=1 width=4) (actual time=0.055..0.055 rows=0 loops=1) -> Index Scan using pur_offer_id_idx on pkk_purchase p0 (cost=0.00..20690.18 rows=1929 width=4) (actual time=0.052..0.052 rows=0 loops=1) Index Cond: (offer_id = $1) Filter: ((((expire_time)::timestamp with time zone > now()) OR (expire_time IS NULL) OR (pending = true)) AND ((cancel_date IS NULL) OR (pending = true))) Total runtime: 0.213 ms (7 rows) Time: 24.654 ms pkk=# vacuum analyze ; VACUUM Time: 128826.078 ms pkk=# prepare pkk_01 ( integer ) as select ... PREPARE Time: 104.658 ms pkk=# execute pkk_01( 241 ); case ------ f (1 row) Time: 7652.708 ms pkk=# explain analyze execute pkk_01( 241 ); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Result (cost=2.66..2.67 rows=1 width=0) (actual time=2872.211..2872.213 rows=1 loops=1) InitPlan -> Limit (cost=0.00..2.66 rows=1 width=4) (actual time=2872.189..2872.189 rows=0 loops=1) -> Seq Scan on pkk_purchase p0 (cost=0.00..37225.83 rows=13983 width=4) (actual time=2872.180..2872.180 rows=0 loops=1) Filter: ((offer_id = $1) AND (((expire_time)::timestamp with time zone > now()) OR (expire_time IS NULL) OR (pending = true)) AND ((cancel_date IS NULL) OR (pending = true))) Total runtime: 2872.339 ms (6 rows) Time: 2873.479 ms So it looks like after the VACCUM the planner resorts to Seq Scan rather than Index Scan. This is because of the value of correlation field in pg_stats (according to PostgreSQL docs) being closer to 0 rather than �1: pkk=# select tablename,attname,correlation from pg_stats where tablename = 'pkk_purchase' and attname = 'offer_id' ; tablename | attname | correlation --------------+----------+------------- pkk_purchase | offer_id | 0.428598 (1 row) So I started to experiment with ALTER TABLE SET STATISTICS values to see which gets the correlation closer to �1. The trend seems to indicat the higher the stat value is set it pushes the correlation value closer to 0: set statistics correlation ---------------------------- 800 0.393108 500 0.408137 200 0.43197 50 0.435211 1 0.45758 And a subsequent PREPARE and EXPLAIN ANALYZE confirms that the Planer reverts back to using the Index Scan after setting stats to 1 (even though correlation value is still closer to 0 than 1): pkk=# explain analyze execute pkk_02( 241 ); QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Result (cost=2.95..2.96 rows=1 width=0) (actual time=0.068..0.069 rows=1 loops=1) InitPlan -> Limit (cost=0.00..2.95 rows=1 width=4) (actual time=0.056..0.056 rows=0 loops=1) -> Index Scan using pur_offer_id_idx on pkk_purchase p0 (cost=0.00..35810.51 rows=12119 width=4) (actual time=0.053..0.053 rows=0 loops=1) Index Cond: (offer_id = $1) Filter: ((((expire_time)::timestamp with time zone > now()) OR (expire_time IS NULL) OR (pending = true)) AND ((cancel_date IS NULL) OR (pending = true))) Total runtime: 0.200 ms (7 rows) So, is this the ultimate solution to this issue? --patrick __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com From pgsql-performance-owner@postgresql.org Mon Nov 8 19:31:03 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D881E3A4087 for ; Mon, 8 Nov 2004 19:30:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95729-10 for ; Mon, 8 Nov 2004 19:30:55 +0000 (GMT) Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu [129.255.60.186]) by svr1.postgresql.org (Postfix) with ESMTP id 0B4623A406A for ; Mon, 8 Nov 2004 19:30:54 +0000 (GMT) Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id iA8JTn330779; Mon, 8 Nov 2004 13:29:49 -0600 Message-ID: <418FC923.2090704@johnmeinel.com> Date: Mon, 08 Nov 2004 13:29:39 -0600 From: John Meinel User-Agent: Mozilla Thunderbird 0.7.1 (X11/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: patrick ~ Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: vacuum analyze slows sql query References: <20041108185702.99883.qmail@web52103.mail.yahoo.com> In-Reply-To: <20041108185702.99883.qmail@web52103.mail.yahoo.com> X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigB574F12AD6861FD6080C3F2E" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/146 X-Sequence-Number: 9100 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB574F12AD6861FD6080C3F2E Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit patrick ~ wrote: [...] > pkk=# explain analyze execute pkk_01( 241 ); > QUERY PLAN > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Result (cost=2.66..2.67 rows=1 width=0) (actual time=2872.211..2872.213 > rows=1 loops=1) > InitPlan > -> Limit (cost=0.00..2.66 rows=1 width=4) (actual > time=2872.189..2872.189 rows=0 loops=1) > -> Seq Scan on pkk_purchase p0 (cost=0.00..37225.83 rows=13983 > width=4) (actual time=2872.180..2872.180 rows=0 loops=1) > Filter: ((offer_id = $1) AND (((expire_time)::timestamp with > time zone > now()) OR (expire_time IS NULL) OR (pending = true)) AND > ((cancel_date IS NULL) OR (pending = true))) > Total runtime: 2872.339 ms > (6 rows) > > Time: 2873.479 ms > [...] > So, is this the ultimate solution to this issue? > > --patrick It's not so much that correlation is < 0.5. It sounds like you're running into the same issue that I ran into in the past. You have a column with lots of repeated values, and a few exceptional ones. Notice this part of the query: -> Seq Scan on pkk_purchase p0 (cost rows=13983) (actual rows=0) For a general number, it thinks it might return 14,000 rows, hence the sequential scan. Before you do ANALYZE, it uses whatever defaults exist, which are probably closer to reality. The problem is that you probably have some values for pkk_purchase where it could return 14,000 rows (possibly much much more). And for those, seq scan is the best plan. However, for the particular value that you are testing, there are very few (no) entries in the table. With a prepared statement (or a function) it has to determine ahead of time what the best query is without knowing what value you are going to ask for. Lets say for a second that you manage to trick it into using index scan, and then you actually call the function with one of the values that returns 1,000s of rows. Probably it will take 10-100 times longer than if it used a seq scan. So what is the solution? The only one I'm aware of is to turn your static function into a dynamic one. So somewhere within the function you build up a SQL query string and call EXECUTE str. This forces the query planner to be run every time you call the function. This means that if you call it will a "nice" value, you will get the fast index scan, and if you call it with a "bad" value, it will switch back to seq scan. The downside is you don't get much of a benefit from using as stored procedure, as it has to run the query planner all the time (as though you issue the query manually each time.) But it still might be better for you in the long run. Example: instead of create function test(int) returns int as ' declare x alias for $1; int y; begin select into y ... from ... where id=x limit ...; return y; end '; use this format create function test(int) returns int as ' declare x alias for $1; int y; begin EXECUTE ''select into y ... from ... where id='' ||quote_literal(x) || '' limit ...''; return y; end; '; I think that will point you in the right direction. John =:-> --------------enigB574F12AD6861FD6080C3F2E Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBj8kjJdeBCYSNAAMRArHjAJ9s1e83jJcer3rIGlLYMPIYuZe3wgCgiuXH OGHybM4byIqBPHLwlDmWY5s= =Yw4f -----END PGP SIGNATURE----- --------------enigB574F12AD6861FD6080C3F2E-- From pgsql-admin-owner@postgresql.org Mon Nov 8 21:28:50 2004 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BAD5E3A409C for ; Mon, 8 Nov 2004 21:28:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37886-06 for ; Mon, 8 Nov 2004 21:28:41 +0000 (GMT) Received: from web52705.mail.yahoo.com (web52705.mail.yahoo.com [206.190.39.156]) by svr1.postgresql.org (Postfix) with SMTP id A904E3A408C for ; Mon, 8 Nov 2004 21:28:41 +0000 (GMT) Message-ID: <20041108212841.75273.qmail@web52705.mail.yahoo.com> Received: from [216.184.101.242] by web52705.mail.yahoo.com via HTTP; Mon, 08 Nov 2004 13:28:41 PST Date: Mon, 8 Nov 2004 13:28:41 -0800 (PST) From: Carlos Lopez Subject: Re: [PERFORM] poor performance in migrated database To: Simon Riggs Cc: pgsql-performance@postgresql.org, pgsql-admin@postgresql.org In-Reply-To: <1099777150.6942.393.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/63 X-Sequence-Number: 15448 This is one of the queries that work,and is the first in a 4 level nested query.... where do I find how to interpret explains??? thanks in advance, Carlos. mate=# explain analyze select * from vdocinvdpre; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Subquery Scan vdocinvdpre (cost=265045.23..281225.66 rows=231149 width=684) (actual time=29883.231..37652.860 rows=210073 loops=1) -> Unique (cost=265045.23..278914.17 rows=231149 width=423) (actual time=29883.182..34109.259 rows=210073 loops=1) -> Sort (cost=265045.23..265623.10 rows=231149 width=423) (actual time=29883.166..31835.849 rows=210073 loops=1) Sort Key: no_doc, seq, codigoinv, lote, no_rollo, costo_uni, po, cantidad_total, id_pedido, id_proveedor, udm, doc_ref, corte, id_planta, accion, costo_total, ubicacion, cantidad_detallada, descripcion, observaciones, factura, fecha_factura, correlativo -> Append (cost=36954.34..60836.63 rows=231149 width=423) (actual time=4989.382..18277.031 rows=210073 loops=1) -> Subquery Scan "*SELECT* 1" (cost=36954.34..44100.17 rows=79542 width=402) (actual time=4989.371..8786.752 rows=58466 loops=1) -> Merge Left Join (cost=36954.34..43304.75 rows=79542 width=402) (actual time=4989.341..7767.335 rows=58466 loops=1) Merge Cond: (("outer".seq = "inner".seq) AND ("outer"."?column18?" = "inner"."?column6?")) -> Sort (cost=29785.78..29925.97 rows=56076 width=366) (actual time=2829.242..3157.807 rows=56076 loops=1) Sort Key: docinvdtrims.seq, ltrim(rtrim((docinvdtrims.no_doc)::text)) -> Seq Scan on docinvdtrims (cost=0.00..2522.76 rows=56076 width=366) (actual time=17.776..954.557 rows=56076 loops=1) -> Sort (cost=7168.56..7310.40 rows=56738 width=60) (actual time=2159.854..2460.061 rows=56738 loops=1) Sort Key: docinvdtrimsubica.seq, ltrim(rtrim((docinvdtrimsubica.no_doc)::text)) -> Seq Scan on docinvdtrimsubica (cost=0.00..1327.38 rows=56738 width=60) (actual time=14.545..528.530 rows=56738 loops=1) -> Subquery Scan "*SELECT* 2" (cost=0.00..16736.46 rows=151607 width=423) (actual time=7.731..7721.147 rows=151607 loops=1) -> Seq Scan on docinvdrollos (cost=0.00..15220.39 rows=151607 width=423) (actual time=7.699..5109.468 rows=151607 loops=1) Total runtime: 38599.868 ms (17 filas) --- Simon Riggs wrote: > On Sat, 2004-11-06 at 19:52, Carlos Lopez wrote: > > The problem is that there are many nested views > which > > normally join tables by using two fields, one > > character and other integer. > > PostgreSQL has difficulty with some multi-column > situations, even though > in general it has a particularly good query > optimizer. > > If the first column is poorly selective, yet the > addition of the second > column makes the combination very highly selective > then PostgreSQL may > not be able to realise this, ANALYZE or not. ANALYZE > doesn't have > anywhere to store multi-column selectivity > statistics. > > EXPLAIN ANALYZE will show you whether this is the > case. It seems likely > that the estimated cardinality of certain joins is > incorrect. > > -- > Best Regards, Simon Riggs > > > ---------------------------(end of > broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose > an index scan if your > joining column's datatypes do not match > ===== ___ Ing. Carlos L�pez Linares IT Consultant Quieres aprender linux? visita http://www.aprende-linux.com.sv __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com From pgsql-performance-owner@postgresql.org Mon Nov 8 23:20:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D410C3A4101 for ; Mon, 8 Nov 2004 23:20:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76379-02 for ; Mon, 8 Nov 2004 23:19:51 +0000 (GMT) Received: from web52105.mail.yahoo.com (web52105.mail.yahoo.com [206.190.39.74]) by svr1.postgresql.org (Postfix) with SMTP id 27F163A40BC for ; Mon, 8 Nov 2004 23:19:52 +0000 (GMT) Message-ID: <20041108231951.23927.qmail@web52105.mail.yahoo.com> Received: from [198.182.200.22] by web52105.mail.yahoo.com via HTTP; Mon, 08 Nov 2004 15:19:51 PST Date: Mon, 8 Nov 2004 15:19:51 -0800 (PST) From: patrick ~ Subject: Re: vacuum analyze slows sql query To: John Meinel Cc: pgsql-performance@postgresql.org In-Reply-To: <418FC923.2090704@johnmeinel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/148 X-Sequence-Number: 9102 Hi John, Thanks for your reply and analysis. --- John Meinel wrote: > patrick ~ wrote: > [...] > > pkk=# explain analyze execute pkk_01( 241 ); > > QUERY PLAN > > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > Result (cost=2.66..2.67 rows=1 width=0) (actual time=2872.211..2872.213 > > rows=1 loops=1) > > InitPlan > > -> Limit (cost=0.00..2.66 rows=1 width=4) (actual > > time=2872.189..2872.189 rows=0 loops=1) > > -> Seq Scan on pkk_purchase p0 (cost=0.00..37225.83 rows=13983 > > width=4) (actual time=2872.180..2872.180 rows=0 loops=1) > > Filter: ((offer_id = $1) AND (((expire_time)::timestamp > with > > time zone > now()) OR (expire_time IS NULL) OR (pending = true)) AND > > ((cancel_date IS NULL) OR (pending = true))) > > Total runtime: 2872.339 ms > > (6 rows) > > > > Time: 2873.479 ms > > > > [...] > > > So, is this the ultimate solution to this issue? > > > > --patrick > > It's not so much that correlation is < 0.5. It sounds like you're > running into the same issue that I ran into in the past. You have a > column with lots of repeated values, and a few exceptional ones. Notice > this part of the query: > -> Seq Scan on pkk_purchase p0 (cost rows=13983) (actual rows=0) > > For a general number, it thinks it might return 14,000 rows, hence the > sequential scan. Before you do ANALYZE, it uses whatever defaults exist, > which are probably closer to reality. > > The problem is that you probably have some values for pkk_purchase where > it could return 14,000 rows (possibly much much more). And for those, > seq scan is the best plan. However, for the particular value that you > are testing, there are very few (no) entries in the table. You are absoultely correct: pkk=# select offer_id,count(*) from pkk_purchase group by offer_id order by count ; offer_id | count ----------+-------- 1019 | 1 1018 | 1 1016 | 1 (many of these) ... | ... 2131 | 6 844 | 6 1098 | 6 (a dozen or so of these) ... | ... 2263 | 682 2145 | 723 2258 | 797 2091 | 863 ... | ... 1153 | 96330 (the few heavy weights) 244 | 122163 242 | 255719 243 | 273427 184 | 348476 > With a prepared statement (or a function) it has to determine ahead of > time what the best query is without knowing what value you are going to > ask for. > > Lets say for a second that you manage to trick it into using index scan, > and then you actually call the function with one of the values that > returns 1,000s of rows. Probably it will take 10-100 times longer than > if it used a seq scan. Hmm... The fact is I am selecting (in this example anyway) over all values in pkk_offer table and calling the stored function with each pkk_offer.offer_id which in turn does a select on pkk_purchase table. Note that offer_id is a foreign key in pkk_purchase referencing pkk_offer table. I don't know if it matters (I suspect that it does) but I am using LIMIT 1 in the sub-query/stored function. All I need is one single row meeting any of the criteria laid out in the stored procedure to establish an offer_id is "pending". > So what is the solution? The only one I'm aware of is to turn your > static function into a dynamic one. > > So somewhere within the function you build up a SQL query string and > call EXECUTE str. This forces the query planner to be run every time you > call the function. This means that if you call it will a "nice" value, > you will get the fast index scan, and if you call it with a "bad" value, > it will switch back to seq scan. > > The downside is you don't get much of a benefit from using as stored > procedure, as it has to run the query planner all the time (as though > you issue the query manually each time.) But it still might be better > for you in the long run. Well, running the query without the stored function, basically typing out the stored function as a sub-query shows me: pkk=# explain analyze select o0.offer_id, ( select case when ( select p0.purchase_id from pkk_purchase p0 where p0.offer_id = o0.offer_id and ( p0.pending = true or ( ( p0.expire_time > now() or p0.expire_time isnull ) and p0.cancel_date isnull ) ) limit 1 ) isnull then false else true end ) from pkk_offer o0 ; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on pkk_offer o0 (cost=0.00..1834.11 rows=618 width=4) (actual time=2413.398..1341885.084 rows=618 loops=1) SubPlan -> Result (cost=2.94..2.95 rows=1 width=0) (actual time=2171.287..2171.289 rows=1 loops=618) InitPlan -> Limit (cost=0.00..2.94 rows=1 width=4) (actual time=2171.264..2171.266 rows=1 loops=618) -> Seq Scan on pkk_purchase p0 (cost=0.00..37225.83 rows=12670 width=4) (actual time=2171.245..2171.245 rows=1 loops=618) Filter: ((offer_id = $0) AND (((expire_time)::timestamp with time zone > now()) OR (expire_time IS NULL) OR (pending = true)) AND ((cancel_date IS NULL) OR (pending = true))) Total runtime: 1341887.523 ms (8 rows) while deleting all statistics on the pkk_% tables I get: pkk=# delete from pg_statistic where pg_statistic.starelid = pg_class.oid and pg_class.relname like 'pkk_%'; DELETE 11 pkk=# explain analyze select o0.offer_id, ( select case when ( select p0.purchase_id from pkk_purchase p0 where p0.offer_id = o0.offer_id and ( p0.pending = true or ( ( p0.expire_time > now() or p0.expire_time isnull ) and p0.cancel_date isnull ) ) limit 1 ) isnull then false else true end ) from pkk_offer o0 ; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Seq Scan on pkk_offer o0 (cost=0.00..6646.94 rows=618 width=4) (actual time=0.190..799.930 rows=618 loops=1) SubPlan -> Result (cost=10.73..10.74 rows=1 width=0) (actual time=1.277..1.278 rows=1 loops=618) InitPlan -> Limit (cost=0.00..10.73 rows=1 width=4) (actual time=1.266..1.267 rows=1 loops=618) -> Index Scan using pur_offer_id_idx on pkk_purchase p0 (cost=0.00..20690.18 rows=1929 width=4) (actual time=1.258..1.258 rows=1 loops=618) Index Cond: (offer_id = $0) Filter: ((((expire_time)::timestamp with time zone > now()) OR (expire_time IS NULL) OR (pending = true)) AND ((cancel_date IS NULL) OR (pending = true))) Total runtime: 801.234 ms (9 rows) As you can see this query (over all values of pkk_offer) with out any pg_statistics on the pkk_purchase table is extremely fast. Is this a bug in the PostgreSQL planner that misjudges the best choice with pg_statistics at hand? --patrick __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com From pgsql-admin-owner@postgresql.org Mon Nov 8 23:58:47 2004 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DD7893A40C4 for ; Mon, 8 Nov 2004 23:58:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86197-06 for ; Mon, 8 Nov 2004 23:57:59 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1212A3A408C for ; Mon, 8 Nov 2004 23:58:01 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA8NvwjS012048; Mon, 8 Nov 2004 18:57:58 -0500 (EST) To: Carlos Lopez Cc: Simon Riggs , pgsql-performance@postgresql.org, pgsql-admin@postgresql.org Subject: Re: [PERFORM] poor performance in migrated database In-reply-to: <20041108212841.75273.qmail@web52705.mail.yahoo.com> References: <20041108212841.75273.qmail@web52705.mail.yahoo.com> Comments: In-reply-to Carlos Lopez message dated "Mon, 08 Nov 2004 13:28:41 -0800" Date: Mon, 08 Nov 2004 18:57:58 -0500 Message-ID: <12047.1099958278@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/71 X-Sequence-Number: 15456 Carlos Lopez writes: > This is one of the queries that work,and is the first > in a 4 level nested query.... Do you really need UNION (as opposed to UNION ALL) in this query? The EXPLAIN shows that almost half the runtime is going into the sort/uniq to eliminate duplicates ... and according to the row counts, there are no duplicates, so it's wasted effort. I looked at your schema and saw an awful lot of SELECT DISTINCTs that looked like they might not be necessary, too. But I'm not willing to crawl through 144 views with no information about which ones are causing you problems. What's a typical query that you are unsatisfied with the performance of? regards, tom lane From pgsql-performance-owner@postgresql.org Tue Nov 9 00:02:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A62253A4134 for ; Tue, 9 Nov 2004 00:01:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89973-02 for ; Tue, 9 Nov 2004 00:01:45 +0000 (GMT) Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu [129.255.60.186]) by svr1.postgresql.org (Postfix) with ESMTP id 5EA403A40FF for ; Tue, 9 Nov 2004 00:01:46 +0000 (GMT) Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id iA901f300601; Mon, 8 Nov 2004 18:01:41 -0600 Message-ID: <419008DA.3000007@johnmeinel.com> Date: Mon, 08 Nov 2004 18:01:30 -0600 From: John Meinel User-Agent: Mozilla Thunderbird 0.7.1 (X11/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: patrick ~ Cc: pgsql-performance@postgresql.org Subject: Re: vacuum analyze slows sql query References: <20041108231951.23927.qmail@web52105.mail.yahoo.com> In-Reply-To: <20041108231951.23927.qmail@web52105.mail.yahoo.com> X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigE8F197F0FDD61F38455DFA7D" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/150 X-Sequence-Number: 9104 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigE8F197F0FDD61F38455DFA7D Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit patrick ~ wrote: > Hi John, > > Thanks for your reply and analysis. > No problem. It just happens that this is a problem we ran into recently. > > --- John Meinel wrote: > > >>patrick ~ wrote: [...] > > Hmm... The fact is I am selecting (in this example anyway) over all > values in pkk_offer table and calling the stored function with each > pkk_offer.offer_id which in turn does a select on pkk_purchase table. > Note that offer_id is a foreign key in pkk_purchase referencing > pkk_offer table. > > I don't know if it matters (I suspect that it does) but I am using > LIMIT 1 in the sub-query/stored function. All I need is one single > row meeting any of the criteria laid out in the stored procedure to > establish an offer_id is "pending". > If you are trying to establish existence, we also had a whole thread on this. Basically what we found was that adding an ORDER BY clause, helped tremendously in getting the planner to switch to an Index scan. You might try something like: SELECT column FROM mytable WHERE column='myval' ORDER BY column LIMIT 1; There seems to be a big difference between the above statement and: SELECT column FROM mytable WHERE column='myval' LIMIT 1; > > >>So what is the solution? The only one I'm aware of is to turn your >>static function into a dynamic one. >> >>So somewhere within the function you build up a SQL query string and >>call EXECUTE str. This forces the query planner to be run every time you >>call the function. This means that if you call it will a "nice" value, >>you will get the fast index scan, and if you call it with a "bad" value, >>it will switch back to seq scan. >> >>The downside is you don't get much of a benefit from using as stored >>procedure, as it has to run the query planner all the time (as though >>you issue the query manually each time.) But it still might be better >>for you in the long run. > > > > Well, running the query without the stored function, basically typing > out the stored function as a sub-query shows me: > > > pkk=# explain analyze select o0.offer_id, ( select case when ( select > p0.purchase_id from pkk_purchase p0 where p0.offer_id = o0.offer_id and ( > p0.pending = true or ( ( p0.expire_time > now() or p0.expire_time isnull ) and > p0.cancel_date isnull ) ) limit 1 ) isnull then false else true end ) from > pkk_offer o0 ; > QUERY PLAN > -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Seq Scan on pkk_offer o0 (cost=0.00..1834.11 rows=618 width=4) (actual > time=2413.398..1341885.084 rows=618 loops=1) > SubPlan > -> Result (cost=2.94..2.95 rows=1 width=0) (actual > time=2171.287..2171.289 rows=1 loops=618) > InitPlan > -> Limit (cost=0.00..2.94 rows=1 width=4) (actual > time=2171.264..2171.266 rows=1 loops=618) > -> Seq Scan on pkk_purchase p0 (cost=0.00..37225.83 > rows=12670 width=4) (actual time=2171.245..2171.245 rows=1 loops=618) > Filter: ((offer_id = $0) AND > (((expire_time)::timestamp with time zone > now()) OR (expire_time IS NULL) OR > (pending = true)) AND ((cancel_date IS NULL) OR (pending = true))) > Total runtime: 1341887.523 ms > (8 rows) > > > while deleting all statistics on the pkk_% tables I get: > > pkk=# delete from pg_statistic where pg_statistic.starelid = pg_class.oid and > pg_class.relname like 'pkk_%'; > DELETE 11 > > pkk=# explain analyze select o0.offer_id, ( select case when ( select > p0.purchase_id from pkk_purchase p0 where p0.offer_id = o0.offer_id and ( > p0.pending = true or ( ( p0.expire_time > now() or p0.expire_time isnull ) and > p0.cancel_date isnull ) ) limit 1 ) isnull then false else true end ) from > pkk_offer o0 ; > QUERY PLAN > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > Seq Scan on pkk_offer o0 (cost=0.00..6646.94 rows=618 width=4) (actual > time=0.190..799.930 rows=618 loops=1) > SubPlan > -> Result (cost=10.73..10.74 rows=1 width=0) (actual time=1.277..1.278 > rows=1 loops=618) > InitPlan > -> Limit (cost=0.00..10.73 rows=1 width=4) (actual > time=1.266..1.267 rows=1 loops=618) > -> Index Scan using pur_offer_id_idx on pkk_purchase p0 > (cost=0.00..20690.18 rows=1929 width=4) (actual time=1.258..1.258 rows=1 > loops=618) > Index Cond: (offer_id = $0) > Filter: ((((expire_time)::timestamp with time zone > > now()) OR (expire_time IS NULL) OR (pending = true)) AND ((cancel_date IS NULL) > OR (pending = true))) > Total runtime: 801.234 ms > (9 rows) > > > As you can see this query (over all values of pkk_offer) with out > any pg_statistics on the pkk_purchase table is extremely fast. > > Is this a bug in the PostgreSQL planner that misjudges the best > choice with pg_statistics at hand? > > --patrick > In order to understand your query I broke it up and restructured it as follows. You might try to add the ORDER BY line, and see what you get. EXPLAIN ANALYZE SELECT o0.offer_id, ( SELECT CASE WHEN ( SELECT p0.purchase_id FROM pkk_purchase p0 WHERE p0.offer_id = o0.offer_id AND ( p0.pending = true OR ( p0.cancel_date ISNULL AND ( p0.expire_time > NOW() or p0.expire_time ISNULL ) ) ) ORDER BY p0.purchase_id --Insert this line LIMIT 1 ) ISNULL THEN false ELSE true END ) FROM pkk_offer o0 ; I also wonder about some parts of your query. I don't know your business logic but you are tacking a lot of the query into the WHERE, and I wonder if postgres just thinks it's going to need to analyze all the data before it gets a match. I also don't remember what columns you have indices on. Or whether it is common to have cancel_date null, or expire_time > NOW() or expire_time null, etc. So is your function just everything within the CASE statement? You might try rewriting it as a loop using a cursor, as I believe using a cursor again lends itself to index scans (as it is even more likely that you will not get all the data.) Something like (this is untested) create function is_pending(int) returns bool as ' declare p_id alias for $1; begin DECLARE is_pending_cursor CURSOR FOR SELECT p0.purchase_id FROM pkk_purchase p0 WHERE p0.offer_id = p_id; FOR READ ONLY; FOR FETCH NEXT is_pending_cursor IF row.pending = true or ... RETURN true; RETURN false; END; '; I don't know cursors terribly well, but this might get you going. Probably in your case you also have a large portion of the records with pending = true, which means that with an index scan it doesn't have to hit very many records. Either you have a low record count for a particular purchase_id, or you have a lot of pendings. seq scan just hurts because it has to sift out all the other id's that you don't care about. But remember, I'm not a guru, just someone who has been hit by the inequal distribution problem. John =:-> --------------enigE8F197F0FDD61F38455DFA7D Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBkAjcJdeBCYSNAAMRAjz4AKDXrnMi//SOGX6Wt0J4atZeGYQCbQCfSwVF id0EsgIWxFvEsYitWKrvRPc= =Yhju -----END PGP SIGNATURE----- --------------enigE8F197F0FDD61F38455DFA7D-- From pgsql-performance-owner@postgresql.org Tue Nov 9 00:05:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DB9093A40D7 for ; Tue, 9 Nov 2004 00:03:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90385-01 for ; Tue, 9 Nov 2004 00:03:45 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 9939D3A408C for ; Tue, 9 Nov 2004 00:03:46 +0000 (GMT) Received: (qmail 7579 invoked from network); 9 Nov 2004 01:04:02 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 9 Nov 2004 01:04:02 +0100 Date: Tue, 09 Nov 2004 01:04:25 +0100 To: pgsql-performance@postgresql.org Subject: Re: vacuum analyze slows sql query References: <20041108231951.23927.qmail@web52105.mail.yahoo.com> From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <20041108231951.23927.qmail@web52105.mail.yahoo.com> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/151 X-Sequence-Number: 9105 >> Lets say for a second that you manage to trick it into using index scan, >> and then you actually call the function with one of the values that >> returns 1,000s of rows. Probably it will take 10-100 times longer than >> if it used a seq scan. > I don't know if it matters (I suspect that it does) but I am using > LIMIT 1 in the sub-query/stored function. All I need is one single > row meeting any of the criteria laid out in the stored procedure to > establish an offer_id is "pending". So, in your case if you LIMIT the index scan will always be fast, and the seq scan will be catastrophic, because you don't need to retrieve all the rows, but just one. (IMHO the planner screws these LIMIT clauses becauses it expects the data to be randomly distributed in the first page while in real life it's not). You could use EXIST to test the existence of a subquery (after all, thats its purpose), or you could : When SELECT ... FROM table WHERE stuff=value LIMIT 1 obstinately uses a seq scan, spray a little order by : When SELECT ... FROM table WHERE stuff=value ORDER BY stuff LIMIT 1 the ORDER BY will make the planner think "I could use the index to order"... From pgsql-performance-owner@postgresql.org Tue Nov 9 00:12:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C725A3A4152 for ; Tue, 9 Nov 2004 00:10:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88511-10 for ; Tue, 9 Nov 2004 00:10:02 +0000 (GMT) Received: from mail.opentransfer.com (mail.opentransfer.com [69.49.238.2]) by svr1.postgresql.org (Postfix) with SMTP id 98A903A413F for ; Tue, 9 Nov 2004 00:10:03 +0000 (GMT) Received: (qmail 4785 invoked from network); 9 Nov 2004 00:10:03 -0000 Received: from unknown (HELO mail2.opentransfer.com) (192.168.66.103) by mailout.opentransfer.com with SMTP; 9 Nov 2004 00:10:03 -0000 Received: (qmail 23814 invoked from network); 9 Nov 2004 00:10:01 -0000 Received: from unknown (HELO ?192.168.10.106?) (62.174.144.2) by mail2.opentransfer.com with SMTP; 9 Nov 2004 00:10:00 -0000 Mime-Version: 1.0 (Apple Message framework v619) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: pgsql-performance@postgresql.org From: Erik Norvelle Subject: Slow performance with Group By Date: Tue, 9 Nov 2004 01:09:58 +0100 X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/152 X-Sequence-Number: 9106 Greetings all, This question has probably been asked many times, but I was unable to use the list archives to search, since the term "Group" matches thousands of of messages with the names of user groups in them... so sorry if I'm repeating! Here's the problem: I have a table of 10,000,000 records called "indethom", each record representing a word in the works of a particular author. Each record contains, among other columns, an CHAR(5) column representing the "lemma" code (i.e. which word it is) called "codelemm", and an integer representing a textual unit, i.e. chapter or other division of a work (these are numbered consecutively from 0 to around 50,000), called "sectref". What I want to do is find out how many times every word occurs in each textual unit (or no row returned for textual units where a particular word doesn't appear). I used a group-by clause to group by "sectref", and then used the COUNT(codelemm) function to sum up the occurrences. The codelemm column had to be grouped on, in order to satisfy Postgres's requirements. Here's the query as I have it: > create table matrix2.tuo as select codelemm, sectref, count(codelemm) from indethom group by codelemm, sectref; And the explain results are as follows: >it=> explain select codelemm, sectref, count(codelemm) from indethom group by codelemm, sectref; > QUERY PLAN >----------------------------------------------------------------------- --------- > GroupAggregate (cost=2339900.60..2444149.44 rows=1790528 width=13) > -> Sort (cost=2339900.60..2364843.73 rows=9977252 width=13) > Sort Key: codelemm, sectref > -> Seq Scan on indethom (cost=0.00..455264.52 rows=9977252 width=13) I have an index defined as follows: > create index indethom_clemm_sect_ndx on indethom using btree(codelemm, sectref); I also performed an ANALYZE after creating the index. I have the gut feeling that there's got to be a better way than a sequence scan on 10,000,000 records, but I'll be darned if I can find any way to improve things here. Thanks for any help you all can offer!! Erik Norvelle From pgsql-performance-owner@postgresql.org Tue Nov 9 00:32:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0F5E03A4155 for ; Tue, 9 Nov 2004 00:32:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97155-08 for ; Tue, 9 Nov 2004 00:31:53 +0000 (GMT) Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu [129.255.60.186]) by svr1.postgresql.org (Postfix) with ESMTP id 3B1273A414E for ; Tue, 9 Nov 2004 00:31:55 +0000 (GMT) Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id iA90Vf300790; Mon, 8 Nov 2004 18:31:41 -0600 Message-ID: <41900FE5.2090704@johnmeinel.com> Date: Mon, 08 Nov 2004 18:31:33 -0600 From: John Meinel User-Agent: Mozilla Thunderbird 0.7.1 (X11/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: patrick ~ Cc: pgsql-performance@postgresql.org Subject: Re: vacuum analyze slows sql query References: <20041108231951.23927.qmail@web52105.mail.yahoo.com> In-Reply-To: <20041108231951.23927.qmail@web52105.mail.yahoo.com> X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigE0CE1ACB02487EF4C0F09CAB" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/153 X-Sequence-Number: 9107 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigE0CE1ACB02487EF4C0F09CAB Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit patrick ~ wrote: > Hi John, > > Thanks for your reply and analysis. > > > --- John Meinel wrote: > > >>patrick ~ wrote: >>[...] >> >>>pkk=# explain analyze execute pkk_01( 241 ); >>> QUERY PLAN >>> >> One other thing that I just thought of. I think it is actually possible to add an index on a function of a column. So if you have the "is_really_pending" function, you might be able to do: CREATE INDEX pkk_is_really_pending ON pkk_purchase (is_really_pending(purchase_id)); But you need a better guru than I to make sure of that. This *might* do what you need. John =:-> --------------enigE0CE1ACB02487EF4C0F09CAB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBkA/lJdeBCYSNAAMRArEdAKCKph0OZ+vBCtZmnXbHYwuv9nNJzACbBUfb zLTb4X5jVoDcoGL9fNJsrOA= =CxJ2 -----END PGP SIGNATURE----- --------------enigE0CE1ACB02487EF4C0F09CAB-- From pgsql-performance-owner@postgresql.org Tue Nov 9 00:56:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 52EF43A411D for ; Tue, 9 Nov 2004 00:56:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01562-10 for ; Tue, 9 Nov 2004 00:56:07 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6817C3A3AE2 for ; Tue, 9 Nov 2004 00:56:07 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA90u47Y012782; Mon, 8 Nov 2004 19:56:04 -0500 (EST) To: Erik Norvelle Cc: pgsql-performance@postgresql.org Subject: Re: Slow performance with Group By In-reply-to: References: Comments: In-reply-to Erik Norvelle message dated "Tue, 09 Nov 2004 01:09:58 +0100" Date: Mon, 08 Nov 2004 19:56:04 -0500 Message-ID: <12781.1099961764@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/154 X-Sequence-Number: 9108 Erik Norvelle writes: >>> it=> explain select codelemm, sectref, count(codelemm) from indethom > group by codelemm, sectref; >>> QUERY PLAN >>> ----------------------------------------------------------------------- > --------- >>> GroupAggregate (cost=2339900.60..2444149.44 rows=1790528 width=13) >>> -> Sort (cost=2339900.60..2364843.73 rows=9977252 width=13) >>> Sort Key: codelemm, sectref >>> -> Seq Scan on indethom (cost=0.00..455264.52 rows=9977252 > width=13) Actually the painful part of that is the sort. If you bump up sort_mem enough it will eventually switch over to a HashAggregate with no sort, which may be a better plan if there's not too many groups (is the estimate of 1.79 million on the mark at all??) regards, tom lane From pgsql-performance-owner@postgresql.org Tue Nov 9 01:29:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EF7083A3AE2 for ; Tue, 9 Nov 2004 01:28:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12737-03 for ; Tue, 9 Nov 2004 01:28:46 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 14FFD3A419B for ; Tue, 9 Nov 2004 01:28:48 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6633163; Mon, 08 Nov 2004 17:30:18 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: Question regarding the file system Date: Mon, 8 Nov 2004 17:31:22 -0800 User-Agent: KMail/1.6.2 Cc: Gabriele Bartolini References: <6.1.2.0.2.20041105220007.03401ec0@box.tin.it> <200411080944.33311.josh@agliodbs.com> <6.1.2.0.2.20041108201810.03437400@box.tin.it> In-Reply-To: <6.1.2.0.2.20041108201810.03437400@box.tin.it> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <200411081731.22491.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/155 X-Sequence-Number: 9109 Gabriele, > By any chance, do you have some reference or some tests that talk about the > fact that RAID5 with less than 5 disks is not performing? Just this list. But it's easy to test yourself; run bonnie++ and compare the performance of seeks and random writes (which PG does a lot of) vs. a plain single disk. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-admin-owner@postgresql.org Tue Nov 9 14:57:18 2004 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 754473A3CB9 for ; Tue, 9 Nov 2004 14:56:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46038-01 for ; Tue, 9 Nov 2004 14:56:29 +0000 (GMT) Received: from web52710.mail.yahoo.com (web52710.mail.yahoo.com [206.190.39.161]) by svr1.postgresql.org (Postfix) with SMTP id 04A0F3A3C99 for ; Tue, 9 Nov 2004 14:56:32 +0000 (GMT) Received: (qmail 86007 invoked by uid 60001); 9 Nov 2004 14:56:31 -0000 Message-ID: <20041109145631.86002.qmail@web52710.mail.yahoo.com> Received: from [216.184.101.242] by web52710.mail.yahoo.com via HTTP; Tue, 09 Nov 2004 06:56:31 PST Date: Tue, 9 Nov 2004 06:56:31 -0800 (PST) From: Carlos Lopez Subject: Re: [PERFORM] poor performance in migrated database To: Tom Lane Cc: pgsql-performance@postgresql.org, pgsql-admin@postgresql.org In-Reply-To: <12047.1099958278@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/76 X-Sequence-Number: 15461 Dear Tom, thanks for your information. Where can I learn more about the explain and analyze?? One view that is giving a lot of problems is vkardex_3 which is used most of the time... The explain analyze I sent is one of the views that conform this one. Thanks in advance. Carlos Lopez Linares --- Tom Lane wrote: > Carlos Lopez writes: > > This is one of the queries that work,and is the > first > > in a 4 level nested query.... > > Do you really need UNION (as opposed to UNION ALL) > in this query? > The EXPLAIN shows that almost half the runtime is > going into the > sort/uniq to eliminate duplicates ... and according > to the row > counts, there are no duplicates, so it's wasted > effort. > > I looked at your schema and saw an awful lot of > SELECT DISTINCTs > that looked like they might not be necessary, too. > But I'm not > willing to crawl through 144 views with no > information about > which ones are causing you problems. What's a > typical query > that you are unsatisfied with the performance of? > > regards, tom lane > ===== ___ Ing. Carlos L�pez Linares IT Consultant Quieres aprender linux? visita http://www.aprende-linux.com.sv __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From pgsql-performance-owner@postgresql.org Tue Nov 9 19:01:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 09E453A3E1D for ; Tue, 9 Nov 2004 19:01:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32295-02 for ; Tue, 9 Nov 2004 19:01:31 +0000 (GMT) Received: from threadless.com (threadless.com [64.207.133.36]) by svr1.postgresql.org (Postfix) with ESMTP id 50F073A2B46 for ; Tue, 9 Nov 2004 19:01:29 +0000 (GMT) Received: from shanepc (h-64-105-237-58.chcgilgm.covad.net [64.105.237.58]) (authenticated bits=0) by threadless.com (8.12.8/8.12.5) with ESMTP id iA9KIqfi012232 for ; Tue, 9 Nov 2004 12:18:52 -0800 Message-ID: <003201c4c68e$8d347ee0$a702a8c0@shanepc> From: "Shane | SkinnyCorp" To: Subject: Need advice on postgresql.conf settings Date: Tue, 9 Nov 2004 13:01:42 -0600 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=LINES_OF_YELLING, LINES_OF_YELLING_2 X-Spam-Level: X-Archive-Number: 200411/157 X-Sequence-Number: 9111 Thanks in advance for anything you can do to help. The real issue is this, we have THE SAME queries taking anywhere from .001 - 90.0 seconds... the server is using 98% of the available RAM at all times (because of the persistant connections via php), and I don't know what to do. Every time I change a .conf setting I feel like it slows it down even more.... and I can't seem to find the balance. I'll give you everything I've got, and I hope to god someone can point out some areas where I could improve the speed of queries overall. For months I've been optimizing my queries, and working around places that I don't need them. They are so incredibly honed, I couldn't even begin to explain.... and when there are less than 10 users browsing our sites, they are LIGHTENING fast... even with 5x the amount of dummy data in the database(s)... so basically the LARGEST factor in this whole performance issue that I can find is the number of users browsing the sites at all times... but lowering shared_buffers to raise max_connections is hurting performance immensley... so I"m totally lost.... please help!! Bless you! THE DETAILS: (for the databases, i'll list only the 'main' tables... as the others are fairly small) Database 1: 5000 'users' 20,000 'threads' 500,000 'posts' ... Database 2: (just starting out) 150 'users' 150 'entries' ... Hardware : Pentium 4 2.44ghz 1.5gb RAM 7200rpm SATA Software: Redhat Linux (kernel v. 2.4.21-9.EL) Postgresql 7.4.2 PHP 4.3.6 (using persistant connections to pgsql) Usage: uptime: 12:23:08 up 132 days, 19:16, 2 users, load average: 19.75, 17.34, 18.86 roughly 100-200 users connected to our server at any given moment roughly 10-15 queries per HTTP page load ---------------------------------------------------------- # ----------------------------- # PostgreSQL configuration file # ----------------------------- # # This file consists of lines of the form: # # name = value # # (The '=' is optional.) White space may be used. Comments are introduced # with '#' anywhere on a line. The complete list of option names and # allowed values can be found in the PostgreSQL documentation. The # commented-out settings shown in this file represent the default values. # # Any option can also be given as a command line switch to the # postmaster, e.g. 'postmaster -c log_connections=on'. Some options # can be changed at run-time with the 'SET' SQL command. # # This file is read on postmaster startup and when the postmaster # receives a SIGHUP. If you edit the file on a running system, you have # to SIGHUP the postmaster for the changes to take effect, or use # "pg_ctl reload". #--------------------------------------------------------------------------- # CONNECTIONS AND AUTHENTICATION #--------------------------------------------------------------------------- # - Connection Settings - tcpip_socket = true max_connections = 75 # note: increasing max_connections costs about 500 bytes of shared # memory per connection slot, in addition to costs from shared_buffers # and max_locks_per_transaction. #superuser_reserved_connections = 2 port = 5432 #unix_socket_directory = '' #unix_socket_group = '' #unix_socket_permissions = 0777 # octal #virtual_host = '' # what interface to listen on; defaults to any #rendezvous_name = '' # defaults to the computer name # - Security & Authentication - #authentication_timeout = 60 # 1-600, in seconds ssl = true password_encryption = true #krb_server_keyfile = '' #db_user_namespace = false #--------------------------------------------------------------------------- # RESOURCE USAGE (except WAL) #--------------------------------------------------------------------------- # - Memory - shared_buffers = 8192 # min 16, at least max_connections*2, 8KB each sort_mem = 8192 # min 64, size in KB vacuum_mem = 4096 # min 1024, size in KB # - Free Space Map - max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each max_fsm_relations = 1000 # min 100, ~50 bytes each # - Kernel Resource Usage - max_files_per_process = 3052 # min 25 #preload_libraries = '' #--------------------------------------------------------------------------- # WRITE AHEAD LOG #--------------------------------------------------------------------------- # - Settings - fsync = true # turns forced synchronization on or off #wal_sync_method = fsync # the default varies across platforms: # fsync, fdatasync, open_sync, or open_datasync wal_buffers = 192 # min 4, 8KB each # - Checkpoints - #checkpoint_segments = 3 # in logfile segments, min 1, 16MB each #checkpoint_timeout = 300 # range 30-3600, in seconds #checkpoint_warning = 30 # 0 is off, in seconds #commit_delay = 0 # range 0-100000, in microseconds #commit_siblings = 5 # range 1-1000 #--------------------------------------------------------------------------- # QUERY TUNING #--------------------------------------------------------------------------- # - Planner Method Enabling - #enable_hashagg = true #enable_hashjoin = true #enable_indexscan = true #enable_mergejoin = true #enable_nestloop = true enable_seqscan = false #enable_sort = true #enable_tidscan = true # - Planner Cost Constants - effective_cache_size = 131072 # typically 8KB each random_page_cost = 2 # units are one sequential page fetch cost cpu_tuple_cost = .01 # (same) default .01 cpu_index_tuple_cost = .001 # (same) default .001 cpu_operator_cost = 0.0025 # (same) default .0025 # - Genetic Query Optimizer - geqo = true geqo_threshold = 20 #geqo_effort = 1 #geqo_generations = 0 #geqo_pool_size = 0 # default based on tables in statement, # range 128-1024 #geqo_selection_bias = 2.0 # range 1.5-2.0 # - Other Planner Options - #default_statistics_target = 10 # range 1-1000 #from_collapse_limit = 8 #join_collapse_limit = 8 # 1 disables collapsing of explicit JOINs #--------------------------------------------------------------------------- # ERROR REPORTING AND LOGGING #--------------------------------------------------------------------------- # - Syslog - #syslog = 0 # range 0-2; 0=stdout; 1=both; 2=syslog #syslog_facility = 'LOCAL0' #syslog_ident = 'postgres' # - When to Log - client_min_messages = error # Values, in order of decreasing detail: # debug5, debug4, debug3, debug2, debug1, # log, info, notice, warning, error log_min_messages = error # Values, in order of decreasing detail: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, log, fatal, # panic log_error_verbosity = default # terse, default, or verbose messages log_min_error_statement = panic # Values in order of increasing severity: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, panic(off) log_min_duration_statement = -1 # Log all statements whose # execution time exceeds the value, in # milliseconds. Zero prints all queries. # Minus-one disables. #silent_mode = false # DO NOT USE without Syslog! # - What to Log - debug_print_parse = false debug_print_rewritten = false debug_print_plan = false debug_pretty_print = false log_connections = false log_duration = false log_pid = false log_statement = false log_timestamp = false log_hostname = false log_source_port = false #--------------------------------------------------------------------------- # RUNTIME STATISTICS #--------------------------------------------------------------------------- # - Statistics Monitoring - log_parser_stats = false log_planner_stats = false log_executor_stats = false log_statement_stats = false # - Query/Index Statistics Collector - stats_start_collector = false stats_command_string = false stats_block_level = false stats_row_level = false stats_reset_on_server_start = false #--------------------------------------------------------------------------- # CLIENT CONNECTION DEFAULTS #--------------------------------------------------------------------------- # - Statement Behavior - #search_path = '$user,public' # schema names #check_function_bodies = true #default_transaction_isolation = 'read committed' #default_transaction_read_only = false #statement_timeout = 0 # 0 is disabled, in milliseconds # - Locale and Formatting - #datestyle = 'iso, mdy' #timezone = unknown # actually, defaults to TZ environment setting #australian_timezones = false #extra_float_digits = 0 # min -15, max 2 #client_encoding = sql_ascii # actually, defaults to database encoding # These settings are initialized by initdb -- they may be changed lc_messages = 'en_US.UTF-8' # locale for system error message strings lc_monetary = 'en_US.UTF-8' # locale for monetary formatting lc_numeric = 'en_US.UTF-8' # locale for number formatting lc_time = 'en_US.UTF-8' # locale for time formatting # - Other Defaults - explain_pretty_print = true #dynamic_library_path = '$libdir' #max_expr_depth = 10000 # min 10 #--------------------------------------------------------------------------- # LOCK MANAGEMENT #--------------------------------------------------------------------------- #deadlock_timeout = 1000 # in milliseconds #max_locks_per_transaction = 64 # min 10, ~260*max_connections bytes each #--------------------------------------------------------------------------- # VERSION/PLATFORM COMPATIBILITY #--------------------------------------------------------------------------- # - Previous Postgres Versions - #add_missing_from = true regex_flavor = advanced # advanced, extended, or basic #sql_inheritance = true # - Other Platforms & Clients - #transform_null_equals = false ------ I've been tweaking the postgresql.conf file for about 5 hours... just today. We've had problems in the past (and I've also emailed this list in the past, but perhaps I failed to ask the right questions).... I guess I need some help with the postgresql configuration file. I would like to start off by asking that you not link me to the same basic .CONF overview, as what I really need at this point is real-world experience and wisdom, as opposed to cold, poorly documented, and incredibly abstract (trial-and-error) type manual entries. From pgsql-performance-owner@postgresql.org Tue Nov 9 19:26:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 08C713A3E05 for ; Tue, 9 Nov 2004 19:26:56 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40240-02 for ; Tue, 9 Nov 2004 19:26:45 +0000 (GMT) Received: from web52104.mail.yahoo.com (web52104.mail.yahoo.com [206.190.39.73]) by svr1.postgresql.org (Postfix) with SMTP id 35B9F3A3D82 for ; Tue, 9 Nov 2004 19:26:45 +0000 (GMT) Received: (qmail 6425 invoked by uid 60001); 9 Nov 2004 19:26:44 -0000 Message-ID: <20041109192644.6423.qmail@web52104.mail.yahoo.com> Received: from [198.182.200.22] by web52104.mail.yahoo.com via HTTP; Tue, 09 Nov 2004 11:26:44 PST Date: Tue, 9 Nov 2004 11:26:44 -0800 (PST) From: patrick ~ Subject: Re: vacuum analyze slows sql query To: John Meinel Cc: pgsql-performance@postgresql.org In-Reply-To: <419008DA.3000007@johnmeinel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/158 X-Sequence-Number: 9112 --- John Meinel wrote: > If you are trying to establish existence, we also had a whole thread on > this. Basically what we found was that adding an ORDER BY clause, helped > tremendously in getting the planner to switch to an Index scan. You > might try something like: > > SELECT column FROM mytable WHERE column='myval' ORDER BY column LIMIT 1; > > There seems to be a big difference between the above statement and: > > SELECT column FROM mytable WHERE column='myval' LIMIT 1; The ORDER BY "trick" worked beautifully! I just hope it'll continue to work consistently in production code. > I also wonder about some parts of your query. I don't know your business > logic but you are tacking a lot of the query into the WHERE, and I > wonder if postgres just thinks it's going to need to analyze all the > data before it gets a match. I have a table of offers (pkk_offer) and a table keeping track of all purchases against each offer (pkk_purchase) and a third table keeping track of billing for each purchase (pkk_billing). That's the basic setup of my db. In actuallity there are more tables and views invovled keeping track of usage, etc. The on UI page that lists all offers in the system needs to indicated to the user (operator) which offers are "pending". The term "pending" is used to mean that the particular offer has either an active purchase against it or has a purchase which hasn't yet been entered into the billing system yet (doesn't yet show up in pkk_billing). An active purcahse is indicated by pkk_purchase.expire_time in the future or IS NULL. Where IS NULL indicates a subscription type purchase (a recurring purchase). Offers are created either to be one-time purchasable or subscription type. The pkk_purchase.pending (boolean) column indicates whether or not the purchase has been entered into the billing system. It is a rare case where this flag remains true for a long period of time (which would indicate something wrong with the billing sub-system). There is a foreign key pkk_purchase.offer_id referencing pkk_offer.offer_id. And likewise, pkk_billing.client_id referencing pkk_purchase.client_id and pkk_billing.purchase_id referecning pkk_purchase.purchase_id. > So is your function just everything within the CASE statement? Yes. I posted a "stripped down" version of the database on pgsql-sql@ list earlier this month if you are interested in looking at it: http://marc.theaimsgroup.com/?l=postgresql-sql&m=109945118928530&w=2 (Just side note: MARC doesn't seem to subscribe to -performance or -hackers. I have requested them to carry these two lists. I think if more people request this it might happen. I like their archiving system). > You might try rewriting it as a loop using a cursor, as I believe using > a cursor again lends itself to index scans (as it is even more likely > that you will not get all the data.) I may try this as well as trying a suggestion by Pierre-Fr���d���ric Caillaud to use EXISTS, though my initial attempt to use it didn't seem to be any faster than my original stored function. So far the ORDER BY "trick" seems to be the best solution. I appreciate everyone's help and suggestions on this topic! Best wishes, --patrick __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com From pgsql-performance-owner@postgresql.org Tue Nov 9 21:57:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 05EBE3A3ED9 for ; Tue, 9 Nov 2004 21:57:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89274-05 for ; Tue, 9 Nov 2004 21:56:55 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8B09C3A3E24 for ; Tue, 9 Nov 2004 21:56:57 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA9LuuC7005509; Tue, 9 Nov 2004 16:56:57 -0500 (EST) To: "Shane | SkinnyCorp" Cc: pgsql-performance@postgresql.org Subject: Re: Need advice on postgresql.conf settings In-reply-to: <003201c4c68e$8d347ee0$a702a8c0@shanepc> References: <003201c4c68e$8d347ee0$a702a8c0@shanepc> Comments: In-reply-to "Shane | SkinnyCorp" message dated "Tue, 09 Nov 2004 13:01:42 -0600" Date: Tue, 09 Nov 2004 16:56:56 -0500 Message-ID: <5508.1100037416@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/159 X-Sequence-Number: 9113 "Shane | SkinnyCorp" writes: > The real issue is this, we have THE SAME queries taking anywhere from .001 - > 90.0 seconds... the server is using 98% of the available RAM at all times > (because of the persistant connections via php), and I don't know what to > do. I have a feeling that the answer is going to boil down to "buy more RAM" --- it sounds a lot like you're just overstressing your server. The more active backends you have, the more RAM goes to process-local memory, and the less is available for kernel disk cache. Even if you don't go into outright swapping, the amount of disk I/O needed goes up the smaller the kernel disk cache gets. Another possible line of attack is to use persistent (pooled) connections to cut down the number of live backend processes you need. However, depending on what your application software is, that might take more time/effort (= money) than dropping in some more RAM. You can investigate this theory by watching "top" output (the first few lines about memory usage, not the process listing) as well as "vmstat" output. > uptime: 12:23:08 up 132 days, 19:16, 2 users, load average: 19.75, > 17.34, 18.86 Load averages approaching 20 are not good either ... what sort of box are you running on anyway? As for the postgresql.conf settings, the only ones I'd seriously question are max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each max_fsm_relations = 1000 # min 100, ~50 bytes each These are the defaults, and are probably too small for a DB exceeding a hundred meg or so. max_files_per_process = 3052 # min 25 You really have your kernel set to support 3052 * 75 simultaneously open files? Back this off. I doubt values beyond a couple hundred buy anything except headaches. wal_buffers = 192 This is an order-of-magnitude overkill too, especially if your transactions are mostly small. I know it's only a megabyte or two, but you evidently need that RAM more elsewhere. enable_seqscan = false I don't think this is a good idea in general. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Nov 9 22:52:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EC86C3A3F85 for ; Tue, 9 Nov 2004 22:52:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05806-09 for ; Tue, 9 Nov 2004 22:52:42 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) by svr1.postgresql.org (Postfix) with ESMTP id CE1593A3FF2 for ; Tue, 9 Nov 2004 22:52:42 +0000 (GMT) Received: by flake.decibel.org (Postfix, from userid 1001) id 42B091C8A6; Tue, 9 Nov 2004 22:23:45 +0000 (GMT) Date: Tue, 9 Nov 2004 16:23:45 -0600 From: "Jim C. Nasby" To: pgsql-performance@postgresql.org Subject: seqscan strikes again Message-ID: <20041109222345.GG46084@decibel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/161 X-Sequence-Number: 9115 I'm wondering if there's any way I can tweak things so that the estimate for the query is more accurate (I have run analyze): QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- HashAggregate (cost=2712755.92..2713043.69 rows=12790 width=24) -> Nested Loop (cost=2997.45..2462374.58 rows=9104776 width=24) Join Filter: (("outer".prev_end_time < ms_t("inner".tick)) AND ("outer".end_time >= ms_t("inner".tick))) -> Seq Scan on bucket b (cost=0.00..51.98 rows=1279 width=20) Filter: ((rrd_id = 1) AND (end_time <= '2004-11-09 16:04:00-06'::timestamp with time zone) AND (end_time > '2004-11-08 16:31:00-06'::timestamp with time zone)) -> Materialize (cost=2997.45..3638.40 rows=64095 width=28) -> Hash Join (cost=94.31..2997.45 rows=64095 width=28) Hash Cond: ("outer".alert_def_id = "inner".id) -> Seq Scan on alert (cost=0.00..1781.68 rows=64068 width=28) -> Hash (cost=88.21..88.21 rows=2440 width=8) -> Hash Join (cost=1.12..88.21 rows=2440 width=8) Hash Cond: ("outer".alert_type_id = "inner".id) -> Seq Scan on alert_def d (cost=0.00..44.39 rows=2439 width=8) -> Hash (cost=1.10..1.10 rows=10 width=4) -> Seq Scan on alert_type t (cost=0.00..1.10 rows=10 width=4) (15 rows) opensims=# set enable_seqscan=false; SET opensims=# explain analyze SELECT a.rrd_bucket_id, alert_type_id opensims-# , count(*), count(*), count(*), min(ci), max(ci), sum(ci), min(rm), max(rm), sum(rm) opensims-# FROM opensims-# (SELECT b.bucket_id AS rrd_bucket_id, s.* opensims(# FROM rrd.bucket b opensims(# JOIN alert_def_type_v s opensims(# ON ( opensims(# b.prev_end_time < tick_tsz opensims(# AND b.end_time >= tick_tsz ) opensims(# WHERE b.rrd_id = '1' opensims(# AND b.end_time <= '2004-11-09 16:04:00-06' opensims(# AND b.end_time > '2004-11-08 16:31:00-06' opensims(# ) a opensims-# GROUP BY rrd_bucket_id, alert_type_id; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- HashAggregate (cost=3787628.37..3787916.15 rows=12790 width=24) (actual time=202.045..215.197 rows=5234 loops=1) -> Hash Join (cost=107.76..3537247.03 rows=9104776 width=24) (actual time=10.728..147.415 rows=17423 loops=1) Hash Cond: ("outer".alert_def_id = "inner".id) -> Nested Loop (cost=0.00..3377768.38 rows=9104775 width=24) (actual time=0.042..93.512 rows=17423 loops=1) -> Index Scan using rrd_bucket__rrd_id__end_time on bucket b (cost=0.00..101.62 rows=1279 width=20) (actual time=0.018..3.040 rows=1413 loops=1) Index Cond: ((rrd_id = 1) AND (end_time <= '2004-11-09 16:04:00-06'::timestamp with time zone) AND (end_time > '2004-11-08 16:31:00-06'::timestamp with time zone)) -> Index Scan using alert__tick_tsz on alert (cost=0.00..2498.49 rows=7119 width=28) (actual time=0.006..0.030 rows=12 loops=1413) Index Cond: (("outer".prev_end_time < ms_t(alert.tick)) AND ("outer".end_time >= ms_t(alert.tick))) -> Hash (cost=101.66..101.66 rows=2440 width=8) (actual time=10.509..10.509 rows=0 loops=1) -> Hash Join (cost=3.13..101.66 rows=2440 width=8) (actual time=0.266..8.499 rows=2439 loops=1) Hash Cond: ("outer".alert_type_id = "inner".id) -> Index Scan using alert_def_pkey on alert_def d (cost=0.00..55.83 rows=2439 width=8) (actual time=0.009..3.368 rows=2439 loops=1) -> Hash (cost=3.11..3.11 rows=10 width=4) (actual time=0.061..0.061 rows=0 loops=1) -> Index Scan using alert_type_pkey on alert_type t (cost=0.00..3.11 rows=10 width=4) (actual time=0.018..0.038 rows=10 loops=1) Total runtime: 218.644 ms (15 rows) opensims=# I'd really like to avoid putting a 'set enable_seqscan=false' in my code, especially since this query only has a problem if it's run on a large date/time window, which normally doesn't happen. -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Tue Nov 9 22:44:17 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EEA8A3A3F85 for ; Tue, 9 Nov 2004 22:44:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05053-01 for ; Tue, 9 Nov 2004 22:44:03 +0000 (GMT) Received: from mail.trippynames.com (mail.trippynames.com [38.113.223.19]) by svr1.postgresql.org (Postfix) with ESMTP id 530BE3A3F2E for ; Tue, 9 Nov 2004 22:44:04 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by mail.trippynames.com (Postfix) with ESMTP id CD34EA6C83; Tue, 9 Nov 2004 14:44:03 -0800 (PST) Received: from mail.trippynames.com ([127.0.0.1]) by localhost (rand.nxad.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 95186-09; Tue, 9 Nov 2004 14:44:02 -0800 (PST) Received: from [192.168.123.123] (unknown [38.113.223.82]) by mail.trippynames.com (Postfix) with ESMTP id 38A52A6C63; Tue, 9 Nov 2004 14:44:02 -0800 (PST) In-Reply-To: <5508.1100037416@sss.pgh.pa.us> References: <003201c4c68e$8d347ee0$a702a8c0@shanepc> <5508.1100037416@sss.pgh.pa.us> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: pgsql-performance@postgresql.org From: Sean Chittenden Subject: Re: Need advice on postgresql.conf settings Date: Tue, 9 Nov 2004 14:44:00 -0800 To: Shane|SkinnyCorp X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/160 X-Sequence-Number: 9114 >> The real issue is this, we have THE SAME queries taking anywhere from >> .001 - >> 90.0 seconds... the server is using 98% of the available RAM at all >> times >> (because of the persistant connections via php), and I don't know >> what to >> do. > > Another possible line of attack is to use persistent (pooled) > connections to cut down the number of live backend processes you need. > However, depending on what your application software is, that might > take more time/effort (= money) than dropping in some more RAM. This particular feature is pure evilness. Using all of my fingers and toes, I can't count the number of times I've had a client do this and get themselves into a world of hurt. Somewhere in the PHP documentation, there should be a big warning wrapped in the blink tag that steers people away from setting this. The extra time necessary to setup a TCP connection is less than the performance drag induced on the backend when persistent connections are enabled. Reread that last sentence until it sinks in. On a local network, this is premature optimization that's hurting you. > max_files_per_process = 3052 # min 25 > > You really have your kernel set to support 3052 * 75 simultaneously > open > files? Back this off. I doubt values beyond a couple hundred buy > anything except headaches. This, on the other hand, has made a large difference for me. Time necessary to complete open(2) calls can be expensive, especially when the database is poorly designed and is touching many different parts of the database spread across multiple files on the backend. 3000 is high, but I've found 500 to be vastly too low in some cases... in others, it's just fine. My rule of thumb has become, if you're doing lots of aggregate functions (ex, SUM(), COUNT()) more than once in the lifetime of a backend, increasing this value helps.. otherwise it buys you little (if so, 1500 is generally sufficient). Faster IO, however, is going to save you here. If you can, increase your disk caching in the OS. On FreeBSD, increase your KVA_PAGES and NBUFs. Since you've freed up more ram by disabling persistent connections, this shouldn't be a problem. -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Tue Nov 9 23:14:48 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A9CD33A3F60 for ; Tue, 9 Nov 2004 23:14:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10331-10 for ; Tue, 9 Nov 2004 23:14:41 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id F15D43A3F27 for ; Tue, 9 Nov 2004 23:14:43 +0000 (GMT) Received: from [192.168.1.51] (dsl093-038-087.pdx1.dsl.speakeasy.net [66.93.38.87]) (authenticated) by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id iA9NEg804325; Tue, 9 Nov 2004 15:14:42 -0800 Message-ID: <41914F5C.9030505@commandprompt.com> Date: Tue, 09 Nov 2004 15:14:36 -0800 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Jim C. Nasby" Cc: pgsql-performance@postgresql.org Subject: Re: seqscan strikes again References: <20041109222345.GG46084@decibel.org> In-Reply-To: <20041109222345.GG46084@decibel.org> Content-Type: multipart/mixed; boundary="------------000903040201070205000908" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/162 X-Sequence-Number: 9116 This is a multi-part message in MIME format. --------------000903040201070205000908 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit > opensims=# > > I'd really like to avoid putting a 'set enable_seqscan=false' in my > code, especially since this query only has a problem if it's run on a > large date/time window, which normally doesn't happen. Try increasing your statistics target for the column and then rerunning analyze. Sincerely, Joshua D. Drake -- Command Prompt, Inc., home of PostgreSQL Replication, and plPHP. Postgresql support, programming shared hosting and dedicated hosting. +1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL --------------000903040201070205000908 Content-Type: text/x-vcard; charset=utf-8; name="jd.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jd.vcf" begin:vcard fn:Joshua D. Drake n:Drake;Joshua D. org:Command Prompt, Inc. adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA email;internet:jd@commandprompt.com title:Consultant tel;work:503-667-4564 tel;fax:503-210-0334 note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. x-mozilla-html:FALSE url:http://www.commandprompt.com/ version:2.1 end:vcard --------------000903040201070205000908-- From pgsql-performance-owner@postgresql.org Tue Nov 9 23:24:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2F6DB3A3FAE for ; Tue, 9 Nov 2004 23:24:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15463-01 for ; Tue, 9 Nov 2004 23:24:36 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id CE1A23A3F9D for ; Tue, 9 Nov 2004 23:24:38 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA9NOWZc006305; Tue, 9 Nov 2004 18:24:32 -0500 (EST) To: "Jim C. Nasby" Cc: pgsql-performance@postgresql.org Subject: Re: seqscan strikes again In-reply-to: <20041109222345.GG46084@decibel.org> References: <20041109222345.GG46084@decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Tue, 09 Nov 2004 16:23:45 -0600" Date: Tue, 09 Nov 2004 18:24:32 -0500 Message-ID: <6304.1100042672@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/163 X-Sequence-Number: 9117 "Jim C. Nasby" writes: > I'm wondering if there's any way I can tweak things so that the estimate > for the query is more accurate (I have run analyze): > -> Index Scan using alert__tick_tsz on alert (cost=0.00..2498.49 rows=7119 width=28) (actual time=0.006..0.030 rows=12 loops=1413) > Index Cond: (("outer".prev_end_time < ms_t(alert.tick)) AND ("outer".end_time >= ms_t(alert.tick))) Can you alter the data representation? 7.4 doesn't have any stats about functional indexes and so it's not likely to come up with a good number about the selectivity of the index on ms_t(tick). It might be worth materializing that value as a plain column and indexing the column. (This being a join, I'm not sure it would help any, but it seems worth trying.) regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 10 09:36:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 95CBD3A2D50 for ; Wed, 10 Nov 2004 09:36:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69309-10 for ; Wed, 10 Nov 2004 09:35:55 +0000 (GMT) Received: from dom3.intranet.online.de (intranet.online.de [212.227.34.162]) by svr1.postgresql.org (Postfix) with ESMTP id 65A423A3BA0 for ; Wed, 10 Nov 2004 09:35:56 +0000 (GMT) Received: from [10.0.40.48] ([10.0.40.48]) by dom3.intranet.online.de (Lotus Domino Release 5.0.11) with ESMTP id 2004111010404296:118830 ; Wed, 10 Nov 2004 10:40:42 +0100 Subject: simple select-statement takes more than 25 sec From: Cao Duy To: pgsql-performance@postgresql.org Message-Id: <1100079350.3980.18.camel@Knoppix> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) Date: Wed, 10 Nov 2004 10:35:50 +0100 X-MIMETrack: Itemize by SMTP Server on DOMINO3/1&1/DE(Release 5.0.11 |July 24, 2002) at 10.11.2004 10:40:42, Serialize by Router on DOMINO3/1&1/DE(Release 5.0.11 |July 24, 2002) at 10.11.2004 10:40:46, Serialize complete at 10.11.2004 10:40:46 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/164 X-Sequence-Number: 9118 Hi all I have a table with ca. 4Mio Rows. here is my simple select-statement: SELECT * FROM CUSTOMER WHERE CUSTOMER_ID=5 the result appears after about 27 sec. what's wrong? the same statement on mysql takes 1 milisec. please help here is the structur of the table CREATE TABLE public.customer ( customer_id bigserial NOT NULL, cooperationpartner_id int8 NOT NULL DEFAULT 0::bigint, maincontact_id int8 NOT NULL DEFAULT 0::bigint, companycontact_id int8, def_paymentdetails_id int8, def_paymentsort_id int8, def_invoicing_id int8, int_customernumber varchar(50), ext_customernumber varchar(50), CONSTRAINT customer_pkey PRIMARY KEY (customer_id), CONSTRAINT customer_ibfk_1 FOREIGN KEY (cooperationpartner_id) REFERENCES public.cooperationpartner (cooperationpartner_id) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT customer_ibfk_2 FOREIGN KEY (maincontact_id) REFERENCES public.contact (contact_id) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT customer_ibfk_3 FOREIGN KEY (companycontact_id) REFERENCES public.contact (contact_id) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT customer_ibfk_4 FOREIGN KEY (def_paymentdetails_id) REFERENCES public.paymentdetails (paymentdetails_id) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT customer_ibfk_5 FOREIGN KEY (def_paymentsort_id) REFERENCES public.paymentsort (paymentsort_id) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT customer_ibfk_6 FOREIGN KEY (def_invoicing_id) REFERENCES public.invoicing (invoicing_id) ON UPDATE NO ACTION ON DELETE NO ACTION ) WITH OIDS; From pgsql-performance-owner@postgresql.org Wed Nov 10 10:18:01 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5E92F3A3CE2 for ; Wed, 10 Nov 2004 10:17:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84340-08 for ; Wed, 10 Nov 2004 10:17:50 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id DBC523A3C55 for ; Wed, 10 Nov 2004 10:17:50 +0000 (GMT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1CRpXv-0005xL-00 for ; Wed, 10 Nov 2004 11:17:47 +0100 Date: Wed, 10 Nov 2004 11:17:47 +0100 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: simple select-statement takes more than 25 sec Message-ID: <20041110101747.GB22780@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <1100079350.3980.18.camel@Knoppix> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1100079350.3980.18.camel@Knoppix> X-Operating-System: Linux 2.6.8.1 on a i686 User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/165 X-Sequence-Number: 9119 On Wed, Nov 10, 2004 at 10:35:50AM +0100, Cao Duy wrote: > here is my simple select-statement: > SELECT * FROM CUSTOMER WHERE CUSTOMER_ID=5 It seems like you're missing an index on customer_id. Set it to PRIMARY KEY or do an explicit CREATE INDEX (followed by an ANALYZE) and it should be a lot faster. /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Wed Nov 10 10:29:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C46C13A3D36 for ; Wed, 10 Nov 2004 10:29:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88218-07 for ; Wed, 10 Nov 2004 10:29:17 +0000 (GMT) Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) by svr1.postgresql.org (Postfix) with ESMTP id 01CA63A3CB0 for ; Wed, 10 Nov 2004 10:29:17 +0000 (GMT) Received: from wp2000 ([157.157.160.157] [157.157.160.157]) by quasar.skima.is; Wed, 10 Nov 2004 10:29:14 Z Message-Id: <000501c4c710$774bb170$0100000a@wp2000> From: "gnari" To: "Cao Duy" , References: <1100079350.3980.18.camel@Knoppix> Subject: Re: simple select-statement takes more than 25 sec Date: Wed, 10 Nov 2004 10:31:40 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/166 X-Sequence-Number: 9120 From: "Cao Duy" > > here is my simple select-statement: > SELECT * FROM CUSTOMER WHERE CUSTOMER_ID=5 > > the result appears after about 27 sec. > > what's wrong? > ... > CREATE TABLE public.customer > ( > customer_id bigserial NOT NULL, you do not specify version or show us an explain analyze, or tell us what indexes you have, but if you want to use an index on the bigint column customer_id, and you are using postgres version 7.4 or less, you need to cast your constant (5) to bigint. try SELECT * FROM CUSTOMER WHERE CUSTOMER_ID=5::bigint or SELECT * FROM CUSTOMER WHERE CUSTOMER_ID='5' gnari From pgsql-performance-owner@postgresql.org Wed Nov 10 11:22:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EFB7D3A3C77 for ; Wed, 10 Nov 2004 11:22:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06957-04 for ; Wed, 10 Nov 2004 11:22:22 +0000 (GMT) Received: from dom3.intranet.online.de (intranet.online.de [212.227.34.162]) by svr1.postgresql.org (Postfix) with ESMTP id 46E223A3BCA for ; Wed, 10 Nov 2004 11:22:23 +0000 (GMT) Received: from [10.0.40.48] ([10.0.40.48]) by dom3.intranet.online.de (Lotus Domino Release 5.0.11) with ESMTP id 2004111012271036:120022 ; Wed, 10 Nov 2004 12:27:10 +0100 Subject: Re: simple select-statement takes more than 25 sec From: Cao Duy To: pgsql-performance@postgresql.org In-Reply-To: <20041110101747.GB22780@uio.no> References: <1100079350.3980.18.camel@Knoppix> <20041110101747.GB22780@uio.no> Message-Id: <1100085737.3980.43.camel@Knoppix> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) Date: Wed, 10 Nov 2004 12:22:17 +0100 X-MIMETrack: Itemize by SMTP Server on DOMINO3/1&1/DE(Release 5.0.11 |July 24, 2002) at 10.11.2004 12:27:10, Serialize by Router on DOMINO3/1&1/DE(Release 5.0.11 |July 24, 2002) at 10.11.2004 12:27:13, Serialize complete at 10.11.2004 12:27:13 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/167 X-Sequence-Number: 9121 Am Mi, den 10.11.2004 schrieb Steinar H. Gunderson um 11:17: > On Wed, Nov 10, 2004 at 10:35:50AM +0100, Cao Duy wrote: > > here is my simple select-statement: > > SELECT * FROM CUSTOMER WHERE CUSTOMER_ID=5 > > It seems like you're missing an index on customer_id. Set it to PRIMARY KEY > or do an explicit CREATE INDEX (followed by an ANALYZE) and it should be a > lot faster. there is an index on customer_id create table customer( ... CONSTRAINT customer_pkey PRIMARY KEY (customer_id), ... ) > /* Steinar */ From pgsql-performance-owner@postgresql.org Wed Nov 10 11:45:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 509BA3A3E22 for ; Wed, 10 Nov 2004 11:45:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 11599-09 for ; Wed, 10 Nov 2004 11:45:28 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id 333993A3F50 for ; Wed, 10 Nov 2004 11:45:29 +0000 (GMT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1CRquj-0006Ax-00 for ; Wed, 10 Nov 2004 12:45:25 +0100 Date: Wed, 10 Nov 2004 12:45:25 +0100 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: simple select-statement takes more than 25 sec Message-ID: <20041110114525.GB23500@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <1100079350.3980.18.camel@Knoppix> <20041110101747.GB22780@uio.no> <1100085737.3980.43.camel@Knoppix> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1100085737.3980.43.camel@Knoppix> X-Operating-System: Linux 2.6.8.1 on a i686 User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/168 X-Sequence-Number: 9122 On Wed, Nov 10, 2004 at 12:22:17PM +0100, Cao Duy wrote: > there is an index on customer_id > > create table customer( > ... > CONSTRAINT customer_pkey PRIMARY KEY (customer_id), > ... > ) Oh, sorry, I missed it among all the foreign keys. :-) Anyhow, as others have pointed out, try doing a select against 5::bigint instead of just 5 (which is an integer). /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Wed Nov 10 13:04:17 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 29BAB3A3C55 for ; Wed, 10 Nov 2004 13:04:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37659-03 for ; Wed, 10 Nov 2004 13:04:02 +0000 (GMT) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id B05CB3A1D98 for ; Wed, 10 Nov 2004 13:04:03 +0000 (GMT) Received: (qmail 18026 invoked from network); 10 Nov 2004 12:03:02 -0000 Received: from unknown (HELO ?10.124.7.6?) (10.124.7.6) by dhcp-7-248.ma.lycos.com with SMTP; 10 Nov 2004 12:03:02 -0000 In-Reply-To: <003201c4c68e$8d347ee0$a702a8c0@shanepc> References: <003201c4c68e$8d347ee0$a702a8c0@shanepc> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: From: Jeff Subject: Re: Need advice on postgresql.conf settings Date: Wed, 10 Nov 2004 08:04:03 -0500 To: "Shane | SkinnyCorp" X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/169 X-Sequence-Number: 9123 On Nov 9, 2004, at 2:01 PM, Shane | SkinnyCorp wrote: > Thanks in advance for anything you can do to help. > > > The real issue is this, we have THE SAME queries taking anywhere from > .001 - 90.0 seconds... the server is using 98% of the available RAM at > all times (because of the persistant connections via php), and I don't > know what to do. Every time I change a I'd recommend strongly ditching the use of pconnect and use pgpool + regular connect. It is a terrific combination that provides pool connections like how you'd think they shoudl work (a pool of N connections to PG shared by Y processes instead of a 1:1 mapping). curiously, have you noticed any pattern to the slowdown? It could be induced by a checkpoint or vacuum. Are you swapping at all? Are your PHP scripts leaking at all, etc.? Your load average is high, how does your CPU idle look (if load is high, and the cpus are pretty idle that is an indicator of being IO bound). good luck. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Nov 10 13:52:38 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E70153A4030 for ; Wed, 10 Nov 2004 13:52:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53787-02 for ; Wed, 10 Nov 2004 13:52:31 +0000 (GMT) Received: from mailgate3.cinetic.de (mailgate3.cinetic.de [217.72.192.164]) by svr1.postgresql.org (Postfix) with ESMTP id BCE493A4084 for ; Wed, 10 Nov 2004 13:52:32 +0000 (GMT) Received: from exchange02.int.cinetic.de (exchange02.int.cinetic.de [10.2.1.12]) by mailgate3.cinetic.de (8.11.6p2/8.11.2/SuSE Linux 8.11.0-0.4) with ESMTP id iAADpvK16412; Wed, 10 Nov 2004 14:51:57 +0100 Received: from [10.1.8.177] ([10.1.8.177]) by exchange02.int.cinetic.de with Microsoft SMTPSVC(6.0.3790.211); Wed, 10 Nov 2004 14:51:57 +0100 Message-ID: <41921CFD.7060604@webde-ag.de> Date: Wed, 10 Nov 2004 14:51:57 +0100 From: Michael Kleiser Reply-To: mkl@webde-ag.de Organization: WEB.DE AG User-Agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.2) Gecko/20040803 X-Accept-Language: de, , de-de, de-at, en, en-us MIME-Version: 1.0 To: Jeff Cc: Shane|SkinnyCorp , pgsql-performance@postgresql.org Subject: How to speed-up inserts with jdbc References: <003201c4c68e$8d347ee0$a702a8c0@shanepc> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 10 Nov 2004 13:51:57.0790 (UTC) FILETIME=[71F9C7E0:01C4C72C] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/170 X-Sequence-Number: 9124 Im PostgreSQL 7.2.2 / Linux 2.4.27 dual-processor Pentium III 900MHz, we have this table: create table testtable (id SERIAL PRIMARY KEY, coni VARCHAR(255), date TIMESTAMP, direction VARCHAR(255), partner VARCHAR(255), type VARCHAR(255), block VARCHAR(255) ); We using Java with JDBC-driver pg72jdbc2.jar our Java-testgrogram is : public class Stresser implements Runnable { public void run() { System.out.println("-> start"); try { Class.forName("org.postgresql.Driver"); Connection con = DriverManager.getConnection("jdbc:postgresql://"+prop.getProperty("host")+":"+prop.getProperty("port")+"/"+prop.getProperty("dbname"), prop.getProperty("user"), prop.getProperty("pwd")); con.setAutoCommit(true); Statement st = con.createStatement(); java.sql.Timestamp datum = new java.sql.Timestamp(new Date().getTime()); Date start = new Date(); System.out.println(start); for (int i=0; i<100; ++i) { st.executeUpdate("insert into history(uuid,coni,date,direction,partner,type) values('uuid','content','"+datum+"','dir','partner','type')"); } Date end = new Date(); System.out.println(end); con.close(); } catch (Exception e) { System.out.println("Exception!"); e.printStackTrace(); } System.out.println("-> ende"); } public static void main(String[] args) { for (int i=0; i<10; ++i) { Stresser s = new Stresser(); Thread t = new Thread(s); t.start(); } } } It is trunning in in 10 Threads. Each thread makes 100 Inserts: For the 1000 Inserts (10 threads a 100 inserts) we need 8 seconds. That's 125 Insets / Seconds. How could we make it faster ? Inserting 1000 rows via INSERT AS SELECT is much faster. regards Michael From pgsql-performance-owner@postgresql.org Wed Nov 10 13:55:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6208E3A3E27 for ; Wed, 10 Nov 2004 13:55:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53659-03 for ; Wed, 10 Nov 2004 13:54:59 +0000 (GMT) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id D4D2B3A4030 for ; Wed, 10 Nov 2004 13:55:00 +0000 (GMT) Received: (qmail 18803 invoked from network); 10 Nov 2004 12:54:01 -0000 Received: from unknown (HELO ?10.124.7.6?) (10.124.7.6) by dhcp-7-248.ma.lycos.com with SMTP; 10 Nov 2004 12:54:01 -0000 In-Reply-To: <41921CFD.7060604@webde-ag.de> References: <003201c4c68e$8d347ee0$a702a8c0@shanepc> <41921CFD.7060604@webde-ag.de> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <1DFE91CA-3320-11D9-9406-000D9366F0C4@torgo.978.org> Content-Transfer-Encoding: 7bit Cc: Shane|SkinnyCorp , pgsql-performance@postgresql.org From: Jeff Subject: Re: How to speed-up inserts with jdbc Date: Wed, 10 Nov 2004 08:55:01 -0500 To: mkl@webde-ag.de X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/171 X-Sequence-Number: 9125 On Nov 10, 2004, at 8:51 AM, Michael Kleiser wrote: > It is trunning in in 10 Threads. Each thread makes 100 Inserts: > > For the 1000 Inserts (10 threads a 100 inserts) > we need 8 seconds. > That's 125 Insets / Seconds. > How could we make it faster ? > Batch the inserts up into a transaction. So you'd have BEGIN insert insert insert ... COMMIT Your numbers will suddenly sky rocket. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Nov 10 14:04:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C27C73A411A for ; Wed, 10 Nov 2004 14:04:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57250-05 for ; Wed, 10 Nov 2004 14:04:29 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 6612D3A4090 for ; Wed, 10 Nov 2004 14:04:31 +0000 (GMT) Received: (qmail 16596 invoked from network); 10 Nov 2004 14:04:29 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 10 Nov 2004 14:04:29 -0000 Message-ID: <41922031.4000303@fastcrypt.com> Date: Wed, 10 Nov 2004 09:05:37 -0500 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 0.8 (X11/20041001) X-Accept-Language: en-us, en MIME-Version: 1.0 To: mkl@webde-ag.de Cc: Jeff , Shane|SkinnyCorp , pgsql-performance@postgresql.org Subject: Re: How to speed-up inserts with jdbc References: <003201c4c68e$8d347ee0$a702a8c0@shanepc> <41921CFD.7060604@webde-ag.de> In-Reply-To: <41921CFD.7060604@webde-ag.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/172 X-Sequence-Number: 9126 couple of things 1) That is a fairly old version of postgres, there are considerable performance improvements in the last 2 releases since, and even more in the pending release. 2) If you are going to insert more rows than that, consider dropping the index before, and recreating after the insert. Dave Michael Kleiser wrote: > Im PostgreSQL 7.2.2 / Linux 2.4.27 dual-processor Pentium III 900MHz, > > we have this table: > > create table testtable (id SERIAL PRIMARY KEY, coni VARCHAR(255), date > TIMESTAMP, direction VARCHAR(255), partner VARCHAR(255), type > VARCHAR(255), block VARCHAR(255) ); > > > We using Java with JDBC-driver pg72jdbc2.jar > > > our Java-testgrogram is : > > > public class Stresser implements Runnable { > public void run() { > System.out.println("-> start"); > try { > > Class.forName("org.postgresql.Driver"); > Connection con = > DriverManager.getConnection("jdbc:postgresql://"+prop.getProperty("host")+":"+prop.getProperty("port")+"/"+prop.getProperty("dbname"), > prop.getProperty("user"), prop.getProperty("pwd")); > con.setAutoCommit(true); > Statement st = con.createStatement(); > java.sql.Timestamp datum = new java.sql.Timestamp(new > Date().getTime()); > Date start = new Date(); > System.out.println(start); > for (int i=0; i<100; ++i) { > st.executeUpdate("insert into > history(uuid,coni,date,direction,partner,type) > values('uuid','content','"+datum+"','dir','partner','type')"); > } > Date end = new Date(); > System.out.println(end); > con.close(); > } catch (Exception e) { > System.out.println("Exception!"); > e.printStackTrace(); > } > System.out.println("-> ende"); > } > > public static void main(String[] args) { > > for (int i=0; i<10; ++i) { > Stresser s = new Stresser(); > Thread t = new Thread(s); > t.start(); > } > } > } > > > It is trunning in in 10 Threads. Each thread makes 100 Inserts: > > For the 1000 Inserts (10 threads a 100 inserts) > we need 8 seconds. > That's 125 Insets / Seconds. > > How could we make it faster ? > > Inserting 1000 rows via INSERT AS SELECT is much faster. > > regards > Michael > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561 From pgsql-performance-owner@postgresql.org Wed Nov 10 14:27:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 76B143A4114 for ; Wed, 10 Nov 2004 14:27:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63483-09 for ; Wed, 10 Nov 2004 14:26:55 +0000 (GMT) Received: from usbb-lacimss1.unisys.com (usbb-lacimss1.unisys.com [192.63.108.51]) by svr1.postgresql.org (Postfix) with ESMTP id 60B123A4089 for ; Wed, 10 Nov 2004 14:26:57 +0000 (GMT) Received: from USBB-LACGW3.na.uis.unisys.com ([129.224.98.43]unverified) by usbb-lacimss1 with InterScan Messaging Security Suite; Wed, 10 Nov 2004 09:30:25 -0500 Received: from USBB-LACGW3.na.uis.unisys.com ([129.224.98.44]) by USBB-LACGW3.na.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.211); Wed, 10 Nov 2004 09:26:20 -0500 Received: from gbmk-eugw2.eu.uis.unisys.com ([129.221.133.27]) by USBB-LACGW3.na.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.211); Wed, 10 Nov 2004 09:26:20 -0500 Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by gbmk-eugw2.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.47); Wed, 10 Nov 2004 14:26:18 +0000 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: How to speed-up inserts with jdbc Date: Wed, 10 Nov 2004 15:26:20 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] How to speed-up inserts with jdbc Thread-Index: AcTHLRwwE97I0CAQTXKUCKPa9q+/eQAA+mRQ From: "Leeuw van der, Tim" To: , "Jeff" Cc: "Shane|SkinnyCorp" , X-OriginalArrivalTime: 10 Nov 2004 14:26:18.0623 (UTC) FILETIME=[3E53F0F0:01C4C731] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/173 X-Sequence-Number: 9127 Hi, Try using parametrized prepared statements, does that make a difference? = Or does PGSQL jdbc not support them in your version? --Tim -----Original Message----- From: pgsql-performance-owner@postgresql.org = [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Michael = Kleiser Sent: Wednesday, November 10, 2004 2:52 PM To: Jeff Cc: Shane|SkinnyCorp; pgsql-performance@postgresql.org Subject: [PERFORM] How to speed-up inserts with jdbc [...] > Statement st =3D con.createStatement(); [...] st.executeUpdate("insert into = history(uuid,coni,date,direction,partner,type) = values('uuid','content','"+datum+"','dir','partner','type')"); [...] From pgsql-performance-owner@postgresql.org Sun Nov 14 05:51:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8B9DA3A4235 for ; Wed, 10 Nov 2004 16:54:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19799-09 for ; Wed, 10 Nov 2004 16:54:42 +0000 (GMT) Received: from server2.sitesell.com (server2.sitesell.com [216.95.221.3]) by svr1.postgresql.org (Postfix) with SMTP id 083993A4222 for ; Wed, 10 Nov 2004 16:54:41 +0000 (GMT) Received: (qmail 27769 invoked from network); 10 Nov 2004 16:54:39 -0000 Received: from dyn-69-135.tor.dsl.tht.net (134.22.69.135) by server2.sitesell.com with SMTP; 10 Nov 2004 16:54:39 -0000 Subject: Tuning suggestions wanted From: Rod Taylor To: Postgresql Performance Content-Type: text/plain Date: Wed, 10 Nov 2004 11:52:34 -0500 Message-Id: <1100105554.79412.37.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/207 X-Sequence-Number: 9161 I'm looking for suggestions on tuning Solaris 9 for a SunFire 890 (Ultra IV chips) connected to an Hitachi 9500V running PostgreSQL 7.4. So that I don't lead people in a direction, I'll hold off for a while before posting our configuration settings. Database is approx 160GB in size with a churn of around 4GB per day (2 GB updated, 2GB inserted, very little removed). It's a mixture of OLTP and reporting. 5% is reports which do trickle writes 95% is short (30 second or less) transactions with about 10 selects, 10 writes (inserts, updates, deletes all mixed in) affecting 150 tuples. Thanks for any tips -- particularly Solaris kernel tuning. -- Rod Taylor From pgsql-performance-owner@postgresql.org Wed Nov 10 17:01:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CDCD83A4215 for ; Wed, 10 Nov 2004 17:01:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23767-04 for ; Wed, 10 Nov 2004 17:00:59 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) by svr1.postgresql.org (Postfix) with ESMTP id 81FB33A4242 for ; Wed, 10 Nov 2004 17:00:56 +0000 (GMT) Received: by flake.decibel.org (Postfix, from userid 1001) id 6BDD51C8A6; Wed, 10 Nov 2004 17:00:55 +0000 (GMT) Date: Wed, 10 Nov 2004 11:00:55 -0600 From: "Jim C. Nasby" To: "Joshua D. Drake" Cc: pgsql-performance@postgresql.org Subject: Re: seqscan strikes again Message-ID: <20041110170055.GJ46084@decibel.org> References: <20041109222345.GG46084@decibel.org> <41914F5C.9030505@commandprompt.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41914F5C.9030505@commandprompt.com> X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/174 X-Sequence-Number: 9128 Which column would you recommend? Did something stick out at you? On Tue, Nov 09, 2004 at 03:14:36PM -0800, Joshua D. Drake wrote: > > >opensims=# > > > >I'd really like to avoid putting a 'set enable_seqscan=false' in my > >code, especially since this query only has a problem if it's run on a > >large date/time window, which normally doesn't happen. > > Try increasing your statistics target for the column and then rerunning > analyze. > > Sincerely, > > Joshua D. Drake -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Wed Nov 10 17:06:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5CF1C3A4228 for ; Wed, 10 Nov 2004 17:06:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23863-10 for ; Wed, 10 Nov 2004 17:06:23 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 96ABF3A3C55 for ; Wed, 10 Nov 2004 17:06:22 +0000 (GMT) Received: from dyn-69-135.tor.dsl.tht.net (dyn-69-135.tor.dsl.tht.net [134.22.69.135]) by tht.net (Postfix) with ESMTP id CEF1B76B0C for ; Wed, 10 Nov 2004 12:06:19 -0500 (EST) Subject: Solaris 9 Tuning Tips requested From: Rod Taylor To: Postgresql Performance Content-Type: text/plain Date: Wed, 10 Nov 2004 12:04:12 -0500 Message-Id: <1100106252.79412.41.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/175 X-Sequence-Number: 9129 I'm looking for suggestions on tuning Solaris 9 for a SunFire 890 (Ultra IV chips) connected to an Hitachi 9500V running PostgreSQL 7.4. Database is approx 160GB in size with a churn of around 4GB per day (2 GB updated, 2GB inserted, very little removed). It's a mixture of OLTP and reporting. 5% is reports which do trickle writes 95% is short (30 second or less) transactions with about 10 selects, 10 writes (inserts, updates, deletes all mixed in) affecting 150 tuples. Thanks for any tips -- particularly Solaris kernel tuning or oddities in Disk IO or configuration settings as they related to Solaris (as they differ from an Intel). -- From pgsql-performance-owner@postgresql.org Wed Nov 10 21:51:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5E54F3A433C for ; Wed, 10 Nov 2004 21:51:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35850-02 for ; Wed, 10 Nov 2004 21:51:35 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.201]) by svr1.postgresql.org (Postfix) with ESMTP id 29F4C3A4318 for ; Wed, 10 Nov 2004 21:51:36 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a36so245271rnf for ; Wed, 10 Nov 2004 13:51:36 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=RqmdZQjgst+zmt/yqZ/KZj0wti6ZCJOiFMGscTRXzSYx6Sx1q17F2Hjr2dvt1k0JgsYeMY2Er3m2Om9P81tWdjH02daqLJ+vZ8EAdNlrtxG+/z/I6wI/prPyJGEGK0gnwHRRwVhTuyReD+GRZdyOeRosJ67VhbU5jyBYfl7Yhas= Received: by 10.38.82.80 with SMTP id f80mr354036rnb; Wed, 10 Nov 2004 13:51:36 -0800 (PST) Received: by 10.38.126.17 with HTTP; Wed, 10 Nov 2004 13:51:35 -0800 (PST) Message-ID: Date: Wed, 10 Nov 2004 16:51:35 -0500 From: Mike Rylander Reply-To: Mike Rylander To: pgsql-performance@postgresql.org Subject: int4 in a GiST index Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/176 X-Sequence-Number: 9130 Hello all, I am using tsearch2 to (imagine this... :) index a text field. There is also a, for lack of a better name, "classification" field called 'field' that will be used to group certain rows together. CREATE TABLE biblio.metarecord_field_entry ( record BIGINT REFERENCES biblio.metarecord (id) ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED, field INT NOT NULL REFERENCES biblio.metarecord_field_map (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, value TEXT, value_fti tsvector, source BIGINT NOT NULL REFERENCES biblio.record (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED ) WITHOUT OIDS; Because there will be "or" queries against the 'value_fti' I want to create a multi-column index across the tsvector and classification columns as that should help with selectivity. But because there is no GiST opclass for INT4 the index creation complains thusly: oils=# CREATE INDEX metarecord_field_entry_value_and_field_idx ON biblio.metarecord_field_entry USING GIST (field, value_fti); ERROR: data type integer has no default operator class for access method "gist" HINT: You must specify an operator class for the index or define a default operator class for the data type. I attempted to give it the 'int4_ops' class, but that also complains: oils=# CREATE INDEX metarecord_field_entry_value_and_field_idx ON biblio.metarecord_field_entry USING GIST (value_fti, field int4_ops); ERROR: operator class "int4_ops" does not exist for access method "gist" I couldn't find any info in the docs (7.4 and 8.0.0b4) for getting GiST to index standard integers. I'm sure this has been done before, but I've note found the magic spell. Of course, I may just be barking up the wrong tree altogether... Thanks in advance! -- Mike Rylander mrylander@gmail.com GPLS -- PINES Development Database Developer From pgsql-performance-owner@postgresql.org Thu Nov 11 02:50:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C3D103A4410 for ; Thu, 11 Nov 2004 02:50:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13950-06 for ; Thu, 11 Nov 2004 02:50:26 +0000 (GMT) Received: from web53706.mail.yahoo.com (web53706.mail.yahoo.com [206.190.37.27]) by svr1.postgresql.org (Postfix) with SMTP id 3744C3A4404 for ; Thu, 11 Nov 2004 02:50:28 +0000 (GMT) Received: (qmail 9048 invoked by uid 60001); 11 Nov 2004 02:50:28 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=0nPXALZPA+QMMpS0M8/HrQDIPfk2K3DMIkKgm4sV0M69MOG5b0sN7uGWIFSux/a6weZkS+m5q5Tp0Uv9amDAgKcmslbpe3x3EjD6d/euX3EhLVIdrVJYK4GIsHdCb/2YavYPfkvbECL3FqfwzOKDjWeCPm06+JF47dLqnBITNbc= ; Message-ID: <20041111025028.9044.qmail@web53706.mail.yahoo.com> Received: from [65.69.58.152] by web53706.mail.yahoo.com via HTTP; Wed, 10 Nov 2004 18:50:28 PST Date: Wed, 10 Nov 2004 18:50:28 -0800 (PST) From: George Essig Subject: Re: int4 in a GiST index To: Mike Rylander Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/177 X-Sequence-Number: 9131 Mike Rylander wrote: > I want to create a multi-column index across the tsvector and classification > columns as that should help with selectivity. But because there is no > GiST opclass for INT4 the index creation complains thusly: Install contrib/btree_gist along with contrib/tsearch2 to create a multicolumn index on the in4 and the tsvector columns. See the following for an example: http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/oscon_tsearch2/multi_column_index.html George Essig From pgsql-performance-owner@postgresql.org Thu Nov 11 05:53:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C855F3A43D7 for ; Thu, 11 Nov 2004 05:53:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56789-05 for ; Thu, 11 Nov 2004 05:53:10 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) by svr1.postgresql.org (Postfix) with ESMTP id E18913A3AFF for ; Thu, 11 Nov 2004 05:53:10 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a36so281881rnf for ; Wed, 10 Nov 2004 21:53:09 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=R2NfFdojsM48joe9UH7k/OJAVPZJDc0/FtSICc8q6Zn90fp8hRV2VIcLLG1ZKyoKrusZo9cqBuLkJrrMBmfFEtAfTzPAAR6OZN6HrhAvlmxwz8gIBejKZasAEuVg58RIDiJO9WaTQDT61NtgpNGeObnRoCDLCzIEXYkWAkPs6U0= Received: by 10.38.79.69 with SMTP id c69mr595021rnb; Wed, 10 Nov 2004 21:53:09 -0800 (PST) Received: by 10.38.126.17 with HTTP; Wed, 10 Nov 2004 21:53:09 -0800 (PST) Message-ID: Date: Thu, 11 Nov 2004 00:53:09 -0500 From: Mike Rylander Reply-To: Mike Rylander To: George Essig Subject: Re: int4 in a GiST index Cc: pgsql-performance@postgresql.org In-Reply-To: <20041111025028.9044.qmail@web53706.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20041111025028.9044.qmail@web53706.mail.yahoo.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/178 X-Sequence-Number: 9132 On Wed, 10 Nov 2004 18:50:28 -0800 (PST), George Essig wrote: > Mike Rylander wrote: > > > I want to create a multi-column index across the tsvector and classification > > columns as that should help with selectivity. But because there is no > > GiST opclass for INT4 the index creation complains thusly: > > Install contrib/btree_gist along with contrib/tsearch2 to create a multicolumn index on the in4 > and the tsvector columns. See the following for an example: > > http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/oscon_tsearch2/multi_column_index.html > > George Essig > Thanks a million. I had actually just found the answer after some more googling, but I hadn't seen that page and it happens to be exactly what I wanted. As a side note I'd like to thank everyone here (and especially George, in this case). I've been on these lists for quite a while and I'm always amazed at the speed, accuracy and precision of the answers on the PG mailing lists. -- Mike Rylander mrylander@gmail.com GPLS -- PINES Development Database Developer From pgsql-performance-owner@postgresql.org Thu Nov 11 18:07:25 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 87F7F3A46D0 for ; Thu, 11 Nov 2004 17:06:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36917-02 for ; Thu, 11 Nov 2004 17:06:24 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 2A4C43A4A46 for ; Thu, 11 Nov 2004 15:24:05 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iABFO4g5001466 for ; Thu, 11 Nov 2004 15:24:04 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iAB7wbOS088093 for pgsql-performance@postgresql.org; Thu, 11 Nov 2004 07:58:37 GMT From: Gaetano Mendola X-Newsgroups: comp.databases.postgresql.performance Subject: Re: seqscan strikes again Date: Thu, 11 Nov 2004 08:58:27 +0100 Organization: PYRENET Midi-pyrenees Provider Lines: 12 Message-ID: <41931BA3.5010008@bigfoot.com> References: <20041109222345.GG46084@decibel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@pyrenet.fr To: "Jim C. Nasby" User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en In-Reply-To: <20041109222345.GG46084@decibel.org> X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/180 X-Sequence-Number: 9134 Jim C. Nasby wrote: > I'm wondering if there's any way I can tweak things so that the estimate > for the query is more accurate (I have run analyze): Can you post your configuration file ? I'd like to see for example your settings about: random_page_cost and effective_cache_size. Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Thu Nov 11 18:09:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 970F73A46DF for ; Thu, 11 Nov 2004 17:06:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35967-09 for ; Thu, 11 Nov 2004 17:06:24 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 2A6013A4A47 for ; Thu, 11 Nov 2004 15:24:05 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iABFO4g7001466 for ; Thu, 11 Nov 2004 15:24:05 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iAB83YAS090135 for pgsql-performance@postgresql.org; Thu, 11 Nov 2004 08:03:34 GMT From: Gaetano Mendola X-Newsgroups: comp.databases.postgresql.performance Subject: Re: vacuum analyze slows sql query Date: Thu, 11 Nov 2004 09:03:24 +0100 Organization: PYRENET Midi-pyrenees Provider Lines: 31 Message-ID: <41931CCC.6070803@bigfoot.com> References: <419008DA.3000007@johnmeinel.com> <20041109192644.6423.qmail@web52104.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@pyrenet.fr To: patrick ~ User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en In-Reply-To: <20041109192644.6423.qmail@web52104.mail.yahoo.com> X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/182 X-Sequence-Number: 9136 patrick ~ wrote: > --- John Meinel wrote: > > >>If you are trying to establish existence, we also had a whole thread on >>this. Basically what we found was that adding an ORDER BY clause, helped >>tremendously in getting the planner to switch to an Index scan. You >>might try something like: >> >>SELECT column FROM mytable WHERE column='myval' ORDER BY column LIMIT 1; >> >>There seems to be a big difference between the above statement and: >> >>SELECT column FROM mytable WHERE column='myval' LIMIT 1; > > > > The ORDER BY "trick" worked beautifully! I just hope it'll > continue to work consistently in production code. For sure it will not break the goal: "check the existence". Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Thu Nov 11 08:05:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 29B373A3C55 for ; Thu, 11 Nov 2004 08:04:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88366-07 for ; Thu, 11 Nov 2004 08:04:09 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.207]) by svr1.postgresql.org (Postfix) with ESMTP id 543CF3A3AE1 for ; Thu, 11 Nov 2004 08:04:09 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a36so288553rnf for ; Thu, 11 Nov 2004 00:04:06 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=pv/Ynpe0EZDuzUnf5j+5uY9EgRQdkQlH33GuCVHYvZllpHanOCXcoF2hG8U5ZmvEQfW2lvjq+ZGgDVJxL3FZPHAawTtPM1UHknKaiJtlbZnkPm3Z4LpBMqJk2q4fPJGYhko8332zBVJt2kS3F990DEOBzTIfqKfbGTF1EoN7sQE= Received: by 10.38.15.8 with SMTP id 8mr1005578rno; Thu, 11 Nov 2004 00:04:06 -0800 (PST) Received: by 10.39.2.50 with HTTP; Thu, 11 Nov 2004 00:04:06 -0800 (PST) Message-ID: <376dd19504111100044aa0ca1e@mail.gmail.com> Date: Thu, 11 Nov 2004 16:04:06 +0800 From: Edwin Eyan Moragas Reply-To: Edwin Eyan Moragas To: mkl@webde-ag.de Subject: Re: How to speed-up inserts with jdbc Cc: Jeff , Shane|SkinnyCorp , pgsql-performance@postgresql.org In-Reply-To: <41921CFD.7060604@webde-ag.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <003201c4c68e$8d347ee0$a702a8c0@shanepc> <41921CFD.7060604@webde-ag.de> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/179 X-Sequence-Number: 9133 On Wed, 10 Nov 2004 14:51:57 +0100, Michael Kleiser wrote: > Statement st = con.createStatement(); > java.sql.Timestamp datum = new java.sql.Timestamp(new Date().getTime()); > Date start = new Date(); > System.out.println(start); > for (int i=0; i<100; ++i) { > st.executeUpdate("insert into history(uuid,coni,date,direction,partner,type) values('uuid','content','"+datum+"','dir','partner','type')"); > } how about using PreparedStatment? that's on the java end. on the pg end, maybe do a BEGIN before the for loop and END at the end of the for loop. -- i'm not flying. i'm falling... in style. From pgsql-performance-owner@postgresql.org Thu Nov 11 18:07:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3A28C3A4639 for ; Thu, 11 Nov 2004 17:06:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35984-09 for ; Thu, 11 Nov 2004 17:06:18 +0000 (GMT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by svr1.postgresql.org (Postfix) with ESMTP id 23FD73A4865 for ; Thu, 11 Nov 2004 15:23:01 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr4.postgresql.org (Postfix) with ESMTP id C2F705AF348 for ; Thu, 11 Nov 2004 10:16:17 +0000 (GMT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1CSBoQ-0002g3-00 for ; Thu, 11 Nov 2004 11:04:18 +0100 Date: Thu, 11 Nov 2004 11:04:18 +0100 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: How to speed-up inserts with jdbc Message-ID: <20041111100418.GA2116@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <003201c4c68e$8d347ee0$a702a8c0@shanepc> <41921CFD.7060604@webde-ag.de> <376dd19504111100044aa0ca1e@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <376dd19504111100044aa0ca1e@mail.gmail.com> X-Operating-System: Linux 2.6.8.1 on a i686 User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/181 X-Sequence-Number: 9135 On Thu, Nov 11, 2004 at 04:04:06PM +0800, Edwin Eyan Moragas wrote: > how about using PreparedStatment? that's on the java end. > on the pg end, maybe do a BEGIN before the for loop and > END at the end of the for loop. You don't even need a "BEGIN" and "END"; his code has a setAutoComit(true) before the for loop, which just has to be changed to setAutoCommit(false) (and add an explicit commit() after the for loop, of course). /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Thu Nov 11 18:36:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 38DA23A42EE for ; Thu, 11 Nov 2004 17:56:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62173-09 for ; Thu, 11 Nov 2004 17:55:59 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.201]) by svr1.postgresql.org (Postfix) with ESMTP id 8AA2A3A4CDA for ; Thu, 11 Nov 2004 16:21:14 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 36so52315wra for ; Thu, 11 Nov 2004 08:21:14 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=GTcKd77VK9DXmdxsixKeJNnydnydJ868HKoy5dOBcrYorHnLU/8dKCHzyB+UAjidy6L6IrYGmwegJ0XTGA47GPa9vcTRUIeyWGAE11D+2uRm/dxHtZsKWO/79YJoNBWtIslvaWi7ouApKYQgIil0heWfi6C9rSZGgHueiEBs3ow= Received: by 10.54.54.78 with SMTP id c78mr336079wra; Thu, 11 Nov 2004 08:21:13 -0800 (PST) Received: by 10.54.43.36 with HTTP; Thu, 11 Nov 2004 08:21:13 -0800 (PST) Message-ID: <88f1825a041111082176f13033@mail.gmail.com> Date: Thu, 11 Nov 2004 11:21:13 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-Reply-To: <88f1825a04110523276f83653b@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105095631064cb0@mail.gmail.com> <008401c4c366$127d5260$8300a8c0@solent> <88f1825a04110513028759dd3@mail.gmail.com> <418C1757.70909@ymogen.net> <25492.1099713863@sss.pgh.pa.us> <88f1825a04110523276f83653b@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/183 X-Sequence-Number: 9137 Ok, you thought maybe this thread died or got abandoned in the face of all the senseless trolling and spam going on.. you were wrong.. ;) I thought though I'd start over trying to explain what's going on. I've gone through some dumps, and recreation of the database with some different filesystem options and whatnot, and starting over fresh here's the situation. First, the structure. CREATE TABLE testtable ( nid serial UNIQUE NOT NULL, sname text NOT NULL, iother int4 ); CREATE UNIQUE INDEX idx_sname_unique ON testtable (sname); ----- With the above, the query "SELECT sname FROM testtable WHERE sname LIKE 'A%';" DOES use an index scan on idx_sname_unique -- sometimes. Other times, the planner thinks a sequential scan would be better. The index is large. There are over 70 million rows in this table. The estimated cost and so forth from EXPLAIN on the above query is way off as well, but I expect that to be the case considering the size of the table -- perhaps there is a tunable in the statistics gathering backend ot fix this? My goal was to obviously make queries of the above type, as well as more refined ones such as "... LIKE 'AB%';" faster. This goal in mind, I thought that creating several indexes (36 of them) would speed things up -- one index per alphanumeric start character, via.. CREATE INDEX idx_sname_suba ON testtable (sname) WHERE sname LIKE 'A%'; CREATE INDEX idx_sname_subb ON testtable (sname) WHERE sname LIKE 'B%'; ... CREATE INDEX idx_sname_subz ON testtable (sname) WHERE sname LIKE 'Z%'; (also including 0..9) I've wracked my brain trying to come up with other ways of doing this, including partitioning the table, and trying the suggestions here such as "substr(1,1)" in the index creation instead of creating many distinct indexes. None of these seems to speed up the queries enough to make them "acceptable" when it comes to runtimes. My data from before was somehow in error.. not sure why. At this point, using one index vs. the other the runtimes are about the same. search=# explain analyze search-# SELECT sname FROM search-# (SELECT sname FROM testtable WHERE sname LIKE 'A%') AS subq search-# WHERE sname LIKE 'AA%'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------- Index Scan using sname_a on "testtable" (cost=0.00..189.41 rows=47 width=20) (actual time=16.219..547053.251 rows=74612 loops=1) Index Cond: ((sname >= 'A'::text) AND (sname < 'B'::text) AND (sname >= 'AA'::text) AND (sname < 'AB'::text)) Filter: ((sname ~~ 'A%'::text) AND (sname ~~ 'AA%'::text)) Total runtime: 547454.939 ms (4 rows) Time: 547458.216 ms search=# explain analyze search-# SELECT sname FROM testtable WHERE sname LIKE 'AA%'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------- Index Scan using sname_unique on "testtable" (cost=0.00..34453.74 rows=8620 width=20) (actual time=77.004..537065.079 rows=74612 loops=1) Index Cond: ((sname >= 'AA'::text) AND (sname < 'AB'::text)) Filter: (sname ~~ 'AA%'::text) Total runtime: 537477.737 ms (4 rows) Time: 537480.571 ms From pgsql-performance-owner@postgresql.org Thu Nov 11 18:51:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ED8693A468B for ; Thu, 11 Nov 2004 18:50:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92343-03 for ; Thu, 11 Nov 2004 18:50:11 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 42C7E3A465D for ; Thu, 11 Nov 2004 18:50:07 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6646425; Thu, 11 Nov 2004 10:51:36 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org, Allen Landsidel Subject: Re: Strange (?) Index behavior? Date: Thu, 11 Nov 2004 10:52:43 -0800 User-Agent: KMail/1.6.2 References: <88f1825a041105095631064cb0@mail.gmail.com> <88f1825a04110523276f83653b@mail.gmail.com> <88f1825a041111082176f13033@mail.gmail.com> In-Reply-To: <88f1825a041111082176f13033@mail.gmail.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411111052.43179.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/184 X-Sequence-Number: 9138 Allen, > Ok, you thought maybe this thread died or got abandoned in the face of > all the senseless trolling and spam going on.. you were wrong.. ;) > > I thought though I'd start over trying to explain what's going on. > I've gone through some dumps, and recreation of the database with some > different filesystem options and whatnot, and starting over fresh > here's the situation. I can't find the beginning of this thread. What's your sort_mem? Shared_buffers? -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Nov 11 19:33:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 96F0E3A425F for ; Thu, 11 Nov 2004 19:31:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08439-10 for ; Thu, 11 Nov 2004 19:31:00 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.199]) by svr1.postgresql.org (Postfix) with ESMTP id 1739D3A4203 for ; Thu, 11 Nov 2004 19:30:58 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 69so109475wri for ; Thu, 11 Nov 2004 11:30:57 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=JSoRsucPQb9QEHWmGIXFWy2nxwaUiFMAfiF9toY8/hZ1yoLmE5aGobnL79DFx0fsvjUrDJG4tzD3fMMJ5JkQ8CHAweNYkyP0yBcoWSdX0ZSXVZ/0EX8IOi/VAMTLAqAei5fsDf0zU+gGQ45YKoA//YmPbJ5vPy6tIf3sLKseUE0= Received: by 10.54.54.78 with SMTP id c78mr362625wra; Thu, 11 Nov 2004 11:30:57 -0800 (PST) Received: by 10.54.43.36 with HTTP; Thu, 11 Nov 2004 11:30:57 -0800 (PST) Message-ID: <88f1825a041111113098cfaa5@mail.gmail.com> Date: Thu, 11 Nov 2004 14:30:57 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-Reply-To: <200411111052.43179.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105095631064cb0@mail.gmail.com> <88f1825a04110523276f83653b@mail.gmail.com> <88f1825a041111082176f13033@mail.gmail.com> <200411111052.43179.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/185 X-Sequence-Number: 9139 On Thu, 11 Nov 2004 10:52:43 -0800, Josh Berkus wrote: > Allen, > > > Ok, you thought maybe this thread died or got abandoned in the face of > > all the senseless trolling and spam going on.. you were wrong.. ;) > > > > I thought though I'd start over trying to explain what's going on. > > I've gone through some dumps, and recreation of the database with some > > different filesystem options and whatnot, and starting over fresh > > here's the situation. > > I can't find the beginning of this thread. What's your sort_mem? > Shared_buffers? Currently sort_mem is 64MB and shared_buffers is 256MB. The box is a dual 800 with 2GB physical, running FreeBSD 4.10-STABLE, single U2W SCSI hdd. From pgsql-performance-owner@postgresql.org Thu Nov 11 20:49:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 80A493A43BC for ; Thu, 11 Nov 2004 20:49:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36476-06 for ; Thu, 11 Nov 2004 20:49:48 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id 9B9263A43AD for ; Thu, 11 Nov 2004 20:49:49 +0000 (GMT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1CSLt5-0007zo-00; Thu, 11 Nov 2004 15:49:47 -0500 To: Allen Landsidel Cc: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? References: <88f1825a041105095631064cb0@mail.gmail.com> <008401c4c366$127d5260$8300a8c0@solent> <88f1825a04110513028759dd3@mail.gmail.com> <418C1757.70909@ymogen.net> <25492.1099713863@sss.pgh.pa.us> <88f1825a04110523276f83653b@mail.gmail.com> <88f1825a041111082176f13033@mail.gmail.com> In-Reply-To: <88f1825a041111082176f13033@mail.gmail.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 11 Nov 2004 15:49:46 -0500 Message-ID: <873bzgdsb9.fsf@stark.xeocode.com> Lines: 33 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/186 X-Sequence-Number: 9140 Allen Landsidel writes: > QUERY PLAN > ----------------------------------------------------------------------------------------------------------------------------------------------- > Index Scan using sname_unique on "testtable" (cost=0.00..34453.74 > rows=8620 width=20) (actual time=77.004..537065.079 rows=74612 > loops=1) > Index Cond: ((sname >= 'AA'::text) AND (sname < 'AB'::text)) > Filter: (sname ~~ 'AA%'::text) > Total runtime: 537477.737 ms > (4 rows) > > Time: 537480.571 ms Nothing you're going to do to the query is going to come up with a more effective plan than this. It's using the index after all. It's never going to be lightning fast because it has to process 75k rows. However 75k rows shouldn't be taking nearly 10 minutes. It should be taking about 10 seconds. The 77ms before finding the first record is a bit suspicious. Have you vacuumed this table regularly? Try a VACUUM FULL VERBOSE, and send the results. You might try to REINDEX it as well, though I doubt that would help. Actually you might consider clustering the table on sname_unique. That would accomplish the same thing as the VACUUM FULL command and also speed up the index scan. And the optimizer knows (if you analyze afterwards) it so it should be more likely to pick the index scan. But currently you have to rerun cluster periodically. -- greg From pgsql-performance-owner@postgresql.org Thu Nov 11 21:11:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 470F53A43C0 for ; Thu, 11 Nov 2004 21:11:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43957-02 for ; Thu, 11 Nov 2004 21:10:57 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.195]) by svr1.postgresql.org (Postfix) with ESMTP id 033F63A43A5 for ; Thu, 11 Nov 2004 21:10:58 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a36so361657rnf for ; Thu, 11 Nov 2004 13:10:58 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=ug2xnrEpLqKt4L+k2OcRs01EfANsl9VK+eshRiTEaAhhiAI64XdCUDdlsEMHIWybfJ/Z618J0P+/i+hHbjRnncfDV/Ne/tvqqnAzZNLodWjIi3hH3jYywUi9pXVjWUIOh3Uk+PJVYg0TMrl8ctczZnIeGAlaTeGvzlr4Wqt02o4= Received: by 10.38.79.69 with SMTP id c69mr1085077rnb; Thu, 11 Nov 2004 13:10:57 -0800 (PST) Received: by 10.39.2.50 with HTTP; Thu, 11 Nov 2004 13:10:57 -0800 (PST) Message-ID: <376dd195041111131012d6cb66@mail.gmail.com> Date: Fri, 12 Nov 2004 05:10:57 +0800 From: Edwin Eyan Moragas Reply-To: Edwin Eyan Moragas To: pgsql-performance@postgresql.org Subject: Re: How to speed-up inserts with jdbc In-Reply-To: <20041111100418.GA2116@uio.no> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <003201c4c68e$8d347ee0$a702a8c0@shanepc> <41921CFD.7060604@webde-ag.de> <376dd19504111100044aa0ca1e@mail.gmail.com> <20041111100418.GA2116@uio.no> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/187 X-Sequence-Number: 9141 On Thu, 11 Nov 2004 11:04:18 +0100, Steinar H. Gunderson wrote: > You don't even need a "BEGIN" and "END"; his code has a setAutoComit(true) > before the for loop, which just has to be changed to setAutoCommit(false) > (and add an explicit commit() after the for loop, of course). amen. i stand corrected. -eem From pgsql-performance-owner@postgresql.org Thu Nov 11 21:13:56 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 095113A425F for ; Thu, 11 Nov 2004 21:13:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41621-10 for ; Thu, 11 Nov 2004 21:12:51 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.202]) by svr1.postgresql.org (Postfix) with ESMTP id C54CF3A3D5B for ; Thu, 11 Nov 2004 21:12:52 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 36so65517wra for ; Thu, 11 Nov 2004 13:12:51 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=uI6kwn9y3Wt2s1nlHGjAmZzDKxpnFUD0fJsfueMgixCYXbtwSDdE3dhqsgrxjHdl1qxQkRSO/s6g86W46tjmA1o+amqAheODg8if3au+hKRtGS++gbProBvEHk9tPEpyY8eXkos0ID5AqeyZsL+fUlD+Iv5E0BAiDrbtCgRFu6o= Received: by 10.54.54.74 with SMTP id c74mr376443wra; Thu, 11 Nov 2004 13:12:51 -0800 (PST) Received: by 10.54.43.36 with HTTP; Thu, 11 Nov 2004 13:12:51 -0800 (PST) Message-ID: <88f1825a04111113125a0fc443@mail.gmail.com> Date: Thu, 11 Nov 2004 16:12:51 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-Reply-To: <873bzgdsb9.fsf@stark.xeocode.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105095631064cb0@mail.gmail.com> <008401c4c366$127d5260$8300a8c0@solent> <88f1825a04110513028759dd3@mail.gmail.com> <418C1757.70909@ymogen.net> <25492.1099713863@sss.pgh.pa.us> <88f1825a04110523276f83653b@mail.gmail.com> <88f1825a041111082176f13033@mail.gmail.com> <873bzgdsb9.fsf@stark.xeocode.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/188 X-Sequence-Number: 9142 On 11 Nov 2004 15:49:46 -0500, Greg Stark wrote: > Allen Landsidel writes: > > > > > QUERY PLAN > > ----------------------------------------------------------------------------------------------------------------------------------------------- > > Index Scan using sname_unique on "testtable" (cost=0.00..34453.74 > > rows=8620 width=20) (actual time=77.004..537065.079 rows=74612 > > loops=1) > > Index Cond: ((sname >= 'AA'::text) AND (sname < 'AB'::text)) > > Filter: (sname ~~ 'AA%'::text) > > Total runtime: 537477.737 ms > > (4 rows) > > > > Time: 537480.571 ms > > Nothing you're going to do to the query is going to come up with a more > effective plan than this. It's using the index after all. It's never going to > be lightning fast because it has to process 75k rows. > > However 75k rows shouldn't be taking nearly 10 minutes. It should be taking > about 10 seconds. That's my feeling as well, I thought the index was to blame because it will be quite large, possibly large enough to not fit in memory nor be quickly bursted up. > The 77ms before finding the first record is a bit suspicious. Have you > vacuumed this table regularly? Try a VACUUM FULL VERBOSE, and send the > results. You might try to REINDEX it as well, though I doubt that would help. This table is *brand spanking new* for lack of a better term. I have the data for it in a CSV. I load the CSV up which takes a bit, then create the indexes, do a vacuum analyze verbose, and then posted the results above. I don't think running vacuum a more times is going to change things, at least not without tweaking config settings that affect vacuum. Not a single row has been inserted or altered since the initial load.. it's just a test. I can't give vacuum stats right now because the thing is reloading (again) with different newfs settings -- something I figure I have the time to fiddle with now, and seldom do at other times. These numbers though don't change much between 8K on up to 64K 'cluster' sizes. I'm trying it now with 8K page sizes, with 8K "minimum fragment" sizes. Should speed things up a tiny bit but not enough to really affect this query. Do you still see a need to have the output from the vacuum? > Actually you might consider clustering the table on sname_unique. That would > accomplish the same thing as the VACUUM FULL command and also speed up the > index scan. And the optimizer knows (if you analyze afterwards) it so it > should be more likely to pick the index scan. But currently you have to rerun > cluster periodically. Clustering is really unworkable in this situation. It would work now, in this limited test case, but using it if this were to go into production is unrealistic. It would have to happen fairly often since this table is updated frequently, which will break the clustering quickly with MVCC. Running it often.. well.. it has 70M+ rows, and the entire table is copied, reordered, and rewritten.. so that's a lot of 'scratch space' needed. Finally, clustering locks the table.. Something I'd already considered but quickly ruled out because of these reasons.. More ideas are welcome though. ;) -Allen From pgsql-performance-owner@postgresql.org Thu Nov 11 21:42:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D73E33A43AD for ; Thu, 11 Nov 2004 21:42:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58118-01 for ; Thu, 11 Nov 2004 21:41:55 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 766B53A425F for ; Thu, 11 Nov 2004 21:41:56 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iABLfp5j011885; Thu, 11 Nov 2004 16:41:51 -0500 (EST) To: Allen Landsidel Cc: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-reply-to: <88f1825a04111113125a0fc443@mail.gmail.com> References: <88f1825a041105095631064cb0@mail.gmail.com> <008401c4c366$127d5260$8300a8c0@solent> <88f1825a04110513028759dd3@mail.gmail.com> <418C1757.70909@ymogen.net> <25492.1099713863@sss.pgh.pa.us> <88f1825a04110523276f83653b@mail.gmail.com> <88f1825a041111082176f13033@mail.gmail.com> <873bzgdsb9.fsf@stark.xeocode.com> <88f1825a04111113125a0fc443@mail.gmail.com> Comments: In-reply-to Allen Landsidel message dated "Thu, 11 Nov 2004 16:12:51 -0500" Date: Thu, 11 Nov 2004 16:41:51 -0500 Message-ID: <11884.1100209311@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/189 X-Sequence-Number: 9143 Allen Landsidel writes: > Clustering is really unworkable in this situation. Nonetheless, please do it in your test scenario, so we can see if it has any effect or not. The speed you're getting works out to about 7.2 msec/row, which would be about right if every single row fetch caused a disk seek, which seems improbable unless the table is just huge compared to your available RAM. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 11 21:48:56 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EFD6D3A428A for ; Thu, 11 Nov 2004 21:48:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59546-03 for ; Thu, 11 Nov 2004 21:48:43 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id A2A3B3A3D32 for ; Thu, 11 Nov 2004 21:48:44 +0000 (GMT) Received: from [192.168.1.51] (dsl093-038-087.pdx1.dsl.speakeasy.net [66.93.38.87]) (authenticated) by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id iABLmY828287; Thu, 11 Nov 2004 13:48:34 -0800 Message-ID: <4193DE2B.5060407@commandprompt.com> Date: Thu, 11 Nov 2004 13:48:27 -0800 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Allen Landsidel Cc: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? References: <88f1825a041105095631064cb0@mail.gmail.com> <008401c4c366$127d5260$8300a8c0@solent> <88f1825a04110513028759dd3@mail.gmail.com> <418C1757.70909@ymogen.net> <25492.1099713863@sss.pgh.pa.us> <88f1825a04110523276f83653b@mail.gmail.com> <88f1825a041111082176f13033@mail.gmail.com> <873bzgdsb9.fsf@stark.xeocode.com> <88f1825a04111113125a0fc443@mail.gmail.com> In-Reply-To: <88f1825a04111113125a0fc443@mail.gmail.com> Content-Type: multipart/mixed; boundary="------------010602020107000303060208" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/190 X-Sequence-Number: 9144 This is a multi-part message in MIME format. --------------010602020107000303060208 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit >>>----------------------------------------------------------------------------------------------------------------------------------------------- >>> Index Scan using sname_unique on "testtable" (cost=0.00..34453.74 >>>rows=8620 width=20) (actual time=77.004..537065.079 rows=74612 >>>loops=1) >>> Index Cond: ((sname >= 'AA'::text) AND (sname < 'AB'::text)) >>> Filter: (sname ~~ 'AA%'::text) >>> Total runtime: 537477.737 ms >>>(4 rows) >>> >>>Time: 537480.571 ms >> >>Nothing you're going to do to the query is going to come up with a more >>effective plan than this. It's using the index after all. It's never going to >>be lightning fast because it has to process 75k rows. >> >>However 75k rows shouldn't be taking nearly 10 minutes. It should be taking >>about 10 seconds. I am confused about this statement. I have a table with 1.77 million rows that I use gist indexes on (TSearch) and I can pull out of it in less than 2 seconds. Are you saying it should be taking 10 seconds because of the type of plan? 10 seconds seems like an awfullong time for this. Sincerely, Joshua D. Drake > > > That's my feeling as well, I thought the index was to blame because it > will be quite large, possibly large enough to not fit in memory nor be > quickly bursted up. > > >>The 77ms before finding the first record is a bit suspicious. Have you >>vacuumed this table regularly? Try a VACUUM FULL VERBOSE, and send the >>results. You might try to REINDEX it as well, though I doubt that would help. > > > This table is *brand spanking new* for lack of a better term. I have > the data for it in a CSV. I load the CSV up which takes a bit, then > create the indexes, do a vacuum analyze verbose, and then posted the > results above. I don't think running vacuum a more times is going to > change things, at least not without tweaking config settings that > affect vacuum. Not a single row has been inserted or altered since the > initial load.. it's just a test. > > I can't give vacuum stats right now because the thing is reloading > (again) with different newfs settings -- something I figure I have the > time to fiddle with now, and seldom do at other times. These numbers > though don't change much between 8K on up to 64K 'cluster' sizes. I'm > trying it now with 8K page sizes, with 8K "minimum fragment" sizes. > Should speed things up a tiny bit but not enough to really affect this > query. > > Do you still see a need to have the output from the vacuum? > > >>Actually you might consider clustering the table on sname_unique. That would >>accomplish the same thing as the VACUUM FULL command and also speed up the >>index scan. And the optimizer knows (if you analyze afterwards) it so it >>should be more likely to pick the index scan. But currently you have to rerun >>cluster periodically. > > > Clustering is really unworkable in this situation. It would work now, > in this limited test case, but using it if this were to go into > production is unrealistic. It would have to happen fairly often since > this table is updated frequently, which will break the clustering > quickly with MVCC. > > Running it often.. well.. it has 70M+ rows, and the entire table is > copied, reordered, and rewritten.. so that's a lot of 'scratch space' > needed. Finally, clustering locks the table.. > > Something I'd already considered but quickly ruled out because of > these reasons.. > > More ideas are welcome though. ;) > > -Allen > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- Command Prompt, Inc., home of PostgreSQL Replication, and plPHP. Postgresql support, programming shared hosting and dedicated hosting. +1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL --------------010602020107000303060208 Content-Type: text/x-vcard; charset=utf-8; name="jd.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jd.vcf" begin:vcard fn:Joshua D. Drake n:Drake;Joshua D. org:Command Prompt, Inc. adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA email;internet:jd@commandprompt.com title:Consultant tel;work:503-667-4564 tel;fax:503-210-0334 note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. x-mozilla-html:FALSE url:http://www.commandprompt.com/ version:2.1 end:vcard --------------010602020107000303060208-- From pgsql-performance-owner@postgresql.org Fri Nov 12 18:39:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F018D3A47DF for ; Fri, 12 Nov 2004 18:39:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79723-07 for ; Fri, 12 Nov 2004 18:39:28 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 93AA83A4784 for ; Fri, 12 Nov 2004 18:39:26 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6650757 for pgsql-performance@postgresql.org; Fri, 12 Nov 2004 10:40:55 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Clarification on two bits on VACUUM FULL VERBOSE output Date: Fri, 12 Nov 2004 10:42:02 -0800 User-Agent: KMail/1.6.2 MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200411121042.02759.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/191 X-Sequence-Number: 9145 Folks, Wanted to get clarification on two bits of output from 7.4's VACUUM FULL VERBOSE: "Total free space (including removable row versions) is 2932036 bytes." If the table referenced has no dead row versions, does this indicate open space on partially full pages? "There were 33076 unused item pointers." Is this a count of dead index pointers, or something else? -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Nov 12 19:20:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 93BCC3A1D9A for ; Fri, 12 Nov 2004 19:20:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95092-01 for ; Fri, 12 Nov 2004 19:20:34 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2557F3A47A7 for ; Fri, 12 Nov 2004 19:20:34 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iACJKUnd021556; Fri, 12 Nov 2004 14:20:30 -0500 (EST) To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org Subject: Re: Clarification on two bits on VACUUM FULL VERBOSE output In-reply-to: <200411121042.02759.josh@agliodbs.com> References: <200411121042.02759.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Fri, 12 Nov 2004 10:42:02 -0800" Date: Fri, 12 Nov 2004 14:20:30 -0500 Message-ID: <21555.1100287230@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/192 X-Sequence-Number: 9146 Josh Berkus writes: > Wanted to get clarification on two bits of output from 7.4's VACUUM FULL > VERBOSE: > "Total free space (including removable row versions) is 2932036 bytes." > If the table referenced has no dead row versions, does this indicate open > space on partially full pages? Yes. > "There were 33076 unused item pointers." > Is this a count of dead index pointers, or something else? No, it's currently-unused item pointers (a/k/a line pointers) on heap pages. See http://developer.postgresql.org/docs/postgres/page.html regards, tom lane From pgsql-performance-owner@postgresql.org Fri Nov 12 20:12:47 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3CD833A45DA for ; Fri, 12 Nov 2004 20:12:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62014-02 for ; Fri, 12 Nov 2004 20:12:35 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.193]) by svr1.postgresql.org (Postfix) with ESMTP id 12BFB3A47E7 for ; Fri, 12 Nov 2004 20:12:36 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 36so105249wra for ; Fri, 12 Nov 2004 12:12:36 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=myYV7/mbR7ztK+EKNHm/8TnY1fM0KWvVkcFbf8afjXQ0M83x6/52AdOMJXx8X04j9b+GeSEAc8R55SKS7LuyZygNsGL/gOWVyqkGAgI8Vh0ZctJ5Q+VFtuk9VFze/OUnOBCKdXn7iXWmEEyy+BPlZUaQoEJI5CN0I85CZJMDF/Q= Received: by 10.54.54.78 with SMTP id c78mr501405wra; Fri, 12 Nov 2004 12:12:35 -0800 (PST) Received: by 10.54.43.36 with HTTP; Fri, 12 Nov 2004 12:12:35 -0800 (PST) Message-ID: <88f1825a04111212123c20086@mail.gmail.com> Date: Fri, 12 Nov 2004 15:12:35 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-Reply-To: <11884.1100209311@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105095631064cb0@mail.gmail.com> <008401c4c366$127d5260$8300a8c0@solent> <88f1825a04110513028759dd3@mail.gmail.com> <418C1757.70909@ymogen.net> <25492.1099713863@sss.pgh.pa.us> <88f1825a04110523276f83653b@mail.gmail.com> <88f1825a041111082176f13033@mail.gmail.com> <873bzgdsb9.fsf@stark.xeocode.com> <88f1825a04111113125a0fc443@mail.gmail.com> <11884.1100209311@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/193 X-Sequence-Number: 9147 On Thu, 11 Nov 2004 16:41:51 -0500, Tom Lane wrote: > Allen Landsidel writes: > > Clustering is really unworkable in this situation. > > Nonetheless, please do it in your test scenario, so we can see if it has > any effect or not. It did not, not enough to measure anyway, which does strike me as pretty odd.. Here's what I've got, after the cluster. Note that this is also on a new filesystem, as I said, have been taking the chance to experiment. The other two results were from a filesystem with 64KB block size, 8KB fragment size. This one is 8KB and 8KB. search=# explain analyze search-# SELECT sname FROM testtable WHERE sname LIKE 'AA%'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------- Index Scan using sname_unique on "testtable" (cost=0.00..642138.83 rows=160399 width=20) (actual time=0.088..514438.470 rows=74612 loops=1) Index Cond: ((sname >= 'AA'::text) AND (sname < 'AB'::text)) Filter: (sname ~~ 'AA%'::text) Total runtime: 514818.837 ms (4 rows) Time: 514821.993 ms > > The speed you're getting works out to about 7.2 msec/row, which would be > about right if every single row fetch caused a disk seek, which seems > improbable unless the table is just huge compared to your available RAM. > > regards, tom lane The CSV for the table is "huge" but not compared to RAM. The dump of the database in native/binary format is ~1GB; the database currently has only this table and the system stuff. The time to fetch the first row was much faster with the cluster in place, but after that, it's pretty much the same. 537s vs. 515s From pgsql-performance-owner@postgresql.org Fri Nov 12 21:09:01 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9FE743A4811 for ; Fri, 12 Nov 2004 21:08:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34659-06 for ; Fri, 12 Nov 2004 21:08:56 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 3756F3A4802 for ; Fri, 12 Nov 2004 21:08:57 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6653609; Fri, 12 Nov 2004 13:10:26 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: Clarification on two bits on VACUUM FULL VERBOSE output Date: Fri, 12 Nov 2004 13:11:33 -0800 User-Agent: KMail/1.6.2 Cc: Tom Lane References: <200411121042.02759.josh@agliodbs.com> <21555.1100287230@sss.pgh.pa.us> In-Reply-To: <21555.1100287230@sss.pgh.pa.us> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <200411121311.33769.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/194 X-Sequence-Number: 9148 Tom, > > "There were 33076 unused item pointers." > > Is this a count of dead index pointers, or something else? > > No, it's currently-unused item pointers (a/k/a line pointers) on heap > pages. =C2=A0See http://developer.postgresql.org/docs/postgres/page.html So this would be a count of pointers whose items had already been moved? =2D-=20 =2D-Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Nov 12 21:19:15 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6C38C3A4813 for ; Fri, 12 Nov 2004 21:19:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04399-03 for ; Fri, 12 Nov 2004 21:19:09 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 05C513A4820 for ; Fri, 12 Nov 2004 21:19:09 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iACLJ6jZ022588; Fri, 12 Nov 2004 16:19:06 -0500 (EST) To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org Subject: Re: Clarification on two bits on VACUUM FULL VERBOSE output In-reply-to: <200411121311.33769.josh@agliodbs.com> References: <200411121042.02759.josh@agliodbs.com> <21555.1100287230@sss.pgh.pa.us> <200411121311.33769.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Fri, 12 Nov 2004 13:11:33 -0800" Date: Fri, 12 Nov 2004 16:19:06 -0500 Message-ID: <22587.1100294346@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/195 X-Sequence-Number: 9149 Josh Berkus writes: >>> "There were 33076 unused item pointers." >>> Is this a count of dead index pointers, or something else? >> >> No, it's currently-unused item pointers (a/k/a line pointers) on heap >> pages. See http://developer.postgresql.org/docs/postgres/page.html > So this would be a count of pointers whose items had already been moved? Either deleted, or moved to another page during VACUUM FULL compaction. Such a pointer can be recycled to point to a new item, if there's room to put another item on its page ... but if not, the pointer is wasted space. I don't believe we ever try to physically eliminate unused item pointers. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Nov 12 22:40:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CF44E3A485A for ; Fri, 12 Nov 2004 22:35:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09686-08 for ; Fri, 12 Nov 2004 22:35:03 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 114FA3A4865 for ; Fri, 12 Nov 2004 22:35:03 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iACMZ0CK006688; Fri, 12 Nov 2004 17:35:01 -0500 (EST) To: Allen Landsidel Cc: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-reply-to: <88f1825a04111212123c20086@mail.gmail.com> References: <88f1825a041105095631064cb0@mail.gmail.com> <008401c4c366$127d5260$8300a8c0@solent> <88f1825a04110513028759dd3@mail.gmail.com> <418C1757.70909@ymogen.net> <25492.1099713863@sss.pgh.pa.us> <88f1825a04110523276f83653b@mail.gmail.com> <88f1825a041111082176f13033@mail.gmail.com> <873bzgdsb9.fsf@stark.xeocode.com> <88f1825a04111113125a0fc443@mail.gmail.com> <11884.1100209311@sss.pgh.pa.us> <88f1825a04111212123c20086@mail.gmail.com> Comments: In-reply-to Allen Landsidel message dated "Fri, 12 Nov 2004 15:12:35 -0500" Date: Fri, 12 Nov 2004 17:35:00 -0500 Message-ID: <6687.1100298900@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/196 X-Sequence-Number: 9150 Allen Landsidel writes: > On Thu, 11 Nov 2004 16:41:51 -0500, Tom Lane wrote: >> Allen Landsidel writes: >>> Clustering is really unworkable in this situation. >> >> Nonetheless, please do it in your test scenario, so we can see if it has >> any effect or not. > It did not, not enough to measure anyway, which does strike me as > pretty odd. Me too. Maybe we are barking up the wrong tree entirely, because I really expected to see a significant change. Lets start from first principles. While you are running this query, what sort of output do you get from "vmstat 1"? I'm wondering if it's I/O bound or CPU bound ... regards, tom lane From pgsql-performance-owner@postgresql.org Sat Nov 13 03:03:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 99ADE3A3C4A for ; Sat, 13 Nov 2004 03:02:56 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56002-06 for ; Sat, 13 Nov 2004 03:02:40 +0000 (GMT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by svr1.postgresql.org (Postfix) with ESMTP id 8045E3A48B0 for ; Sat, 13 Nov 2004 03:01:45 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.203]) by svr4.postgresql.org (Postfix) with ESMTP id 4932C5AF685 for ; Sat, 13 Nov 2004 00:28:40 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 67so431718wri for ; Fri, 12 Nov 2004 16:26:39 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=ezk/swlOiwKjT1rf+x6M4+AWbmb3TyrULfyqB0WwjLmfVx0diTBalZmfr4138kJel3UVLsZEbnh194aa8qSsv7vAhrRXqFaqcZbVV6bEVdgGSbSuYIHbfquMYrnHu1j0DkslOG0IlpXNFb2vDE+mdxA6m7D9eS1Sxw9srUaj6EU= Received: by 10.54.54.74 with SMTP id c74mr527568wra; Fri, 12 Nov 2004 16:26:39 -0800 (PST) Received: by 10.54.43.36 with HTTP; Fri, 12 Nov 2004 16:26:39 -0800 (PST) Message-ID: <88f1825a041112162629790db1@mail.gmail.com> Date: Fri, 12 Nov 2004 19:26:39 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: pgsql-performance@postgresql.org Subject: Re: Strange (?) Index behavior? In-Reply-To: <6687.1100298900@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105095631064cb0@mail.gmail.com> <418C1757.70909@ymogen.net> <25492.1099713863@sss.pgh.pa.us> <88f1825a04110523276f83653b@mail.gmail.com> <88f1825a041111082176f13033@mail.gmail.com> <873bzgdsb9.fsf@stark.xeocode.com> <88f1825a04111113125a0fc443@mail.gmail.com> <11884.1100209311@sss.pgh.pa.us> <88f1825a04111212123c20086@mail.gmail.com> <6687.1100298900@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/197 X-Sequence-Number: 9151 On Fri, 12 Nov 2004 17:35:00 -0500, Tom Lane wrote: > > > Allen Landsidel writes: > > On Thu, 11 Nov 2004 16:41:51 -0500, Tom Lane wrote: > >> Allen Landsidel writes: > >>> Clustering is really unworkable in this situation. > >> > >> Nonetheless, please do it in your test scenario, so we can see if it has > >> any effect or not. > > > It did not, not enough to measure anyway, which does strike me as > > pretty odd. > > Me too. Maybe we are barking up the wrong tree entirely, because I > really expected to see a significant change. > > Lets start from first principles. While you are running this query, > what sort of output do you get from "vmstat 1"? I'm wondering if it's > I/O bound or CPU bound ... I am running systat -vmstat 1 constantly on the box.. it's almost always I/O bound.. and the numbers are far lower than what I expect them to be, under 1MB/s. bonnie++ shows decent scores so.. I'm not sure what's goin on. [allen@dbtest01 /mnt_db/work#]bonnie++ -d /mnt_db/work -c 2 -u nobody Using uid:65534, gid:65534. Writing a byte at a time...done Writing intelligently...done Rewriting...done Reading a byte at a time...done Reading intelligently...done start 'em...done...done...done...done...done... Create files in sequential order...done. Stat files in sequential order...done. Delete files in sequential order...done. Create files in random order...done. Stat files in random order...done. Delete files in random order...done. Version 1.93c ------Sequential Output------ --Sequential Input- --Random- Concurrency 2 -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP dbtest01.distr 300M 100 98 17426 21 17125 18 197 98 182178 99 2027 42 Latency 96208us 594ms 472ms 56751us 15691us 3710ms Version 1.93c ------Sequential Create------ --------Random Create-------- dbtest01.distribute -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP 16 12932 90 +++++ +++ 20035 98 11912 91 +++++ +++ 13074 93 Latency 26691us 268us 18789us 26755us 13586us 25039us 1.93c,1.93c,dbtest01.distributedmail.com,2,1100269160,300M,,100,98,17426,21,17125,18,197,98,182178,99,2027,42,16,,,,,12932,90,+++++,+++,20035,98,11912,91,+++++,+++,13074,93,96208us,594ms,472ms,56751us,15691us,3710ms,26691us,268us,18789us,26755us,13586us,25039us Looking at these numbers, obviously things could be a bit quicker, but it doesn't look slow enough to my eyes or experience to account for what I'm seeing with the query performance.. During the query, swap doesn't get touched, the cpus are mostly idle, but the disk activity seems to be maxed at under 1MB/s, 100% busy. To refresh and extend.. The box is FreeBSD 4.10-STABLE Dual 800MHz PIII's, 2GB of memory Relevent kernel options: maxusers 512 ... options SYSVSHM options SHMMAXPGS=262144 options SHMSEG=512 options SHMMNI=512 options SYSVSEM options SEMMNI=512 options SEMMNS=1024 options SEMMNU=512 options SEMMAP=512 ... nothing custom going on in /etc/sysctl.conf Filesystem is.. /dev/da1s1e on /mnt_db (ufs, local, noatime, soft-updates) And, from my postgresql.conf.. shared_buffers = 32768 # min 16, at least max_connections*2, 8KB each sort_mem = 65536 # min 64, size in KB vacuum_mem = 65536 # min 1024, size in KB ... max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each max_fsm_relations = 1000 # min 100, ~50 bytes each ... stats_start_collector = true stats_command_string = true stats_block_level = false stats_row_level = true stats_reset_on_server_start = true Thanks for helping me out with this Tom and everyone else. I suppose it's possible that something could be physically wrong with the drive, but I'm not seeing anything in syslog. I'm going to poke around with camcontrol looking for any bad sectors / remapped stuff while I wait for replies. -Allen From pgsql-performance-owner@postgresql.org Sat Nov 13 11:26:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 93C2C3A49CF for ; Sat, 13 Nov 2004 11:26:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50370-03 for ; Sat, 13 Nov 2004 11:26:09 +0000 (GMT) Received: from web10703.mail.yahoo.com (web10703.mail.yahoo.com [216.136.130.211]) by svr1.postgresql.org (Postfix) with SMTP id 68ED83A49AF for ; Sat, 13 Nov 2004 11:26:10 +0000 (GMT) Received: (qmail 18085 invoked by uid 60001); 13 Nov 2004 11:26:10 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=ILII+T0QNbrp7GwvBv1LdBX5beLdqdnpKjysDJ+sbiH77z5ynUU5V8nY6XpqjiYOKM/ExgHfBjXJlRhH8xjiOkVSW7FW6zt3B9r0O+Z7bWTzNR3kv+qXDYDbUlXyE6gmXZHF0ysfnUOYQ3y9Wdhsqd2g8adhtZ+uCcYJI/PndhI= ; Message-ID: <20041113112609.18083.qmail@web10703.mail.yahoo.com> Received: from [203.101.40.166] by web10703.mail.yahoo.com via HTTP; Sat, 13 Nov 2004 03:26:09 PST Date: Sat, 13 Nov 2004 03:26:09 -0800 (PST) From: vivek singh Subject: Insertion puzzles To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/198 X-Sequence-Number: 9152 Hello to all, I am new to this group and postgresql. I am working on a project which uses postgresql and project is time critical. We did all optimization in our project but postgresql seems to be a bottle-neck. To solve this we run the database operations in a different thread. But still, with large volume of data in database the insert operation becomes very slow (ie. to insert 100 records in 5 tables, it takes nearly 3minutes). vacuum analyze helps a bit but performance improvement is not much. We are using the default postgres setting (ie. didn't change postgresql.conf). One more point: When we try to upload a pg_dump of nearly 60K records for 7 tables it took more than 10hrs. System config: Redhat Linux7.2 RAM: 256MB postgres: 7.1.3 connection: ODBC Thanks to all, please consider it even if it is silly doubt. Vivek __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com From pgsql-performance-owner@postgresql.org Sat Nov 13 13:31:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D9F533A4A51 for ; Sat, 13 Nov 2004 13:31:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75271-04 for ; Sat, 13 Nov 2004 13:31:25 +0000 (GMT) Received: from postfix.snow.erlang.no (unknown [80.202.218.91]) by svr1.postgresql.org (Postfix) with ESMTP id 340A83A3AFC for ; Sat, 13 Nov 2004 13:31:27 +0000 (GMT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by postfix.snow.erlang.no (Postfix) with ESMTP id A915A19EE81; Sat, 13 Nov 2004 14:31:26 +0100 (CET) In-Reply-To: <20041113112609.18083.qmail@web10703.mail.yahoo.com> References: <20041113112609.18083.qmail@web10703.mail.yahoo.com> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Apple-Mail-2--361095528" Message-Id: <4909EB74-3578-11D9-8406-000393BAA290@uninett.no> Cc: vivek singh From: =?ISO-8859-1?Q?Andreas_=C5kre_Solberg?= Subject: Re: Insertion puzzles Date: Sat, 13 Nov 2004 14:31:11 +0100 To: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/199 X-Sequence-Number: 9153 --Apple-Mail-2--361095528 Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-1--361095690; protocol="application/pkcs7-signature" --Apple-Mail-1--361095690 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; format=flowed On Nov 13, 2004, at 12:26, vivek singh wrote: > But > still, with large volume of data in database the > insert operation becomes very slow (ie. to insert 100 > records in 5 tables, it takes nearly 3minutes). What are the performance when you use COPY FROM instead of INSERT ? And have you tested the performance with fsync on and off. --=20 Andreas =C5kre Solberg, UNINETT AS Testnett Contact info and Public PGP Key available on: http://andreas.solweb.no/?account=3DWork --Apple-Mail-1--361095690 Content-Transfer-Encoding: base64 Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGKDCCAuEw ggJKoAMCAQICAwsoazANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt YWlsIElzc3VpbmcgQ0EwHhcNMDMxMTE2MjIyNjM5WhcNMDQxMTE1MjIyNjM5WjBMMR8wHQYDVQQD ExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMSkwJwYJKoZIhvcNAQkBFhpBbmRyZWFzLlNvbGJlcmdA dW5pbmV0dC5ubzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALaCc3U+xLLZTl4hN1LV taw62wIL1Mibyw0PNOhoPY0bkq51K30gqNwpkjPfAqR2+DnimXua+5zrqO5UGVoV8wDfFU10MUQ3 Otnv3mCPVkSZj1H8NQPxaR+t0k4tcnlqnns0nEXWwdFfbgDHMahbXU0Rk9f8Mkig26/8Apxjuc+Q 6U0QNmPobkcvX+vPCZ81E0qb+4rkBNUkavckMSphG/0c8weW+i4vv1GARc7qnJuZ2ktf/bsBQmLv 91HaOMvvbsN49kExAAtkcL9H6PSX63/hG3DcTtulpzUf1RCmcdBbDEx1h6KjZUlXFMMlF38c13Dd LAfgbhXKdfwZILFAUXUCAwEAAaM3MDUwJQYDVR0RBB4wHIEaQW5kcmVhcy5Tb2xiZXJnQHVuaW5l dHQubm8wDAYDVR0TAQH/BAIwADANBgkqhkiG9w0BAQQFAAOBgQDEBl1iYwBM2JZ/W/aIQCyV1vkl c/Bx14AiJ2Nnw5PBM2LiT22eEbJ88cy+6e6g7+oJrocg93CMVZ49PGpIScVsAw9I61XOPfg/YWnY FliRWqzoU/veWRRRyBogL8PHHzOikwnnYTwibrzk39yZA6+Hy3mnbM57AS+PX5hzz+o7SDCCAz8w ggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0 ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcx KDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0 ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxA dGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpB MSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUg UGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA xKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B1OVQCjDXAmNaLIkVcI7d yfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/ p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8MDow OKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVtYWlsQ0EuY3Js MAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJpdmF0ZUxhYmVsMi0xMzgw DQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOWlJ1/TCG4+DYfqi2fNi/A 9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amcOY6MIE9lX5Xa9/eH1sYI Tq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8xggLnMIIC4wIBATBpMGIxCzAJBgNVBAYT AlpBMSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3 dGUgUGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIDCyhrMAkGBSsOAwIaBQCgggFTMBgGCSqG SIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTA0MTExMzEzMzExMlowIwYJKoZI hvcNAQkEMRYEFFIvz1n5thtbDjOoUOvqreCjul97MHgGCSsGAQQBgjcQBDFrMGkwYjELMAkGA1UE BhMCWkExJTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1Ro YXd0ZSBQZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBAgMLKGswegYLKoZIhvcNAQkQAgsxa6Bp MGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSww KgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIDCyhrMA0GCSqGSIb3 DQEBAQUABIIBAA1pFWCqbduPJ0CxgV3u/+vHxWLNBFwkDQ0bDU7d/hJa21sDijUu/02xTe1ZWKrH pg+QA6AF7aamyB9yU+R22DgGol5wYdJJB0oig107EsDj49o6Ota7gwmSZ1KmUd3N/k3APUPU6yPF gK8FdOuQ1+BWMKfkm+DbkS+lCOMHz7r0Si6erOkFnGZjmzTDK8tFh+POzWv8xKWKvA7X51DIJttZ dzzyUVxu+Ips5teDpD8X1fcQT38ijehaqPZ/hW2v3cPU++5XPYPcdxSbmQh+HoZxKO49t+YGLkTI yZtB7G2YGYHAhdf2raE56CiZplxNgNvD8BpPymm0xarh7hY1ITMAAAAAAAA= --Apple-Mail-1--361095690-- --Apple-Mail-2--361095528 content-type: application/pgp-signature; x-mac-type=70674453; name=PGP.sig content-disposition: inline content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: PGP 8.1 Comment: My public key is available at http://andreas.solweb.no iQA/AwUBQZYMrPyFPYEtpdl2EQKsIwCg4qmqQPLSEkRQIyRcHsX+IT6LfU8AoOaQ Iz5WEKA1LBI5QU/blkZMvspy =2ZPg -----END PGP SIGNATURE----- --Apple-Mail-2--361095528-- From pgsql-performance-owner@postgresql.org Sat Nov 13 16:53:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6126A3A3AFC for ; Sat, 13 Nov 2004 16:53:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13248-08 for ; Sat, 13 Nov 2004 16:53:50 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 21E693A4A9F for ; Sat, 13 Nov 2004 16:53:48 +0000 (GMT) Received: (qmail 29385 invoked from network); 13 Nov 2004 16:53:41 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 13 Nov 2004 16:53:41 -0000 Message-ID: <41963C60.8000608@fastcrypt.com> Date: Sat, 13 Nov 2004 11:54:56 -0500 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-1?Q?Andreas_=C5kre_Solberg?= Cc: pgsql-performance@postgresql.org, vivek singh Subject: Re: Insertion puzzles References: <20041113112609.18083.qmail@web10703.mail.yahoo.com> <4909EB74-3578-11D9-8406-000393BAA290@uninett.no> In-Reply-To: <4909EB74-3578-11D9-8406-000393BAA290@uninett.no> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/200 X-Sequence-Number: 9154 Well, the default configuration for postgresql 7.1.3 is *very* conservative. ( ie. very slow) You should seriously consider upgrading to 7.4.6 as server performance has increased; in some cases significantly. If that is not an option, certainly tuning the shared buffers, and effective cache settings would be advisable. dave Andreas �kre Solberg wrote: > > On Nov 13, 2004, at 12:26, vivek singh wrote: > >> But >> still, with large volume of data in database the >> insert operation becomes very slow (ie. to insert 100 >> records in 5 tables, it takes nearly 3minutes). > > > What are the performance when you use COPY FROM instead of INSERT ? > And have you tested the performance with fsync on and off. > -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561 From pgsql-performance-owner@postgresql.org Sat Nov 13 17:13:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E58153A4AB1 for ; Sat, 13 Nov 2004 17:13:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19184-02 for ; Sat, 13 Nov 2004 17:13:44 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id B28E03A4AC6 for ; Sat, 13 Nov 2004 17:13:44 +0000 (GMT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id BBD8E354BA; Sat, 13 Nov 2004 09:13:42 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id BA6A5354B8; Sat, 13 Nov 2004 09:13:42 -0800 (PST) Date: Sat, 13 Nov 2004 09:13:42 -0800 (PST) From: Stephan Szabo To: vivek singh Cc: pgsql-performance@postgresql.org Subject: Re: Insertion puzzles In-Reply-To: <20041113112609.18083.qmail@web10703.mail.yahoo.com> Message-ID: <20041113091029.L35307@megazone.bigpanda.com> References: <20041113112609.18083.qmail@web10703.mail.yahoo.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/201 X-Sequence-Number: 9155 On Sat, 13 Nov 2004, vivek singh wrote: > I am new to this group and postgresql. I am working on > a project which uses postgresql and project is time > critical. We did all optimization in our project but > postgresql seems to be a bottle-neck. To solve this we > run the database operations in a different thread. But > still, with large volume of data in database the > insert operation becomes very slow (ie. to insert 100 > records in 5 tables, it takes nearly 3minutes). That's pretty bad. What does the schema look like? Are there any foreign keys, triggers or rules being hit? > vacuum analyze helps a bit but performance improvement > is not much. > We are using the default postgres setting (ie. didn't > change postgresql.conf). Hmm, there are a few settings to try to change, although to be honest, I'm not sure which ones beyond shared_buffers (maybe try a couple thousand) are applicable to 7.1.3. You really should upgrade. Alot of serious bug fixes and performance enhancements have been made from 7.1.x to 7.4.x. From pgsql-performance-owner@postgresql.org Sat Nov 13 23:24:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0BFFB3A4B55 for ; Sat, 13 Nov 2004 23:24:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03613-05 for ; Sat, 13 Nov 2004 23:24:36 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id C053C3A1EC0 for ; Sat, 13 Nov 2004 23:24:38 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iADNOWg5005227 for ; Sat, 13 Nov 2004 23:24:32 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iADMxSMj099723 for pgsql-performance@postgresql.org; Sat, 13 Nov 2004 22:59:28 GMT From: William Yu X-Newsgroups: comp.databases.postgresql.performance Subject: Some quick Opteron 32-bit/64-bit results Date: Sat, 13 Nov 2004 14:59:22 -0800 Organization: Hub.Org Networking Services Lines: 9 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/202 X-Sequence-Number: 9156 I just finished upgrading the OS on our Opteron 148 from Redhat9 to Fedora FC2 X86_64 with full recompiles of Postgres/Apache/Perl/Samba/etc. The verdict: a definite performance improvement. I tested just a few CPU intensive queries and many of them are a good 30%-50% faster. Transactional/batch jobs involving client machines (i.e. include fixed client/networking/odbc overhead) seem to be about 10%-20% faster although I will need run more data through the system to get a better feel of the numbers. From pgsql-performance-owner@postgresql.org Sun Nov 14 00:24:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D43C63A4B79 for ; Sun, 14 Nov 2004 00:24:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15998-08 for ; Sun, 14 Nov 2004 00:24:35 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 72B523A4B54 for ; Sun, 14 Nov 2004 00:24:35 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iAE0OWg5018063 for ; Sun, 14 Nov 2004 00:24:32 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iADNwwom012394 for pgsql-performance@postgresql.org; Sat, 13 Nov 2004 23:58:58 GMT From: William Yu X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Some quick Opteron 32-bit/64-bit results Date: Sat, 13 Nov 2004 15:58:59 -0800 Organization: Hub.Org Networking Services Lines: 19 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en In-Reply-To: To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/204 X-Sequence-Number: 9158 Biggest speedup I've found yet is the backup process (PG_DUMP --> GZIP). 100% faster in 64-bit mode. This drastic speed might be more the result of 64-bit GZIP though as I've seen benchmarks in the past showing encryption/compression running 2 or 3 times faster in 64-bit mode versus 32-bit. William Yu wrote: > I just finished upgrading the OS on our Opteron 148 from Redhat9 to > Fedora FC2 X86_64 with full recompiles of Postgres/Apache/Perl/Samba/etc. > > The verdict: a definite performance improvement. I tested just a few CPU > intensive queries and many of them are a good 30%-50% faster. > Transactional/batch jobs involving client machines (i.e. include fixed > client/networking/odbc overhead) seem to be about 10%-20% faster > although I will need run more data through the system to get a better > feel of the numbers. From pgsql-performance-owner@postgresql.org Sun Nov 14 00:14:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0CEDA3A4B9A for ; Sun, 14 Nov 2004 00:14:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14068-05 for ; Sun, 14 Nov 2004 00:14:38 +0000 (GMT) Received: from planae.com.br (nat.planae.com.br [200.210.129.190]) by svr1.postgresql.org (Postfix) with SMTP id ED7B03A4B96 for ; Sun, 14 Nov 2004 00:14:38 +0000 (GMT) Received: (qmail 22889 invoked by uid 1004); 14 Nov 2004 00:14:05 -0000 Received: from 127.0.0.1 by mercurio.planae.com.br (envelope-from , uid 0) with qmail-scanner-1.23 (uvscan: v4.3.20/v4406. Clear:RC:1(127.0.0.1):. Processed in 0.886484 secs); 14 Nov 2004 00:14:04 -0000 Received: from localhost (HELO webmail.planae.com.br) (127.0.0.1) by localhost with SMTP; 14 Nov 2004 00:14:03 -0000 Received: from 10.20.2.50 (SquirrelMail authenticated user gfnobrega@planae.com.br); by webmail.planae.com.br with HTTP; Sat, 13 Nov 2004 22:14:03 -0200 (BRST) Message-ID: <1505.10.20.2.50.1100391243.squirrel@10.20.2.50> In-Reply-To: References: Date: Sat, 13 Nov 2004 22:14:03 -0200 (BRST) Subject: Re: Some quick Opteron 32-bit/64-bit results From: Gustavo Franklin =?iso-8859-1?Q?N=F3brega?= To: "William Yu" Cc: pgsql-performance@postgresql.org User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/203 X-Sequence-Number: 9157 Hi Willian, Which are the GCC flags that you it used to compile PostgreSQL? Best regards, Gustavo Franklin N�brega Infraestrutura e Banco de Dados Planae Tecnologia da Informa��o (+55) 14 3224-3066 Ramal 209 www.planae.com.br > I just finished upgrading the OS on our Opteron 148 from Redhat9 to > Fedora FC2 X86_64 with full recompiles of Postgres/Apache/Perl/Samba/etc. > > The verdict: a definite performance improvement. I tested just a few CPU > intensive queries and many of them are a good 30%-50% faster. > Transactional/batch jobs involving client machines (i.e. include fixed > client/networking/odbc overhead) seem to be about 10%-20% faster > although I will need run more data through the system to get a better > feel of the numbers. > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > From pgsql-performance-owner@postgresql.org Sun Nov 14 00:54:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 12A3B3A40CA for ; Sun, 14 Nov 2004 00:54:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20650-07 for ; Sun, 14 Nov 2004 00:54:35 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 82F7E3A40BC for ; Sun, 14 Nov 2004 00:54:35 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iAE0sWg5023340 for ; Sun, 14 Nov 2004 00:54:32 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iAE0qhvp022992 for pgsql-performance@postgresql.org; Sun, 14 Nov 2004 00:52:43 GMT From: William Yu X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Some quick Opteron 32-bit/64-bit results Date: Sat, 13 Nov 2004 16:52:45 -0800 Organization: Hub.Org Networking Services Lines: 43 Message-ID: References: <1505.10.20.2.50.1100391243.squirrel@10.20.2.50> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en In-Reply-To: <1505.10.20.2.50.1100391243.squirrel@10.20.2.50> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/205 X-Sequence-Number: 9159 I gave -O3 a try with -funroll-loops, -fomit-frame-pointer and a few others. Seemed to perform about the same as the default -O2 so I just left it as -O2. Gustavo Franklin N�brega wrote: > Hi Willian, > > Which are the GCC flags that you it used to compile PostgreSQL? > > Best regards, > > Gustavo Franklin N�brega > Infraestrutura e Banco de Dados > Planae Tecnologia da Informa��o > (+55) 14 3224-3066 Ramal 209 > www.planae.com.br > > >>I just finished upgrading the OS on our Opteron 148 from Redhat9 to >>Fedora FC2 X86_64 with full recompiles of Postgres/Apache/Perl/Samba/etc. >> >>The verdict: a definite performance improvement. I tested just a few CPU >>intensive queries and many of them are a good 30%-50% faster. >>Transactional/batch jobs involving client machines (i.e. include fixed >>client/networking/odbc overhead) seem to be about 10%-20% faster >>although I will need run more data through the system to get a better >>feel of the numbers. >> >>---------------------------(end of broadcast)--------------------------- >>TIP 2: you can get off all lists at once with the unregister command >> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >> > > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > From pgsql-performance-owner@postgresql.org Sun Nov 14 01:37:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D56773A3FE8 for ; Sun, 14 Nov 2004 01:37:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29759-03 for ; Sun, 14 Nov 2004 01:37:06 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id A0E4A3A3D6D for ; Sun, 14 Nov 2004 01:37:08 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6658152; Sat, 13 Nov 2004 17:38:37 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: Insertion puzzles Date: Sat, 13 Nov 2004 17:36:12 -0800 User-Agent: KMail/1.6.2 Cc: vivek singh References: <20041113112609.18083.qmail@web10703.mail.yahoo.com> In-Reply-To: <20041113112609.18083.qmail@web10703.mail.yahoo.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411131736.12421.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/206 X-Sequence-Number: 9160 Vivek, > Redhat Linux7.2 > RAM: 256MB > postgres: 7.1.3 Um, you do realise that both RH 7.2 and PostgreSQL 7.1 are "no longer supported" but their respective communities? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Nov 16 05:24:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 47E3F3A4B8C for ; Sun, 14 Nov 2004 02:00:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30929-10 for ; Sun, 14 Nov 2004 02:00:46 +0000 (GMT) Received: from relay1.mail2web.com (relay1.mail2web.com [168.144.1.81]) by svr1.postgresql.org (Postfix) with ESMTP id 47ED83A414D for ; Sun, 14 Nov 2004 02:00:48 +0000 (GMT) Received: from M2W072.mail2web.com ([168.144.251.182]) by relay1.mail2web.com with Microsoft SMTPSVC(5.0.2195.6713); Sat, 13 Nov 2004 21:00:48 -0500 Message-ID: <102570-22004110142048396@M2W072.mail2web.com> X-Priority: 3 Reply-To: dentfirst13@earthlink.net X-Originating-IP: 66.23.218.85 X-URL: http://mail2web.com/ From: "dentfirst13@earthlink.net" To: sing_vivek@yahoo.com, pgsql-performance@postgresql.org Subject: Re: Insertion puzzles Date: Sat, 13 Nov 2004 21:00:48 -0500 MIME-Version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-OriginalArrivalTime: 14 Nov 2004 02:00:48.0264 (UTC) FILETIME=[C29BD080:01C4C9ED] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.7 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS, PRIORITY_NO_NAME X-Spam-Level: * X-Archive-Number: 200411/218 X-Sequence-Number: 9172 Vivek, I ran into the exact same problem you did=2E I tried many, many changes t= o the conf file, I tried O=2ES=2E tuning but performance stunk=2E I had a f= airly simple job that had a lot of updates and inserts that was taking 4 1/2 hours=2E I re-wrote it to be more "Postgres friendly" - meaning less database updates and got it down under 2 1/2 hours (still horrible)=2E=20= Understand, the legacy non-postgres ISAM db took about 15 minutes to perform the same task=2E I assumed it was a system problem that would go away when we upgraded servers but it did not=2E I converted to MySQL and = the exact same java process takes 5 minutes! Postgres is a great DB for some,= for our application it was not - you may want to consider other products that are a bit faster and do not require the vacuuming of stale data=2E Original Message: ----------------- From: vivek singh sing_vivek@yahoo=2Ecom Date: Sat, 13 Nov 2004 03:26:09 -0800 (PST) To: pgsql-performance@postgresql=2Eorg Subject: [PERFORM] Insertion puzzles Hello to all, I am new to this group and postgresql=2E I am working on a project which uses postgresql and project is time critical=2E We did all optimization in our project but postgresql seems to be a bottle-neck=2E To solve this we run the database operations in a different thread=2E But still, with large volume of data in database the insert operation becomes very slow (ie=2E to insert 100 records in 5 tables, it takes nearly 3minutes)=2E vacuum analyze helps a bit but performance improvement is not much=2E We are using the default postgres setting (ie=2E didn't change postgresql=2Econf)=2E One more point: When we try to upload a pg_dump of nearly 60K records for 7 tables it took more than 10hrs=2E=20 System config: Redhat Linux7=2E2 RAM: 256MB postgres: 7=2E1=2E3 connection: ODBC Thanks to all, please consider it even if it is silly doubt=2E=20 =20 Vivek =09=09 __________________________________=20 Do you Yahoo!?=20 Check out the new Yahoo! Front Page=2E=20 www=2Eyahoo=2Ecom=20 =20 ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql=2Eorg= -------------------------------------------------------------------- mail2web - Check your email from the web at http://mail2web=2Ecom/ =2E From pgsql-performance-owner@postgresql.org Mon Nov 15 00:44:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2DCE23A48FE for ; Mon, 15 Nov 2004 00:44:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18002-04 for ; Mon, 15 Nov 2004 00:44:41 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 950993A3FF8 for ; Mon, 15 Nov 2004 00:44:42 +0000 (GMT) Received: (qmail 19894 invoked from network); 15 Nov 2004 00:44:37 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 15 Nov 2004 00:44:37 -0000 Message-ID: <4197FC44.6020803@fastcrypt.com> Date: Sun, 14 Nov 2004 19:45:56 -0500 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Berkus Cc: pgsql-performance@postgresql.org, vivek singh Subject: Re: Insertion puzzles References: <20041113112609.18083.qmail@web10703.mail.yahoo.com> <200411131736.12421.josh@agliodbs.com> In-Reply-To: <200411131736.12421.josh@agliodbs.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/208 X-Sequence-Number: 9162 Actually, the most damning thing in this configuration I had missed earlier 256MB of ram ! Dave Josh Berkus wrote: >Vivek, > > > >>Redhat Linux7.2 >>RAM: 256MB >>postgres: 7.1.3 >> >> > >Um, you do realise that both RH 7.2 and PostgreSQL 7.1 are "no longer >supported" but their respective communities? > > > -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561 From pgsql-performance-owner@postgresql.org Mon Nov 15 07:04:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 785073A2B63 for ; Mon, 15 Nov 2004 07:04:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 00912-07 for ; Mon, 15 Nov 2004 07:04:02 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id B79D13A3F02 for ; Mon, 15 Nov 2004 07:04:03 +0000 (GMT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1CTau6-00063q-00; Mon, 15 Nov 2004 02:03:58 -0500 To: William Yu Cc: pgsql-performance@postgresql.org Subject: Re: Some quick Opteron 32-bit/64-bit results References: In-Reply-To: From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 15 Nov 2004 02:03:58 -0500 Message-ID: <87vfc78ug1.fsf@stark.xeocode.com> Lines: 12 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/209 X-Sequence-Number: 9163 William Yu writes: > Biggest speedup I've found yet is the backup process (PG_DUMP --> GZIP). 100% > faster in 64-bit mode. This drastic speed might be more the result of 64-bit > GZIP though as I've seen benchmarks in the past showing encryption/compression > running 2 or 3 times faster in 64-bit mode versus 32-bit. Isn't this a major kernel bump too? So a different scheduler, different IO scheduler, etc? -- greg From pgsql-performance-owner@postgresql.org Mon Nov 15 07:55:15 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A1E2D3A3AFB for ; Mon, 15 Nov 2004 07:55:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12877-02 for ; Mon, 15 Nov 2004 07:54:52 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id C80FB3A1EC8 for ; Mon, 15 Nov 2004 07:54:53 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iAF7spg5013615 for ; Mon, 15 Nov 2004 07:54:51 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iAF7pG5T012848 for pgsql-performance@postgresql.org; Mon, 15 Nov 2004 07:51:16 GMT From: William Yu X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Some quick Opteron 32-bit/64-bit results Date: Sun, 14 Nov 2004 23:51:19 -0800 Organization: Hub.Org Networking Services Lines: 23 Message-ID: References: <87vfc78ug1.fsf@stark.xeocode.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en In-Reply-To: <87vfc78ug1.fsf@stark.xeocode.com> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/210 X-Sequence-Number: 9164 Greg Stark wrote: > William Yu writes: > > >>Biggest speedup I've found yet is the backup process (PG_DUMP --> GZIP). 100% >>faster in 64-bit mode. This drastic speed might be more the result of 64-bit >>GZIP though as I've seen benchmarks in the past showing encryption/compression >>running 2 or 3 times faster in 64-bit mode versus 32-bit. > > > Isn't this a major kernel bump too? So a different scheduler, different IO > scheduler, etc? > I'm sure there's some speedup due to the kernel bump. I really didn't have the patience to even burn the FC2 32-bit CDs much less install both 32-bit & 64-bit FC2 in order to have a more accurate baseline comparison. However, that being said -- when you see huge speed increases like 50% 100% for dump+gzip, it's doubtful the kernel/process scheduler/IO scheduler could have made that drastic of a difference. Maybe somebody else who has done a 2.4 -> 2.6 upgrade can give us a baseline to subtract from my numbers. From pgsql-performance-owner@postgresql.org Mon Nov 15 15:23:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 558873A4442 for ; Mon, 15 Nov 2004 15:23:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38727-06 for ; Mon, 15 Nov 2004 15:23:01 +0000 (GMT) Received: from mail.libertyrms.com (unknown [207.219.45.62]) by svr1.postgresql.org (Postfix) with ESMTP id AF1BF3A442E for ; Mon, 15 Nov 2004 15:23:02 +0000 (GMT) Received: from dba4.int.libertyrms.com ([10.1.3.13] ident=ahammond) by mail.libertyrms.com with esmtp (Exim 4.22) id 1CTih1-0000Rc-R9; Mon, 15 Nov 2004 15:22:59 +0000 Message-ID: <4198C9D3.3020302@ca.afilias.info> Date: Mon, 15 Nov 2004 10:22:59 -0500 From: Andrew Hammond Organization: Afilias Canada Corp. User-Agent: Mozilla Thunderbird 0.8 (X11/20040926) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Joshua Marsh Cc: pg@fastcrypt.com, pgsql-performance@postgresql.org Subject: Re: Large Database Performance suggestions References: <38242de904102120143c55ba34@mail.gmail.com> <4178F149.9090408@fastcrypt.com> <38242de904102608246d060f7d@mail.gmail.com> In-Reply-To: <38242de904102608246d060f7d@mail.gmail.com> X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Mail-From: ahammond@ca.afilias.info X-SA-Exim-Scanned: No; SAEximRunCond expanded to false X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/211 X-Sequence-Number: 9165 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Joshua Marsh wrote: | Thanks for all of your help so far. Here is some of the information | you guys were asking for: | | Test System: | 2x AMD Opteron 244 (1.8Ghz) | 8GB RAM | 7x 72GB SCSI HDD (Raid 5) You probably want to look at investing in a SAN. - -- Andrew Hammond 416-673-4138 ahammond@ca.afilias.info Database Administrator, Afilias Canada Corp. CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBmMnSgfzn5SevSpoRAlp2AKCVXQkZLR7TuGId/OLveHPqpzC4zwCffNFC 7zjXzJ6Ukg4TeO1ecWj/nFQ= =N5vp -----END PGP SIGNATURE----- From pgsql-performance-owner@postgresql.org Mon Nov 15 17:48:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1054D3A475C for ; Mon, 15 Nov 2004 17:48:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87120-04 for ; Mon, 15 Nov 2004 17:48:39 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.204]) by svr1.postgresql.org (Postfix) with ESMTP id E3D263A470C for ; Mon, 15 Nov 2004 17:48:37 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 63so537294wri for ; Mon, 15 Nov 2004 09:48:36 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=l6o43WV5+GVivDItlz3YIAjRHpJDn9OXMpzkDCQsKLA5eJ84VVedWisHsHOTM1fCVxpJtBNc1K3rcRyJl4x8Ys3p0l4tGFioXis6b0sjr8cMZJ3LN7IIji9qI79vxKIN2w+LaOZGzUTSBl1bD/6TJ7wchjyo17kqYQx8daVfAOA= Received: by 10.54.19.33 with SMTP id 33mr322678wrs; Mon, 15 Nov 2004 09:48:36 -0800 (PST) Received: by 10.54.20.23 with HTTP; Mon, 15 Nov 2004 09:48:36 -0800 (PST) Message-ID: <1dc7f0e3041115094846c08c34@mail.gmail.com> Date: Mon, 15 Nov 2004 12:48:36 -0500 From: Alexandre Leclerc Reply-To: Alexandre Leclerc To: pgsql-performance@postgresql.org Subject: Question on pgsql optimisation of SQL and structure (index, etc) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/212 X-Sequence-Number: 9166 Good day, I use pgsql 7.4: I would like to know if indexes will solve my problem (I fear the system will become slow with the time). And also some questions on how pgsql optimise for speed. *Database* -- Assuming those tables (not original, but enought to get the point): CREATE TABLE prod.jobs ( job_id serial PRIMARY KEY, order_id integer NOT NULL REFERENCES sales.orders, ); CREATE TABLE design.products ( product_id serial PRIMARY KEY, company_id integer NOT NULL REFERENCES sales.companies ON UPDATE CASCADE, product_code varchar(24) NOT NULL, CONSTRAINT product_code_already_used_for_this_company UNIQUE (company_id, product_code) ); CREATE TABLE prod.jobs_products ( product_id integer REFERENCES design.products ON UPDATE CASCADE, ) INHERITS (prod.jobs); -- Assuming this view: CREATE VIEW prod.orders_jobs_view AS SELECT job_id, order_id, product_code FROM ( SELECT *, NULL AS product_id FROM ONLY prod.jobs UNION SELECT * FROM prod.jobs_products ) AS alljobs LEFT JOIN design.products ON alljobs.product_id = products.product_id; *Question 1* Assuming this request: SELECT * FROM prod.orders_jobs_view WHERE order_id = 1; I imagine that somewhere down the road, this will get slow since there is no index on the order_id. I tought of creating two indexes... With the previous VIEW and database schema, will the following boost the DB; as I don't know how PostgreSQL works internally: CREATE UNIQUE INDEX order_jobs ON prod.jobs(order_id); CREATE UNIQUE INDEX order_jobs_products ON prod.jobs_products(order_id); *Question 2* If no to question 1, what can I do to boost the database speed. I do have prety heavy views on data, and I would like to get some speed as the DB will get filled up quickly. *Question 3* When creating a wien with linked "UNION" tables as previous... when we do a SELECT with a WHERE clause, will the database act efficiently by adding the WHERE clause to the UNIONed tables in the FROM clause? Example: SELECT * FROM prod.orders_jobs_view WHERE order_id = 1; whould cause something like SELECT job_id, order_id, product_code FROM ( SELECT *, NULL AS product_id FROM ONLY prod.jobs WHERE order_id = 1 UNION SELECT * FROM prod.jobs_products WHERE order_id = 1 ) AS alljobs LEFT JOIN design.products ON alljobs.product_id = products.product_id; in order to speed the union processing? Thank you for any help on this. -- Alexandre Leclerc From pgsql-performance-owner@postgresql.org Mon Nov 15 21:01:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1A08A3A4A88 for ; Mon, 15 Nov 2004 21:01:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47829-07 for ; Mon, 15 Nov 2004 21:00:59 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id C3CFA3A4A5C for ; Mon, 15 Nov 2004 21:00:59 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6664842; Mon, 15 Nov 2004 13:02:28 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org, Alexandre Leclerc Subject: Re: Question on pgsql optimisation of SQL and structure (index, etc) Date: Mon, 15 Nov 2004 13:03:37 -0800 User-Agent: KMail/1.6.2 References: <1dc7f0e3041115094846c08c34@mail.gmail.com> In-Reply-To: <1dc7f0e3041115094846c08c34@mail.gmail.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411151303.37551.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/213 X-Sequence-Number: 9167 Alexandre, > -- Assuming those tables (not original, but enought to get the point): > > CREATE TABLE prod.jobs ( > job_id serial PRIMARY KEY, > order_id integer NOT NULL REFERENCES sales.orders, > ); > > CREATE TABLE design.products ( > product_id serial PRIMARY KEY, > company_id integer NOT NULL REFERENCES sales.companies ON > UPDATE CASCADE, > product_code varchar(24) NOT NULL, > CONSTRAINT product_code_already_used_for_this_company UNIQUE > (company_id, product_code) > ); > > CREATE TABLE prod.jobs_products ( > product_id integer REFERENCES design.products ON UPDATE CASCADE, > ) INHERITS (prod.jobs); First off, let me say that I find this schema rather bizarre. The standard way to handle your situation would be to add a join table instead of inheritance for jobs_products: CREATE TABLE jobs_products ( job_id INT NOT NULL REFERENCES prod.jobs(job_id) ON DELETE CASCADE, product_id INT NOT NULL REFERENCES design.products(product_id) ON UPDATE CASCADE, CONSTRAINT jobs_products_pk PRIMARY KEY (job_id, product_id) ); Then this view: > CREATE VIEW prod.orders_jobs_view AS > SELECT job_id, order_id, product_code > FROM ( > SELECT *, NULL AS product_id FROM ONLY prod.jobs > UNION > SELECT * FROM prod.jobs_products > ) AS alljobs LEFT JOIN design.products ON alljobs.product_id = > products.product_id; Becomes much simpler, and better performance: CREATE VIEW prod.orders_jobs_view AS SELECT job_id, order_id, product_code FROM prod.jobs LEFT JOIN prod.jobs_products ON prod.jobs.job_id = prod.jobs_products.job_id LEFT JOIN design.products ON prod.jobs_products.product_id = design.products.product_id; > I imagine that somewhere down the road, this will get slow since there > is no index on the order_id. I tought of creating two indexes... With > the previous VIEW and database schema, will the following boost the > DB; as I don't know how PostgreSQL works internally: Yes. Any time you have a foreign key, you should index it unless you have a really good reason not to. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Nov 15 21:23:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1BE2A3A4221 for ; Mon, 15 Nov 2004 21:23:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55362-09 for ; Mon, 15 Nov 2004 21:23:37 +0000 (GMT) Received: from pm-mx3.mx.noos.fr (pm-mx3.mgn.net [195.46.220.211]) by svr1.postgresql.org (Postfix) with ESMTP id BF5E93A4A91 for ; Mon, 15 Nov 2004 21:23:38 +0000 (GMT) Received: from s249.dhcp212-198-144.noos.fr (s249.dhcp212-198-144.noos.fr [212.198.144.249]) by pm-mx3.mx.noos.fr (Postfix) with ESMTP id 5767026F18 for ; Mon, 15 Nov 2004 22:22:03 +0100 (MET) From: =?iso-8859-15?q?Herv=E9_Piedvache?= To: pgsql-performance@postgresql.org Subject: Why distinct so slow ? Date: Mon, 15 Nov 2004 22:22:02 +0100 User-Agent: KMail/1.7 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200411152222.02601.footcow@noos.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/214 X-Sequence-Number: 9168 Hi, I have a strange (for me) result ... Why the second request is really quicker with a Seq Scan than the first one with a DISTINCT and using an index !? The table have really 183957 rows ... not like the Seq Scan seems to expect ... !? I understand nothing here ... Thanks for your explanations ... # explain analyze SELECT distinct s.id_category FROM site s; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------- Unique (cost=0.00..11903.15 rows=56 width=4) (actual time=0.147..1679.170 rows=68 loops=1) -> Index Scan using ix_site_id_category on site s (cost=0.00..11496.38 rows=162706 width=4) (actual time=0.143..1452.611 rows=183957 loops=1) Total runtime: 1679.496 ms (3 rows) Time: 1680,810 ms # explain analyze SELECT s.id_category FROM site s group by id_category; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------- HashAggregate (cost=7307.83..7307.83 rows=56 width=4) (actual time=1198.968..1199.084 rows=68 loops=1) -> Seq Scan on site s (cost=0.00..6901.06 rows=162706 width=4) (actual time=0.097..921.676 rows=183957 loops=1) Total runtime: 1199.260 ms (3 rows) -- Bill Footcow From pgsql-performance-owner@postgresql.org Mon Nov 15 22:22:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C9BAE3A4B8F for ; Mon, 15 Nov 2004 22:22:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69785-09 for ; Mon, 15 Nov 2004 22:22:37 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.198]) by svr1.postgresql.org (Postfix) with ESMTP id BF0093A4B81 for ; Mon, 15 Nov 2004 22:22:36 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 58so537714wri for ; Mon, 15 Nov 2004 14:22:37 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=j+YWDPZQW7S+QIOoSgLIseW99suJfELPMFAPjUuk/DwHi9SeTXEDekvIjYj4UPMZYfOlvJ3bOviyxdyfc7JbDd8IKzXh6EZYokDVaHSvHH2UMKtV1dfhyvm71q8auGlI29t1TojcF4nAiyLElAxsQvPnHLGblc7pvlP1XKh6uXg= Received: by 10.54.25.5 with SMTP id 5mr119866wry; Mon, 15 Nov 2004 14:22:36 -0800 (PST) Received: by 10.54.43.36 with HTTP; Mon, 15 Nov 2004 14:22:36 -0800 (PST) Message-ID: <88f1825a04111514223d1be7d@mail.gmail.com> Date: Mon, 15 Nov 2004 17:22:36 -0500 From: Allen Landsidel Reply-To: Allen Landsidel To: Postgresql Performance Subject: Re: Strange (?) Index behavior? In-Reply-To: <88f1825a041112162629790db1@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <88f1825a041105095631064cb0@mail.gmail.com> <25492.1099713863@sss.pgh.pa.us> <88f1825a04110523276f83653b@mail.gmail.com> <88f1825a041111082176f13033@mail.gmail.com> <873bzgdsb9.fsf@stark.xeocode.com> <88f1825a04111113125a0fc443@mail.gmail.com> <11884.1100209311@sss.pgh.pa.us> <88f1825a04111212123c20086@mail.gmail.com> <6687.1100298900@sss.pgh.pa.us> <88f1825a041112162629790db1@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/215 X-Sequence-Number: 9169 Sorry if I'm contributing more noise to the signal here, just thought I'd repost this one to the list since it may have gotten lost in all the garbage from the guy unhappy about the usenet thing.. ---------- Forwarded message ---------- From: Allen Landsidel Date: Fri, 12 Nov 2004 19:26:39 -0500 Subject: Re: [PERFORM] Strange (?) Index behavior? To: pgsql-performance@postgresql.org On Fri, 12 Nov 2004 17:35:00 -0500, Tom Lane wrote: > > > Allen Landsidel writes: > > On Thu, 11 Nov 2004 16:41:51 -0500, Tom Lane wrote: > >> Allen Landsidel writes: > >>> Clustering is really unworkable in this situation. > >> > >> Nonetheless, please do it in your test scenario, so we can see if it has > >> any effect or not. > > > It did not, not enough to measure anyway, which does strike me as > > pretty odd. > > Me too. Maybe we are barking up the wrong tree entirely, because I > really expected to see a significant change. > > Lets start from first principles. While you are running this query, > what sort of output do you get from "vmstat 1"? I'm wondering if it's > I/O bound or CPU bound ... I am running systat -vmstat 1 constantly on the box.. it's almost always I/O bound.. and the numbers are far lower than what I expect them to be, under 1MB/s. bonnie++ shows decent scores so.. I'm not sure what's goin on. [allen@dbtest01 /mnt_db/work#]bonnie++ -d /mnt_db/work -c 2 -u nobody Using uid:65534, gid:65534. Writing a byte at a time...done Writing intelligently...done Rewriting...done Reading a byte at a time...done Reading intelligently...done start 'em...done...done...done...done...done... Create files in sequential order...done. Stat files in sequential order...done. Delete files in sequential order...done. Create files in random order...done. Stat files in random order...done. Delete files in random order...done. Version 1.93c ------Sequential Output------ --Sequential Input- --Random- Concurrency 2 -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP dbtest01.distr 300M 100 98 17426 21 17125 18 197 98 182178 99 2027 42 Latency 96208us 594ms 472ms 56751us 15691us 3710ms Version 1.93c ------Sequential Create------ --------Random Create-------- dbtest01.distribute -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP 16 12932 90 +++++ +++ 20035 98 11912 91 +++++ +++ 13074 93 Latency 26691us 268us 18789us 26755us 13586us 25039us 1.93c,1.93c,dbtest01.distributedmail.com,2,1100269160,300M,,100,98,17426,21,17125,18,197,98,182178,99,2027,42,16,,,,,12932,90,+++++,+++,20035,98,11912,91,+++++,+++,13074,93,96208us,594ms,472ms,56751us,15691us,3710ms,26691us,268us,18789us,26755us,13586us,25039us Looking at these numbers, obviously things could be a bit quicker, but it doesn't look slow enough to my eyes or experience to account for what I'm seeing with the query performance.. During the query, swap doesn't get touched, the cpus are mostly idle, but the disk activity seems to be maxed at under 1MB/s, 100% busy. To refresh and extend.. The box is FreeBSD 4.10-STABLE Dual 800MHz PIII's, 2GB of memory Relevent kernel options: maxusers 512 ... options SYSVSHM options SHMMAXPGS=262144 options SHMSEG=512 options SHMMNI=512 options SYSVSEM options SEMMNI=512 options SEMMNS=1024 options SEMMNU=512 options SEMMAP=512 ... nothing custom going on in /etc/sysctl.conf Filesystem is.. /dev/da1s1e on /mnt_db (ufs, local, noatime, soft-updates) And, from my postgresql.conf.. shared_buffers = 32768 # min 16, at least max_connections*2, 8KB each sort_mem = 65536 # min 64, size in KB vacuum_mem = 65536 # min 1024, size in KB ... max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each max_fsm_relations = 1000 # min 100, ~50 bytes each ... stats_start_collector = true stats_command_string = true stats_block_level = false stats_row_level = true stats_reset_on_server_start = true Thanks for helping me out with this Tom and everyone else. I suppose it's possible that something could be physically wrong with the drive, but I'm not seeing anything in syslog. I'm going to poke around with camcontrol looking for any bad sectors / remapped stuff while I wait for replies. -Allen From pgsql-performance-owner@postgresql.org Mon Nov 15 23:10:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 509C03A4BDC for ; Mon, 15 Nov 2004 23:10:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83713-04 for ; Mon, 15 Nov 2004 23:10:00 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.207]) by svr1.postgresql.org (Postfix) with ESMTP id 2C3553A44DA for ; Mon, 15 Nov 2004 23:10:02 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 40so411675wri for ; Mon, 15 Nov 2004 15:10:02 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=BaAP3gVcZikldk679TgF8QuMBgjUpru6zUUihdyYZ0c0APeuNt6DKHWp9Va08bgbuWC10Wg/5eJlZX5HDDYtQsvOyHSluEUBmkFOd8w6dTQiK2PVB9oXCphEyqf9NHs5ZhsTw2MoQOCD8W+/YCktd2DgAjOJP5m2XAovLA+nNCE= Received: by 10.54.17.70 with SMTP id 70mr333166wrq; Mon, 15 Nov 2004 15:10:01 -0800 (PST) Received: by 10.54.20.23 with HTTP; Mon, 15 Nov 2004 15:10:01 -0800 (PST) Message-ID: <1dc7f0e3041115151015e34130@mail.gmail.com> Date: Mon, 15 Nov 2004 18:10:01 -0500 From: Alexandre Leclerc Reply-To: Alexandre Leclerc To: PERFORM Subject: Performance difference: SELECT from VIEW or not? Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/216 X-Sequence-Number: 9170 I'm just currious about which is the best, if I have many query based on the first one: -- suppose this view (used many times): CREATE VIEW prod.alljobs_view AS SELECT * FROM prod.jobs LEFT JOIN prod.jobs_products ON jobs.job_id = jobs_products.job_id; -- suppose this other query: CREATE VIEW prod.orders_jobs_view AS SELECT job_id, order_id, product_code FROM prod.alljobs_view LEFT JOIN design.products ON alljobs_view.product_id = products.product_id; -- would this be more effective on database side than:? CREATE VIEW prod.orders_jobs_view AS SELECT job_id, order_id, product_code FROM prod.jobs LEFT JOIN prod.jobs_products ON jobs.job_id = jobs_products.job_id LEFT JOIN design.products ON jobs_products.product_id = products.product_id; Which is the best, or is there any difference? (I can't test it myself, I have too few data). Regards. -- Alexandre Leclerc From pgsql-performance-owner@postgresql.org Mon Nov 15 23:30:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A935A3A4C02 for ; Mon, 15 Nov 2004 23:30:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87612-07 for ; Mon, 15 Nov 2004 23:30:47 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 20A673A44DA for ; Mon, 15 Nov 2004 23:30:50 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAFNUfcb011693; Mon, 15 Nov 2004 18:30:42 -0500 (EST) To: Alexandre Leclerc Cc: PERFORM Subject: Re: Performance difference: SELECT from VIEW or not? In-reply-to: <1dc7f0e3041115151015e34130@mail.gmail.com> References: <1dc7f0e3041115151015e34130@mail.gmail.com> Comments: In-reply-to Alexandre Leclerc message dated "Mon, 15 Nov 2004 18:10:01 -0500" Date: Mon, 15 Nov 2004 18:30:41 -0500 Message-ID: <11692.1100561441@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/217 X-Sequence-Number: 9171 Alexandre Leclerc writes: > -- suppose this view (used many times): > CREATE VIEW prod.alljobs_view AS > SELECT * > FROM prod.jobs > LEFT JOIN prod.jobs_products ON jobs.job_id = jobs_products.job_id; > -- suppose this other query: > CREATE VIEW prod.orders_jobs_view AS > SELECT job_id, order_id, product_code > FROM prod.alljobs_view > LEFT JOIN design.products ON alljobs_view.product_id = > products.product_id; > -- would this be more effective on database side than:? > CREATE VIEW prod.orders_jobs_view AS > SELECT job_id, order_id, product_code > FROM prod.jobs > LEFT JOIN prod.jobs_products ON jobs.job_id = jobs_products.job_id > LEFT JOIN design.products ON jobs_products.product_id = > products.product_id; > Which is the best, or is there any difference? For the specific case mentioned, there's not going to be any visible difference (maybe a few more catalog lookups to expand two view definitions instead of one). However, it's real easy to shoot yourself in the foot with views and outer joins. Don't forget that the syntactic ordering of outer joins is also a semantic and performance constraint. (a left join b) left join c is different from a left join (b left join c) and a view is basically a parenthesized subselect ... regards, tom lane From pgsql-performance-owner@postgresql.org Tue Nov 16 09:09:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 25E173A3CB9 for ; Tue, 16 Nov 2004 09:09:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37515-03 for ; Tue, 16 Nov 2004 09:09:35 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 575243A3CC6 for ; Tue, 16 Nov 2004 09:09:35 +0000 (GMT) Received: (qmail 7327 invoked by uid 1112); 16 Nov 2004 09:10:17 -0000 Date: Tue, 16 Nov 2004 04:10:17 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: pgsql-performance@postgresql.org Subject: mis-estimation on data-warehouse aggregate creation Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/219 X-Sequence-Number: 9173 I've have a miniature data-warehouse in which I'm trying to rebuild pre-calcuated aggregate data directly in the database and I'm geting some poor plans due to a bad mis-estimation of the number of rows involved. In a standard star schema I have a sales fact table and dimensions product, customer, and period. From those dimensions I have created "shrunken" versions of them that only have productline, salesperson and month data. Now I want to rollup the base fact table to a "shrunken" version with data summed up for these smaller aggregate dimensions. The idea is to take a sales table (productid, customerid, periodid, quantity, usdamount) and create a table with the same columns that have the "id" columns pointing to the matching smaller dimensions and total up the quantity and usdamount. Since the shrunken dimension tables have renumbered ids we look these up by joining on all of the common columns between the base and shrunken dimensions. The following query does just that: CREATE TABLE shf_sales_by_salesperson_productline_month AS SELECT SUM(sales.quantity) AS quantity, SUM(sales.usdamount) AS usdamount, shd_productline.id AS productid, shd_month.id AS periodid, shd_salesperson.id AS customerid FROM sales JOIN ( SELECT shd_productline.id, product.id AS productid FROM product, shd_productline WHERE product.productline = shd_productline.productline AND product.category = shd_productline.category AND product.platform = shd_productline.platform ) shd_productline ON sales.productid = shd_productline.productid JOIN ( SELECT shd_month.id, period.id AS periodid FROM period, shd_month WHERE period.monthnumber = shd_month.monthnumber AND period.monthname = shd_month.monthname AND period.year = shd_month.year AND period.monthyear = shd_month.monthyear AND period.quarter = shd_month.quarter AND period.quarteryear = shd_month.quarteryear ) shd_month ON sales.periodid = shd_month.periodid JOIN ( SELECT shd_salesperson.id, customer.id AS customerid FROM customer, shd_salesperson WHERE customer.salesperson = shd_salesperson.salesperson ) shd_salesperson ON sales.customerid = shd_salesperson.customerid GROUP BY shd_productline.id, shd_month.id, shd_salesperson.id This generates the following EXPLAIN ANALYZE plan for the SELECT portion: HashAggregate (cost=32869.33..32869.34 rows=1 width=36) (actual time=475182.855..475188.304 rows=911 loops=1) -> Nested Loop (cost=377.07..32869.32 rows=1 width=36) (actual time=130.179..464299.167 rows=1232140 loops=1) Join Filter: ("outer".salesperson = "inner".salesperson) -> Nested Loop (cost=377.07..32868.18 rows=1 width=44) (actual time=130.140..411975.760 rows=1232140 loops=1) Join Filter: ("outer".customerid = "inner".id) -> Hash Join (cost=377.07..32864.32 rows=1 width=32) (actual time=130.072..23167.501 rows=1232140 loops=1) Hash Cond: ("outer".productid = "inner".id) -> Hash Join (cost=194.23..32679.08 rows=375 width=28) (actual time=83.118..14019.802 rows=1232140 loops=1) Hash Cond: ("outer".periodid = "inner".id) -> Seq Scan on sales (cost=0.00..26320.40 rows=1232140 width=24) (actual time=0.109..3335.275 rows=1232140 loops=1) -> Hash (cost=194.23..194.23 rows=1 width=12) (actual time=81.548..81.548 rows=0 loops=1) -> Hash Join (cost=4.70..194.23 rows=1 width=12) (actual time=2.544..72.798 rows=3288 loops=1) Hash Cond: (("outer".monthnumber = "inner".monthnumber) AND ("outer".monthname = "inner".monthname) AND ("outer"."year" = "inner"."year") AND ("outer".monthyear = "inner".monthyear) AND ("outer".quarter = "inner".quarter) AND ("outer".quarteryear = "inner".quarteryear)) -> Seq Scan on period (cost=0.00..90.88 rows=3288 width=54) (actual time=0.009..9.960 rows=3288 loops=1) -> Hash (cost=3.08..3.08 rows=108 width=58) (actual time=1.643..1.643 rows=0 loops=1) -> Seq Scan on shd_month (cost=0.00..3.08 rows=108 width=58) (actual time=0.079..0.940 rows=108 loops=1) -> Hash (cost=182.18..182.18 rows=265 width=12) (actual time=45.431..45.431 rows=0 loops=1) -> Hash Join (cost=1.23..182.18 rows=265 width=12) (actual time=1.205..40.216 rows=1932 loops=1) Hash Cond: (("outer".productline = "inner".productline) AND ("outer".category = "inner".category) AND ("outer".platform = "inner".platform)) -> Seq Scan on product (cost=0.00..149.32 rows=1932 width=32) (actual time=0.013..6.179 rows=1932 loops=1) -> Hash (cost=1.13..1.13 rows=13 width=45) (actual time=0.199..0.199 rows=0 loops=1) -> Seq Scan on shd_productline (cost=0.00..1.13 rows=13 width=45) (actual time=0.048..0.083 rows=13 loops=1) -> Seq Scan on customer (cost=0.00..2.83 rows=83 width=20) (actual time=0.005..0.174 rows=83 loops=1232140) -> Seq Scan on shd_salesperson (cost=0.00..1.06 rows=6 width=24) (actual time=0.004..0.019 rows=6 loops=1232140) Total runtime: 475197.372 ms (25 rows) Note that the estimated number of input rows to the final HashAggreggate is 1 while the actual number is 1.2 million. By rewriting the JOIN conditions to LEFT JOIN we force the planner to recognize that there will be a match for every row in the sales table: HashAggregate (cost=74601.88..74644.00 rows=8424 width=36) (actual time=39956.115..39961.507 rows=911 loops=1) -> Hash Left Join (cost=382.43..59200.13 rows=1232140 width=36) (actual time=140.879..30765.373 rows=1232140 loops=1) Hash Cond: ("outer".customerid = "inner".id) -> Hash Left Join (cost=377.07..40712.67 rows=1232140 width=32) (actual time=136.069..22721.760 rows=1232140 loops=1) Hash Cond: ("outer".periodid = "inner".id) -> Hash Left Join (cost=182.84..34353.99 rows=1232140 width=28) (actual time=50.815..14742.610 rows=1232140 loops=1) Hash Cond: ("outer".productid = "inner".id) -> Seq Scan on sales (cost=0.00..26320.40 rows=1232140 width=24) (actual time=0.099..4490.148 rows=1232140 loops=1) -> Hash (cost=182.18..182.18 rows=265 width=12) (actual time=49.114..49.114 rows=0 loops=1) -> Hash Join (cost=1.23..182.18 rows=265 width=12) (actual time=1.331..43.662 rows=1932 loops=1) Hash Cond: (("outer".productline = "inner".productline) AND ("outer".category = "inner".category) AND ("outer".platform = "inner".platform)) -> Seq Scan on product (cost=0.00..149.32 rows=1932 width=32) (actual time=0.128..11.246 rows=1932 loops=1) -> Hash (cost=1.13..1.13 rows=13 width=45) (actual time=0.200..0.200 rows=0 loops=1) -> Seq Scan on shd_productline (cost=0.00..1.13 rows=13 width=45) (actual time=0.047..0.081 rows=13 loops=1) -> Hash (cost=194.23..194.23 rows=1 width=12) (actual time=83.651..83.651 rows=0 loops=1) -> Hash Join (cost=4.70..194.23 rows=1 width=12) (actual time=2.675..74.693 rows=3288 loops=1) Hash Cond: (("outer".monthnumber = "inner".monthnumber) AND ("outer".monthname = "inner".monthname) AND ("outer"."year" = "inner"."year") AND ("outer".monthyear = "inner".monthyear) AND ("outer".quarter = "inner".quarter) AND ("outer".quarteryear = "inner".quarteryear)) -> Seq Scan on period (cost=0.00..90.88 rows=3288 width=54) (actual time=0.118..12.126 rows=3288 loops=1) -> Hash (cost=3.08..3.08 rows=108 width=58) (actual time=1.658..1.658 rows=0 loops=1) -> Seq Scan on shd_month (cost=0.00..3.08 rows=108 width=58) (actual time=0.081..0.947 rows=108 loops=1) -> Hash (cost=5.15..5.15 rows=83 width=12) (actual time=3.131..3.131 rows=0 loops=1) -> Hash Join (cost=1.07..5.15 rows=83 width=12) (actual time=1.937..2.865 rows=83 loops=1) Hash Cond: ("outer".salesperson = "inner".salesperson) -> Seq Scan on customer (cost=0.00..2.83 rows=83 width=20) (actual time=0.137..0.437 rows=83 loops=1) -> Hash (cost=1.06..1.06 rows=6 width=24) (actual time=0.152..0.152 rows=0 loops=1) -> Seq Scan on shd_salesperson (cost=0.00..1.06 rows=6 width=24) (actual time=0.045..0.064 rows=6 loops=1) Total runtime: 39974.236 ms (27 rows) Given better row estimates the resulting plan runs more than ten times faster. Why is the planner doing so poorly with estimating the number of rows returned? I tried: SET default_statistics_target = 1000; VACUUM FULL ANALYZE; but the results were the same. This is on 8.0beta4. Any ideas? Kris Jurka From pgsql-performance-owner@postgresql.org Tue Nov 16 10:56:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5878F3A3FAF for ; Tue, 16 Nov 2004 10:56:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69046-10 for ; Tue, 16 Nov 2004 10:56:04 +0000 (GMT) Received: from talisker.lacave.net (talisker.lacave.net [217.145.39.3]) by svr1.postgresql.org (Postfix) with SMTP id 601A53A3F95 for ; Tue, 16 Nov 2004 10:56:03 +0000 (GMT) Received: (qmail 43082 invoked from network); 16 Nov 2004 10:55:41 -0000 Received: from localhost (HELO ballantines.local) (127.0.0.1) by talisker.lacave.net with SMTP; 16 Nov 2004 10:55:41 -0000 Date: Tue, 16 Nov 2004 11:55:59 +0100 From: "F. Senault" X-Mailer: The Bat! (v3.0.1.33) Professional Reply-To: "F. Senault" Organization: Secte de l'Elephant Fuschia X-Priority: 3 (Normal) Message-ID: <179155563.20041116115559@lacave.net> To: pgsql-performance@postgresql.org Subject: Re: mis-estimation on data-warehouse aggregate creation In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanner: F-prot v4.4.7 (engine 3.14.13) X-Virus-Definitions: SIGN.DEF (11 November 2004), SIGN2.DEF (12 November 2004), MACRO.DEF (15 November 2004) X-Virus-Flag: NO X-Remote-IP: 127.0.0.1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/220 X-Sequence-Number: 9174 Tuesday, November 16, 2004, 10:10:17 AM, you wrote: > HashAggregate (cost=32869.33..32869.34 rows=1 width=36) ^ > (actual time=475182.855..475188.304 rows=911 loops=1) ^^^ > -> Nested Loop (cost=377.07..32869.32 rows=1 width=36) ^ > (actual time=130.179..464299.167 rows=1232140 loops=1) ^^^^^^^ Let me guess... You've never run "analyze" on your tables ? Fred From pgsql-performance-owner@postgresql.org Tue Nov 16 14:56:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4379F3A3EDB for ; Tue, 16 Nov 2004 14:56:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52381-10 for ; Tue, 16 Nov 2004 14:55:58 +0000 (GMT) Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) by svr1.postgresql.org (Postfix) with ESMTP id 252963A3E2D for ; Tue, 16 Nov 2004 14:56:01 +0000 (GMT) Received: from mailer.elma.loc (localhost [127.0.0.1]) by localhost (Postfix) with ESMTP id 4D0AEEC1EF for ; Tue, 16 Nov 2004 15:59:13 +0100 (CET) Received: from zoot.elma.loc (herve.elma.fr [10.0.1.2]) by mailer.elma.loc (Postfix) with ESMTP id 33E2EEC139 for ; Tue, 16 Nov 2004 15:59:13 +0100 (CET) From: =?iso-8859-15?q?Herv=E9_Piedvache?= Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique To: pgsql-performance@postgresql.org Subject: Tsearch2 really slower than ilike ? Date: Tue, 16 Nov 2004 15:55:58 +0100 User-Agent: KMail/1.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200411161555.59144.herve@elma.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/221 X-Sequence-Number: 9175 Hi, I'm completly dispointed with Tsearch2 ... I have a table like this : Table "public.site" Column | Type | Modifiers ---------------+-----------------------------+--------------------------------------------------------------- id_site | integer | not null default nextval('public.site_id_site_seq'::text) site_name | text | site_url | text | url | text | language | text | datecrea | date | default now() id_category | integer | time_refresh | integer | active | integer | error | integer | description | text | version | text | idx_site_name | tsvector | lastcheck | date | lastupdate | timestamp without time zone | Indexes: "site_id_site_key" unique, btree (id_site) "ix_idx_site_name" gist (idx_site_name) Triggers: tsvectorupdate_site_name BEFORE INSERT OR UPDATE ON site FOR EACH ROW EXECUTE PROCEDURE tsearch2('idx_site_name', 'site_name') I have 183 956 records in the database ... SELECT s.site_name, s.id_site, s.description, s.site_url, case when exists (select id_user from user_choice u where u.id_site=s.id_site and u.id_user = 1) then 1 else 0 end as bookmarked FROM site s WHERE s.idx_site_name @@ to_tsquery('atari'); Explain Analyze : QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ Index Scan using ix_idx_site_name on site s (cost=0.00..1202.12 rows=184 width=158) (actual time=4687.674..4698.422 rows=1 loops=1) Index Cond: (idx_site_name @@ '\'atari\''::tsquery) Filter: (idx_site_name @@ '\'atari\''::tsquery) SubPlan -> Seq Scan on user_choice u (cost=0.00..3.46 rows=1 width=4) (actual time=0.232..0.232 rows=0 loops=1) Filter: ((id_site = $0) AND (id_user = 1)) Total runtime: 4698.608 ms First time I run the request I have a result in about 28 seconds. SELECT s.site_name, s.id_site, s.description, s.site_url, case when exists (select id_user from user_choice u where u.id_site=s.id_site and u.id_user = 1) then 1 else 0 end as bookmarked FROM site_rss s WHERE s.site_name ilike '%atari%' QUERY PLAN ---------------------------------------------------------------------------------------------------------------- Seq Scan on site_rss s (cost=0.00..11863.16 rows=295 width=158) (actual time=17.414..791.937 rows=12 loops=1) Filter: (site_name ~~* '%atari%'::text) SubPlan -> Seq Scan on user_choice u (cost=0.00..3.46 rows=1 width=4) (actual time=0.222..0.222 rows=0 loops=12) Filter: ((id_site = $0) AND (id_user = 1)) Total runtime: 792.099 ms First time I run the request I have a result in about 789 miliseconds !!??? I'm using PostgreSQL v7.4.6 with a Bi-Penitum III 933 Mhz and 1 Gb of RAM. Any idea ... ? For the moment I'm going back to use the ilike solution ... but I was really thinking that Tsearch2 could be a better solution ... Regards, -- Herv� Piedvache Elma Ing�nierie Informatique 6 rue du Faubourg Saint-Honor� F-75008 - Paris - France Pho. 33-144949901 Fax. 33-144949902 From pgsql-performance-owner@postgresql.org Tue Nov 16 15:33:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 602093A40C0 for ; Tue, 16 Nov 2004 15:33:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70680-04 for ; Tue, 16 Nov 2004 15:33:00 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 63FD33A40EB for ; Tue, 16 Nov 2004 15:33:03 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id iAGFWwWq001230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 16 Nov 2004 08:33:01 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id iAGFWvKK006128; Tue, 16 Nov 2004 08:32:57 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id iAGFWvJu006127; Tue, 16 Nov 2004 08:32:57 -0700 (MST) (envelope-from mfuhr) Date: Tue, 16 Nov 2004 08:32:57 -0700 From: Michael Fuhr To: =?us-ascii?B?PT9pc28tODg1OS0xNT9xP0hlcnY9RTlfUGllZHZhY2hlPz0=?= Cc: pgsql-performance@postgresql.org Subject: Re: Tsearch2 really slower than ilike ? Message-ID: <20041116153256.GA6026@winnie.fuhr.org> References: <200411161555.59144.herve@elma.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=unknown-8bit Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <200411161555.59144.herve@elma.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/222 X-Sequence-Number: 9176 On Tue, Nov 16, 2004 at 03:55:58PM +0100, Herv� Piedvache wrote: > WHERE s.idx_site_name @@ to_tsquery('atari'); How much text does each site_name field contain? From the field name I'd guess only a few words. Based on my own experience, if the fields were documents containing thousands of words then I'd expect tsearch2 to be faster than ILIKE by an order of magnitude or more. -- Michael Fuhr http://www.fuhr.org/~mfuhr/ From pgsql-performance-owner@postgresql.org Tue Nov 16 15:48:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C88423A4156 for ; Tue, 16 Nov 2004 15:48:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77107-02 for ; Tue, 16 Nov 2004 15:48:08 +0000 (GMT) Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) by svr1.postgresql.org (Postfix) with ESMTP id 3AB403A4141 for ; Tue, 16 Nov 2004 15:48:11 +0000 (GMT) Received: from mailer.elma.loc (localhost [127.0.0.1]) by localhost (Postfix) with ESMTP id 9DA22EC08D; Tue, 16 Nov 2004 16:51:25 +0100 (CET) Received: from zoot.elma.loc (herve.elma.fr [10.0.1.2]) by mailer.elma.loc (Postfix) with ESMTP id 7D539EC023; Tue, 16 Nov 2004 16:51:25 +0100 (CET) From: =?iso-8859-15?q?Herv=E9_Piedvache?= Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique To: Michael Fuhr Subject: Re: Tsearch2 really slower than ilike ? Date: Tue, 16 Nov 2004 16:48:11 +0100 User-Agent: KMail/1.7.1 Cc: pgsql-performance@postgresql.org References: <200411161555.59144.herve@elma.fr> <20041116153256.GA6026@winnie.fuhr.org> In-Reply-To: <20041116153256.GA6026@winnie.fuhr.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200411161648.11519.herve@elma.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/223 X-Sequence-Number: 9177 Michael, Le Mardi 16 Novembre 2004 16:32, Michael Fuhr a �crit : > On Tue, Nov 16, 2004 at 03:55:58PM +0100, Herv� Piedvache wrote: > > WHERE s.idx_site_name @@ to_tsquery('atari'); > > How much text does each site_name field contain? From the field > name I'd guess only a few words. Based on my own experience, if > the fields were documents containing thousands of words then I'd > expect tsearch2 to be faster than ILIKE by an order of magnitude > or more. Yes site name ... is company names or web site name ... so not many word in each record ... but I don't understand why more words are more efficient than few words ?? sorry ... Regards, -- Herv� Piedvache Elma Ing�nierie Informatique 6 rue du Faubourg Saint-Honor� F-75008 - Paris - France Pho. 33-144949901 Fax. 33-144949902 From pgsql-performance-owner@postgresql.org Tue Nov 16 15:59:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E9DC73A3D30 for ; Tue, 16 Nov 2004 15:58:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79943-04 for ; Tue, 16 Nov 2004 15:58:33 +0000 (GMT) Received: from omu-eweb1.solutionary.com (unknown [207.188.34.4]) by svr1.postgresql.org (Postfix) with ESMTP id CD4D63A3C0B for ; Tue, 16 Nov 2004 15:58:35 +0000 (GMT) Received: from OMU-EXCH1.solutionary.com ([207.188.36.32]) by omu-eweb1.solutionary.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 16 Nov 2004 09:57:07 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C4CBF4.ECB89016" Subject: Efficient way to remove OID data Date: Tue, 16 Nov 2004 09:57:07 -0600 Message-ID: <9697D58F4D8FF94892AF75A0A5D8CCCC01C1ED1B@OMU-EXCH1.solutionary.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Efficient way to remove OID data Thread-Index: AcTL9OyuCWdKiP1vRTuhCMZ0MOG7Xg== From: "James Gunzelman" To: X-OriginalArrivalTime: 16 Nov 2004 15:57:07.0892 (UTC) FILETIME=[ECD2E740:01C4CBF4] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=HTML_60_70, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200411/224 X-Sequence-Number: 9178 This is a multi-part message in MIME format. ------_=_NextPart_001_01C4CBF4.ECB89016 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I have a table that has 2 columns of an OID type. I would like to issue a truncate table command but my understanding is that the data pointed to by the OIDs is not removed and orphaned. What would be the most efficient way to truncate the table and not have orphaned data? =20 Thanks =20 ____________________________________ =20 Jim Gunzelman Senior Software Engineer =20 phone: 402.361.3078 fax: 402.361.3100 e-mail: JamesGunzelmane@Solutionary.com =20 Solutionary, Inc. www.Solutionary.com =20 =20 Making Security Manageable 24x7 _____________________________________ =20 Confidentiality Notice The content of this communication, along with any attachments, is covered by federal and state law governing electronic communications and may contain confidential and legally privileged information. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, use or copying of the information contained herein is strictly prohibited. If you have received this communication in error, please immediately contact us by telephone at (402) 361-3000 or e-mail security@solutionary.com. Thank you. =20 Copyright 2000-2004, Solutionary, Inc. All rights reserved. ActiveGuard, eV3, Solutionary and the Solutionary logo are registered trademarks of Solutionary, Inc. =20 =20 =20 ------_=_NextPart_001_01C4CBF4.ECB89016 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Message
I have = a table that=20 has 2 columns of an OID type.  I would like to issue a truncate = table=20 command but my understanding is that the data pointed to by the OIDs is = not=20 removed and orphaned.  What would be the most efficient way to = truncate the=20 table and not have orphaned data?
 
Thanks
 

____________________________________

 

Jim = Gunzelman

Senior Software=20 Engineer

 

phone: 402.361.3078   fax:=20 402.361.3100

e-mail: =20 JamesGunzelmane@Solutionary.com

 

Solutionary,=20 Inc.

www.Solutionary.com      =20

 

Making Security Manageable = 24x7

_____________________________________

 

Confidentiality=20 Notice

The content = of this=20 communication, along with any attachments, is covered by federal and = state law=20 governing electronic communications and may contain confidential and = legally=20 privileged information.  = If the=20 reader of this message is not the intended recipient, you are hereby = notified=20 that any dissemination, distribution, use or copying of the information=20 contained herein is strictly prohibited. =20 If you have received this communication in error, please = immediately=20 contact us by telephone at (402) 361-3000 or e-mail=20 security@solutionary.com.  = Thank=20 you.

 

Copyright 2000-2004, = Solutionary,=20 Inc. All rights reserved.  ActiveGuard, eV3, Solutionary = and the=20 Solutionary logo are registered trademarks of Solutionary,=20 Inc.

 

 

 
=00 ------_=_NextPart_001_01C4CBF4.ECB89016-- From pgsql-performance-owner@postgresql.org Tue Nov 16 16:06:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3ABF83A3C82 for ; Tue, 16 Nov 2004 16:05:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83756-02 for ; Tue, 16 Nov 2004 16:05:21 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id E667C3A3C42 for ; Tue, 16 Nov 2004 16:05:20 +0000 (GMT) Received: from [192.168.1.20] (clbb-248.saw.net [64.146.135.248]) (authenticated) by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id iAGG5F816661; Tue, 16 Nov 2004 08:05:15 -0800 Message-ID: <419A250C.9020300@commandprompt.com> Date: Tue, 16 Nov 2004 08:04:28 -0800 From: "Joshua D. Drake" User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-15?Q?Herv=E9_Piedvache?= Cc: Michael Fuhr , pgsql-performance@postgresql.org Subject: Re: Tsearch2 really slower than ilike ? References: <200411161555.59144.herve@elma.fr> <20041116153256.GA6026@winnie.fuhr.org> <200411161648.11519.herve@elma.fr> In-Reply-To: <200411161648.11519.herve@elma.fr> Content-Type: multipart/mixed; boundary="------------020105030809020707080102" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/225 X-Sequence-Number: 9179 This is a multi-part message in MIME format. --------------020105030809020707080102 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit >>or more. >> >> > >Yes site name ... is company names or web site name ... so not many word in >each record ... but I don't understand why more words are more efficient than >few words ?? sorry ... > > Well there are a couple of reasons but the easiest one is index size. An ILIKE btree index is in general going to be much smaller than a gist index. The smaller the index the faster it is searched. Sincerely, Joshua D. Drake >Regards, > > -- Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC Postgresql support, programming shared hosting and dedicated hosting. +1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com PostgreSQL Replicator -- production quality replication for PostgreSQL --------------020105030809020707080102 Content-Type: text/x-vcard; charset=utf-8; name="jd.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jd.vcf" begin:vcard fn:Joshua Drake n:Drake;Joshua org:Command Prompt, Inc. adr:;;PO Box 215 ;Cascade Locks;OR;97014;US email;internet:jd@commandprompt.com title:Consultant tel;work:503-667-4564 tel;fax:503-210-0334 x-mozilla-html:FALSE url:http://www.commandprompt.com version:2.1 end:vcard --------------020105030809020707080102-- From pgsql-performance-owner@postgresql.org Tue Nov 16 16:09:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 180CE3A230E for ; Tue, 16 Nov 2004 16:07:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84131-05 for ; Tue, 16 Nov 2004 16:07:15 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id C99BE3A3CE5 for ; Tue, 16 Nov 2004 16:07:14 +0000 (GMT) Received: from [192.168.1.20] (clbb-248.saw.net [64.146.135.248]) (authenticated) by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id iAGG7C817227; Tue, 16 Nov 2004 08:07:12 -0800 Message-ID: <419A2581.2050409@commandprompt.com> Date: Tue, 16 Nov 2004 08:06:25 -0800 From: "Joshua D. Drake" User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-15?Q?Herv=E9_Piedvache?= Cc: pgsql-performance@postgresql.org Subject: Re: Tsearch2 really slower than ilike ? References: <200411161555.59144.herve@elma.fr> In-Reply-To: <200411161555.59144.herve@elma.fr> Content-Type: multipart/mixed; boundary="------------000300000904030804060907" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/226 X-Sequence-Number: 9180 This is a multi-part message in MIME format. --------------000300000904030804060907 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > > QUERY PLAN >---------------------------------------------------------------------------------------------------------------- > Seq Scan on site_rss s (cost=0.00..11863.16 rows=295 width=158) (actual >time=17.414..791.937 rows=12 loops=1) > Filter: (site_name ~~* '%atari%'::text) > SubPlan > -> Seq Scan on user_choice u (cost=0.00..3.46 rows=1 width=4) (actual >time=0.222..0.222 rows=0 loops=12) > Filter: ((id_site = $0) AND (id_user = 1)) > Total runtime: 792.099 ms > >First time I run the request I have a result in about 789 miliseconds !!??? > >I'm using PostgreSQL v7.4.6 with a Bi-Penitum III 933 Mhz and 1 Gb of RAM. > >Any idea ... ? For the moment I'm going back to use the ilike solution ... but >I was really thinking that Tsearch2 could be a better solution ... > > > Well I would be curious about what happens the second time you run the query. The first time is kind of a bad example because it has to push the index into ram. Sincerely, Joshua D. Drake >Regards, > > -- Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC Postgresql support, programming shared hosting and dedicated hosting. +1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com PostgreSQL Replicator -- production quality replication for PostgreSQL --------------000300000904030804060907 Content-Type: text/x-vcard; charset=utf-8; name="jd.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jd.vcf" begin:vcard fn:Joshua Drake n:Drake;Joshua org:Command Prompt, Inc. adr:;;PO Box 215 ;Cascade Locks;OR;97014;US email;internet:jd@commandprompt.com title:Consultant tel;work:503-667-4564 tel;fax:503-210-0334 x-mozilla-html:FALSE url:http://www.commandprompt.com version:2.1 end:vcard --------------000300000904030804060907-- From pgsql-performance-owner@postgresql.org Tue Nov 16 16:20:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 344B33A3CA4 for ; Tue, 16 Nov 2004 16:18:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86567-10 for ; Tue, 16 Nov 2004 16:18:01 +0000 (GMT) Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) by svr1.postgresql.org (Postfix) with ESMTP id E2D173A3BC8 for ; Tue, 16 Nov 2004 16:17:53 +0000 (GMT) Received: from ra (ra [158.250.29.2]) by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id iAGGHZQT017940; Tue, 16 Nov 2004 19:17:35 +0300 (MSK) Date: Tue, 16 Nov 2004 19:17:35 +0300 (MSK) From: Oleg Bartunov X-X-Sender: megera@ra.sai.msu.su To: =?iso-8859-15?q?Herv=E9_Piedvache?= Cc: Michael Fuhr , pgsql-performance@postgresql.org Subject: Re: Tsearch2 really slower than ilike ? In-Reply-To: <200411161648.11519.herve@elma.fr> Message-ID: References: <200411161555.59144.herve@elma.fr> <20041116153256.GA6026@winnie.fuhr.org> <200411161648.11519.herve@elma.fr> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/227 X-Sequence-Number: 9181 could you provide me a dump of your table (just id and tsvector columns), so I could try on my computer. Also, plain query (simple and clean) which demonstrated your problem would be preferred next time ! Oleg On Tue, 16 Nov 2004, [iso-8859-15] Herv? Piedvache wrote: > Michael, > > Le Mardi 16 Novembre 2004 16:32, Michael Fuhr a ?crit : >> On Tue, Nov 16, 2004 at 03:55:58PM +0100, Herv? Piedvache wrote: >>> WHERE s.idx_site_name @@ to_tsquery('atari'); >> >> How much text does each site_name field contain? From the field >> name I'd guess only a few words. Based on my own experience, if >> the fields were documents containing thousands of words then I'd >> expect tsearch2 to be faster than ILIKE by an order of magnitude >> or more. > > Yes site name ... is company names or web site name ... so not many word in > each record ... but I don't understand why more words are more efficient than > few words ?? sorry ... > > Regards, > Regards, Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83 From pgsql-performance-owner@postgresql.org Tue Nov 16 16:23:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9D35D3A3D55 for ; Tue, 16 Nov 2004 16:21:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90655-03 for ; Tue, 16 Nov 2004 16:21:24 +0000 (GMT) Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) by svr1.postgresql.org (Postfix) with ESMTP id 0DD5A3A3CA4 for ; Tue, 16 Nov 2004 16:21:21 +0000 (GMT) Received: from mailer.elma.loc (localhost [127.0.0.1]) by localhost (Postfix) with ESMTP id 26000EC20D; Tue, 16 Nov 2004 17:24:33 +0100 (CET) Received: from zoot.elma.loc (herve.elma.fr [10.0.1.2]) by mailer.elma.loc (Postfix) with ESMTP id 05C89EC113; Tue, 16 Nov 2004 17:24:33 +0100 (CET) From: =?iso-8859-15?q?Herv=E9_Piedvache?= Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique To: "Joshua D. Drake" Subject: Re: Tsearch2 really slower than ilike ? Date: Tue, 16 Nov 2004 17:21:18 +0100 User-Agent: KMail/1.7.1 Cc: pgsql-performance@postgresql.org References: <200411161555.59144.herve@elma.fr> <419A2581.2050409@commandprompt.com> In-Reply-To: <419A2581.2050409@commandprompt.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200411161721.18840.herve@elma.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/228 X-Sequence-Number: 9182 Le Mardi 16 Novembre 2004 17:06, Joshua D. Drake a �crit : > > QUERY PLAN > >-------------------------------------------------------------------------- > >-------------------------------------- Seq Scan on site_rss s > > (cost=0.00..11863.16 rows=295 width=158) (actual time=17.414..791.937 > > rows=12 loops=1) > > Filter: (site_name ~~* '%atari%'::text) > > SubPlan > > -> Seq Scan on user_choice u (cost=0.00..3.46 rows=1 width=4) > > (actual time=0.222..0.222 rows=0 loops=12) > > Filter: ((id_site = $0) AND (id_user = 1)) > > Total runtime: 792.099 ms > > > >First time I run the request I have a result in about 789 miliseconds > > !!??? > > > >I'm using PostgreSQL v7.4.6 with a Bi-Penitum III 933 Mhz and 1 Gb of RAM. > > > >Any idea ... ? For the moment I'm going back to use the ilike solution ... > > but I was really thinking that Tsearch2 could be a better solution ... > > Well I would be curious about what happens the second time you run the > query. > The first time is kind of a bad example because it has to push the index > into ram. The second time is really quicker yes ... about 312 miliseconds ... But for each search I have after it take about 3 or 4 seconds ... So what can I do ? Regards, -- Herv� Piedvache Elma Ing�nierie Informatique 6 rue du Faubourg Saint-Honor� F-75008 - Paris - France Pho. 33-144949901 Fax. 33-144949902 From pgsql-performance-owner@postgresql.org Tue Nov 16 16:35:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CDC7B3A2B29 for ; Tue, 16 Nov 2004 16:27:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93454-03 for ; Tue, 16 Nov 2004 16:27:37 +0000 (GMT) Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) by svr1.postgresql.org (Postfix) with ESMTP id B0B9C3A3C0B for ; Tue, 16 Nov 2004 16:27:30 +0000 (GMT) Received: from ra (ra [158.250.29.2]) by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id iAGGR5QT018156; Tue, 16 Nov 2004 19:27:05 +0300 (MSK) Date: Tue, 16 Nov 2004 19:27:05 +0300 (MSK) From: Oleg Bartunov X-X-Sender: megera@ra.sai.msu.su To: "Joshua D. Drake" Cc: =?ISO-8859-15?Q?Herv=E9_Piedvache?= , Michael Fuhr , pgsql-performance@postgresql.org Subject: Re: Tsearch2 really slower than ilike ? In-Reply-To: <419A250C.9020300@commandprompt.com> Message-ID: References: <200411161555.59144.herve@elma.fr> <20041116153256.GA6026@winnie.fuhr.org> <200411161648.11519.herve@elma.fr> <419A250C.9020300@commandprompt.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/229 X-Sequence-Number: 9183 On Tue, 16 Nov 2004, Joshua D. Drake wrote: > >>> or more. >>> >> >> Yes site name ... is company names or web site name ... so not many word in >> each record ... but I don't understand why more words are more efficient >> than few words ?? sorry ... >> > Well there are a couple of reasons but the easiest one is index size. > An ILIKE btree index is in general going to be much smaller than a gist > index. > The smaller the index the faster it is searched. for single word queries @@ should have the same performance as ilike with index disabled and better for complex queries. > > Sincerely, > > Joshua D. Drake > > > >> Regards, >> > > > Regards, Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83 From pgsql-performance-owner@postgresql.org Tue Nov 16 19:43:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7F5443A3F57 for ; Tue, 16 Nov 2004 19:43:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65756-05 for ; Tue, 16 Nov 2004 19:43:39 +0000 (GMT) Received: from mx1.neopolitan.us (mx1.neopolitan.us [65.87.16.224]) by svr1.postgresql.org (Postfix) with ESMTP id 850F43A3D54 for ; Tue, 16 Nov 2004 19:43:39 +0000 (GMT) Received: from [65.87.16.98] (HELO vulture.corp.neopolitan.com) by mx1.neopolitan.us (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 6414907 for pgsql-performance@postgresql.org; Tue, 16 Nov 2004 11:43:39 -0800 Subject: Re: Insertion puzzles From: "J. Andrew Rogers" To: pgsql-performance@postgresql.org In-Reply-To: <102570-22004110142048396@M2W072.mail2web.com> References: <102570-22004110142048396@M2W072.mail2web.com> Content-Type: text/plain Organization: Message-Id: <1100633534.26741.28.camel@vulture.corp.neopolitan.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 16 Nov 2004 11:43:38 -0800 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=MAILTO_TO_SPAM_ADDR X-Spam-Level: * X-Archive-Number: 200411/230 X-Sequence-Number: 9184 On Sat, 2004-11-13 at 18:00, dentfirst13@earthlink.net wrote: > I ran into the exact same problem you did. I tried many, many changes to > the conf file, I tried O.S. tuning but performance stunk. I had a fairly > simple job that had a lot of updates and inserts that was taking 4 1/2 > hours. I re-wrote it to be more "Postgres friendly" - meaning less > database updates and got it down under 2 1/2 hours (still horrible). > Understand, the legacy non-postgres ISAM db took about 15 minutes to > perform the same task. I assumed it was a system problem that would go > away when we upgraded servers but it did not. I converted to MySQL and the > exact same java process takes 5 minutes! Postgres is a great DB for some, > for our application it was not - you may want to consider other products > that are a bit faster and do not require the vacuuming of stale data. I have to wonder if the difference is in how your job is being chopped up by the different connection mechanisms. The only time I've had performance problems like this, it was the result of pathological and unwelcome behaviors in the way things were being handled in the connector or database design. We have a 15GB OLTP/OLAP database on five spindles with a large insert/update load and >100M rows, and I don't think it takes 2.5 hours to do *anything*. This includes inserts/updates of hundreds of thousands of rows at a shot, which takes very little time. I've gotten really bad performance before under postgres, but once I isolated the reason I've always gotten performance that was comparable to any other commercial RDBMS on the same hardware. J. Andrew Rogers From pgsql-performance-owner@postgresql.org Tue Nov 16 19:49:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5AFCB3A3FB6 for ; Tue, 16 Nov 2004 19:49:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65609-10 for ; Tue, 16 Nov 2004 19:49:02 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 228CC3A3FE7 for ; Tue, 16 Nov 2004 19:49:02 +0000 (GMT) Received: (qmail 20335 invoked by uid 1112); 16 Nov 2004 19:49:31 -0000 Date: Tue, 16 Nov 2004 14:49:31 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: "F. Senault" Cc: pgsql-performance@postgresql.org Subject: Re: mis-estimation on data-warehouse aggregate creation In-Reply-To: <179155563.20041116115559@lacave.net> Message-ID: References: <179155563.20041116115559@lacave.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/231 X-Sequence-Number: 9185 On Tue, 16 Nov 2004, F. Senault wrote: > Let me guess... You've never run "analyze" on your tables ? > No, I have. I mentioned that I did in my email, but you can also tell by the exactly correct guesses for some other plan steps: -> Seq Scan on period (cost=0.00..90.88 rows=3288 width=54) (actual time=0.118..12.126 rows=3288 loops=1) Kris Jurka From pgsql-performance-owner@postgresql.org Tue Nov 16 21:11:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 308E93A401A for ; Tue, 16 Nov 2004 21:11:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95704-06 for ; Tue, 16 Nov 2004 21:11:29 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.193]) by svr1.postgresql.org (Postfix) with ESMTP id 6F9F23A3FF8 for ; Tue, 16 Nov 2004 21:11:30 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 63so605860wri for ; Tue, 16 Nov 2004 13:11:30 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=m4wIfNeDL1MzR9ewOzxnwX3+N1uhZzZAgF3573PESskAnDjlPAruDcpRsoKyOiZgvkBY20cjqsHnhfhomjvyOCSs9DrQrFC3CpZIoQZ4bfie/KhPmBabTd8PmdWWmyOqL4AUSvhn0vyc5X+sObuxrcTnJMOgRVkjA8A/h4If8X0= Received: by 10.54.19.33 with SMTP id 33mr365873wrs; Tue, 16 Nov 2004 13:11:30 -0800 (PST) Received: by 10.54.20.23 with HTTP; Tue, 16 Nov 2004 13:11:30 -0800 (PST) Message-ID: <1dc7f0e304111613116532a64b@mail.gmail.com> Date: Tue, 16 Nov 2004 16:11:30 -0500 From: Alexandre Leclerc Reply-To: Alexandre Leclerc To: PERFORM Subject: nuderstanding 'explain analyse' Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/232 X-Sequence-Number: 9186 Hello, I build two SELECT queries, and in one I used COALESCE with a CASE, and in the second one I used only CASE statements. When analysing, I'm getting the exact same result, except the cost. (For now I have so few data that the results are too fragmented. If the plans for both queries are exactly the same, should I assume that the cost will also be the same? Thanks for any help. -- Alexandre Leclerc From pgsql-performance-owner@postgresql.org Tue Nov 16 21:13:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AD0EE3A4039 for ; Tue, 16 Nov 2004 21:13:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97058-02 for ; Tue, 16 Nov 2004 21:13:24 +0000 (GMT) Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) by svr1.postgresql.org (Postfix) with ESMTP id 567BB3A3D1E for ; Tue, 16 Nov 2004 21:13:16 +0000 (GMT) Received: from ra (ra [158.250.29.2]) by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id iAGLD8QT024474; Wed, 17 Nov 2004 00:13:09 +0300 (MSK) Date: Wed, 17 Nov 2004 00:13:08 +0300 (MSK) From: Oleg Bartunov X-X-Sender: megera@ra.sai.msu.su To: =?iso-8859-15?q?Herv=E9_Piedvache?= Cc: pgsql-performance@postgresql.org Subject: Re: Tsearch2 really slower than ilike ? In-Reply-To: <200411161555.59144.herve@elma.fr> Message-ID: References: <200411161555.59144.herve@elma.fr> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/233 X-Sequence-Number: 9187 ok, I downloaded dump of table and here is what I found: zz=# select count(*) from tt; count -------- 183956 (1 row) zz=# select * from stat('select tt from tt') order by ndoc desc, nentry desc,wo rd limit 10; word | ndoc | nentry --------------+-------+-------- blog | 12710 | 12835 weblog | 4857 | 4859 news | 4402 | 4594 life | 4136 | 4160 world | 1980 | 1986 journal | 1882 | 1883 livejourn | 1737 | 1737 thought | 1669 | 1677 web | 1154 | 1161 scotsman.com | 1138 | 1138 (10 rows) zz=# explain analyze select tt from tt where tt @@ 'blog'; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------- Index Scan using tt_idx on tt (cost=0.00..728.83 rows=184 width=32) (actual time=0.047..141.110 rows=12710 loops=1) Index Cond: (tt @@ '\'blog\''::tsquery) Filter: (tt @@ '\'blog\''::tsquery) Total runtime: 154.105 ms (4 rows) It's really fast ! So, I don't understand your problem. I run query on my desktop machine, nothing special. Oleg On Tue, 16 Nov 2004, [iso-8859-15] Herv? Piedvache wrote: > Hi, > > I'm completly dispointed with Tsearch2 ... > > I have a table like this : > Table "public.site" > Column | Type | > Modifiers > ---------------+-----------------------------+--------------------------------------------------------------- > id_site | integer | not null default > nextval('public.site_id_site_seq'::text) > site_name | text | > site_url | text | > url | text | > language | text | > datecrea | date | default now() > id_category | integer | > time_refresh | integer | > active | integer | > error | integer | > description | text | > version | text | > idx_site_name | tsvector | > lastcheck | date | > lastupdate | timestamp without time zone | > Indexes: > "site_id_site_key" unique, btree (id_site) > "ix_idx_site_name" gist (idx_site_name) > Triggers: > tsvectorupdate_site_name BEFORE INSERT OR UPDATE ON site FOR EACH ROW > EXECUTE PROCEDURE tsearch2('idx_site_name', 'site_name') > > I have 183 956 records in the database ... > > SELECT s.site_name, s.id_site, s.description, s.site_url, > case when exists (select id_user > from user_choice u > where u.id_site=s.id_site > and u.id_user = 1) then 1 > else 0 end as bookmarked > FROM site s > WHERE s.idx_site_name @@ to_tsquery('atari'); > > Explain Analyze : > QUERY PLAN > ------------------------------------------------------------------------------------------------------------------------------------------ > Index Scan using ix_idx_site_name on site s (cost=0.00..1202.12 rows=184 > width=158) (actual time=4687.674..4698.422 rows=1 loops=1) > Index Cond: (idx_site_name @@ '\'atari\''::tsquery) > Filter: (idx_site_name @@ '\'atari\''::tsquery) > SubPlan > -> Seq Scan on user_choice u (cost=0.00..3.46 rows=1 width=4) (actual > time=0.232..0.232 rows=0 loops=1) > Filter: ((id_site = $0) AND (id_user = 1)) > Total runtime: 4698.608 ms > > First time I run the request I have a result in about 28 seconds. > > SELECT s.site_name, s.id_site, s.description, s.site_url, > case when exists (select id_user > from user_choice u > where u.id_site=s.id_site > and u.id_user = 1) then 1 > else 0 end as bookmarked > FROM site_rss s > WHERE s.site_name ilike '%atari%' > > QUERY PLAN > ---------------------------------------------------------------------------------------------------------------- > Seq Scan on site_rss s (cost=0.00..11863.16 rows=295 width=158) (actual > time=17.414..791.937 rows=12 loops=1) > Filter: (site_name ~~* '%atari%'::text) > SubPlan > -> Seq Scan on user_choice u (cost=0.00..3.46 rows=1 width=4) (actual > time=0.222..0.222 rows=0 loops=12) > Filter: ((id_site = $0) AND (id_user = 1)) > Total runtime: 792.099 ms > > First time I run the request I have a result in about 789 miliseconds !!??? > > I'm using PostgreSQL v7.4.6 with a Bi-Penitum III 933 Mhz and 1 Gb of RAM. > > Any idea ... ? For the moment I'm going back to use the ilike solution ... but > I was really thinking that Tsearch2 could be a better solution ... > > Regards, > Regards, Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83 From pgsql-performance-owner@postgresql.org Tue Nov 16 21:33:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 566B63A2B23 for ; Tue, 16 Nov 2004 21:33:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01325-06 for ; Tue, 16 Nov 2004 21:33:14 +0000 (GMT) Received: from cmailg3.svr.pol.co.uk (cmailg3.svr.pol.co.uk [195.92.195.173]) by svr1.postgresql.org (Postfix) with ESMTP id E28F73A4016 for ; Tue, 16 Nov 2004 21:33:14 +0000 (GMT) Received: from modem-2555.llama.dialup.pol.co.uk ([217.135.185.251] helo=[192.168.0.102]) by cmailg3.svr.pol.co.uk with esmtp (Exim 4.41) id 1CUAwi-00023n-Kp; Tue, 16 Nov 2004 21:33:05 +0000 Subject: Re: mis-estimation on data-warehouse aggregate creation From: Simon Riggs To: Kris Jurka Cc: pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain Organization: 2nd Quadrant Message-Id: <1100640596.4113.5680.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 16 Nov 2004 21:29:56 +0000 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/234 X-Sequence-Number: 9188 On Tue, 2004-11-16 at 09:10, Kris Jurka wrote: > By rewriting the JOIN > conditions to LEFT JOIN we force the planner to recognize that there will > be a match for every row in the sales table: > You realise that returns a different answer (or at least it potentially does, depending upon your data? > -> Hash Join (cost=4.70..194.23 rows=1 width=12) (actual time=2.675..74.693 rows=3288 loops=1) > Hash Cond: (("outer".monthnumber = "inner".monthnumber) AND ("outer".monthname = "inner".monthname) AND ("outer"."year" = "inner"."year") AND ("outer".monthyear = "inner".monthyear) AND ("outer".quarter = "inner".quarter) AND ("outer".quarteryear = "inner".quarteryear)) > -> Seq Scan on period (cost=0.00..90.88 rows=3288 width=54) (actual time=0.118..12.126 rows=3288 loops=1) > -> Hash (cost=3.08..3.08 rows=108 width=58) (actual time=1.658..1.658 rows=0 loops=1) > -> Seq Scan on shd_month (cost=0.00..3.08 rows=108 width=58) (actual time=0.081..0.947 rows=108 loops=1) ISTM your trouble starts here ^^^ estimate=1, but rows=3288 The join condition has so many ANDed predicates that we assume that this will reduce the selectivity considerably. It does not, and so you pay the cost dearly later on. In both plans, the trouble starts at this point. If you pre-build tables that have only a single join column between the full.oldids and shrunken.renumberedids then this will most likely work correctly, since the planner will be able to correctly estimate the join selectivity. i.e. put product.id onto shd_productline ahead of time, so you can avoid the complex join. Setting join_collapse_limit lower doesn't look like it would help, since the plan already shows joining the sub-queries together first. -- Best Regards, Simon Riggs From pgsql-performance-owner@postgresql.org Wed Nov 17 03:55:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 22D953A41E3 for ; Wed, 17 Nov 2004 03:55:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04731-05 for ; Wed, 17 Nov 2004 03:54:49 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id 31CF43A230E for ; Wed, 17 Nov 2004 03:54:51 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: query plan question Date: Tue, 16 Nov 2004 22:54:51 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26B972@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: query plan question Thread-Index: AcTMWTDzheJNchtaRTai6F1qQHgv7A== From: "David Parker" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/235 X-Sequence-Number: 9189 I have a query for which postgres is generating a different plan on = different machines. The database schema is the same, the dataset is the = same, the configuration is the same (e.g., pg_autovacuum running in both = cases), both systems are Solaris 9. The main difference in the two = systems is that one is sparc and the other is intel. The query runs in about 40 ms on the intel box, but takes about 18 = seconds on the sparc box. Now, the intel boxes we have are certainly = faster, but I'm curious why the query plan might be different. For the intel: QUERY PLAN Unique (cost=3D11.50..11.52 rows=3D2 width=3D131) -> Sort (cost=3D11.50..11.50 rows=3D2 width=3D131) Sort Key: up.prefix, s.name, s.tuid, s.foundryversion -> Hash Join (cost=3D10.42..11.49 rows=3D2 width=3D131) Hash Cond: ("outer".dbid =3D "inner"."schema") -> Seq Scan on "schema" s (cost=3D0.00..1.02 rows=3D2 = width=3D128) -> Hash (cost=3D10.41..10.41 rows=3D4 width=3D11) -> Nested Loop (cost=3D0.00..10.41 rows=3D4 = width=3D11) -> Nested Loop (cost=3D0.00..2.14 rows=3D4 = width=3D4) -> Seq Scan on flow fl = (cost=3D0.00..0.00 rows=3D1 width=3D4) Filter: (servicetype =3D 646) -> Index Scan using usage_flow_i on = "usage" u (cost=3D0.00..2.06 rows=3D6 width=3D8) Index Cond: (u.flow =3D = "outer".dbid) -> Index Scan using usageparameter_usage_i on = usageparameter up (cost=3D0.00..2.06 rows=3D1 width=3D15) Index Cond: (up."usage" =3D = "outer".dbid) Filter: ((prefix)::text <> 'xsd'::text) For the sparc: QUERY PLAN Unique (cost=3D10.81..10.83 rows=3D1 width=3D167) -> Sort (cost=3D10.81..10.82 rows=3D1 width=3D167) Sort Key: up.prefix, s.name, s.tuid, s.foundryversion -> Nested Loop (cost=3D9.75..10.80 rows=3D1 width=3D167) Join Filter: ("outer".flow =3D "inner".dbid) -> Hash Join (cost=3D9.75..10.79 rows=3D1 width=3D171) Hash Cond: ("outer".dbid =3D "inner"."schema") -> Seq Scan on "schema" s (cost=3D0.00..1.02 = rows=3D2 width=3D128) -> Hash (cost=3D9.75..9.75 rows=3D1 width=3D51) -> Nested Loop (cost=3D0.00..9.75 rows=3D1 = width=3D51) Join Filter: ("inner"."usage" =3D = "outer".dbid) -> Index Scan using usage_flow_i on = "usage" u (cost=3D0.00..4.78 rows=3D1 width=3D8) -> Index Scan using = usageparameter_schema_i on usageparameter up (cost=3D0.00..4.96 = rows=3D1 width=3D51) Filter: ((prefix)::text <> = 'xsd'::text) -> Seq Scan on flow fl (cost=3D0.00..0.00 rows=3D1 = width=3D4) Filter: (servicetype =3D 646) I assume the problem with the second plan starts with doing a Nested = Loop rather than a Hash Join at the 4th line of the plan, but I don't = know why it would be different for the same schema, same dataset. What factors go into the planner's decision to choose a nested loop over = a hash join? Should I be looking at adjusting my runtime configuration = on the sparc box somehow? Thanks. - DAP -------------------------------------------------------------------------= --------- David Parker Tazz Networks (401) 709-5130 =A0 From pgsql-performance-owner@postgresql.org Wed Nov 17 04:02:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 36A093A408D for ; Wed, 17 Nov 2004 04:00:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05542-08 for ; Wed, 17 Nov 2004 04:00:28 +0000 (GMT) Received: from mail1.panix.com (mail1.panix.com [166.84.1.72]) by svr1.postgresql.org (Postfix) with ESMTP id B9E4E3A41D3 for ; Wed, 17 Nov 2004 04:00:28 +0000 (GMT) Received: from panix5.panix.com (panix5.panix.com [166.84.1.5]) by mail1.panix.com (Postfix) with ESMTP id 73B6A58B13 for ; Tue, 16 Nov 2004 23:00:24 -0500 (EST) Received: (from adler@localhost) by panix5.panix.com (8.11.6p3/8.8.8/PanixN1.1) id iAH40Oe16197 for pgsql-performance@postgresql.org; Tue, 16 Nov 2004 23:00:24 -0500 (EST) Date: Tue, 16 Nov 2004 23:00:24 -0500 From: Michael Adler To: pgsql-performance@postgresql.org Subject: memcached and PostgreSQL Message-ID: <20041117040024.GB8838@pobox.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/236 X-Sequence-Number: 9190 http://pugs.postgresql.org/sfpug/archives/000021.html I noticed that some of you left coasters were talking about memcached and pgsql. I'm curious to know what was discussed. In reading about memcached, it seems that many people are using it to circumvent the scalability problems of MySQL (lack of MVCC). from their site: Shouldn't the database do this? Regardless of what database you use (MS-SQL, Oracle, Postgres, MysQL-InnoDB, etc..), there's a lot of overhead in implementing ACID properties in a RDBMS, especially when disks are involved, which means queries are going to block. For databases that aren't ACID-compliant (like MySQL-MyISAM), that overhead doesn't exist, but reading threads block on the writing threads. memcached never blocks. So What does memcached offer pgsql users? It would still seem to offer the benefit of a multi-machined cache. -Mike From pgsql-performance-owner@postgresql.org Wed Nov 17 04:36:08 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8007B3A4252 for ; Wed, 17 Nov 2004 04:35:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17099-05 for ; Wed, 17 Nov 2004 04:35:53 +0000 (GMT) Received: from mail.pws.com.au (mail.pws.com.au [210.23.138.139]) by svr1.postgresql.org (Postfix) with SMTP id C83033A4249 for ; Wed, 17 Nov 2004 04:35:51 +0000 (GMT) Received: (qmail 24709 invoked by uid 0); 17 Nov 2004 15:35:45 +1100 Received: from cpe-203-45-44-212.vic.bigpond.net.au (HELO wizzard.pws.com.au) (russell@pws.com.au@203.45.44.212) by mail.pws.com.au with SMTP; 17 Nov 2004 15:35:45 +1100 From: Russell Smith To: pgsql-performance@postgresql.org Subject: Re: query plan question Date: Wed, 17 Nov 2004 15:35:42 +1100 User-Agent: KMail/1.7 References: <07FDEE0ED7455A48AC42AC2070EDFF7C26B972@corpsrv2.tazznetworks.com> In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C26B972@corpsrv2.tazznetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200411171535.42690.mr-russ@pws.com.au> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/237 X-Sequence-Number: 9191 On Wed, 17 Nov 2004 02:54 pm, you wrote: > I have a query for which postgres is generating a different plan on different machines. The database schema is the same, the dataset is the same, the configuration is the same (e.g., pg_autovacuum running in both cases), both systems are Solaris 9. The main difference in the two systems is that one is sparc and the other is intel. > > The query runs in about 40 ms on the intel box, but takes about 18 seconds on the sparc box. Now, the intel boxes we have are certainly faster, but I'm curious why the query plan might be different. > > For the intel: > > QUERY PLAN > Unique (cost=11.50..11.52 rows=2 width=131) > -> Sort (cost=11.50..11.50 rows=2 width=131) > Sort Key: up.prefix, s.name, s.tuid, s.foundryversion > -> Hash Join (cost=10.42..11.49 rows=2 width=131) > Hash Cond: ("outer".dbid = "inner"."schema") > -> Seq Scan on "schema" s (cost=0.00..1.02 rows=2 width=128) > -> Hash (cost=10.41..10.41 rows=4 width=11) > -> Nested Loop (cost=0.00..10.41 rows=4 width=11) > -> Nested Loop (cost=0.00..2.14 rows=4 width=4) > -> Seq Scan on flow fl (cost=0.00..0.00 rows=1 width=4) > Filter: (servicetype = 646) > -> Index Scan using usage_flow_i on "usage" u (cost=0.00..2.06 rows=6 width=8) > Index Cond: (u.flow = "outer".dbid) > -> Index Scan using usageparameter_usage_i on usageparameter up (cost=0.00..2.06 rows=1 width=15) > Index Cond: (up."usage" = "outer".dbid) > Filter: ((prefix)::text <> 'xsd'::text) > > For the sparc: > > QUERY PLAN > Unique (cost=10.81..10.83 rows=1 width=167) > -> Sort (cost=10.81..10.82 rows=1 width=167) > Sort Key: up.prefix, s.name, s.tuid, s.foundryversion > -> Nested Loop (cost=9.75..10.80 rows=1 width=167) > Join Filter: ("outer".flow = "inner".dbid) > -> Hash Join (cost=9.75..10.79 rows=1 width=171) > Hash Cond: ("outer".dbid = "inner"."schema") > -> Seq Scan on "schema" s (cost=0.00..1.02 rows=2 width=128) > -> Hash (cost=9.75..9.75 rows=1 width=51) > -> Nested Loop (cost=0.00..9.75 rows=1 width=51) > Join Filter: ("inner"."usage" = "outer".dbid) > -> Index Scan using usage_flow_i on "usage" u (cost=0.00..4.78 rows=1 width=8) > -> Index Scan using usageparameter_schema_i on usageparameter up (cost=0.00..4.96 rows=1 width=51) > Filter: ((prefix)::text <> 'xsd'::text) > -> Seq Scan on flow fl (cost=0.00..0.00 rows=1 width=4) > Filter: (servicetype = 646) > Unique (cost=11.50..11.52 rows=2 width=131) Unique (cost=10.81..10.83 rows=1 width=167) The estimations for the cost is basically the same, 10ms for the first row. Can you supply Explain analyze to see what it's actually doing? Russell Smith From pgsql-performance-owner@postgresql.org Wed Nov 17 05:31:25 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C88E13A42C0 for ; Wed, 17 Nov 2004 05:31:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30312-07 for ; Wed, 17 Nov 2004 05:31:22 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.202]) by svr1.postgresql.org (Postfix) with ESMTP id DAA493A4227 for ; Wed, 17 Nov 2004 05:31:16 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 71so371710wra for ; Tue, 16 Nov 2004 21:31:15 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=fxi5vrrv/Vcf8UgkUACDifEUOltVaaH7q/s5uW6LppMNKmsccvVpi9LF7JjcCd5E13206UmnPXu2Ftc+noH9epKI3paa1JfynGAjY0WAlxpT6D8w6E79QuxWOlc8rUvNOtz4RPO0/4rz2tjt+IcF5+vF6X4h2ghsSqzBoZW3Pko= Received: by 10.54.18.78 with SMTP id 78mr644693wrr; Tue, 16 Nov 2004 21:31:15 -0800 (PST) Received: by 10.54.52.30 with HTTP; Tue, 16 Nov 2004 21:31:15 -0800 (PST) Message-ID: <6c21003b041116213166af022d@mail.gmail.com> Date: Tue, 16 Nov 2004 23:31:15 -0600 From: Don Drake Reply-To: Don Drake To: pgsql-performance@postgresql.org Subject: Table Partitions: To Inherit Or Not To Inherit Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/238 X-Sequence-Number: 9192 I've read the previous thread on the list regarding partitioning mechanisms and I just wrote a plpgsql function to create the partition tables (by date) as well as another function used to do the insert (it determines which table will be inserted). The creation of the partition tables uses the inherits clause when creating. It creates an exact copy of the table it's inheriting from, and adds the indexes since inherits doesn't do that for me. CREATE TABLE hourly_report_data_2004_11_16 () INHERITS (hourly_report_data) When I query on the hourly_report_data, the explain plan shows it query all the tables that inherited from it. That's all great. What's really the difference between this and creating separate tables with the same column definition without the inherit, and then create a view to "merge" them together? Also, I've run into a snag in that I have a hourly_detail table, that has a foreign key to the hourly_report_data. The inherit method above does not honor the foreign key relationship to the children table of hourly_report_data. I can't insert any data into the hourly_detail table due to the constraint failing. The hourly_detail table is relatively tiny compared to the enormous hourly_report_data table, so if I don't have to partition that one I would rather not. Any suggestions on this? Thanks. -Don -- Donald Drake President Drake Consulting http://www.drakeconsult.com/ 312-560-1574 From pgsql-performance-owner@postgresql.org Wed Nov 17 05:49:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6D1BE3A41F1 for ; Wed, 17 Nov 2004 05:49:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35802-03 for ; Wed, 17 Nov 2004 05:49:07 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 7AAE53A41A3 for ; Wed, 17 Nov 2004 05:49:07 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6671944; Tue, 16 Nov 2004 21:50:37 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: memcached and PostgreSQL Date: Tue, 16 Nov 2004 21:47:54 -0800 User-Agent: KMail/1.6.2 Cc: Michael Adler References: <20041117040024.GB8838@pobox.com> In-Reply-To: <20041117040024.GB8838@pobox.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411162147.54831.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/239 X-Sequence-Number: 9193 Michael, > So What does memcached offer pgsql users? It would still seem to offer > the benefit of a multi-machined cache. Yes, and a very, very fast one too ... like, 120,000 operations per second. PostgreSQL can't match that because of the overhead of authentication, security, transaction visibility checking, etc. So memcached becomes a very good place to stick data that's read often but not updated often, or alternately data that changes often but is disposable. An example of the former is a user+ACL list; and example of the latter is web session information ... or simple materialized views. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Nov 17 05:52:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 217833A4276 for ; Wed, 17 Nov 2004 05:52:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33925-10 for ; Wed, 17 Nov 2004 05:52:26 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id F0D273A41F1 for ; Wed, 17 Nov 2004 05:52:26 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6671957; Tue, 16 Nov 2004 21:53:56 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org, Don Drake Subject: Re: Table Partitions: To Inherit Or Not To Inherit Date: Tue, 16 Nov 2004 21:51:14 -0800 User-Agent: KMail/1.6.2 References: <6c21003b041116213166af022d@mail.gmail.com> In-Reply-To: <6c21003b041116213166af022d@mail.gmail.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411162151.14693.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/240 X-Sequence-Number: 9194 Don, > What's really the difference between this and creating separate tables > with the same column definition without the inherit, and then create a > view to "merge" them together? Easier syntax for queries. If you created completely seperate tables and UNIONED them together, you'd have to be constantly modifying a VIEW which tied the tables together. With inheritance, you just do "SELECT * FROM parent_table" and it handles finding all the children for you. > Also, I've run into a snag in that I have a hourly_detail table, that > has a foreign key to the hourly_report_data. The inherit method above > does not honor the foreign key relationship to the children table of > hourly_report_data. I can't insert any data into the hourly_detail > table due to the constraint failing. This is a known limitation of inherited tables, at least in current implementations. I think it's on the TODO list. For now, either live without the FKs, or implement them through custom triggers/rules. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Nov 17 06:09:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9C9583A41DB for ; Wed, 17 Nov 2004 06:09:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38335-10 for ; Wed, 17 Nov 2004 06:09:02 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 5E1F13A41A3 for ; Wed, 17 Nov 2004 06:09:02 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6672005; Tue, 16 Nov 2004 22:10:32 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org, Alexandre Leclerc Subject: Re: nuderstanding 'explain analyse' Date: Tue, 16 Nov 2004 22:07:50 -0800 User-Agent: KMail/1.6.2 References: <1dc7f0e304111613116532a64b@mail.gmail.com> In-Reply-To: <1dc7f0e304111613116532a64b@mail.gmail.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411162207.50341.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/241 X-Sequence-Number: 9195 Alexandre, > If the plans for both queries are exactly the same, should I assume > that the cost will also be the same? Nope. A seq scan over 1,000,000,000 rows is going to cost a LOT more than a seq scan over 1000 rows, even though it's the same plan. When you have the data sorted out, post explain analyzes and we'll take a shot at it. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Nov 17 06:41:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4FACD3A4260 for ; Wed, 17 Nov 2004 06:41:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47528-04 for ; Wed, 17 Nov 2004 06:40:54 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id 1E5973A41DB for ; Wed, 17 Nov 2004 06:40:54 +0000 (GMT) Received: from [192.168.1.20] (clbb-248.saw.net [64.146.135.248]) (authenticated bits=0) by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id iAH6erf2022376; Tue, 16 Nov 2004 22:40:53 -0800 Message-ID: <419AF247.90209@commandprompt.com> Date: Tue, 16 Nov 2004 22:40:07 -0800 From: "Joshua D. Drake" User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Parker Cc: pgsql-performance@postgresql.org Subject: Re: query plan question References: <07FDEE0ED7455A48AC42AC2070EDFF7C26B972@corpsrv2.tazznetworks.com> In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C26B972@corpsrv2.tazznetworks.com> Content-Type: multipart/mixed; boundary="------------090707030805050401020009" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/242 X-Sequence-Number: 9196 This is a multi-part message in MIME format. --------------090707030805050401020009 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit David Parker wrote: >I have a query for which postgres is generating a different plan on different machines. The database schema is the same, the dataset is the same, the configuration is the same (e.g., pg_autovacuum running in both cases), both systems are Solaris 9. The main difference in the two systems is that one is sparc and the other is intel. > >The query runs in about 40 ms on the intel box, but takes about 18 seconds on the sparc box. Now, the intel boxes we have are certainly faster, but I'm curious why the query plan might be different. > > If they are the same and PostgreSQL are the same, are the intel machines Xeons? Sincerely, Joshua D. Drake >For the intel: > >QUERY PLAN >Unique (cost=11.50..11.52 rows=2 width=131) > -> Sort (cost=11.50..11.50 rows=2 width=131) > Sort Key: up.prefix, s.name, s.tuid, s.foundryversion > -> Hash Join (cost=10.42..11.49 rows=2 width=131) > Hash Cond: ("outer".dbid = "inner"."schema") > -> Seq Scan on "schema" s (cost=0.00..1.02 rows=2 width=128) > -> Hash (cost=10.41..10.41 rows=4 width=11) > -> Nested Loop (cost=0.00..10.41 rows=4 width=11) > -> Nested Loop (cost=0.00..2.14 rows=4 width=4) > -> Seq Scan on flow fl (cost=0.00..0.00 rows=1 width=4) > Filter: (servicetype = 646) > -> Index Scan using usage_flow_i on "usage" u (cost=0.00..2.06 rows=6 width=8) > Index Cond: (u.flow = "outer".dbid) > -> Index Scan using usageparameter_usage_i on usageparameter up (cost=0.00..2.06 rows=1 width=15) > Index Cond: (up."usage" = "outer".dbid) > Filter: ((prefix)::text <> 'xsd'::text) > >For the sparc: > >QUERY PLAN >Unique (cost=10.81..10.83 rows=1 width=167) > -> Sort (cost=10.81..10.82 rows=1 width=167) > Sort Key: up.prefix, s.name, s.tuid, s.foundryversion > -> Nested Loop (cost=9.75..10.80 rows=1 width=167) > Join Filter: ("outer".flow = "inner".dbid) > -> Hash Join (cost=9.75..10.79 rows=1 width=171) > Hash Cond: ("outer".dbid = "inner"."schema") > -> Seq Scan on "schema" s (cost=0.00..1.02 rows=2 width=128) > -> Hash (cost=9.75..9.75 rows=1 width=51) > -> Nested Loop (cost=0.00..9.75 rows=1 width=51) > Join Filter: ("inner"."usage" = "outer".dbid) > -> Index Scan using usage_flow_i on "usage" u (cost=0.00..4.78 rows=1 width=8) > -> Index Scan using usageparameter_schema_i on usageparameter up (cost=0.00..4.96 rows=1 width=51) > Filter: ((prefix)::text <> 'xsd'::text) > -> Seq Scan on flow fl (cost=0.00..0.00 rows=1 width=4) > Filter: (servicetype = 646) > >I assume the problem with the second plan starts with doing a Nested Loop rather than a Hash Join at the 4th line of the plan, but I don't know why it would be different for the same schema, same dataset. > >What factors go into the planner's decision to choose a nested loop over a hash join? Should I be looking at adjusting my runtime configuration on the sparc box somehow? > >Thanks. > >- DAP >---------------------------------------------------------------------------------- >David Parker Tazz Networks (401) 709-5130 > > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster > > -- Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC Postgresql support, programming shared hosting and dedicated hosting. +1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com PostgreSQL Replicator -- production quality replication for PostgreSQL --------------090707030805050401020009 Content-Type: text/x-vcard; charset=utf-8; name="jd.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jd.vcf" begin:vcard fn:Joshua Drake n:Drake;Joshua org:Command Prompt, Inc. adr:;;PO Box 215 ;Cascade Locks;OR;97014;US email;internet:jd@commandprompt.com title:Consultant tel;work:503-667-4564 tel;fax:503-210-0334 x-mozilla-html:FALSE url:http://www.commandprompt.com version:2.1 end:vcard --------------090707030805050401020009-- From pgsql-performance-owner@postgresql.org Wed Nov 17 07:48:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C30783A42C1 for ; Wed, 17 Nov 2004 07:48:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62480-08 for ; Wed, 17 Nov 2004 07:48:38 +0000 (GMT) Received: from main.gmane.org (main.gmane.org [80.91.229.2]) by svr1.postgresql.org (Postfix) with ESMTP id 162003A41AB for ; Wed, 17 Nov 2004 07:48:38 +0000 (GMT) Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1CUKYO-0004CS-00 for ; Wed, 17 Nov 2004 08:48:36 +0100 Received: from 62.79.119.132.adsl.vbr.tiscali.dk ([62.79.119.132]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 17 Nov 2004 08:48:36 +0100 Received: from troels by 62.79.119.132.adsl.vbr.tiscali.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 17 Nov 2004 08:48:36 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-performance@postgresql.org From: Troels Arvin Subject: Re: memcached and PostgreSQL Date: Wed, 17 Nov 2004 08:48:33 +0100 Lines: 28 Message-ID: References: <20041117040024.GB8838@pobox.com> <200411162147.54831.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 62.79.119.132.adsl.vbr.tiscali.dk User-Agent: Pan/0.14.2.91 (As She Crawled Across the Table) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/243 X-Sequence-Number: 9197 On Tue, 16 Nov 2004 21:47:54 -0800, Josh Berkus wrote: > So memcached becomes a very good place to stick data that's read often but not > updated often, or alternately data that changes often but is disposable. An > example of the former is a user+ACL list; and example of the latter is web > session information ... or simple materialized views. Has anyone tried at least two of 1. memcached 2. Tugela Cache (pretty much the same as memcached, I think) 3. Sharedance In that case: Do you have any comparative remarks? Links: 1: http://www.danga.com/memcached/ 2: http://meta.wikimedia.org/wiki/Tugela_Cache http://cvs.sourceforge.net/viewcvs.py/wikipedia/tugelacache/ 3: http://sharedance.pureftpd.org/ -- Greetings from Troels Arvin, Copenhagen, Denmark From pgsql-performance-owner@postgresql.org Wed Nov 17 08:08:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4CDA43A4317 for ; Wed, 17 Nov 2004 08:08:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67069-10 for ; Wed, 17 Nov 2004 08:08:29 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id 1D8973A42C1 for ; Wed, 17 Nov 2004 08:08:30 +0000 (GMT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1CUKrV-0002XC-00; Wed, 17 Nov 2004 03:08:21 -0500 To: Josh Berkus Cc: pgsql-performance@postgresql.org, Michael Adler Subject: Re: memcached and PostgreSQL References: <20041117040024.GB8838@pobox.com> <200411162147.54831.josh@agliodbs.com> In-Reply-To: <200411162147.54831.josh@agliodbs.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 17 Nov 2004 03:08:20 -0500 Message-ID: <87y8h06gp7.fsf@stark.xeocode.com> Lines: 17 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/244 X-Sequence-Number: 9198 Josh Berkus writes: > So memcached becomes a very good place to stick data that's read often but not > updated often, or alternately data that changes often but is disposable. An > example of the former is a user+ACL list; and example of the latter is web > session information ... or simple materialized views. I would like very much to use something like memcached for a materialized view I have. The problem is that I have to join it against other tables. I've thought about providing a SRF in postgres to read records out of memcached but I'm unclear it would it really help at all. Has anyone tried anything like this? -- greg From pgsql-performance-owner@postgresql.org Wed Nov 17 08:19:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DAE743A42B9 for ; Wed, 17 Nov 2004 08:19:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72961-02 for ; Wed, 17 Nov 2004 08:19:10 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id B14723A41EA for ; Wed, 17 Nov 2004 08:19:08 +0000 (GMT) Received: (qmail 20076 invoked by uid 1112); 17 Nov 2004 08:19:39 -0000 Date: Wed, 17 Nov 2004 03:19:39 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Simon Riggs Cc: pgsql-performance@postgresql.org Subject: Re: mis-estimation on data-warehouse aggregate creation In-Reply-To: <1100640596.4113.5680.camel@localhost.localdomain> Message-ID: References: <1100640596.4113.5680.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/245 X-Sequence-Number: 9199 On Tue, 16 Nov 2004, Simon Riggs wrote: > The join condition has so many ANDed predicates that we assume that this > will reduce the selectivity considerably. It does not, and so you pay > the cost dearly later on. > Yes, that makes a lot of sense. Without some incredibly good cross-column statistics there is no way it could expect all of the rows to match. Thanks for the analysis. Kris Jurka From pgsql-performance-owner@postgresql.org Wed Nov 17 12:33:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A3A473A3D00 for ; Wed, 17 Nov 2004 12:33:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45096-09 for ; Wed, 17 Nov 2004 12:32:55 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id 59B343A3E90 for ; Wed, 17 Nov 2004 12:32:56 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C4CCA1.9061FBD4" Subject: Re: query plan question Date: Wed, 17 Nov 2004 07:32:55 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26B991@corpsrv2.tazznetworks.com> X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] query plan question Thread-Index: AcTMYAKbsl/HzNm2SMeYLdCP5CzBMwAQRIdg From: "David Parker" To: "Russell Smith" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/246 X-Sequence-Number: 9200 This is a multi-part message in MIME format. ------_=_NextPart_001_01C4CCA1.9061FBD4 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Oh, I didn't realize that analyze gave that much more info. I've got a lot to learn about this tuning stuff ;-)=20 I've attached the output. I see from the new output where the slow query is taking its time (the nested loop at line 10), but I still have no idea why this plan is getting chosen.... Thanks! - DAP >-----Original Message----- >From: pgsql-performance-owner@postgresql.org=20 >[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of=20 >Russell Smith >Sent: Tuesday, November 16, 2004 11:36 PM >To: pgsql-performance@postgresql.org >Subject: Re: [PERFORM] query plan question > >On Wed, 17 Nov 2004 02:54 pm, you wrote: >> I have a query for which postgres is generating a different=20 >plan on different machines. The database schema is the same,=20 >the dataset is the same, the configuration is the same (e.g.,=20 >pg_autovacuum running in both cases), both systems are Solaris=20 >9. The main difference in the two systems is that one is sparc=20 >and the other is intel. >>=20 >> The query runs in about 40 ms on the intel box, but takes=20 >about 18 seconds on the sparc box. Now, the intel boxes we=20 >have are certainly faster, but I'm curious why the query plan=20 >might be different. >>=20 >> For the intel: >>=20 >> QUERY PLAN >> Unique (cost=3D11.50..11.52 rows=3D2 width=3D131) >> -> Sort (cost=3D11.50..11.50 rows=3D2 width=3D131) >> Sort Key: up.prefix, s.name, s.tuid, s.foundryversion >> -> Hash Join (cost=3D10.42..11.49 rows=3D2 width=3D131) >> Hash Cond: ("outer".dbid =3D "inner"."schema") >> -> Seq Scan on "schema" s (cost=3D0.00..1.02=20 >rows=3D2 width=3D128) >> -> Hash (cost=3D10.41..10.41 rows=3D4 width=3D11) >> -> Nested Loop (cost=3D0.00..10.41=20 >rows=3D4 width=3D11) >> -> Nested Loop (cost=3D0.00..2.14=20 >rows=3D4 width=3D4) >> -> Seq Scan on flow fl =20 >(cost=3D0.00..0.00 rows=3D1 width=3D4) >> Filter: (servicetype =3D 646) >> -> Index Scan using=20 >usage_flow_i on "usage" u (cost=3D0.00..2.06 rows=3D6 width=3D8) >> Index Cond: (u.flow =3D=20 >"outer".dbid) >> -> Index Scan using=20 >usageparameter_usage_i on usageparameter up (cost=3D0.00..2.06=20 >rows=3D1 width=3D15) >> Index Cond: (up."usage" =3D=20 >"outer".dbid) >> Filter: ((prefix)::text <>=20 >> 'xsd'::text) >>=20 >> For the sparc: >>=20 >> QUERY PLAN >> Unique (cost=3D10.81..10.83 rows=3D1 width=3D167) >> -> Sort (cost=3D10.81..10.82 rows=3D1 width=3D167) >> Sort Key: up.prefix, s.name, s.tuid, s.foundryversion >> -> Nested Loop (cost=3D9.75..10.80 rows=3D1 width=3D167) >> Join Filter: ("outer".flow =3D "inner".dbid) >> -> Hash Join (cost=3D9.75..10.79 rows=3D1 = width=3D171) >> Hash Cond: ("outer".dbid =3D "inner"."schema") >> -> Seq Scan on "schema" s =20 >(cost=3D0.00..1.02 rows=3D2 width=3D128) >> -> Hash (cost=3D9.75..9.75 rows=3D1 width=3D51) >> -> Nested Loop (cost=3D0.00..9.75=20 >rows=3D1 width=3D51) >> Join Filter:=20 >("inner"."usage" =3D "outer".dbid) >> -> Index Scan using=20 >usage_flow_i on "usage" u (cost=3D0.00..4.78 rows=3D1 width=3D8) >> -> Index Scan using=20 >usageparameter_schema_i on usageparameter up (cost=3D0.00..4.96=20 >rows=3D1 width=3D51) >> Filter:=20 >((prefix)::text <> 'xsd'::text) >> -> Seq Scan on flow fl (cost=3D0.00..0.00=20 >rows=3D1 width=3D4) >> Filter: (servicetype =3D 646) >>=20 >Unique (cost=3D11.50..11.52 rows=3D2 width=3D131) Unique =20 >(cost=3D10.81..10.83 rows=3D1 width=3D167) > >The estimations for the cost is basically the same, 10ms for=20 >the first row. Can you supply Explain analyze to see what=20 >it's actually doing? > >Russell Smith > >---------------------------(end of=20 >broadcast)--------------------------- >TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > ------_=_NextPart_001_01C4CCA1.9061FBD4 Content-Type: text/plain; name="sparcl-plan-analyze.txt" Content-Transfer-Encoding: base64 Content-Description: sparcl-plan-analyze.txt Content-Disposition: attachment; filename="sparcl-plan-analyze.txt" UVVFUlkgUExBTg0KIlVuaXF1ZSAgKGNvc3Q9MTAuODEuLjEwLjgzIHJvd3M9MSB3aWR0aD0xNjcp IChhY3R1YWwgdGltZT0xOTM5MC42ODQuLjE5MzkwLjY4NyByb3dzPTEgbG9vcHM9MSkiDQoiICAt PiAgU29ydCAgKGNvc3Q9MTAuODEuLjEwLjgyIHJvd3M9MSB3aWR0aD0xNjcpIChhY3R1YWwgdGlt ZT0xOTM5MC42NzguLjE5MzkwLjY3OSByb3dzPTEgbG9vcHM9MSkiDQoiICAgICAgICBTb3J0IEtl eTogdXAucHJlZml4LCBzLm5hbWUsIHMudHVpZCwgcy5mb3VuZHJ5dmVyc2lvbiINCiIgICAgICAg IC0+ICBOZXN0ZWQgTG9vcCAgKGNvc3Q9OS43NS4uMTAuODAgcm93cz0xIHdpZHRoPTE2NykgKGFj dHVhbCB0aW1lPTE5Mzc3LjA1MS4uMTkzOTAuMzkxIHJvd3M9MSBsb29wcz0xKSINCiIgICAgICAg ICAgICAgIEpvaW4gRmlsdGVyOiAoIm91dGVyIi5mbG93ID0gImlubmVyIi5kYmlkKSINCiIgICAg ICAgICAgICAgIC0+ICBIYXNoIEpvaW4gIChjb3N0PTkuNzUuLjEwLjc5IHJvd3M9MSB3aWR0aD0x NzEpIChhY3R1YWwgdGltZT0xOTE3My42ODQuLjE5MTgxLjgyNyByb3dzPTc3MCBsb29wcz0xKSIN CiIgICAgICAgICAgICAgICAgICAgIEhhc2ggQ29uZDogKCJvdXRlciIuZGJpZCA9ICJpbm5lciIu InNjaGVtYSIpIg0KIiAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9uICJzY2hlbWEi IHMgIChjb3N0PTAuMDAuLjEuMDIgcm93cz0yIHdpZHRoPTEyOCkgKGFjdHVhbCB0aW1lPTAuMjQw Li4wLjY5MyByb3dzPTIwIGxvb3BzPTEpIg0KIiAgICAgICAgICAgICAgICAgICAgLT4gIEhhc2gg IChjb3N0PTkuNzUuLjkuNzUgcm93cz0xIHdpZHRoPTUxKSAoYWN0dWFsIHRpbWU9MTkxNzMuMzU0 Li4xOTE3My4zNTQgcm93cz0wIGxvb3BzPTEpIg0KIiAgICAgICAgICAgICAgICAgICAgICAgICAg LT4gIE5lc3RlZCBMb29wICAoY29zdD0wLjAwLi45Ljc1IHJvd3M9MSB3aWR0aD01MSkgKGFjdHVh bCB0aW1lPTMwLjQ1Ni4uMTkxNjYuNzU5IHJvd3M9NzcwIGxvb3BzPTEpIg0KIiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgSm9pbiBGaWx0ZXI6ICgiaW5uZXIiLiJ1c2FnZSIgPSAib3V0 ZXIiLmRiaWQpIg0KIiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEluZGV4IFNj YW4gdXNpbmcgdXNhZ2VfZmxvd19pIG9uICJ1c2FnZSIgdSAgKGNvc3Q9MC4wMC4uNC43OCByb3dz PTEgd2lkdGg9OCkgKGFjdHVhbCB0aW1lPTAuNTkzLi45LjU3NiByb3dzPTc3MSBsb29wcz0xKSIN CiIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBJbmRleCBTY2FuIHVzaW5nIHVz YWdlcGFyYW1ldGVyX3NjaGVtYV9pIG9uIHVzYWdlcGFyYW1ldGVyIHVwICAoY29zdD0wLjAwLi40 Ljk2IHJvd3M9MSB3aWR0aD01MSkgKGFjdHVhbCB0aW1lPTE2LjE3MS4uMjIuNDExIHJvd3M9Nzcw IGxvb3BzPTc3MSkiDQoiICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGaWx0 ZXI6ICgocHJlZml4KTo6dGV4dCA8PiAneHNkJzo6dGV4dCkiDQoiICAgICAgICAgICAgICAtPiAg U2VxIFNjYW4gb24gZmxvdyBmbCAgKGNvc3Q9MC4wMC4uMC4wMCByb3dzPTEgd2lkdGg9NCkgKGFj dHVhbCB0aW1lPTAuMDA3Li4wLjI2MCByb3dzPTEgbG9vcHM9NzcwKSINCiIgICAgICAgICAgICAg ICAgICAgIEZpbHRlcjogKHNlcnZpY2V0eXBlID0gNjQ2KSINCiJUb3RhbCBydW50aW1lOiAxOTM5 MS4xNzMgbXMiDQo= ------_=_NextPart_001_01C4CCA1.9061FBD4 Content-Type: text/plain; name="intel-plan-analyze.txt" Content-Transfer-Encoding: base64 Content-Description: intel-plan-analyze.txt Content-Disposition: attachment; filename="intel-plan-analyze.txt" UVVFUlkgUExBTg0KIlVuaXF1ZSAgKGNvc3Q9MTEuNTAuLjExLjUyIHJvd3M9MiB3aWR0aD0xMzEp IChhY3R1YWwgdGltZT0wLjcyNC4uMC43Mjcgcm93cz0xIGxvb3BzPTEpIg0KIiAgLT4gIFNvcnQg IChjb3N0PTExLjUwLi4xMS41MCByb3dzPTIgd2lkdGg9MTMxKSAoYWN0dWFsIHRpbWU9MC43MjIu LjAuNzIzIHJvd3M9MSBsb29wcz0xKSINCiIgICAgICAgIFNvcnQgS2V5OiB1cC5wcmVmaXgsIHMu bmFtZSwgcy50dWlkLCBzLmZvdW5kcnl2ZXJzaW9uIg0KIiAgICAgICAgLT4gIEhhc2ggSm9pbiAg KGNvc3Q9MTAuNDIuLjExLjQ5IHJvd3M9MiB3aWR0aD0xMzEpIChhY3R1YWwgdGltZT0wLjU1MS4u MC42NzAgcm93cz0xIGxvb3BzPTEpIg0KIiAgICAgICAgICAgICAgSGFzaCBDb25kOiAoIm91dGVy Ii5kYmlkID0gImlubmVyIi4ic2NoZW1hIikiDQoiICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4g b24gInNjaGVtYSIgcyAgKGNvc3Q9MC4wMC4uMS4wMiByb3dzPTIgd2lkdGg9MTI4KSAoYWN0dWFs IHRpbWU9MC4wMjcuLjAuMTI5IHJvd3M9MjAgbG9vcHM9MSkiDQoiICAgICAgICAgICAgICAtPiAg SGFzaCAgKGNvc3Q9MTAuNDEuLjEwLjQxIHJvd3M9NCB3aWR0aD0xMSkgKGFjdHVhbCB0aW1lPTAu NDc4Li4wLjQ3OCByb3dzPTAgbG9vcHM9MSkiDQoiICAgICAgICAgICAgICAgICAgICAtPiAgTmVz dGVkIExvb3AgIChjb3N0PTAuMDAuLjEwLjQxIHJvd3M9NCB3aWR0aD0xMSkgKGFjdHVhbCB0aW1l PTAuMzU1Li4wLjQ1NSByb3dzPTEgbG9vcHM9MSkiDQoiICAgICAgICAgICAgICAgICAgICAgICAg ICAtPiAgTmVzdGVkIExvb3AgIChjb3N0PTAuMDAuLjIuMTQgcm93cz00IHdpZHRoPTQpIChhY3R1 YWwgdGltZT0wLjE3OS4uMC4yNDkgcm93cz0zIGxvb3BzPTEpIg0KIiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIGZsb3cgZmwgIChjb3N0PTAuMDAuLjAuMDAg cm93cz0xIHdpZHRoPTQpIChhY3R1YWwgdGltZT0wLjA1Ny4uMC4xMTIgcm93cz0xIGxvb3BzPTEp Ig0KIiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRmlsdGVyOiAoc2Vydmlj ZXR5cGUgPSA2NDYpIg0KIiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEluZGV4 IFNjYW4gdXNpbmcgdXNhZ2VfZmxvd19pIG9uICJ1c2FnZSIgdSAgKGNvc3Q9MC4wMC4uMi4wNiBy b3dzPTYgd2lkdGg9OCkgKGFjdHVhbCB0aW1lPTAuMTE1Li4wLjEyMSByb3dzPTMgbG9vcHM9MSki DQoiICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmRleCBDb25kOiAodS5m bG93ID0gIm91dGVyIi5kYmlkKSINCiIgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBJbmRl eCBTY2FuIHVzaW5nIHVzYWdlcGFyYW1ldGVyX3VzYWdlX2kgb24gdXNhZ2VwYXJhbWV0ZXIgdXAg IChjb3N0PTAuMDAuLjIuMDYgcm93cz0xIHdpZHRoPTE1KSAoYWN0dWFsIHRpbWU9MC4wNDQuLjAu MDQ2IHJvd3M9MCBsb29wcz0zKSINCiIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIElu ZGV4IENvbmQ6ICh1cC4idXNhZ2UiID0gIm91dGVyIi5kYmlkKSINCiIgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIEZpbHRlcjogKChwcmVmaXgpOjp0ZXh0IDw+ICd4c2QnOjp0ZXh0KSIN CiJUb3RhbCBydW50aW1lOiAwLjg0MiBtcyINCg== ------_=_NextPart_001_01C4CCA1.9061FBD4-- From pgsql-performance-owner@postgresql.org Wed Nov 17 13:09:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4A8503A3D69 for ; Wed, 17 Nov 2004 13:08:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56492-04 for ; Wed, 17 Nov 2004 13:08:41 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id 4A3DB3A3C47 for ; Wed, 17 Nov 2004 13:08:43 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: query plan question Date: Wed, 17 Nov 2004 08:08:43 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26B995@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] query plan question Thread-Index: AcTMcGSIN8CCH13lTLKrAQMf17Pb5wANdt6A From: "David Parker" To: "Joshua D. Drake" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/247 X-Sequence-Number: 9201 >If they are the same and PostgreSQL are the same, are the=20 >intel machines Xeons? Yup, dual 3.06-GHz Intel Xeon Processors. I'm not sure off the top of my head what the sparcs are exactly. We're in the process of moving completely to intel, but we still have to support our app on sparc, and we are seeing these weird differences... - DAP From pgsql-performance-owner@postgresql.org Wed Nov 17 14:00:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0F06B3A3F11 for ; Wed, 17 Nov 2004 14:00:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72319-09 for ; Wed, 17 Nov 2004 14:00:30 +0000 (GMT) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id E1ABF3A3F15 for ; Wed, 17 Nov 2004 14:00:31 +0000 (GMT) Received: (qmail 27386 invoked from network); 17 Nov 2004 13:01:14 -0000 Received: from dhcp-7-195.ma.lycos.com (HELO ?10.124.7.195?) (10.124.7.195) by dhcp-7-248.ma.lycos.com with SMTP; 17 Nov 2004 13:01:14 -0000 In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C26B991@corpsrv2.tazznetworks.com> References: <07FDEE0ED7455A48AC42AC2070EDFF7C26B991@corpsrv2.tazznetworks.com> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <11A038F0-38A1-11D9-B5CC-000D9366F0C4@torgo.978.org> Content-Transfer-Encoding: 7bit Cc: "Russell Smith" , From: Jeff Subject: Re: query plan question Date: Wed, 17 Nov 2004 09:00:42 -0500 To: "David Parker" X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/248 X-Sequence-Number: 9202 On Nov 17, 2004, at 7:32 AM, David Parker wrote: > Oh, I didn't realize that analyze gave that much more info. I've got a > lot to learn about this tuning stuff ;-) > > I've attached the output. I see from the new output where the slow > query > is taking its time (the nested loop at line 10), but I still have no > idea why this plan is getting chosen.... > looks like your stats are incorrect on the sparc. Did you forget to run vacuum analyze on it? also, do both db's have the same data loaded? there are some very different numbers in terms of actual rows floating around there... -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Nov 17 14:43:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1E65B3A3EEB for ; Wed, 17 Nov 2004 14:43:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88475-08 for ; Wed, 17 Nov 2004 14:43:36 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id BBC643A3ECA for ; Wed, 17 Nov 2004 14:43:39 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: query plan question Date: Wed, 17 Nov 2004 09:43:39 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26B9AF@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] query plan question Thread-Index: AcTMrc33mNw9DvEBTlqTixKvSU5xjwAA67xA From: "David Parker" To: "Jeff" Cc: "Russell Smith" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/249 X-Sequence-Number: 9203 I've got pg_autovacuum running on both platforms. I've verified that the tables involved in the query have the same number of rows on both databases. I'm not sure where to look to see how the stats might be different. The "good" database's pg_statistic table has 24 more rows than that in the "bad" database, so there's definitely a difference. The good database's pg_statistic has rows for 2 extra tables, but they are not tables involved in the query in question... So something must be up with stats, but can you tell me what the most signicant columns in the pg_statistic table are for the planner making its decision? I'm sure this has been discussed before, so if there's a thread you can point me to, that would be great - I realize it's a big general question. Thanks for your time. - DAP >-----Original Message----- >From: Jeff [mailto:threshar@torgo.978.org]=20 >Sent: Wednesday, November 17, 2004 9:01 AM >To: David Parker >Cc: Russell Smith; pgsql-performance@postgresql.org >Subject: Re: [PERFORM] query plan question > > >On Nov 17, 2004, at 7:32 AM, David Parker wrote: > >> Oh, I didn't realize that analyze gave that much more info.=20 >I've got a=20 >> lot to learn about this tuning stuff ;-) >> >> I've attached the output. I see from the new output where the slow=20 >> query is taking its time (the nested loop at line 10), but I still=20 >> have no idea why this plan is getting chosen.... >> > >looks like your stats are incorrect on the sparc. >Did you forget to run vacuum analyze on it? > >also, do both db's have the same data loaded? >there are some very different numbers in terms of actual rows floating=20 >around there... > >-- >Jeff Trout >http://www.jefftrout.com/ >http://www.stuarthamm.net/ > > From pgsql-performance-owner@postgresql.org Wed Nov 17 15:06:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6A8603A4030 for ; Wed, 17 Nov 2004 15:06:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97532-03 for ; Wed, 17 Nov 2004 15:06:11 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id AA2A33A3F58 for ; Wed, 17 Nov 2004 15:06:13 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: query plan question Date: Wed, 17 Nov 2004 10:06:13 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26B9C4@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] query plan question Thread-Index: AcTMrc33mNw9DvEBTlqTixKvSU5xjwAA67xAAAFI4pA= From: "David Parker" To: "David Parker" , "Jeff" Cc: "Russell Smith" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/250 X-Sequence-Number: 9204 Hmm, I'm really a beginner at this... It turns out that the pg_statistic table in my good database has records in it for the tables in the query, while the pg_statistic table in my bad database has no records for those tables at all! So I guess I need to figure out why pg_autovacuum isn't analyzing those tables. - DAP=20 >-----Original Message----- >From: David Parker=20 >Sent: Wednesday, November 17, 2004 9:44 AM >To: 'Jeff' >Cc: Russell Smith; pgsql-performance@postgresql.org >Subject: RE: [PERFORM] query plan question > >I've got pg_autovacuum running on both platforms. I've=20 >verified that the tables involved in the query have the same=20 >number of rows on both databases. > >I'm not sure where to look to see how the stats might be=20 >different. The "good" database's pg_statistic table has 24=20 >more rows than that in the "bad" database, so there's=20 >definitely a difference. The good database's pg_statistic has=20 >rows for 2 extra tables, but they are not tables involved in=20 >the query in question... > >So something must be up with stats, but can you tell me what=20 >the most signicant columns in the pg_statistic table are for=20 >the planner making its decision? I'm sure this has been=20 >discussed before, so if there's a thread you can point me to,=20 >that would be great - I realize it's a big general question. > >Thanks for your time. > >- DAP > >>-----Original Message----- >>From: Jeff [mailto:threshar@torgo.978.org] >>Sent: Wednesday, November 17, 2004 9:01 AM >>To: David Parker >>Cc: Russell Smith; pgsql-performance@postgresql.org >>Subject: Re: [PERFORM] query plan question >> >> >>On Nov 17, 2004, at 7:32 AM, David Parker wrote: >> >>> Oh, I didn't realize that analyze gave that much more info.=20 >>I've got a >>> lot to learn about this tuning stuff ;-) >>> >>> I've attached the output. I see from the new output where the slow=20 >>> query is taking its time (the nested loop at line 10), but I still=20 >>> have no idea why this plan is getting chosen.... >>> >> >>looks like your stats are incorrect on the sparc. >>Did you forget to run vacuum analyze on it? >> >>also, do both db's have the same data loaded? >>there are some very different numbers in terms of actual rows=20 >floating=20 >>around there... >> >>-- >>Jeff Trout >>http://www.jefftrout.com/ >>http://www.stuarthamm.net/ >> >> From pgsql-performance-owner@postgresql.org Wed Nov 17 15:46:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8718D3A40A4 for ; Wed, 17 Nov 2004 15:46:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09301-10 for ; Wed, 17 Nov 2004 15:46:27 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 32E623A402C for ; Wed, 17 Nov 2004 15:46:31 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAHFkQlP016084; Wed, 17 Nov 2004 10:46:27 -0500 (EST) To: "David Parker" Cc: "Jeff" , "Russell Smith" , pgsql-performance@postgresql.org Subject: Re: query plan question In-reply-to: <07FDEE0ED7455A48AC42AC2070EDFF7C26B9C4@corpsrv2.tazznetworks.com> References: <07FDEE0ED7455A48AC42AC2070EDFF7C26B9C4@corpsrv2.tazznetworks.com> Comments: In-reply-to "David Parker" message dated "Wed, 17 Nov 2004 10:06:13 -0500" Date: Wed, 17 Nov 2004 10:46:26 -0500 Message-ID: <16083.1100706386@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/251 X-Sequence-Number: 9205 "David Parker" writes: > So I guess I need to figure out why pg_autovacuum isn't analyzing those > tables. Which autovacuum version are you using? The early releases had some nasty bugs that would allow it to skip tables sometimes. I think all the known problems are fixed as of recent 7.4.x updates. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 17 15:59:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 18C563A4039 for ; Wed, 17 Nov 2004 15:59:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16782-04 for ; Wed, 17 Nov 2004 15:59:47 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id AC5BF3A3D61 for ; Wed, 17 Nov 2004 15:59:45 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: query plan question Date: Wed, 17 Nov 2004 10:59:44 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26B9D5@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] query plan question Thread-Index: AcTMvJ3G7jtoHBKjQampGrNS+oSsqQAAXzJg From: "David Parker" To: "Tom Lane" Cc: "Jeff" , "Russell Smith" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/252 X-Sequence-Number: 9206 We're using postgresql 7.4.5. I've only recently put pg_autovacuum in place as part of our installation, and I'm basically taking the defaults. I doubt it's a problem with autovacuum itself, but rather with my configuration of it. I have some reading to do, so any pointers to existing autovacuum threads would be greatly appreciated! Thanks. - DAP >-----Original Message----- >From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 >Sent: Wednesday, November 17, 2004 10:46 AM >To: David Parker >Cc: Jeff; Russell Smith; pgsql-performance@postgresql.org >Subject: Re: [PERFORM] query plan question=20 > >"David Parker" writes: >> So I guess I need to figure out why pg_autovacuum isn't analyzing=20 >> those tables. > >Which autovacuum version are you using? The early releases=20 >had some nasty bugs that would allow it to skip tables=20 >sometimes. I think all the known problems are fixed as of=20 >recent 7.4.x updates. > > regards, tom lane > From pgsql-performance-owner@postgresql.org Wed Nov 17 16:18:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A7C1D3A3D61 for ; Wed, 17 Nov 2004 16:18:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 21619-07 for ; Wed, 17 Nov 2004 16:18:04 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.205]) by svr1.postgresql.org (Postfix) with ESMTP id CDF743A4179 for ; Wed, 17 Nov 2004 16:18:02 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a36so901829rnf for ; Wed, 17 Nov 2004 08:18:02 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=dMrsVE3hgX0D4/YrHdVroYpORmqpNw6urvWFc7tclbeBncguuLwvEhiSuY8gsPbEVpYPB6ZEGLXEqpInSljnIGKZbKeR56QXxOSRpL70qWi1ixCBwf5nTIS00hE5NmFX+BqQJ9sHZv2HSxsxPqZ13FcMag97f38SdzNNTbl75jo= Received: by 10.38.82.27 with SMTP id f27mr535630rnb; Wed, 17 Nov 2004 08:18:02 -0800 (PST) Received: by 10.38.126.17 with HTTP; Wed, 17 Nov 2004 08:18:02 -0800 (PST) Message-ID: Date: Wed, 17 Nov 2004 11:18:02 -0500 From: Mike Rylander Reply-To: Mike Rylander To: Greg Stark Subject: Re: memcached and PostgreSQL Cc: pgsql-performance@postgresql.org In-Reply-To: <87y8h06gp7.fsf@stark.xeocode.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20041117040024.GB8838@pobox.com> <200411162147.54831.josh@agliodbs.com> <87y8h06gp7.fsf@stark.xeocode.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/254 X-Sequence-Number: 9208 On 17 Nov 2004 03:08:20 -0500, Greg Stark wrote: > Josh Berkus writes: > > > So memcached becomes a very good place to stick data that's read often but not > > updated often, or alternately data that changes often but is disposable. An > > example of the former is a user+ACL list; and example of the latter is web > > session information ... or simple materialized views. > > I would like very much to use something like memcached for a materialized view > I have. The problem is that I have to join it against other tables. > > I've thought about providing a SRF in postgres to read records out of > memcached but I'm unclear it would it really help at all. > > Has anyone tried anything like this? I haven't tried it yet, but I plan too. An intersting case might be to use plperlu to interface with memcached and store hashes in the cache via some external process, like a CGI script. Then just define a TYPE for the perl SRF to return, and store the data as an array of hashes with keys matching the TYPE. A (perhaps useless) example could then be something like: CREATE TYPE user_info AS ( sessionid TEXT, userid INT, lastaccess TIMESTAMP, lastrequest TEXT); CREATE FUNCTION get_user_info_by_session ( TEXT) RETURNS SETOF user_info AS $$ use Cache::Memcached; my $session = shift; my $c = $_SHARED{memcached} || Cache::Memcached->new( {servers => '127.0.0.1:1111'} ); my $user_info = $m->get('web_access_list'); # $user_info looks like # [ {userid => 5, lastrequest => 'http://...', lastaccess => localtime(), # sessionid => '123456789'}, { ...} ] # and is stored by a CGI. @info = grep {$$_{sessionid} eq $session} @$user_info; return \@info; $$ LANGUAGE 'plperlu'; SELECT u.username, f.lastrequest FROM users u, get_user_info_by_session('123456789') WHERE f.userid = u.userid; Any thoughts? > > -- > greg > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html > -- Mike Rylander mrylander@gmail.com GPLS -- PINES Development Database Developer From pgsql-performance-owner@postgresql.org Wed Nov 17 16:43:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B0DCC3A3ECC for ; Wed, 17 Nov 2004 16:43:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33509-03 for ; Wed, 17 Nov 2004 16:43:23 +0000 (GMT) Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) by svr1.postgresql.org (Postfix) with ESMTP id EFF0F3A3E8A for ; Wed, 17 Nov 2004 16:43:23 +0000 (GMT) Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] helo=[192.168.0.66]) by outbound.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.42) id 1CUSto-000KZo-Qh; Wed, 17 Nov 2004 11:43:16 -0500 Message-ID: <419B7F26.2060009@zeut.net> Date: Wed, 17 Nov 2004 11:41:10 -0500 From: "Matthew T. O'Connor" Organization: Terrie O'Connor Realtors User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Parker Cc: Tom Lane , Jeff , Russell Smith , pgsql-performance@postgresql.org Subject: Re: query plan question References: <07FDEE0ED7455A48AC42AC2070EDFF7C26B9D5@corpsrv2.tazznetworks.com> In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C26B9D5@corpsrv2.tazznetworks.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mail-Handler: MailHop Outbound by DynDNS.org X-Originating-IP: 67.80.199.173 X-Report-Abuse-To: abuse@dyndns.org (see http://www.mailhop.org/outbound/abuse.html for abuse reporting information) X-MHO-User: zeut X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/255 X-Sequence-Number: 9209 David Parker wrote: >We're using postgresql 7.4.5. I've only recently put pg_autovacuum in >place as part of our installation, and I'm basically taking the >defaults. I doubt it's a problem with autovacuum itself, but rather with >my configuration of it. I have some reading to do, so any pointers to >existing autovacuum threads would be greatly appreciated! > Well the first thing to do is increase the verbosity of the pg_autovacuum logging output. If you use -d2 or higher, pg_autovacuum will print out a lot of detail on what it thinks the thresholds are and why it is or isn't performing vacuums and analyzes. Attach some of the log and I'll take a look at it. From pgsql-performance-owner@postgresql.org Wed Nov 17 17:13:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BC9FF3A425A for ; Wed, 17 Nov 2004 17:13:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44930-02 for ; Wed, 17 Nov 2004 17:13:14 +0000 (GMT) Received: from mail2.dbitech.ca (radius.wavefire.com [64.141.13.252]) by svr1.postgresql.org (Postfix) with SMTP id 4E29C3A4179 for ; Wed, 17 Nov 2004 17:13:13 +0000 (GMT) Received: (qmail 25035 invoked from network); 17 Nov 2004 18:15:15 -0000 Received: from dbitech.wavefire.com (HELO ?64.141.15.253?) (darcy@64.141.15.253) by radius.wavefire.com with SMTP; 17 Nov 2004 18:15:15 -0000 From: Darcy Buskermolen Organization: Wavefire Technologies Corp. To: Michael Adler Subject: Re: memcached and PostgreSQL Date: Wed, 17 Nov 2004 09:13:09 -0800 User-Agent: KMail/1.6.2 Cc: pgsql-performance@postgresql.org References: <20041117040024.GB8838@pobox.com> In-Reply-To: <20041117040024.GB8838@pobox.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411170913.09390.darcy@wavefire.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/256 X-Sequence-Number: 9210 On November 16, 2004 08:00 pm, Michael Adler wrote: > http://pugs.postgresql.org/sfpug/archives/000021.html > > I noticed that some of you left coasters were talking about memcached > and pgsql. I'm curious to know what was discussed. > > In reading about memcached, it seems that many people are using it to > circumvent the scalability problems of MySQL (lack of MVCC). > > from their site: > > > Shouldn't the database do this? > > Regardless of what database you use (MS-SQL, Oracle, Postgres, > MysQL-InnoDB, etc..), there's a lot of overhead in implementing ACID > properties in a RDBMS, especially when disks are involved, which means > queries are going to block. For databases that aren't ACID-compliant > (like MySQL-MyISAM), that overhead doesn't exist, but reading threads > block on the writing threads. memcached never blocks. > > > So What does memcached offer pgsql users? It would still seem to offer > the benefit of a multi-machined cache. Have a look at the pdf presentation found on the following site: http://people.freebsd.org/~seanc/pgmemcache/ > > -Mike > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings -- Darcy Buskermolen Wavefire Technologies Corp. ph: 250.717.0200 fx: 250.763.1759 http://www.wavefire.com From pgsql-performance-owner@postgresql.org Wed Nov 17 17:17:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A00C73A4323 for ; Wed, 17 Nov 2004 17:16:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45583-03 for ; Wed, 17 Nov 2004 17:16:15 +0000 (GMT) Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) by svr1.postgresql.org (Postfix) with ESMTP id 628A93A4273 for ; Wed, 17 Nov 2004 17:16:14 +0000 (GMT) Received: from mailer.elma.loc (localhost [127.0.0.1]) by localhost (Postfix) with ESMTP id D5C7CEC19C; Wed, 17 Nov 2004 18:19:22 +0100 (CET) Received: from zoot.elma.loc (herve.elma.fr [10.0.1.2]) by mailer.elma.loc (Postfix) with ESMTP id B2DC5EC15F; Wed, 17 Nov 2004 18:19:22 +0100 (CET) From: =?iso-8859-15?q?Herv=E9_Piedvache?= Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique To: Oleg Bartunov Subject: Re: Tsearch2 really slower than ilike ? Date: Wed, 17 Nov 2004 18:16:10 +0100 User-Agent: KMail/1.7.1 Cc: pgsql-performance@postgresql.org References: <200411161555.59144.herve@elma.fr> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200411171816.10794.herve@elma.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/257 X-Sequence-Number: 9211 Oleg, Sorry but when I do your request I get : # select id_site from site where idx_site_name @@ �'livejourn'; ERROR: �type "�" does not exist What is this ? (private: I don't know what happend with my mail, but I do nothing special to disturb the contains when I'm writting to you ...) Le Mardi 16 Novembre 2004 22:13, Oleg Bartunov a �crit : > ok, I downloaded dump of table and here is what I found: > > zz=# select count(*) from tt; > count > -------- > 183956 > (1 row) > > zz=# select * from stat('select tt from tt') order by ndoc desc, nentry > desc,wo > rd limit 10; > word | ndoc | nentry > --------------+-------+-------- > blog | 12710 | 12835 > weblog | 4857 | 4859 > news | 4402 | 4594 > life | 4136 | 4160 > world | 1980 | 1986 > journal | 1882 | 1883 > livejourn | 1737 | 1737 > thought | 1669 | 1677 > web | 1154 | 1161 > scotsman.com | 1138 | 1138 > (10 rows) > > zz=# explain analyze select tt from tt where tt @@ 'blog'; > QUERY PLAN > --------------------------------------------------------------------------- >------------------------------------------- Index Scan using tt_idx on tt > (cost=0.00..728.83 rows=184 width=32) (actual time=0.047..141.110 > rows=12710 loops=1) Index Cond: (tt @@ '\'blog\''::tsquery) > Filter: (tt @@ '\'blog\''::tsquery) > Total runtime: 154.105 ms > (4 rows) > > It's really fast ! So, I don't understand your problem. > I run query on my desktop machine, nothing special. > > > Oleg > > On Tue, 16 Nov 2004, [iso-8859-15] Herv? Piedvache wrote: > > Hi, > > > > I'm completly dispointed with Tsearch2 ... > > > > I have a table like this : > > Table "public.site" > > Column | Type | > > Modifiers > > ---------------+-----------------------------+--------------------------- > >------------------------------------ id_site | integer > > | not null default > > nextval('public.site_id_site_seq'::text) > > site_name | text | > > site_url | text | > > url | text | > > language | text | > > datecrea | date | default now() > > id_category | integer | > > time_refresh | integer | > > active | integer | > > error | integer | > > description | text | > > version | text | > > idx_site_name | tsvector | > > lastcheck | date | > > lastupdate | timestamp without time zone | > > Indexes: > > "site_id_site_key" unique, btree (id_site) > > "ix_idx_site_name" gist (idx_site_name) > > Triggers: > > tsvectorupdate_site_name BEFORE INSERT OR UPDATE ON site FOR EACH ROW > > EXECUTE PROCEDURE tsearch2('idx_site_name', 'site_name') > > > > I have 183 956 records in the database ... > > > > SELECT s.site_name, s.id_site, s.description, s.site_url, > > case when exists (select id_user > > from user_choice u > > where u.id_site=s.id_site > > and u.id_user = 1) > > then 1 else 0 end as bookmarked > > FROM site s > > WHERE s.idx_site_name @@ to_tsquery('atari'); > > > > Explain Analyze : > > QUERY PLAN > > ------------------------------------------------------------------------- > >----------------------------------------------------------------- Index > > Scan using ix_idx_site_name on site s (cost=0.00..1202.12 rows=184 > > width=158) (actual time=4687.674..4698.422 rows=1 loops=1) > > Index Cond: (idx_site_name @@ '\'atari\''::tsquery) > > Filter: (idx_site_name @@ '\'atari\''::tsquery) > > SubPlan > > -> Seq Scan on user_choice u (cost=0.00..3.46 rows=1 width=4) > > (actual time=0.232..0.232 rows=0 loops=1) > > Filter: ((id_site = $0) AND (id_user = 1)) > > Total runtime: 4698.608 ms > > > > First time I run the request I have a result in about 28 seconds. > > > > SELECT s.site_name, s.id_site, s.description, s.site_url, > > case when exists (select id_user > > from user_choice u > > where u.id_site=s.id_site > > and u.id_user = 1) > > then 1 else 0 end as bookmarked > > FROM site_rss s > > WHERE s.site_name ilike '%atari%' > > > > QUERY PLAN > > ------------------------------------------------------------------------- > >--------------------------------------- Seq Scan on site_rss s > > (cost=0.00..11863.16 rows=295 width=158) (actual time=17.414..791.937 > > rows=12 loops=1) > > Filter: (site_name ~~* '%atari%'::text) > > SubPlan > > -> Seq Scan on user_choice u (cost=0.00..3.46 rows=1 width=4) > > (actual time=0.222..0.222 rows=0 loops=12) > > Filter: ((id_site = $0) AND (id_user = 1)) > > Total runtime: 792.099 ms > > > > First time I run the request I have a result in about 789 miliseconds > > !!??? > > > > I'm using PostgreSQL v7.4.6 with a Bi-Penitum III 933 Mhz and 1 Gb of > > RAM. > > > > Any idea ... ? For the moment I'm going back to use the ilike solution > > ... but I was really thinking that Tsearch2 could be a better solution > > ... > > > > Regards, > > Regards, > Oleg > _____________________________________________________________ > Oleg Bartunov, sci.researcher, hostmaster of AstroNet, > Sternberg Astronomical Institute, Moscow University (Russia) > Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ > phone: +007(095)939-16-83, +007(095)939-23-83 > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match -- Herv� Piedvache Elma Ing�nierie Informatique 6 rue du Faubourg Saint-Honor� F-75008 - Paris - France Pho. 33-144949901 Fax. 33-144949902 From pgsql-performance-owner@postgresql.org Wed Nov 17 17:23:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 68CF03A4102 for ; Wed, 17 Nov 2004 17:23:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45531-10 for ; Wed, 17 Nov 2004 17:23:54 +0000 (GMT) Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1E6433A3E8A for ; Wed, 17 Nov 2004 17:23:45 +0000 (GMT) Received: from ra (ra [158.250.29.2]) by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id iAHHNZQT026085; Wed, 17 Nov 2004 20:23:35 +0300 (MSK) Date: Wed, 17 Nov 2004 20:23:35 +0300 (MSK) From: Oleg Bartunov X-X-Sender: megera@ra.sai.msu.su To: =?iso-8859-15?q?Herv=E9_Piedvache?= Cc: pgsql-performance@postgresql.org Subject: Re: Tsearch2 really slower than ilike ? In-Reply-To: <200411171816.10794.herve@elma.fr> Message-ID: References: <200411161555.59144.herve@elma.fr> <200411171816.10794.herve@elma.fr> MIME-Version: 1.0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: Content-Type: TEXT/PLAIN; charset=koi8-r; format=flowed Content-Transfer-Encoding: 8BIT X-Archive-Number: 200411/258 X-Sequence-Number: 9212 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---559023410-1817792895-1100712215=:18871 Content-Type: TEXT/PLAIN; charset=koi8-r; format=flowed Content-Transfer-Encoding: 8BIT 1;2c1;2c1;2cOn Wed, 17 Nov 2004, [iso-8859-15] Herv? Piedvache wrote: > Oleg, > > Sorry but when I do your request I get : > # select id_site from site where idx_site_name @@ �'livejourn'; > ERROR: �type "�" does not exist > no idea :) btw, what version of postgresql and OS you're running. Could you try minimal test - check sql commands from tsearch2 sources, some basic queries from tsearch2 documentation, tutorials. btw, your query should looks like select id_site from site_rss where idx_site_name @@ 'livejourn'; ^^^^^^^^ How did you run your queries at all ? I mean your first message about poor tsearch2 performance. 1;2c1;2c1;2c > What is this ? > > (private: I don't know what happend with my mail, but I do nothing special to > disturb the contains when I'm writting to you ...) > > Le Mardi 16 Novembre 2004 22:13, Oleg Bartunov a ?crit : >> ok, I downloaded dump of table and here is what I found: >> >> zz=# select count(*) from tt; >> count >> -------- >> 183956 >> (1 row) >> >> zz=# select * from stat('select tt from tt') order by ndoc desc, nentry >> desc,wo >> rd limit 10; >> word | ndoc | nentry >> --------------+-------+-------- >> blog | 12710 | 12835 >> weblog | 4857 | 4859 >> news | 4402 | 4594 >> life | 4136 | 4160 >> world | 1980 | 1986 >> journal | 1882 | 1883 >> livejourn | 1737 | 1737 >> thought | 1669 | 1677 >> web | 1154 | 1161 >> scotsman.com | 1138 | 1138 >> (10 rows) >> >> zz=# explain analyze select tt from tt where tt @@ 'blog'; >> QUERY PLAN >> --------------------------------------------------------------------------- >> ------------------------------------------- Index Scan using tt_idx on tt >> (cost=0.00..728.83 rows=184 width=32) (actual time=0.047..141.110 >> rows=12710 loops=1) Index Cond: (tt @@ '\'blog\''::tsquery) >> Filter: (tt @@ '\'blog\''::tsquery) >> Total runtime: 154.105 ms >> (4 rows) >> >> It's really fast ! So, I don't understand your problem. >> I run query on my desktop machine, nothing special. >> >> >> Oleg >> >> On Tue, 16 Nov 2004, [iso-8859-15] Herv? Piedvache wrote: >>> Hi, >>> >>> I'm completly dispointed with Tsearch2 ... >>> >>> I have a table like this : >>> Table "public.site" >>> Column | Type | >>> Modifiers >>> ---------------+-----------------------------+--------------------------- >>> ------------------------------------ id_site | integer >>> | not null default >>> nextval('public.site_id_site_seq'::text) >>> site_name | text | >>> site_url | text | >>> url | text | >>> language | text | >>> datecrea | date | default now() >>> id_category | integer | >>> time_refresh | integer | >>> active | integer | >>> error | integer | >>> description | text | >>> version | text | >>> idx_site_name | tsvector | >>> lastcheck | date | >>> lastupdate | timestamp without time zone | >>> Indexes: >>> "site_id_site_key" unique, btree (id_site) >>> "ix_idx_site_name" gist (idx_site_name) >>> Triggers: >>> tsvectorupdate_site_name BEFORE INSERT OR UPDATE ON site FOR EACH ROW >>> EXECUTE PROCEDURE tsearch2('idx_site_name', 'site_name') >>> >>> I have 183 956 records in the database ... >>> >>> SELECT s.site_name, s.id_site, s.description, s.site_url, >>> case when exists (select id_user >>> from user_choice u >>> where u.id_site=s.id_site >>> and u.id_user = 1) >>> then 1 else 0 end as bookmarked >>> FROM site s >>> WHERE s.idx_site_name @@ to_tsquery('atari'); >>> >>> Explain Analyze : >>> QUERY PLAN >>> ------------------------------------------------------------------------- >>> ----------------------------------------------------------------- Index >>> Scan using ix_idx_site_name on site s (cost=0.00..1202.12 rows=184 >>> width=158) (actual time=4687.674..4698.422 rows=1 loops=1) >>> Index Cond: (idx_site_name @@ '\'atari\''::tsquery) >>> Filter: (idx_site_name @@ '\'atari\''::tsquery) >>> SubPlan >>> -> Seq Scan on user_choice u (cost=0.00..3.46 rows=1 width=4) >>> (actual time=0.232..0.232 rows=0 loops=1) >>> Filter: ((id_site = $0) AND (id_user = 1)) >>> Total runtime: 4698.608 ms >>> >>> First time I run the request I have a result in about 28 seconds. >>> >>> SELECT s.site_name, s.id_site, s.description, s.site_url, >>> case when exists (select id_user >>> from user_choice u >>> where u.id_site=s.id_site >>> and u.id_user = 1) >>> then 1 else 0 end as bookmarked >>> FROM site_rss s >>> WHERE s.site_name ilike '%atari%' >>> >>> QUERY PLAN >>> ------------------------------------------------------------------------- >>> --------------------------------------- Seq Scan on site_rss s >>> (cost=0.00..11863.16 rows=295 width=158) (actual time=17.414..791.937 >>> rows=12 loops=1) >>> Filter: (site_name ~~* '%atari%'::text) >>> SubPlan >>> -> Seq Scan on user_choice u (cost=0.00..3.46 rows=1 width=4) >>> (actual time=0.222..0.222 rows=0 loops=12) >>> Filter: ((id_site = $0) AND (id_user = 1)) >>> Total runtime: 792.099 ms >>> >>> First time I run the request I have a result in about 789 miliseconds >>> !!??? >>> >>> I'm using PostgreSQL v7.4.6 with a Bi-Penitum III 933 Mhz and 1 Gb of >>> RAM. >>> >>> Any idea ... ? For the moment I'm going back to use the ilike solution >>> ... but I was really thinking that Tsearch2 could be a better solution >>> ... >>> >>> Regards, >> >> Regards, >> Oleg >> _____________________________________________________________ >> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, >> Sternberg Astronomical Institute, Moscow University (Russia) >> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ >> phone: +007(095)939-16-83, +007(095)939-23-83 >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 9: the planner will ignore your desire to choose an index scan if your >> joining column's datatypes do not match > > Regards, Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83 ---559023410-1817792895-1100712215=:18871-- From pgsql-performance-owner@postgresql.org Wed Nov 17 19:04:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 867693A4395 for ; Wed, 17 Nov 2004 19:04:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79706-01 for ; Wed, 17 Nov 2004 19:04:00 +0000 (GMT) Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) by svr1.postgresql.org (Postfix) with ESMTP id 695A73A4346 for ; Wed, 17 Nov 2004 19:03:59 +0000 (GMT) Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] helo=[192.168.0.66]) by outbound.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.42) id 1CUV5v-0008D7-FY; Wed, 17 Nov 2004 14:03:55 -0500 Message-ID: <419BA01C.7000903@zeut.net> Date: Wed, 17 Nov 2004 14:01:48 -0500 From: "Matthew T. O'Connor" Organization: Terrie O'Connor Realtors User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Parker Cc: Tom Lane , Jeff , Russell Smith , pgsql-performance@postgresql.org Subject: Re: query plan question References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BA10@corpsrv2.tazznetworks.com> In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C26BA10@corpsrv2.tazznetworks.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mail-Handler: MailHop Outbound by DynDNS.org X-Originating-IP: 67.80.199.173 X-Report-Abuse-To: abuse@dyndns.org (see http://www.mailhop.org/outbound/abuse.html for abuse reporting information) X-MHO-User: zeut X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/259 X-Sequence-Number: 9213 Well based on the autovacuum log that you attached, all of those tables are insert only (at least during the time period included in the log. Is that correct? If so, autovacuum will never do a vacuum (unless required by xid wraparound issues) on those tables. So this doesn't appear to be an autovacuum problem. I'm not sure about the missing pg_statistic entries anyone else care to field that one? Matthew David Parker wrote: >Thanks. The tables I'm concerned with are named: 'schema', 'usage', >'usageparameter', and 'flow'. It looks like autovacuum is performing >analyzes: > >% grep "Performing: " logs/.db.tazz.vacuum.log >[2004-11-17 12:05:58 PM] Performing: ANALYZE >"public"."scriptlibrary_library" >[2004-11-17 12:15:59 PM] Performing: ANALYZE >"public"."scriptlibraryparm" >[2004-11-17 12:15:59 PM] Performing: ANALYZE "public"."usageparameter" >[2004-11-17 12:21:00 PM] Performing: ANALYZE "public"."usageproperty" >[2004-11-17 12:21:00 PM] Performing: ANALYZE "public"."route" >[2004-11-17 12:21:00 PM] Performing: ANALYZE "public"."usageparameter" >[2004-11-17 12:21:00 PM] Performing: ANALYZE >"public"."scriptlibrary_library" >[2004-11-17 12:26:01 PM] Performing: ANALYZE "public"."usage" >[2004-11-17 12:26:01 PM] Performing: ANALYZE "public"."usageparameter" >[2004-11-17 12:31:04 PM] Performing: ANALYZE "public"."usageproperty" >[2004-11-17 12:36:04 PM] Performing: ANALYZE "public"."route" >[2004-11-17 12:36:04 PM] Performing: ANALYZE "public"."service_usage" >[2004-11-17 12:36:04 PM] Performing: ANALYZE "public"."usageparameter" > >But when I run the following: > >select * from pg_statistic where starelid in >(select oid from pg_class where relname in >('schema','usageparameter','flow','usage')) > >it returns no records. Shouldn't it? It doesn't appear to be doing a >vacuum anywhere, which makes sense because none of these tables have >over the default threshold of 1000. Are there statistics which only get >generated by vacuum? > >I've attached a gzip of the pg_autovacuum log file, with -d 3. > >Thanks again. > >- DAP > > > > >>-----Original Message----- >>From: Matthew T. O'Connor [mailto:matthew@zeut.net] >>Sent: Wednesday, November 17, 2004 11:41 AM >>To: David Parker >>Cc: Tom Lane; Jeff; Russell Smith; pgsql-performance@postgresql.org >>Subject: Re: [PERFORM] query plan question >> >>David Parker wrote: >> >> >> >>>We're using postgresql 7.4.5. I've only recently put pg_autovacuum in >>>place as part of our installation, and I'm basically taking the >>>defaults. I doubt it's a problem with autovacuum itself, but rather >>>with my configuration of it. I have some reading to do, so >>> >>> >>any pointers >> >> >>>to existing autovacuum threads would be greatly appreciated! >>> >>> >>> >>Well the first thing to do is increase the verbosity of the >>pg_autovacuum logging output. If you use -d2 or higher, >>pg_autovacuum will print out a lot of detail on what it thinks >>the thresholds are and >>why it is or isn't performing vacuums and analyzes. Attach >>some of the >>log and I'll take a look at it. >> >> >> From pgsql-performance-owner@postgresql.org Wed Nov 17 19:16:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 31DE13A3F53 for ; Wed, 17 Nov 2004 19:16:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82216-05 for ; Wed, 17 Nov 2004 19:16:08 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id E7C773A2BC2 for ; Wed, 17 Nov 2004 19:16:08 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6674725; Wed, 17 Nov 2004 11:17:38 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: Analyzer is clueless Date: Wed, 17 Nov 2004 11:14:43 -0800 User-Agent: KMail/1.6.2 Cc: David Brown References: <20041117160824.B694D3A3ECC@svr1.postgresql.org> In-Reply-To: <20041117160824.B694D3A3ECC@svr1.postgresql.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411171114.43884.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/260 X-Sequence-Number: 9214 Dan, > I'm doing some performance profiling with a simple two-table query: Please send EXPLAIN ANALYZE for each query, and not just EXPLAIN. Thanks! -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Nov 17 19:52:15 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C4B3A3A4397 for ; Wed, 17 Nov 2004 19:52:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93719-04 for ; Wed, 17 Nov 2004 19:52:01 +0000 (GMT) Received: from mail1.panix.com (mail1.panix.com [166.84.1.72]) by svr1.postgresql.org (Postfix) with ESMTP id 4F2B63A40C7 for ; Wed, 17 Nov 2004 19:52:01 +0000 (GMT) Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mail1.panix.com (Postfix) with ESMTP id ED88C58B3B; Wed, 17 Nov 2004 14:51:59 -0500 (EST) Received: (from adler@localhost) by panix2.panix.com (8.11.6p3/8.8.8/PanixN1.1) id iAHJpwP05116; Wed, 17 Nov 2004 14:51:58 -0500 (EST) Date: Wed, 17 Nov 2004 14:51:58 -0500 From: Michael Adler To: Darcy Buskermolen Cc: pgsql-performance@postgresql.org Subject: Re: memcached and PostgreSQL Message-ID: <20041117195158.GA18831@pobox.com> References: <20041117040024.GB8838@pobox.com> <200411170913.09390.darcy@wavefire.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200411170913.09390.darcy@wavefire.com> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/261 X-Sequence-Number: 9215 On Wed, Nov 17, 2004 at 09:13:09AM -0800, Darcy Buskermolen wrote: > On November 16, 2004 08:00 pm, Michael Adler wrote: > > http://pugs.postgresql.org/sfpug/archives/000021.html > > > > I noticed that some of you left coasters were talking about memcached > > and pgsql. I'm curious to know what was discussed. > > Have a look at the pdf presentation found on the following site: > > http://people.freebsd.org/~seanc/pgmemcache/ Thanks for that. That presentation was rather broad and the API seems rather general purpose, but I wonder why you would really want access the cache by way of the DB? If one major point of memcache is to allocate RAM to a low-overhead server instead of to the RDBMS's disk cache, why would you add the overhead of the RDBMS to the process? (this is a bit of straw man, but just trying to flesh-out the pros and cons) Still, it seems like a convenient way to maintain cache coherency, assuming that your application doesn't already have a clean way to do that. (just my uninformed opinion, though...) -Mike From pgsql-performance-owner@postgresql.org Wed Nov 17 21:03:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 614DF3A440B for ; Wed, 17 Nov 2004 21:03:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16203-05 for ; Wed, 17 Nov 2004 21:03:05 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id 3BB933A40A4 for ; Wed, 17 Nov 2004 21:03:06 +0000 (GMT) Received: from [192.168.1.51] (dsl093-038-087.pdx1.dsl.speakeasy.net [66.93.38.87]) (authenticated bits=0) by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id iAHL32f2026110; Wed, 17 Nov 2004 13:03:02 -0800 Message-ID: <419BBC83.7020802@commandprompt.com> Date: Wed, 17 Nov 2004 13:02:59 -0800 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Brown Cc: pgsql-performance@postgresql.org Subject: Re: Analyzer is clueless References: <20041117160824.B694D3A3ECC@svr1.postgresql.org> In-Reply-To: <20041117160824.B694D3A3ECC@svr1.postgresql.org> Content-Type: multipart/mixed; boundary="------------030305080100080300050200" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/262 X-Sequence-Number: 9216 This is a multi-part message in MIME format. --------------030305080100080300050200 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello, Have you tried increasing the statistics target for orderdate and rerunning analyze? Sincerely, Joshua D. Drake David Brown wrote: > I'm doing some performance profiling with a simple two-table query: > > SELECT L."ProductID", sum(L."Amount") > FROM "drinv" H > JOIN "drinvln" L ON L."OrderNo" = H."OrderNo" > WHERE > ("OrderDate" between '2003-01-01' AND '2003-04-30') > GROUP BY L."ProductID" > > drinv and drinvln have about 100,000 and 3,500,000 rows respectively. Actual data size in the large table is 500-600MB. OrderNo is indexed in both tables, as is OrderDate. > > The environment is PGSQL 8 on Win2k with 512MB RAM (results are similar to 7.3 from Mammoth). I've tried tweaking various conf parameters, but apart from using up memory, nothing seems to have had a tangible effect - the Analyzer doesn't seem to take resources into account like some of the doco suggests. > > The date selection represents about 5% of the range. Here's the plan summaries: > > Three months (2003-01-01 to 2003-03-30) = 1 second > > HashAggregate (cost=119365.53..119368.74 rows=642 width=26) > -> Nested Loop (cost=0.00..118791.66 rows=114774 width=26) > -> Index Scan using "drinv_OrderDate" on drinv h (cost=0.00..200.27 rows=3142 width=8) > Index Cond: (("OrderDate" >= '2003-01-01'::date) AND ("OrderDate" <= '2003-03-30'::date)) > -> Index Scan using "drinvln_OrderNo" on drinvln l (cost=0.00..28.73 rows=721 width=34) > Index Cond: (l."OrderNo" = "outer"."OrderNo") > > > Four months (2003-01-01 to 2003-04-30) = 60 seconds > > HashAggregate (cost=126110.53..126113.74 rows=642 width=26) > -> Hash Join (cost=277.55..125344.88 rows=153130 width=26) > Hash Cond: ("outer"."OrderNo" = "inner"."OrderNo") > -> Seq Scan on drinvln l (cost=0.00..106671.35 rows=3372935 width=34) > -> Hash (cost=267.07..267.07 rows=4192 width=8) > -> Index Scan using "drinv_OrderDate" on drinv h (cost=0.00..267.07 rows=4192 width=8) > Index Cond: (("OrderDate" >= '2003-01-01'::date) AND ("OrderDate" <= '2003-04-30'::date)) > > > Four months (2003-01-01 to 2003-04-30) with Seq_scan disabled = 75 seconds > > > HashAggregate (cost=130565.83..130569.04 rows=642 width=26) > -> Merge Join (cost=519.29..129800.18 rows=153130 width=26) > Merge Cond: ("outer"."OrderNo" = "inner"."OrderNo") > -> Sort (cost=519.29..529.77 rows=4192 width=8) > Sort Key: h."OrderNo" > -> Index Scan using "drinv_OrderDate" on drinv h (cost=0.00..267.07 rows=4192 width=8) > Index Cond: (("OrderDate" >= '2003-01-01'::date) AND ("OrderDate" <= '2003-04-30'::date)) > -> Index Scan using "drinvln_OrderNo" on drinvln l (cost=0.00..119296.29 rows=3372935 width=34) > > Statistics were run on each table before query execution. The random page cost was lowered to 2, but as you can see, the estimated costs are wild anyway. > > As a comparison, MS SQL Server took less than 15 seconds, or 4 times faster. > > MySQL (InnoDB) took 2 seconds, which is 30 times faster. > > The query looks straightforward to me (it might be clearer with a subselect), so what on earth is wrong? > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- Command Prompt, Inc., home of PostgreSQL Replication, and plPHP. Postgresql support, programming shared hosting and dedicated hosting. +1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL --------------030305080100080300050200 Content-Type: text/x-vcard; charset=utf-8; name="jd.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jd.vcf" begin:vcard fn:Joshua D. Drake n:Drake;Joshua D. org:Command Prompt, Inc. adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA email;internet:jd@commandprompt.com title:Consultant tel;work:503-667-4564 tel;fax:503-210-0334 note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. x-mozilla-html:FALSE url:http://www.commandprompt.com/ version:2.1 end:vcard --------------030305080100080300050200-- From pgsql-performance-owner@postgresql.org Wed Nov 17 21:04:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BEE0B3A442C for ; Wed, 17 Nov 2004 21:04:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16764-08 for ; Wed, 17 Nov 2004 21:04:27 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 68DC23A3F50 for ; Wed, 17 Nov 2004 21:04:28 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6675216; Wed, 17 Nov 2004 13:05:58 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: memcached and PostgreSQL Date: Wed, 17 Nov 2004 13:07:06 -0800 User-Agent: KMail/1.6.2 Cc: Michael Adler , Darcy Buskermolen References: <20041117040024.GB8838@pobox.com> <200411170913.09390.darcy@wavefire.com> <20041117195158.GA18831@pobox.com> In-Reply-To: <20041117195158.GA18831@pobox.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411171307.06584.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/263 X-Sequence-Number: 9217 Michael, > Still, it seems like a convenient way to maintain cache coherency, > assuming that your application doesn't already have a clean way to do > that. Precisely. The big problem with memory caching is the cache getting out of sync with the database. Updating the cache through database triggers helps ameliorate that. However, our inability to pass messages with NOTIFY somewhat limits the the utility of this solution Sean wants "on commit triggers", but there's some major issues to work out with that. Passing messages with NOTIFY would be easier and almost as good. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Nov 17 21:31:56 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 221473A4454 for ; Wed, 17 Nov 2004 21:31:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23017-10 for ; Wed, 17 Nov 2004 21:31:31 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id 1C2553A4439 for ; Wed, 17 Nov 2004 21:31:32 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: sort_mem affect on inserts? Date: Wed, 17 Nov 2004 16:31:31 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26BA3D@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: sort_mem affect on inserts? Thread-Index: AcTM7M4MPzer6JQARau9v5kce9IC/Q== From: "David Parker" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/264 X-Sequence-Number: 9218 I understand that the sort_mem conf setting affects queries with order = by, etc., and the doc mentions that it is used in create index. Does = sort_mem affect the updating of indexes, i.e., can the sort_mem setting = affect the performance of inserts? - DAP -------------------------------------------------------------------------= --------- David Parker Tazz Networks (401) 709-5130 =A0 From pgsql-performance-owner@postgresql.org Wed Nov 17 22:05:25 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2075F3A440B for ; Wed, 17 Nov 2004 22:04:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34330-07 for ; Wed, 17 Nov 2004 22:04:50 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id F22023A449D for ; Wed, 17 Nov 2004 22:04:51 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6675497; Wed, 17 Nov 2004 14:06:21 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: sort_mem affect on inserts? Date: Wed, 17 Nov 2004 14:07:30 -0800 User-Agent: KMail/1.6.2 Cc: "David Parker" References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BA3D@corpsrv2.tazznetworks.com> In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C26BA3D@corpsrv2.tazznetworks.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411171407.30795.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/265 X-Sequence-Number: 9219 David, > I understand that the sort_mem conf setting affects queries with order by, > etc., and the doc mentions that it is used in create index. Does sort_mem > affect the updating of indexes, i.e., can the sort_mem setting affect the > performance of inserts? Only if the table has Foriegn Keys whose lookup might require a large sort. Otherwise, no. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Nov 17 22:14:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F2CE73A437D for ; Wed, 17 Nov 2004 22:14:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39017-01 for ; Wed, 17 Nov 2004 22:14:06 +0000 (GMT) Received: from vsmtp14.tin.it (vsmtp14.tin.it [212.216.176.118]) by svr1.postgresql.org (Postfix) with ESMTP id D30513A445C for ; Wed, 17 Nov 2004 22:14:07 +0000 (GMT) Received: from [82.50.151.198] (82.50.151.198) by vsmtp14.tin.it (7.0.027) (authenticated as silvia.pg@virgilio.it) id 414B1A5801A17EC1 for pgsql-performance@postgresql.org; Wed, 17 Nov 2004 23:14:05 +0100 Message-ID: <419BCD20.4010906@tiscali.it> Date: Wed, 17 Nov 2004 23:13:52 +0100 From: "silviapg@tiscali.it" User-Agent: Mozilla Thunderbird 0.8 (X11/20040926) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: postgres eating CPU Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/266 X-Sequence-Number: 9220 Hi, in March there was an interesting discussion on the list with the subject "postgres eating CPU on HP9000". Now I'm the same problem on a Dell dual processor machine. Anybody know if there was a solution? Thanks Piergiorgio From pgsql-performance-owner@postgresql.org Wed Nov 17 22:24:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 933713A4482 for ; Wed, 17 Nov 2004 22:24:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41955-03 for ; Wed, 17 Nov 2004 22:24:31 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 8FCAD3A443A for ; Wed, 17 Nov 2004 22:24:33 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6675599; Wed, 17 Nov 2004 14:26:03 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: postgres eating CPU Date: Wed, 17 Nov 2004 14:27:13 -0800 User-Agent: KMail/1.6.2 Cc: "silviapg@tiscali.it" References: <419BCD20.4010906@tiscali.it> In-Reply-To: <419BCD20.4010906@tiscali.it> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411171427.13134.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/267 X-Sequence-Number: 9221 > in March there was an interesting discussion on the list with the > subject "postgres eating CPU on HP9000". Link, please? -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Nov 17 22:38:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 651BD3A437D for ; Wed, 17 Nov 2004 22:35:52 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45365-03 for ; Wed, 17 Nov 2004 22:35:41 +0000 (GMT) Received: from cmailm2.svr.pol.co.uk (cmailm2.svr.pol.co.uk [195.92.193.210]) by svr1.postgresql.org (Postfix) with ESMTP id 14E323A44FC for ; Wed, 17 Nov 2004 22:35:42 +0000 (GMT) Received: from modem-2210.llama.dialup.pol.co.uk ([217.135.184.162] helo=[192.168.0.102]) by cmailm2.svr.pol.co.uk with esmtp (Exim 4.41) id 1CUYOr-0000dk-At; Wed, 17 Nov 2004 22:35:41 +0000 Subject: Re: Analyzer is clueless From: Simon Riggs To: David Brown Cc: pgsql-performance@postgresql.org In-Reply-To: <20041117160824.B694D3A3ECC@svr1.postgresql.org> References: <20041117160824.B694D3A3ECC@svr1.postgresql.org> Content-Type: text/plain Organization: 2nd Quadrant Message-Id: <1100730768.4113.7709.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Wed, 17 Nov 2004 22:32:48 +0000 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/268 X-Sequence-Number: 9222 On Thu, 2004-11-18 at 02:08, David Brown wrote: > Statistics were run on each table before query execution. The random page cost was lowered to 2, but as you can see, the estimated costs are wild anyway. > > As a comparison, MS SQL Server took less than 15 seconds, or 4 times faster. > > MySQL (InnoDB) took 2 seconds, which is 30 times faster. > > The query looks straightforward to me (it might be clearer with a subselect), so what on earth is wrong? The query is, as you say, straightforward. You are clearly working with a query that is on the very edge of the decision between using an index or not. The main issue is that PostgreSQL's default histogram statistics setting is lower than other RDBMS. This means that it is less able to discriminate between cases such as yours that are close to the edge. This is a trade-off between run-time of the ANALYZE command and the benefit it produces. As Joshua suggests, increasing the statistics target for this table will likely allow the optimizer to correctly determine the selectivity of the index and take the right path. If this is a general RDBMS comparison, you may wish to extend the system's default_statistics_target = 80 or at least > 10. To improve this query, you may wish to extend the table's statistics target using: ALTER TABLE "drinv" ALTER COLUMN OrderDate SET STATISTICS 100; which should allow the planner to more accurately estimate statistics and thereby select an index, if appropriate. The doco has recently been changed with regard to effective_cache_size; you don't mention what beta release level you're using. That is the only planner parameter that takes cache size into account, so any other changes would certainly have zero effect on this *plan* though might still benefit execution time. Please post EXPLAIN ANALYZE output for any further questions. -- Best Regards, Simon Riggs From pgsql-performance-owner@postgresql.org Wed Nov 17 22:51:17 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 415AA3A446A for ; Wed, 17 Nov 2004 22:51:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48519-07 for ; Wed, 17 Nov 2004 22:51:11 +0000 (GMT) Received: from vsmtp14.tin.it (vsmtp14.tin.it [212.216.176.118]) by svr1.postgresql.org (Postfix) with ESMTP id D23963A437D for ; Wed, 17 Nov 2004 22:51:13 +0000 (GMT) Received: from [82.50.151.198] (82.50.151.198) by vsmtp14.tin.it (7.0.027) (authenticated as silvia.pg@virgilio.it) id 414B1A5801A1A7DA; Wed, 17 Nov 2004 23:51:14 +0100 Message-ID: <419BD5DF.5090902@tiscali.it> Date: Wed, 17 Nov 2004 23:51:11 +0100 From: "silviapg@tiscali.it" User-Agent: Mozilla Thunderbird 0.8 (X11/20040926) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Cc: josh@agliodbs.com Subject: Re: postgres eating CPU References: <419BCD20.4010906@tiscali.it> <200411171427.13134.josh@agliodbs.com> In-Reply-To: <200411171427.13134.josh@agliodbs.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/269 X-Sequence-Number: 9223 Josh Berkus wrote: >>in March there was an interesting discussion on the list with the >>subject "postgres eating CPU on HP9000". >> >> > >Link, please? > > > http://archives.postgresql.org/pgsql-performance/2004-03/msg00380.php From pgsql-performance-owner@postgresql.org Wed Nov 17 23:21:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 188133A4471 for ; Wed, 17 Nov 2004 23:21:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56160-10 for ; Wed, 17 Nov 2004 23:21:01 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id A2AF03A4466 for ; Wed, 17 Nov 2004 23:21:03 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6675849; Wed, 17 Nov 2004 15:22:32 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: postgres eating CPU Date: Wed, 17 Nov 2004 15:23:41 -0800 User-Agent: KMail/1.6.2 Cc: "silviapg@tiscali.it" References: <419BCD20.4010906@tiscali.it> <200411171427.13134.josh@agliodbs.com> <419BD5DF.5090902@tiscali.it> In-Reply-To: <419BD5DF.5090902@tiscali.it> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411171523.41850.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/270 X-Sequence-Number: 9224 > >>in March there was an interesting discussion on the list with the > >>subject "postgres eating CPU on HP9000". Aha, this one. Yeah, I believe that they upgraded to 7.4 inorder to deal with REINDEX issues. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Nov 17 23:38:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C70063A4498 for ; Wed, 17 Nov 2004 23:38:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62473-03 for ; Wed, 17 Nov 2004 23:38:45 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 585BE3A4492 for ; Wed, 17 Nov 2004 23:38:47 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAHNceHa005434; Wed, 17 Nov 2004 18:38:41 -0500 (EST) To: "silviapg@tiscali.it" Cc: pgsql-performance@postgresql.org, josh@agliodbs.com Subject: Re: postgres eating CPU In-reply-to: <419BD5DF.5090902@tiscali.it> References: <419BCD20.4010906@tiscali.it> <200411171427.13134.josh@agliodbs.com> <419BD5DF.5090902@tiscali.it> Comments: In-reply-to "silviapg@tiscali.it" message dated "Wed, 17 Nov 2004 23:51:11 +0100" Date: Wed, 17 Nov 2004 18:38:40 -0500 Message-ID: <5433.1100734720@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=TO_ADDRESS_EQ_REAL X-Spam-Level: X-Archive-Number: 200411/271 X-Sequence-Number: 9225 "silviapg@tiscali.it" writes: > in March there was an interesting discussion on the list with the > subject "postgres eating CPU on HP9000". > http://archives.postgresql.org/pgsql-performance/2004-03/msg00380.php Reviewing that, the problem is most likely that (a) they didn't have max_fsm_pages set high enough to cover the database, and (b) they were running 7.3.* which is prone to index bloat. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 18 00:20:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 119FA3A44CC for ; Thu, 18 Nov 2004 00:20:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72656-06 for ; Thu, 18 Nov 2004 00:20:08 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) by svr1.postgresql.org (Postfix) with ESMTP id 0FE6A3A4113 for ; Thu, 18 Nov 2004 00:20:10 +0000 (GMT) Received: by flake.decibel.org (Postfix, from userid 1001) id 194CF1C90B; Thu, 18 Nov 2004 00:20:09 +0000 (GMT) Date: Wed, 17 Nov 2004 18:20:09 -0600 From: "Jim C. Nasby" To: Simon Riggs Cc: David Brown , pgsql-performance@postgresql.org Subject: Re: Analyzer is clueless Message-ID: <20041118002008.GL80532@decibel.org> References: <20041117160824.B694D3A3ECC@svr1.postgresql.org> <1100730768.4113.7709.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1100730768.4113.7709.camel@localhost.localdomain> X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/272 X-Sequence-Number: 9226 On Wed, Nov 17, 2004 at 10:32:48PM +0000, Simon Riggs wrote: > The main issue is that PostgreSQL's default histogram statistics setting > is lower than other RDBMS. This means that it is less able to > discriminate between cases such as yours that are close to the edge. > This is a trade-off between run-time of the ANALYZE command and the > benefit it produces. As Joshua suggests, increasing the statistics > target for this table will likely allow the optimizer to correctly > determine the selectivity of the index and take the right path. Is there still a good reason to have the histogram stats so low? Should the default be changed to more like 100 at this point? Also, how extensively does the planner use n_distinct, null_frac, reltuples and the histogram to see what the odds are of finding a unique value or a low number of values? I've seen cases where it seems the planer doesn't think it'll be getting a unique value or a small set of values even though stats indicates that it should be. One final question... would there be interest in a process that would dynamically update the histogram settings for tables based on how distinct/unique each field was? -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Thu Nov 18 01:38:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3665E3A4489 for ; Thu, 18 Nov 2004 01:38:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91936-06 for ; Thu, 18 Nov 2004 01:38:33 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 2050E3A450F for ; Thu, 18 Nov 2004 01:38:36 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6676327; Wed, 17 Nov 2004 17:40:06 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: Analyzer is clueless Date: Wed, 17 Nov 2004 17:41:16 -0800 User-Agent: KMail/1.6.2 Cc: "Jim C. Nasby" , Simon Riggs , David Brown References: <20041117160824.B694D3A3ECC@svr1.postgresql.org> <1100730768.4113.7709.camel@localhost.localdomain> <20041118002008.GL80532@decibel.org> In-Reply-To: <20041118002008.GL80532@decibel.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411171741.16515.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/273 X-Sequence-Number: 9227 Jim, > Is there still a good reason to have the histogram stats so low? Should > the default be changed to more like 100 at this point? Low overhead. This is actually a TODO for me for 8.1. I need to find some test cases to set a differential level of histogram access for indexed fields, so like 10 for most fields but 100/150/200 for indexed fields. However, I got stalled on finding test cases and then ran out of time. > Also, how extensively does the planner use n_distinct, null_frac, > reltuples and the histogram to see what the odds are of finding a unique > value or a low number of values? I've seen cases where it seems the > planer doesn't think it'll be getting a unique value or a small set of > values even though stats indicates that it should be. > > One final question... would there be interest in a process that would > dynamically update the histogram settings for tables based on how > distinct/unique each field was? Well, the process by which the analyzer decides that a field is unique could probably use some troubleshooting. And we always, always could use suggestions/tests/help with the query planner. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Nov 18 01:58:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EBCA43A453D for ; Thu, 18 Nov 2004 01:58:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95990-08 for ; Thu, 18 Nov 2004 01:57:55 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 44CB73A4523 for ; Thu, 18 Nov 2004 01:57:58 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAI1viCR011477; Wed, 17 Nov 2004 20:57:44 -0500 (EST) To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org, "Jim C. Nasby" , Simon Riggs , David Brown Subject: Re: Analyzer is clueless In-reply-to: <200411171741.16515.josh@agliodbs.com> References: <20041117160824.B694D3A3ECC@svr1.postgresql.org> <1100730768.4113.7709.camel@localhost.localdomain> <20041118002008.GL80532@decibel.org> <200411171741.16515.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Wed, 17 Nov 2004 17:41:16 -0800" Date: Wed, 17 Nov 2004 20:57:44 -0500 Message-ID: <11476.1100743064@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/274 X-Sequence-Number: 9228 >> I've seen cases where it seems the >> planer doesn't think it'll be getting a unique value or a small set of >> values even though stats indicates that it should be. A test case exhibiting the problem would be helpful. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 17 16:09:01 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 947733A3ED8 for ; Wed, 17 Nov 2004 16:08:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18194-06 for ; Wed, 17 Nov 2004 16:08:28 +0000 (GMT) Received: from gizmo08ps.bigpond.com (gizmo08ps.bigpond.com [144.140.71.18]) by svr1.postgresql.org (Postfix) with SMTP id B694D3A3ECC for ; Wed, 17 Nov 2004 16:08:24 +0000 (GMT) Received: (qmail 14677 invoked from network); 17 Nov 2004 16:08:17 -0000 Received: from unknown (HELO psmam13.bigpond.com) (144.135.25.106) by gizmo08ps.bigpond.com with SMTP; 17 Nov 2004 16:08:17 -0000 Received: from cpe-141-168-103-177.qld.bigpond.net.au ([141.168.103.177]) by psmam13.bigpond.com(MAM REL_3_4_2a 243/5174672) with SMTP id 5174672; Thu, 18 Nov 2004 02:08:17 +1000 Date: Thu, 18 Nov 2004 02:08:33 +0000 From: David Brown To: pgsql-performance@postgresql.org Subject: Analyzer is clueless X-Mailer: David Brown's registered AK-Mail 3.2 [eng] Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Message-Id: <20041117160824.B694D3A3ECC@svr1.postgresql.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.9 tagged_above=0.0 required=5.0 tests=DATE_IN_FUTURE_06_12 X-Spam-Level: * X-Archive-Number: 200411/253 X-Sequence-Number: 9207 I'm doing some performance profiling with a simple two-table query: SELECT L."ProductID", sum(L."Amount") FROM "drinv" H JOIN "drinvln" L ON L."OrderNo" =3D H."OrderNo" WHERE ("OrderDate" between '2003-01-01' AND '2003-04-30') GROUP BY L."ProductID" drinv and drinvln have about 100,000 and 3,500,000 rows respectively. Actu= al data size in the large table is 500-600MB. OrderNo is indexed in both t= ables, as is OrderDate. The environment is PGSQL 8 on Win2k with 512MB RAM (results are similar to= 7.3 from Mammoth). I've tried tweaking various conf parameters, but apart= from using up memory, nothing seems to have had a tangible effect - the A= nalyzer doesn't seem to take resources into account like some of the doco = suggests. The date selection represents about 5% of the range. Here's the plan summa= ries: Three months (2003-01-01 to 2003-03-30) =3D 1 second HashAggregate (cost=3D119365.53..119368.74 rows=3D642 width=3D26) -> Nested Loop (cost=3D0.00..118791.66 rows=3D114774 width=3D26) -> Index Scan using "drinv_OrderDate" on drinv h (cost=3D0.00..2= 00.27 rows=3D3142 width=3D8) Index Cond: (("OrderDate" >=3D '2003-01-01'::date) AND ("Ord= erDate" <=3D '2003-03-30'::date)) -> Index Scan using "drinvln_OrderNo" on drinvln l (cost=3D0.00.= =2E28.73 rows=3D721 width=3D34) Index Cond: (l."OrderNo" =3D "outer"."OrderNo") Four months (2003-01-01 to 2003-04-30) =3D 60 seconds HashAggregate (cost=3D126110.53..126113.74 rows=3D642 width=3D26) -> Hash Join (cost=3D277.55..125344.88 rows=3D153130 width=3D26) Hash Cond: ("outer"."OrderNo" =3D "inner"."OrderNo") -> Seq Scan on drinvln l (cost=3D0.00..106671.35 rows=3D3372935 = width=3D34) -> Hash (cost=3D267.07..267.07 rows=3D4192 width=3D8) -> Index Scan using "drinv_OrderDate" on drinv h (cost=3D0= =2E00..267.07 rows=3D4192 width=3D8) Index Cond: (("OrderDate" >=3D '2003-01-01'::date) AND= ("OrderDate" <=3D '2003-04-30'::date)) Four months (2003-01-01 to 2003-04-30) with Seq_scan disabled =3D 75 secon= ds HashAggregate (cost=3D130565.83..130569.04 rows=3D642 width=3D26) -> Merge Join (cost=3D519.29..129800.18 rows=3D153130 width=3D26) Merge Cond: ("outer"."OrderNo" =3D "inner"."OrderNo") -> Sort (cost=3D519.29..529.77 rows=3D4192 width=3D8) Sort Key: h."OrderNo" -> Index Scan using "drinv_OrderDate" on drinv h (cost=3D0= =2E00..267.07 rows=3D4192 width=3D8) Index Cond: (("OrderDate" >=3D '2003-01-01'::date) AND= ("OrderDate" <=3D '2003-04-30'::date)) -> Index Scan using "drinvln_OrderNo" on drinvln l (cost=3D0.00.= =2E119296.29 rows=3D3372935 width=3D34) Statistics were run on each table before query execution. The random page = cost was lowered to 2, but as you can see, the estimated costs are wild an= yway. As a comparison, MS SQL Server took less than 15 seconds, or 4 times faste= r. MySQL (InnoDB) took 2 seconds, which is 30 times faster. The query looks straightforward to me (it might be clearer with a subselec= t), so what on earth is wrong? From pgsql-performance-owner@postgresql.org Thu Nov 18 03:31:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 451113A44DC for ; Thu, 18 Nov 2004 03:31:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16928-10 for ; Thu, 18 Nov 2004 03:31:21 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id 1CA3E3A4134 for ; Thu, 18 Nov 2004 03:31:24 +0000 (GMT) Received: from [192.168.1.20] (clbb-248.saw.net [64.146.135.248]) (authenticated bits=0) by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id iAI3VLf2006213; Wed, 17 Nov 2004 19:31:22 -0800 Message-ID: <419C175C.1090309@commandprompt.com> Date: Wed, 17 Nov 2004 19:30:36 -0800 From: "Joshua D. Drake" User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org, "silviapg@tiscali.it" Subject: Re: postgres eating CPU References: <419BCD20.4010906@tiscali.it> <200411171427.13134.josh@agliodbs.com> In-Reply-To: <200411171427.13134.josh@agliodbs.com> Content-Type: multipart/mixed; boundary="------------060308060406020204050103" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/275 X-Sequence-Number: 9229 This is a multi-part message in MIME format. --------------060308060406020204050103 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Josh Berkus wrote: >>in March there was an interesting discussion on the list with the >>subject "postgres eating CPU on HP9000". >> http://archives.postgresql.org/pgsql-performance/2004-03/msg00380.php -- Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC Postgresql support, programming shared hosting and dedicated hosting. +1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com PostgreSQL Replicator -- production quality replication for PostgreSQL --------------060308060406020204050103 Content-Type: text/x-vcard; charset=utf-8; name="jd.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jd.vcf" begin:vcard fn:Joshua Drake n:Drake;Joshua org:Command Prompt, Inc. adr:;;PO Box 215 ;Cascade Locks;OR;97014;US email;internet:jd@commandprompt.com title:Consultant tel;work:503-667-4564 tel;fax:503-210-0334 x-mozilla-html:FALSE url:http://www.commandprompt.com version:2.1 end:vcard --------------060308060406020204050103-- From pgsql-performance-owner@postgresql.org Thu Nov 18 09:27:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C19F53A4172 for ; Thu, 18 Nov 2004 09:27:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04413-02 for ; Thu, 18 Nov 2004 09:27:03 +0000 (GMT) Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) by svr1.postgresql.org (Postfix) with ESMTP id 3C0EA3A4085 for ; Thu, 18 Nov 2004 09:27:04 +0000 (GMT) Received: from mailer.elma.loc (localhost [127.0.0.1]) by localhost (Postfix) with ESMTP id BFFEEEC229; Thu, 18 Nov 2004 10:30:11 +0100 (CET) Received: from zoot.elma.loc (herve.elma.fr [10.0.1.2]) by mailer.elma.loc (Postfix) with ESMTP id 922B4EC22F; Thu, 18 Nov 2004 10:30:10 +0100 (CET) From: =?iso-8859-15?q?Herv=E9_Piedvache?= Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique To: Oleg Bartunov Subject: Re: Tsearch2 really slower than ilike ? Date: Thu, 18 Nov 2004 10:27:00 +0100 User-Agent: KMail/1.7.1 Cc: pgsql-performance@postgresql.org References: <200411161555.59144.herve@elma.fr> <200411171816.10794.herve@elma.fr> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200411181027.00592.herve@elma.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/276 X-Sequence-Number: 9230 Oleg, Le Mercredi 17 Novembre 2004 18:23, Oleg Bartunov a �crit : > > Sorry but when I do your request I get : > > # select id_site from site where idx_site_name @@ �'livejourn'; > > ERROR: �type "�" does not exist > > no idea :) btw, what version of postgresql and OS you're running. > Could you try minimal test - check sql commands from tsearch2 sources, > some basic queries from tsearch2 documentation, tutorials. > > btw, your query should looks like > select id_site from site_rss where idx_site_name @@ 'livejourn'; > ^^^^^^^^ > > How did you run your queries at all ? I mean your first message about > poor tsearch2 performance. I don't know what happend yesterday ... it's running now ... You sent me : zz=# explain analyze select id_site from site_rss where idx_site_name @@ �'livejourn'; � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------- � Index Scan using ix_idx_site_name on site_rss �(cost=0.00..733.62 rows=184 width=4) (actual time=0.339..39.183 rows=1737 loops=1) � � Index Cond: (idx_site_name @@ '\'livejourn\''::tsquery) � � Filter: (idx_site_name @@ '\'livejourn\''::tsquery) � Total runtime: 40.997 ms (4 rows) >It's really fast ! So, I don't understand your problem. >I run query on my desktop machine, nothing special. I get this : QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------- Index Scan using ix_idx_site_name on site_rss s (cost=0.00..574.19 rows=187 width=24) (actual time=105.097..7157.277 rows=388 loops=1) Index Cond: (idx_site_name @@ '\'livejourn\''::tsquery) Filter: (idx_site_name @@ '\'livejourn\''::tsquery) Total runtime: 7158.576 ms (4 rows) With the ilike I get : QUERY PLAN ------------------------------------------------------------------------------------------------------------ Seq Scan on site_rss s (cost=0.00..8360.23 rows=1 width=24) (actual time=8.195..879.440 rows=404 loops=1) Filter: (site_name ~~* '%livejourn%'::text) Total runtime: 882.600 ms (3 rows) I don't know what is your desktop ... but I'm using PostgreSQL 7.4.6, on Debian Woody with a PC Bi-PIII 933 Mhz and 1 Gb of memory ... the server is dedicated to this database ... !! I have no idea ! Regards, -- Herv� Piedvache Elma Ing�nierie Informatique 6 rue du Faubourg Saint-Honor� F-75008 - Paris - France Pho. 33-144949901 Fax. 33-144949902 From pgsql-performance-owner@postgresql.org Thu Nov 18 09:37:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2D25F3A4356 for ; Thu, 18 Nov 2004 09:37:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05565-07 for ; Thu, 18 Nov 2004 09:37:38 +0000 (GMT) Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) by svr1.postgresql.org (Postfix) with ESMTP id 450D43A4344 for ; Thu, 18 Nov 2004 09:37:32 +0000 (GMT) Received: from ra (ra [158.250.29.2]) by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id iAI9bOQT017226; Thu, 18 Nov 2004 12:37:25 +0300 (MSK) Date: Thu, 18 Nov 2004 12:37:24 +0300 (MSK) From: Oleg Bartunov X-X-Sender: megera@ra.sai.msu.su To: =?iso-8859-15?q?Herv=E9_Piedvache?= Cc: pgsql-performance@postgresql.org Subject: Re: Tsearch2 really slower than ilike ? In-Reply-To: <200411181027.00592.herve@elma.fr> Message-ID: References: <200411161555.59144.herve@elma.fr> <200411171816.10794.herve@elma.fr> <200411181027.00592.herve@elma.fr> MIME-Version: 1.0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: Content-Type: TEXT/PLAIN; charset=koi8-r; format=flowed Content-Transfer-Encoding: 8BIT X-Archive-Number: 200411/277 X-Sequence-Number: 9231 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---559023410-1271212614-1100770644=:18871 Content-Type: TEXT/PLAIN; charset=koi8-r; format=flowed Content-Transfer-Encoding: 8BIT Have you run 'vacuum analyze' ? 1;2c1;2c1;2c 1;2c1;2c1;2cmy desktop is very simple PIII, 512 Mb RAM. 1;2c1;2c1;2c Oleg 1;2c1;2c1;2c 1;2c1;2c1;2cOn Thu, 18 Nov 2004, [iso-8859-15] Herv? Piedvache wrote: > Oleg, > > Le Mercredi 17 Novembre 2004 18:23, Oleg Bartunov a ?crit : >>> Sorry but when I do your request I get : >>> # select id_site from site where idx_site_name @@ �'livejourn'; >>> ERROR: �type "�" does not exist >> >> no idea :) btw, what version of postgresql and OS you're running. >> Could you try minimal test - check sql commands from tsearch2 sources, >> some basic queries from tsearch2 documentation, tutorials. >> >> btw, your query should looks like >> select id_site from site_rss where idx_site_name @@ 'livejourn'; >> ^^^^^^^^ >> >> How did you run your queries at all ? I mean your first message about >> poor tsearch2 performance. > > I don't know what happend yesterday ... it's running now ... > > You sent me : > zz=# explain analyze select id_site from site_rss where idx_site_name > @@ �'livejourn'; > � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �QUERY PLAN > ----------------------------------------------------------------------------------------------------------------------------------- > � Index Scan using ix_idx_site_name on site_rss �(cost=0.00..733.62 rows=184 > width=4) (actual time=0.339..39.183 rows=1737 loops=1) > � � Index Cond: (idx_site_name @@ '\'livejourn\''::tsquery) > � � Filter: (idx_site_name @@ '\'livejourn\''::tsquery) > � Total runtime: 40.997 ms > (4 rows) > >> It's really fast ! So, I don't understand your problem. >> I run query on my desktop machine, nothing special. > > > I get this : > QUERY PLAN > ----------------------------------------------------------------------------------------------------------------------------------------- > Index Scan using ix_idx_site_name on site_rss s (cost=0.00..574.19 rows=187 > width=24) (actual time=105.097..7157.277 rows=388 loops=1) > Index Cond: (idx_site_name @@ '\'livejourn\''::tsquery) > Filter: (idx_site_name @@ '\'livejourn\''::tsquery) > Total runtime: 7158.576 ms > (4 rows) > > With the ilike I get : > QUERY PLAN > ------------------------------------------------------------------------------------------------------------ > Seq Scan on site_rss s (cost=0.00..8360.23 rows=1 width=24) (actual > time=8.195..879.440 rows=404 loops=1) > Filter: (site_name ~~* '%livejourn%'::text) > Total runtime: 882.600 ms > (3 rows) > > I don't know what is your desktop ... but I'm using PostgreSQL 7.4.6, on > Debian Woody with a PC Bi-PIII 933 Mhz and 1 Gb of memory ... the server is > dedicated to this database ... !! > > I have no idea ! > > Regards, > > Regards, Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83 ---559023410-1271212614-1100770644=:18871-- From pgsql-performance-owner@postgresql.org Thu Nov 18 10:30:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4DFD33A4017 for ; Thu, 18 Nov 2004 10:30:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20738-07 for ; Thu, 18 Nov 2004 10:30:14 +0000 (GMT) Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) by svr1.postgresql.org (Postfix) with ESMTP id 0D99E3A3E96 for ; Thu, 18 Nov 2004 10:30:15 +0000 (GMT) Received: from mailer.elma.loc (localhost [127.0.0.1]) by localhost (Postfix) with ESMTP id A0284EC22B; Thu, 18 Nov 2004 11:33:23 +0100 (CET) Received: from zoot.elma.loc (herve.elma.fr [10.0.1.2]) by mailer.elma.loc (Postfix) with ESMTP id 5DA1AEC229; Thu, 18 Nov 2004 11:33:23 +0100 (CET) From: =?iso-8859-15?q?Herv=E9_Piedvache?= Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique To: Oleg Bartunov Subject: Re: Tsearch2 really slower than ilike ? Date: Thu, 18 Nov 2004 11:30:13 +0100 User-Agent: KMail/1.7.1 Cc: pgsql-performance@postgresql.org References: <200411161555.59144.herve@elma.fr> <200411181027.00592.herve@elma.fr> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200411181130.13702.herve@elma.fr> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/278 X-Sequence-Number: 9232 Le Jeudi 18 Novembre 2004 10:37, Oleg Bartunov a �crit : > Have you run 'vacuum analyze' ? Yep every night VACUUM FULL VERBOSE ANALYZE; of all the database ! > 1;2c1;2c1;2c > 1;2c1;2c1;2cmy desktop is very simple PIII, 512 Mb RAM. > 1;2c1;2c1;2c Oleg > 1;2c1;2c1;2c YOU send strange caracters ! ;o) > 1;2c1;2c1;2cOn Thu, 18 Nov 2004, [iso-8859-15] Herv? Piedvache wrote: > > Oleg, > > > > Le Mercredi 17 Novembre 2004 18:23, Oleg Bartunov a ?crit : > >>> Sorry but when I do your request I get : > >>> # select id_site from site where idx_site_name @@ �'livejourn'; > >>> ERROR: �type "�" does not exist > >> > >> no idea :) btw, what version of postgresql and OS you're running. > >> Could you try minimal test - check sql commands from tsearch2 sources, > >> some basic queries from tsearch2 documentation, tutorials. > >> > >> btw, your query should looks like > >> select id_site from site_rss where idx_site_name @@ 'livejourn'; > >> ^^^^^^^^ > >> > >> How did you run your queries at all ? I mean your first message about > >> poor tsearch2 performance. > > > > I don't know what happend yesterday ... it's running now ... > > > > You sent me : > > zz=# explain analyze select id_site from site_rss where idx_site_name > > @@ �'livejourn'; > > � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �QUERY PLAN > > ------------------------------------------------------------------------- > >---------------------------------------------------------- Index Scan > > using ix_idx_site_name on site_rss �(cost=0.00..733.62 rows=184 width=4) > > (actual time=0.339..39.183 rows=1737 loops=1) > > � � Index Cond: (idx_site_name @@ '\'livejourn\''::tsquery) > > � � Filter: (idx_site_name @@ '\'livejourn\''::tsquery) > > � Total runtime: 40.997 ms > > (4 rows) > > > >> It's really fast ! So, I don't understand your problem. > >> I run query on my desktop machine, nothing special. > > > > I get this : > > QUERY PLAN > > ------------------------------------------------------------------------- > >---------------------------------------------------------------- Index > > Scan using ix_idx_site_name on site_rss s (cost=0.00..574.19 rows=187 > > width=24) (actual time=105.097..7157.277 rows=388 loops=1) > > Index Cond: (idx_site_name @@ '\'livejourn\''::tsquery) > > Filter: (idx_site_name @@ '\'livejourn\''::tsquery) > > Total runtime: 7158.576 ms > > (4 rows) > > > > With the ilike I get : > > QUERY PLAN > > ------------------------------------------------------------------------- > >----------------------------------- Seq Scan on site_rss s > > (cost=0.00..8360.23 rows=1 width=24) (actual time=8.195..879.440 rows=404 > > loops=1) > > Filter: (site_name ~~* '%livejourn%'::text) > > Total runtime: 882.600 ms > > (3 rows) > > > > I don't know what is your desktop ... but I'm using PostgreSQL 7.4.6, on > > Debian Woody with a PC Bi-PIII 933 Mhz and 1 Gb of memory ... the server > > is dedicated to this database ... !! > > > > I have no idea ! > > > > Regards, > > Regards, > Oleg > _____________________________________________________________ > Oleg Bartunov, sci.researcher, hostmaster of AstroNet, > Sternberg Astronomical Institute, Moscow University (Russia) > Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ > phone: +007(095)939-16-83, +007(095)939-23-83 > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend -- Herv� Piedvache Elma Ing�nierie Informatique 6 rue du Faubourg Saint-Honor� F-75008 - Paris - France Pho. 33-144949901 Fax. 33-144949902 From pgsql-performance-owner@postgresql.org Thu Nov 18 10:34:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 537CE3A400F for ; Thu, 18 Nov 2004 10:34:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20738-09 for ; Thu, 18 Nov 2004 10:34:33 +0000 (GMT) Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5A55A3A2BC2 for ; Thu, 18 Nov 2004 10:34:27 +0000 (GMT) Received: from ra (ra [158.250.29.2]) by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id iAIAYKQT018562; Thu, 18 Nov 2004 13:34:20 +0300 (MSK) Date: Thu, 18 Nov 2004 13:34:20 +0300 (MSK) From: Oleg Bartunov X-X-Sender: megera@ra.sai.msu.su To: =?iso-8859-15?q?Herv=E9_Piedvache?= Cc: pgsql-performance@postgresql.org Subject: Re: Tsearch2 really slower than ilike ? In-Reply-To: <200411181130.13702.herve@elma.fr> Message-ID: References: <200411161555.59144.herve@elma.fr> <200411181027.00592.herve@elma.fr> <200411181130.13702.herve@elma.fr> MIME-Version: 1.0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: Content-Type: TEXT/PLAIN; charset=koi8-r; format=flowed Content-Transfer-Encoding: 8BIT X-Archive-Number: 200411/279 X-Sequence-Number: 9233 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---559023410-1857409239-1100774060=:18871 Content-Type: TEXT/PLAIN; charset=koi8-r; format=flowed Content-Transfer-Encoding: 8BIT 1;2c1;2c1;2cBlin ! what's happenning with my terminal when I read messagess from this guy ? I don't even know how to call him - I see just Herv? Oleg 1;2c1;2c1;2c1;2c 1;2cOn Thu, 18 Nov 2004, [iso-8859-15] Herv? Piedvache wrote: > Le Jeudi 18 Novembre 2004 10:37, Oleg Bartunov a ?crit : >> Have you run 'vacuum analyze' ? > > Yep every night VACUUM FULL VERBOSE ANALYZE; of all the database ! > >> 1;2c1;2c1;2c >> 1;2c1;2c1;2cmy desktop is very simple PIII, 512 Mb RAM. >> 1;2c1;2c11;2c1;2c1;2c;2c Oleg1;2c1;2c1;2c >> 11;2c1;2c1;2c;2c1;2c1;2c > > YOU send strange caracters ! ;o) > >> 1;2c1;2c1;2cOn Thu, 18 Nov 2004, [iso-8859-15] Herv? Piedvache wrote: >>> Oleg, >>> >>> Le Mercredi 17 Novembre 2004 18:23, Oleg Bartunov a ?crit : >>>>> Sorry but when I do your request I get : >>>>> # select id_site from site where idx_site_name @@ �'livejourn'; >>>>> ERROR: �type "�" d1;2c1;2c1;2c1;2coes not exist >>>> >>>> no idea :) btw, what version of postgresql and OS you're running. >>>> Could you try minimal test - check sql commands from tsearch2 sources, >>>> some basic queries from tsearch2 documentation, tutorials. >>>> >>>> btw, your query should looks like >>>> select id_site from site_rss where idx_site_name @@ 'livejourn'; >>>> ^^^^^^^^ >>>> >>>> How did you run your queries at all ? I mean your first message about >>>> poor tsearch2 performance. >>> >>> I don't know what happend yesterday ... it's running now ... >>> >>> You sent me : >>> zz=# explain analyze select id_site from site_rss where idx_site_name >>> @@ �'livejourn'; >>> � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �QUERY PLAN >>> ------------------------------------------------------------------------- >>> ---------------------------------------------------------- Index Scan >>> using ix_idx_site_name on site_rss �(cost=0.00..733.62 rows=184 width=4) >>> (actual time=0.339..39.183 rows=1737 loops=1) >>> � � Index Cond: (idx_site_name @@ '\'livejourn\''::tsquery) >>> � � Filter: (idx_site_name @@ '\'livejourn\''::tsquery) >>> � Total runtime: 40.997 ms >>> (4 rows) >>> >>>> It's really fast ! So, I don't understand your problem. >>>> I run query on my desktop machine, nothing special. >>> >>> I get this : >>> QUERY PLAN >>> ------------------------------------------------------------------------- >>> ---------------------------------------------------------------- Index >>> Scan using ix_idx_site_name on site_rss s (cost=0.00..574.19 rows=187 >>> width=24) (actual time=105.097..7157.277 rows=388 loops=1) >>> Index Cond: (idx_site_name @@ '\'livejourn\''::tsquery) >>> Filter: (idx_site_name @@ '\'livejourn\''::tsquery) >>> Total runtime: 7158.576 ms >>> (4 rows) >>> >>> With the ilike I get : >>> QUERY PLAN >>> ------------------------------------------------------------------------- >>> ----------------------------------- Seq Scan on site_rss s >>> (cost=0.00..8360.23 rows=1 width=24) (actual time=8.195..879.440 rows=404 >>> loops=1) >>> Filter: (site_name ~~* '%livejourn%'::text) >>> Total runtime: 882.600 ms >>> (3 rows) >>> >>> I don't know what is your desktop ... but I'm using PostgreSQL 7.4.6, on >>> Debian Woody with a PC Bi-PIII 933 Mhz and 1 Gb of memory ... the server >>> is dedicated to this database ... !! >>> >>> I have no idea ! >>> >>> Regards, >> >> Regards, >> Oleg >> _____________________________________________________________ >> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, >> Sternberg Astronomical Institute, Moscow University (Russia) >> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ >> phone: +007(095)939-16-83, +007(095)939-23-83 >> ---------------------------(end of broadcast)--------------------------- >> TIP 8: explain analyze is your friend > > Regards, Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83 ---559023410-1857409239-1100774060=:18871-- From pgsql-performance-owner@postgresql.org Thu Nov 18 10:53:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2BD683A4647 for ; Thu, 18 Nov 2004 10:53:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29615-10 for ; Thu, 18 Nov 2004 10:53:32 +0000 (GMT) Received: from usbb-lacimss3.unisys.com (usbb-lacimss3.unisys.com [192.63.108.53]) by svr1.postgresql.org (Postfix) with ESMTP id 0CD0D3A4631 for ; Thu, 18 Nov 2004 10:53:33 +0000 (GMT) Received: from usbb-lacgw1.lac.uis.unisys.com ([129.226.160.21]unverified) by usbb-lacimss3 with InterScan Messaging Security Suite; Thu, 18 Nov 2004 05:58:11 -0500 Received: from usbb-lacgw1.lac.uis.unisys.com ([129.226.160.23]) by usbb-lacgw1.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.211); Thu, 18 Nov 2004 05:53:24 -0500 Received: from gbmk-eugw1.eu.uis.unisys.com ([129.221.133.28]) by usbb-lacgw1.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.211); Thu, 18 Nov 2004 05:53:24 -0500 Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by gbmk-eugw1.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.47); Thu, 18 Nov 2004 10:53:09 +0000 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: base64 Subject: Re: Tsearch2 really slower than ilike ? Date: Thu, 18 Nov 2004 11:53:08 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Tsearch2 really slower than ilike ? Thread-Index: AcTNW9e/eqdTVvytRFCbxbKRQh9E0gAAGulw From: "Leeuw van der, Tim" To: "Oleg Bartunov" Cc: X-OriginalArrivalTime: 18 Nov 2004 10:53:09.0090 (UTC) FILETIME=[CA7A1420:01C4CD5C] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/280 X-Sequence-Number: 9234 RnJlbmNoIGVuY29kaW5ncyB2cy4gQ3lyaWxsaWMgZW5jb2RpbmdzPyBDaGFyYWN0ZXJzIGNvbWlu ZyB0aHJ1IHRoZSBtYWlsIGluIHNvbWUgZW5jb2RpbmcgdGhhdCBkb24ndCBnZXQgdHJhbnNsYXRl ZCBwcm9wZXJseS4NCg0KSGlzIG5hbWUgaXMgSGVydmUgUGllZHZhY2hlLCB3aGVyZSB0aGUgMm5k ICdlJyBpbiBIZXJ2ZSBpcyBhbiBhY2NlbnRlZCBjaGFyYWN0ZXIuIEl0IG11c3Qgc29tZWhvdyBk byB3ZWlyZCB0aGluZ3MgdG8geW91ciB0ZXJtaW5hbCB3aGVuIGl0J3MgdHJ5aW5nIHRvIG1hcCB0 aGF0IGludG8gdGhlIGVuY29kaW5nIHdoaWNoIHlvdSB1c2UuDQoNCk1lc3NhZ2VzIGZyb20geW91 IGFsc28gY29tZSBvdXQgaW4gbXkgbWFpbGVyOyBsb3RzIG9mICcxOzJjMTsyYycgc2VxdWVuY2Vz IChvbmUgLSBzZW1pLWNvbG9uIC0gMiAtIGNoYXJhY3Rlci1jIGFuZCByZXBlYXQpDQoNCmNoZWVy cywNCg0KLS1UaW0NCg0KLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCkZyb206IHBnc3FsLXBl cmZvcm1hbmNlLW93bmVyQHBvc3RncmVzcWwub3JnDQpbbWFpbHRvOnBnc3FsLXBlcmZvcm1hbmNl LW93bmVyQHBvc3RncmVzcWwub3JnXU9uIEJlaGFsZiBPZiBPbGVnDQpCYXJ0dW5vdg0KU2VudDog VGh1cnNkYXksIE5vdmVtYmVyIDE4LCAyMDA0IDExOjM0IEFNDQpUbzogSGVydmUgUGllZHZhY2hl DQpDYzogcGdzcWwtcGVyZm9ybWFuY2VAcG9zdGdyZXNxbC5vcmcNClN1YmplY3Q6IFJlOiBbUEVS Rk9STV0gVHNlYXJjaDIgcmVhbGx5IHNsb3dlciB0aGFuIGlsaWtlID8NCg0KDQoxOzJjMTsyYzE7 MmNCbGluICENCg0Kd2hhdCdzIGhhcHBlbm5pbmcgd2l0aCBteSB0ZXJtaW5hbCB3aGVuIEkgcmVh ZCBtZXNzYWdlc3MgZnJvbSB0aGlzIGd1eSA/DQpJIGRvbid0IGV2ZW4ga25vdyBob3cgdG8gY2Fs bCBoaW0gLSBJIHNlZSBqdXN0IEhlcnY/DQoNCiAJT2xlZw0KMTsyYzE7MmMxOzJjMTsyYw0KMTsy Y09uIFRodSwgMTggTm92IDIwMDQsIFtpc28tODg1OS0xNV0gSGVydj8gUGllZHZhY2hlIHdyb3Rl Og0KDQo+IExlIEpldWRpIDE4IE5vdmVtYnJlIDIwMDQgMTA6MzcsIE9sZWcgQmFydHVub3YgYSA/ Y3JpdCA6DQo+PiBIYXZlIHlvdSBydW4gJ3ZhY3V1bSBhbmFseXplJyA/DQo+DQo+IFllcCBldmVy eSBuaWdodCBWQUNVVU0gRlVMTCBWRVJCT1NFIEFOQUxZWkU7IG9mIGFsbCB0aGUgZGF0YWJhc2Ug IQ0KPg0KPj4gMTsyYzE7MmMxOzJjDQo+PiAxOzJjMTsyYzE7MmNteSBkZXNrdG9wIGlzIHZlcnkg c2ltcGxlIFBJSUksIDUxMiBNYiBSQU0uDQo+PiAxOzJjMTsyYzExOzJjMTsyYzE7MmM7MmMgT2xl ZzE7MmMxOzJjMTsyYw0KPj4gMTE7MmMxOzJjMTsyYzsyYzE7MmMxOzJjDQo+DQo+IFlPVSBzZW5k IHN0cmFuZ2UgY2FyYWN0ZXJzICEgO28pDQo+DQo+PiAxOzJjMTsyYzE7MmNPbiBUaHUsIDE4IE5v diAyMDA0LCBbaXNvLTg4NTktMTVdIEhlcnY/IFBpZWR2YWNoZSB3cm90ZToNCj4+PiBPbGVnLA0K Pj4+DQo+Pj4gTGUgTWVyY3JlZGkgMTcgTm92ZW1icmUgMjAwNCAxODoyMywgT2xlZyBCYXJ0dW5v diBhID9jcml0IDoNCj4+Pj4+IFNvcnJ5IGJ1dCB3aGVuIEkgZG8geW91ciByZXF1ZXN0IEkgZ2V0 IDoNCj4+Pj4+ICMgc2VsZWN0IGlkX3NpdGUgZnJvbSBzaXRlIHdoZXJlIGlkeF9zaXRlX25hbWUg QEAgwqAnbGl2ZWpvdXJuJzsNCj4+Pj4+IEVSUk9SOiDCoHR5cGUgIsKgIiBkMTsyYzE7MmMxOzJj MTsyY29lcyBub3QgZXhpc3QNCj4+Pj4NCj4+Pj4gbm8gaWRlYSA6KSBidHcsIHdoYXQgdmVyc2lv biBvZiBwb3N0Z3Jlc3FsIGFuZCBPUyB5b3UncmUgcnVubmluZy4NCj4+Pj4gQ291bGQgeW91IHRy eSBtaW5pbWFsIHRlc3QgLSBjaGVjayBzcWwgY29tbWFuZHMgZnJvbSB0c2VhcmNoMiBzb3VyY2Vz LA0KPj4+PiBzb21lIGJhc2ljIHF1ZXJpZXMgZnJvbSB0c2VhcmNoMiBkb2N1bWVudGF0aW9uLCB0 dXRvcmlhbHMuDQo+Pj4+DQo+Pj4+IGJ0dywgeW91ciBxdWVyeSBzaG91bGQgbG9va3MgbGlrZQ0K Pj4+PiBzZWxlY3QgaWRfc2l0ZSBmcm9tIHNpdGVfcnNzIHdoZXJlIGlkeF9zaXRlX25hbWUgQEAg J2xpdmVqb3Vybic7DQo+Pj4+ICAgICAgICAgICAgICAgICAgICAgIF5eXl5eXl5eDQo+Pj4+DQo+ Pj4+IEhvdyBkaWQgeW91IHJ1biB5b3VyIHF1ZXJpZXMgYXQgYWxsID8gSSBtZWFuIHlvdXIgZmly c3QgbWVzc2FnZSBhYm91dA0KPj4+PiBwb29yIHRzZWFyY2gyIHBlcmZvcm1hbmNlLg0KPj4+DQo+ Pj4gSSBkb24ndCBrbm93IHdoYXQgaGFwcGVuZCB5ZXN0ZXJkYXkgLi4uIGl0J3MgcnVubmluZyBu b3cgLi4uDQo+Pj4NCj4+PiBZb3Ugc2VudCBtZSA6DQo+Pj4geno9IyBleHBsYWluIGFuYWx5emUg c2VsZWN0IGlkX3NpdGUgZnJvbSBzaXRlX3JzcyB3aGVyZSBpZHhfc2l0ZV9uYW1lDQo+Pj4gQEAg wqAnbGl2ZWpvdXJuJzsNCj4+PiDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDC oCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoFFV RVJZIFBMQU4NCj4+PiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQo+Pj4gLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSBJbmRleCBTY2FuDQo+Pj4gdXNp bmcgaXhfaWR4X3NpdGVfbmFtZSBvbiBzaXRlX3JzcyDCoChjb3N0PTAuMDAuLjczMy42MiByb3dz PTE4NCB3aWR0aD00KQ0KPj4+IChhY3R1YWwgdGltZT0wLjMzOS4uMzkuMTgzIHJvd3M9MTczNyBs b29wcz0xKQ0KPj4+IMKgIMKgIEluZGV4IENvbmQ6IChpZHhfc2l0ZV9uYW1lIEBAICdcJ2xpdmVq b3VyblwnJzo6dHNxdWVyeSkNCj4+PiDCoCDCoCBGaWx0ZXI6IChpZHhfc2l0ZV9uYW1lIEBAICdc J2xpdmVqb3VyblwnJzo6dHNxdWVyeSkNCj4+PiDCoCBUb3RhbCBydW50aW1lOiA0MC45OTcgbXMN Cj4+PiAoNCByb3dzKQ0KPj4+DQo+Pj4+IEl0J3MgcmVhbGx5IGZhc3QgISBTbywgSSBkb24ndCB1 bmRlcnN0YW5kIHlvdXIgcHJvYmxlbS4NCj4+Pj4gSSBydW4gcXVlcnkgb24gbXkgZGVza3RvcCBt YWNoaW5lLCBub3RoaW5nIHNwZWNpYWwuDQo+Pj4NCj4+PiBJIGdldCB0aGlzIDoNCj4+PiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IFFVRVJZIFBMQU4NCj4+PiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQo+Pj4gLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSBJbmRleA0KPj4+ IFNjYW4gdXNpbmcgaXhfaWR4X3NpdGVfbmFtZSBvbiBzaXRlX3JzcyBzICAoY29zdD0wLjAwLi41 NzQuMTkgcm93cz0xODcNCj4+PiB3aWR0aD0yNCkgKGFjdHVhbCB0aW1lPTEwNS4wOTcuLjcxNTcu Mjc3IHJvd3M9Mzg4IGxvb3BzPTEpDQo+Pj4gICBJbmRleCBDb25kOiAoaWR4X3NpdGVfbmFtZSBA QCAnXCdsaXZlam91cm5cJyc6OnRzcXVlcnkpDQo+Pj4gICBGaWx0ZXI6IChpZHhfc2l0ZV9uYW1l IEBAICdcJ2xpdmVqb3VyblwnJzo6dHNxdWVyeSkNCj4+PiBUb3RhbCBydW50aW1lOiA3MTU4LjU3 NiBtcw0KPj4+ICg0IHJvd3MpDQo+Pj4NCj4+PiBXaXRoIHRoZSBpbGlrZSBJIGdldCA6DQo+Pj4g ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUVVFUlkgUExB Tg0KPj4+IC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0NCj4+PiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLSBTZXEgU2NhbiBvbiBzaXRlX3JzcyBzDQo+Pj4gKGNvc3Q9MC4wMC4uODM2MC4yMyBy b3dzPTEgd2lkdGg9MjQpIChhY3R1YWwgdGltZT04LjE5NS4uODc5LjQ0MCByb3dzPTQwNA0KPj4+ IGxvb3BzPTEpDQo+Pj4gICBGaWx0ZXI6IChzaXRlX25hbWUgfn4qICclbGl2ZWpvdXJuJSc6OnRl eHQpDQo+Pj4gVG90YWwgcnVudGltZTogODgyLjYwMCBtcw0KPj4+ICgzIHJvd3MpDQo+Pj4NCj4+ PiBJIGRvbid0IGtub3cgd2hhdCBpcyB5b3VyIGRlc2t0b3AgLi4uIGJ1dCBJJ20gdXNpbmcgUG9z dGdyZVNRTCA3LjQuNiwgb24NCj4+PiBEZWJpYW4gV29vZHkgd2l0aCBhIFBDIEJpLVBJSUkgOTMz IE1oeiBhbmQgMSBHYiBvZiBtZW1vcnkgLi4uIHRoZSBzZXJ2ZXINCj4+PiBpcyBkZWRpY2F0ZWQg dG8gdGhpcyBkYXRhYmFzZSAuLi4gISENCj4+Pg0KPj4+IEkgaGF2ZSBubyBpZGVhICENCj4+Pg0K Pj4+IFJlZ2FyZHMsDQo+Pg0KPj4gIAlSZWdhcmRzLA0KPj4gIAkJT2xlZw0KPj4gX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fXw0KPj4g T2xlZyBCYXJ0dW5vdiwgc2NpLnJlc2VhcmNoZXIsIGhvc3RtYXN0ZXIgb2YgQXN0cm9OZXQsDQo+ PiBTdGVybmJlcmcgQXN0cm9ub21pY2FsIEluc3RpdHV0ZSwgTW9zY293IFVuaXZlcnNpdHkgKFJ1 c3NpYSkNCj4+IEludGVybmV0OiBvbGVnQHNhaS5tc3Uuc3UsIGh0dHA6Ly93d3cuc2FpLm1zdS5z dS9+bWVnZXJhLw0KPj4gcGhvbmU6ICswMDcoMDk1KTkzOS0xNi04MywgKzAwNygwOTUpOTM5LTIz LTgzDQo+PiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0oZW5kIG9mIGJyb2FkY2FzdCktLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0NCj4+IFRJUCA4OiBleHBsYWluIGFuYWx5emUgaXMgeW91 ciBmcmllbmQNCj4NCj4NCg0KIAlSZWdhcmRzLA0KIAkJT2xlZw0KX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fXw0KT2xlZyBCYXJ0dW5v diwgc2NpLnJlc2VhcmNoZXIsIGhvc3RtYXN0ZXIgb2YgQXN0cm9OZXQsDQpTdGVybmJlcmcgQXN0 cm9ub21pY2FsIEluc3RpdHV0ZSwgTW9zY293IFVuaXZlcnNpdHkgKFJ1c3NpYSkNCkludGVybmV0 OiBvbGVnQHNhaS5tc3Uuc3UsIGh0dHA6Ly93d3cuc2FpLm1zdS5zdS9+bWVnZXJhLw0KcGhvbmU6 ICswMDcoMDk1KTkzOS0xNi04MywgKzAwNygwOTUpOTM5LTIzLTgzDQotLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0oZW5kIG9mIGJyb2FkY2FzdCktLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0N ClRJUCA2OiBIYXZlIHlvdSBzZWFyY2hlZCBvdXIgbGlzdCBhcmNoaXZlcz8NCg0KICAgICAgICAg ICAgICAgaHR0cDovL2FyY2hpdmVzLnBvc3RncmVzcWwub3JnDQo= From pgsql-performance-owner@postgresql.org Thu Nov 18 13:42:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 06FB73A4675 for ; Thu, 18 Nov 2004 13:42:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80803-09 for ; Thu, 18 Nov 2004 13:42:17 +0000 (GMT) Received: from navgstl1.scottrade.com (navgstl1.scottrader.com [208.219.220.247]) by svr1.postgresql.org (Postfix) with SMTP id 39C4E3A461E for ; Thu, 18 Nov 2004 13:42:20 +0000 (GMT) Received: from sagstl2.scottrade.com ([208.219.220.215]) by navgstl1.scottrade.com (SMSSMTP 4.0.0.59) with SMTP id M2004111807422005953 for ; Thu, 18 Nov 2004 07:42:20 -0600 Received: from exchstl1.scottrade.com ([172.28.140.45]) by sagstl2.scottrade.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 18 Nov 2004 07:42:20 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Subject: Query Performance and IOWait Date: Thu, 18 Nov 2004 07:42:20 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Tsearch2 really slower than ilike ? Thread-Index: AcTNW9e/eqdTVvytRFCbxbKRQh9E0gAAGulwAAYGMOA= From: "Andrew Janian" To: X-OriginalArrivalTime: 18 Nov 2004 13:42:20.0655 (UTC) FILETIME=[6D47F7F0:01C4CD74] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/281 X-Sequence-Number: 9235 SGVsbG8gQWxsLA0KDQpJIGhhdmUgYSBzZXR1cCB3aXRoIGEgRGVsbCBQb3dlcmVkZ2UgMjY1MCB3 aXRoIFJlZCBIYXQgYW5kIFBvc3RncmVzIDcuNC41IHdpdGggYSBkYXRhYmFzZSB3aXRoIGFib3V0 IDI3R0Igb2YgZGF0YS4gIFRoZSB0YWJsZSBpbiBxdWVzdGlvbiBoYXMgYWJvdXQgMzUgbWlsbGlv biByb3dzLg0KDQpJIGFtIHJ1bm5pbmcgdGhlIGZvbGxvd2luZyBxdWVyeToNCg0KU0VMRUNUICoN CkZST00gbWJfZml4X21lc3NhZ2UNCldIRVJFIG1zZ19jbGllbnRfb3JkZXJfaWQgSU4gKA0KCVNF TEVDVCBtc2dfY2xpZW50X29yZGVyX2lkDQoJRlJPTSBtYl9maXhfbWVzc2FnZQ0KCVdIRVJFIG1z Z19sb2dfdGltZSA+PSAnMjAwNC0wNi0wMScNCgkJQU5EIG1zZ19sb2dfdGltZSA8ICcyMDA0LTA2 LTAxIDEzOjMwOjAwLjAwMCcNCgkJQU5EIG1zZ19tZXNzYWdlX3R5cGUgSU4gKCdEJywnRycpDQoJ CUFORCBtYl9vcmRfdHlwZSA9ICcxJw0KCSkNCglBTkQgbXNnX2xvZ190aW1lID4gJzIwMDQtMDYt MDEnDQoJQU5EIG1zZ19sb2dfdGltZSA8ICcyMDA0LTA2LTAxIDIzOjU5OjU5Ljk5OScNCglBTkQg bXNnX21lc3NhZ2VfdHlwZSA9ICc4Jw0KCUFORCAobWJfcmF3X3RleHQgTElLRSAnJTM5PTElJyBP UiBtYl9yYXdfdGV4dCBMSUtFICclMzk9MiUnKTsNCg0Kd2l0aCB0aGUgZm9sbG93aW5nIHBsYW46 DQoNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFFVRVJZIFBM QU4NCk5lc3RlZCBMb29wIElOIEpvaW4gIChjb3N0PTAuMDAuLjM0MDQ3LjI5IHJvd3M9MSB3aWR0 aD01MjYpDQogIC0+ICBJbmRleCBTY2FuIHVzaW5nIG1maV9sb2dfdGltZSBvbiBtYl9maXhfbWVz c2FnZSAgKGNvc3Q9MC4wMC4uMjIyMzEuMzEgcm93cz0yNTM5IHdpZHRoPTUyNikNCiAgICAgICBJ bmRleCBDb25kOiAoKG1zZ19sb2dfdGltZSA+ICcyMDA0LTA2LTAxIDAwOjAwOjAwJzo6dGltZXN0 YW1wIHdpdGhvdXQgdGltZSB6b25lKSBBTkQgKG1zZ19sb2dfdGltZSA8ICcyMDA0LTA2LTAxIDIz OjU5OjU5Ljk5OSc6OnRpbWVzdGFtcCB3aXRob3V0IHRpbWUgem9uZSkpDQogICAgICAgRmlsdGVy OiAoKChtc2dfbWVzc2FnZV90eXBlKTo6dGV4dCA9ICc4Jzo6dGV4dCkgQU5EICgoKG1iX3Jhd190 ZXh0KTo6dGV4dCB+fiAnJTM5PTElJzo6dGV4dCkgT1IgKChtYl9yYXdfdGV4dCk6OnRleHQgfn4g JyUzOT0yJSc6OnRleHQpKSkNCiAgLT4gIEluZGV4IFNjYW4gdXNpbmcgbWZpX2NsaWVudF9vcmRp ZCBvbiBtYl9maXhfbWVzc2FnZSAgKGNvc3Q9MC4wMC4uNDQ1LjU2IHJvd3M9MSB3aWR0aD0xOCkN CiAgICAgICBJbmRleCBDb25kOiAoKCJvdXRlciIubXNnX2NsaWVudF9vcmRlcl9pZCk6OnRleHQg PSAobWJfZml4X21lc3NhZ2UubXNnX2NsaWVudF9vcmRlcl9pZCk6OnRleHQpDQogICAgICAgRmls dGVyOiAoKG1zZ19sb2dfdGltZSA+PSAnMjAwNC0wNi0wMSAwMDowMDowMCc6OnRpbWVzdGFtcCB3 aXRob3V0IHRpbWUgem9uZSkgQU5EIChtc2dfbG9nX3RpbWUgPCAnMjAwNC0wNi0wMSAxMzozMDow MCc6OnRpbWVzdGFtcCB3aXRob3V0IHRpbWUgem9uZSkgQU5EICgobXNnX21lc3NhZ2VfdHlwZSk6 OnRleHQgPSAnRCc6OnRleHQpIE9SICgobXNnX21lc3NhZ2VfdHlwZSk6OnRleHQgPSAnRyc6OnRl eHQpKSBBTkQgKChtYl9vcmRfdHlwZSk6OnRleHQgPSAnMSc6OnRleHQpKQ0KDQpXaGlsZSBydW5u aW5nLCB0aGlzIHF1ZXJ5IHByb2R1Y2VzIDEwMCUgaW93YWl0IHVzYWdlIG9uIGl0cyBwcm9jZXNz b3IgYW5kIHRha2VzIGEgdW5nb2RseSBhbW91bnQgb2YgdGltZSAoYWJvdXQgYW4gaG91cikuDQoN ClRoZSBwb3N0Z3JlcyBzZXR0aW5ncyBhcmUgYXMgZm9sbG93czoNCg0Kc2hhcmVkX2J1ZmZlcnMg PSAzMjc2OCAgICAgICAgICAjIG1pbiAxNiwgYXQgbGVhc3QgbWF4X2Nvbm5lY3Rpb25zKjIsIDhL QiBlYWNoDQpzb3J0X21lbSA9IDI2MjE0NCAgICAgICAgICAgICAgICMgbWluIDY0LCBzaXplIGlu IEtCDQoNCkFuZCB0aGUgL2V0Yy9zeXNjdGwuY29uZiBoYXM6DQprZXJuZWwuc2htYWxsID0gMjc0 MjM1MzkyDQprZXJuZWwuc2htbWF4ID0gMjc0MjM1MzkyDQoNClRoZSBzeXN0ZW0gaGFzIDRHQiBv ZiBSQU0uDQoNCkkgYW0gcHJldHR5IHN1cmUgb2YgdGhlc2Ugc2V0dGluZ3MsIGJ1dCBvbmx5IGZy b20gbXkgcmVhZGluZyBvZiB0aGUgZG9jcyBhbmQgb3RoZXJzJyByZWNvbW1lbmRhdGlvbnMgb25s aW5lLg0KDQpUaGFua3MsDQoNCkFuZHJldyBKYW5pYW4NCk9NUyBEZXZlbG9wbWVudA0KU2NvdHRy YWRlIEZpbmFuY2lhbCBTZXJ2aWNlcw0KKDMxNCkgOTY1LTE1NTUgeCAxNTEzDQpDZWxsOiAoMzE0 KSAzNjktMjA4Mw0K From pgsql-performance-owner@postgresql.org Thu Nov 18 13:57:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6DA0A3A4675; Thu, 18 Nov 2004 13:57:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90246-05; Thu, 18 Nov 2004 13:57:06 +0000 (GMT) Received: from dfw-gate1.raytheon.com (dfw-gate1.raytheon.com [199.46.199.230]) by svr1.postgresql.org (Postfix) with ESMTP id 6E1833A3E21; Thu, 18 Nov 2004 13:57:08 +0000 (GMT) Received: from ds02c01.directory.ray.com (ds02c01.directory.ray.com [147.25.138.115]) by dfw-gate1.raytheon.com (8.12.10/8.12.10) with ESMTP id iAIDv8E6005481; Thu, 18 Nov 2004 07:57:08 -0600 (CST) Received: from ds02c01 (localhost [127.0.0.1]) by ds02c01.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id iAIDv6Qt013144; Thu, 18 Nov 2004 13:57:06 GMT Received: from ds02c01.directory.ray.com with LMTP by ds02c01 (2.0.6/sieved-2-0-build-559); Thu, 18 Nov 2004 13:57:06 +0000 Received: from notesserver5.ftw.us.ray.com (notesserver5.ftw.us.ray.com [151.168.145.35]) by ds02c01.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id iAIDude6012876 sender Richard_D_Levine@raytheon.com; Thu, 18 Nov 2004 13:56:39 GMT Subject: Re: Query Performance and IOWait To: "Andrew Janian" Cc: pgsql-performance@postgresql.org, pgsql-performance-owner@postgresql.org X-Mailer: Lotus Notes Release 5.0.8 June 18, 2001 Message-ID: From: Richard_D_Levine@raytheon.com Date: Thu, 18 Nov 2004 08:56:41 -0500 X-MIMETrack: Serialize by Router on NotesServer5/HDC(Release 6.5.2|June 01, 2004) at 11/18/2004 08:56:39 AM MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-SPAM: 0.00 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200411/282 X-Sequence-Number: 9236 Andrew, It seems that you could combine the subquery's WHERE clause with the main query's to produce a simpler query, i.e. one without a subquery. Rick "Andrew Janian" To: Sent by: cc: pgsql-performance-owner@pos Subject: [PERFORM] Query Performance and IOWait tgresql.org 11/18/2004 08:42 AM Hello All, I have a setup with a Dell Poweredge 2650 with Red Hat and Postgres 7.4.5 with a database with about 27GB of data. The table in question has about 35 million rows. I am running the following query: SELECT * FROM mb_fix_message WHERE msg_client_order_id IN ( SELECT msg_client_order_id FROM mb_fix_message WHERE msg_log_time >= '2004-06-01' AND msg_log_time < '2004-06-01 13:30:00.000' AND msg_message_type IN ('D','G') AND mb_ord_type = '1' ) AND msg_log_time > '2004-06-01' AND msg_log_time < '2004-06-01 23:59:59.999' AND msg_message_type = '8' AND (mb_raw_text LIKE '%39=1%' OR mb_raw_text LIKE '%39=2%'); with the following plan: QUERY PLAN Nested Loop IN Join (cost=0.00..34047.29 rows=1 width=526) -> Index Scan using mfi_log_time on mb_fix_message (cost=0.00..22231.31 rows=2539 width=526) Index Cond: ((msg_log_time > '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 23:59:59.999'::timestamp without time zone)) Filter: (((msg_message_type)::text = '8'::text) AND (((mb_raw_text)::text ~~ '%39=1%'::text) OR ((mb_raw_text)::text ~~ '%39=2%'::text))) -> Index Scan using mfi_client_ordid on mb_fix_message (cost=0.00..445.56 rows=1 width=18) Index Cond: (("outer".msg_client_order_id)::text = (mb_fix_message.msg_client_order_id)::text) Filter: ((msg_log_time >= '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 13:30:00'::timestamp without time zone) AND ((msg_message_type)::text = 'D'::text) OR ((msg_message_type)::text = 'G'::text)) AND ((mb_ord_type)::text = '1'::text)) While running, this query produces 100% iowait usage on its processor and takes a ungodly amount of time (about an hour). The postgres settings are as follows: shared_buffers = 32768 # min 16, at least max_connections*2, 8KB each sort_mem = 262144 # min 64, size in KB And the /etc/sysctl.conf has: kernel.shmall = 274235392 kernel.shmmax = 274235392 The system has 4GB of RAM. I am pretty sure of these settings, but only from my reading of the docs and others' recommendations online. Thanks, Andrew Janian OMS Development Scottrade Financial Services (314) 965-1555 x 1513 Cell: (314) 369-2083 ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings From pgsql-performance-owner@postgresql.org Thu Nov 18 14:02:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 61BAC3A4675; Thu, 18 Nov 2004 14:02:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91024-04; Thu, 18 Nov 2004 14:01:57 +0000 (GMT) Received: from navgstl1.scottrade.com (navgstl1.scottsdalesecurities.com [208.219.220.247]) by svr1.postgresql.org (Postfix) with SMTP id E81493A46A4; Thu, 18 Nov 2004 14:01:59 +0000 (GMT) Received: from sagstl2.scottrade.com ([208.219.220.215]) by navgstl1.scottrade.com (SMSSMTP 4.0.0.59) with SMTP id M2004111808015906540 ; Thu, 18 Nov 2004 08:01:59 -0600 Received: from exchstl1.scottrade.com ([172.28.140.45]) by sagstl2.scottrade.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 18 Nov 2004 08:01:59 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: Query Performance and IOWait Date: Thu, 18 Nov 2004 08:01:58 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Query Performance and IOWait Thread-Index: AcTNdoD9XbMma+xgRj6XB6+HpCvtMAAAIFgA From: "Andrew Janian" To: Cc: , X-OriginalArrivalTime: 18 Nov 2004 14:01:59.0842 (UTC) FILETIME=[2C21A020:01C4CD77] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/283 X-Sequence-Number: 9237 Actually, unfortunately, that won't work. The subquery gets a list of = message IDs and then the outer query gets the responses to those = messages. Also, I dumped this data and imported it all to ms sql server and then = ran it there. The query ran in 2s. Andrew -----Original Message----- From: Richard_D_Levine@raytheon.com [mailto:Richard_D_Levine@raytheon.com] Sent: Thursday, November 18, 2004 7:57 AM To: Andrew Janian Cc: pgsql-performance@postgresql.org; pgsql-performance-owner@postgresql.org Subject: Re: [PERFORM] Query Performance and IOWait Andrew, It seems that you could combine the subquery's WHERE clause with the = main query's to produce a simpler query, i.e. one without a subquery. Rick = =20 "Andrew Janian" = =20 To: = = =20 Sent by: cc: = =20 pgsql-performance-owner@pos Subject: = [PERFORM] Query Performance and IOWait = =20 tgresql.org = =20 = =20 = =20 11/18/2004 08:42 AM = =20 = =20 = =20 Hello All, I have a setup with a Dell Poweredge 2650 with Red Hat and Postgres = 7.4.5 with a database with about 27GB of data. The table in question has = about 35 million rows. I am running the following query: SELECT * FROM mb_fix_message WHERE msg_client_order_id IN ( SELECT msg_client_order_id FROM mb_fix_message WHERE msg_log_time >=3D '2004-06-01' AND msg_log_time < '2004-06-01 13:30:00.000' AND msg_message_type IN ('D','G') AND mb_ord_type =3D '1' ) AND msg_log_time > '2004-06-01' AND msg_log_time < '2004-06-01 23:59:59.999' AND msg_message_type =3D '8' AND (mb_raw_text LIKE '%39=3D1%' OR mb_raw_text LIKE = '%39=3D2%'); with the following plan: QUERY PLAN Nested Loop IN Join (cost=3D0.00..34047.29 rows=3D1 width=3D526) -> Index Scan using mfi_log_time on mb_fix_message = (cost=3D0.00..22231.31 rows=3D2539 width=3D526) Index Cond: ((msg_log_time > '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 = 23:59:59.999'::timestamp without time zone)) Filter: (((msg_message_type)::text =3D '8'::text) AND (((mb_raw_text)::text ~~ '%39=3D1%'::text) OR ((mb_raw_text)::text ~~ '%39=3D2%'::text))) -> Index Scan using mfi_client_ordid on mb_fix_message (cost=3D0.00..445.56 rows=3D1 width=3D18) Index Cond: (("outer".msg_client_order_id)::text =3D (mb_fix_message.msg_client_order_id)::text) Filter: ((msg_log_time >=3D '2004-06-01 00:00:00'::timestamp = without time zone) AND (msg_log_time < '2004-06-01 13:30:00'::timestamp without time zone) AND ((msg_message_type)::text =3D 'D'::text) OR ((msg_message_type)::text =3D 'G'::text)) AND ((mb_ord_type)::text =3D '1'::text)) While running, this query produces 100% iowait usage on its processor = and takes a ungodly amount of time (about an hour). The postgres settings are as follows: shared_buffers =3D 32768 # min 16, at least max_connections*2, = 8KB each sort_mem =3D 262144 # min 64, size in KB And the /etc/sysctl.conf has: kernel.shmall =3D 274235392 kernel.shmmax =3D 274235392 The system has 4GB of RAM. I am pretty sure of these settings, but only from my reading of the docs and others' recommendations online. Thanks, Andrew Janian OMS Development Scottrade Financial Services (314) 965-1555 x 1513 Cell: (314) 369-2083 ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings From pgsql-performance-owner@postgresql.org Thu Nov 18 14:18:47 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 340693A46AB for ; Thu, 18 Nov 2004 14:18:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94378-09 for ; Thu, 18 Nov 2004 14:18:27 +0000 (GMT) Received: from iglassmail.istructure.com (unknown [24.199.154.122]) by svr1.postgresql.org (Postfix) with ESMTP id BFE693A4624 for ; Thu, 18 Nov 2004 14:18:29 +0000 (GMT) Received: from iglassnoc3 ([192.168.177.128]) by iglassmail.istructure.com with Microsoft SMTPSVC(6.0.3790.211); Thu, 18 Nov 2004 09:21:08 -0500 From: "Woody Woodring" To: "'Andrew Janian'" Cc: Subject: Re: Query Performance and IOWait Date: Thu, 18 Nov 2004 09:18:26 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.6353 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcTNdoD9XbMma+xgRj6XB6+HpCvtMAAAIFgAAAB2HJA= In-Reply-To: Message-ID: X-OriginalArrivalTime: 18 Nov 2004 14:21:08.0750 (UTC) FILETIME=[D8EF12E0:01C4CD79] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/284 X-Sequence-Number: 9238 Andrew, What version of Redhat are you running? We have found running Enterprise Update 3 kernel kills our Dell boxes with IOWait, both NFS and local disk traffic. Update 2 kernel does not seem to have the issue, and we are in the process of trying Update 4 beta to see if it is better. Woody iGLASS Networks www.iglass.net -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Andrew Janian Sent: Thursday, November 18, 2004 9:02 AM To: Richard_D_Levine@raytheon.com Cc: pgsql-performance@postgresql.org; pgsql-performance-owner@postgresql.org Subject: Re: [PERFORM] Query Performance and IOWait Actually, unfortunately, that won't work. The subquery gets a list of message IDs and then the outer query gets the responses to those messages. Also, I dumped this data and imported it all to ms sql server and then ran it there. The query ran in 2s. Andrew -----Original Message----- From: Richard_D_Levine@raytheon.com [mailto:Richard_D_Levine@raytheon.com] Sent: Thursday, November 18, 2004 7:57 AM To: Andrew Janian Cc: pgsql-performance@postgresql.org; pgsql-performance-owner@postgresql.org Subject: Re: [PERFORM] Query Performance and IOWait Andrew, It seems that you could combine the subquery's WHERE clause with the main query's to produce a simpler query, i.e. one without a subquery. Rick "Andrew Janian" To: Sent by: cc: pgsql-performance-owner@pos Subject: [PERFORM] Query Performance and IOWait tgresql.org 11/18/2004 08:42 AM Hello All, I have a setup with a Dell Poweredge 2650 with Red Hat and Postgres 7.4.5 with a database with about 27GB of data. The table in question has about 35 million rows. I am running the following query: SELECT * FROM mb_fix_message WHERE msg_client_order_id IN ( SELECT msg_client_order_id FROM mb_fix_message WHERE msg_log_time >= '2004-06-01' AND msg_log_time < '2004-06-01 13:30:00.000' AND msg_message_type IN ('D','G') AND mb_ord_type = '1' ) AND msg_log_time > '2004-06-01' AND msg_log_time < '2004-06-01 23:59:59.999' AND msg_message_type = '8' AND (mb_raw_text LIKE '%39=1%' OR mb_raw_text LIKE '%39=2%'); with the following plan: QUERY PLAN Nested Loop IN Join (cost=0.00..34047.29 rows=1 width=526) -> Index Scan using mfi_log_time on mb_fix_message (cost=0.00..22231.31 rows=2539 width=526) Index Cond: ((msg_log_time > '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 23:59:59.999'::timestamp without time zone)) Filter: (((msg_message_type)::text = '8'::text) AND (((mb_raw_text)::text ~~ '%39=1%'::text) OR ((mb_raw_text)::text ~~ '%39=2%'::text))) -> Index Scan using mfi_client_ordid on mb_fix_message (cost=0.00..445.56 rows=1 width=18) Index Cond: (("outer".msg_client_order_id)::text = (mb_fix_message.msg_client_order_id)::text) Filter: ((msg_log_time >= '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 13:30:00'::timestamp without time zone) AND ((msg_message_type)::text = 'D'::text) OR ((msg_message_type)::text = 'G'::text)) AND ((mb_ord_type)::text = '1'::text)) While running, this query produces 100% iowait usage on its processor and takes a ungodly amount of time (about an hour). The postgres settings are as follows: shared_buffers = 32768 # min 16, at least max_connections*2, 8KB each sort_mem = 262144 # min 64, size in KB And the /etc/sysctl.conf has: kernel.shmall = 274235392 kernel.shmmax = 274235392 The system has 4GB of RAM. I am pretty sure of these settings, but only from my reading of the docs and others' recommendations online. Thanks, Andrew Janian OMS Development Scottrade Financial Services (314) 965-1555 x 1513 Cell: (314) 369-2083 ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Thu Nov 18 15:40:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 56BB83A4716 for ; Thu, 18 Nov 2004 15:40:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 25861-07 for ; Thu, 18 Nov 2004 15:39:57 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id E83C73A46FC for ; Thu, 18 Nov 2004 15:39:59 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAIFdxeU016866; Thu, 18 Nov 2004 10:39:59 -0500 (EST) To: "Andrew Janian" Cc: pgsql-performance@postgresql.org Subject: Re: Query Performance and IOWait In-reply-to: References: Comments: In-reply-to "Andrew Janian" message dated "Thu, 18 Nov 2004 07:42:20 -0600" Date: Thu, 18 Nov 2004 10:39:59 -0500 Message-ID: <16865.1100792399@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/285 X-Sequence-Number: 9239 "Andrew Janian" writes: > QUERY PLAN > Nested Loop IN Join (cost=0.00..34047.29 rows=1 width=526) > -> Index Scan using mfi_log_time on mb_fix_message (cost=0.00..22231.31 rows=2539 width=526) > Index Cond: ((msg_log_time > '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 23:59:59.999'::timestamp without time zone)) > Filter: (((msg_message_type)::text = '8'::text) AND (((mb_raw_text)::text ~~ '%39=1%'::text) OR ((mb_raw_text)::text ~~ '%39=2%'::text))) > -> Index Scan using mfi_client_ordid on mb_fix_message (cost=0.00..445.56 rows=1 width=18) > Index Cond: (("outer".msg_client_order_id)::text = (mb_fix_message.msg_client_order_id)::text) > Filter: ((msg_log_time >= '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 13:30:00'::timestamp without time zone) AND ((msg_message_type)::text = 'D'::text) OR ((msg_message_type)::text = 'G'::text)) AND ((mb_ord_type)::text = '1'::text)) > While running, this query produces 100% iowait usage on its processor and takes a ungodly amount of time (about an hour). This plan looks fairly reasonable if the rowcount estimates are accurate. Have you ANALYZEd the table lately? You might need to bump up the statistics target for the msg_log_time column to improve the quality of the estimates. It would be useful to see EXPLAIN ANALYZE results too (yes I know it'll take you an hour to get them...) regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 18 15:57:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EC87A3A40B2 for ; Thu, 18 Nov 2004 15:57:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32447-10 for ; Thu, 18 Nov 2004 15:57:14 +0000 (GMT) Received: from navgstl1.scottrade.com (navgstl1.scottsave.com [208.219.220.247]) by svr1.postgresql.org (Postfix) with SMTP id 7E63A3A463A for ; Thu, 18 Nov 2004 15:57:17 +0000 (GMT) Received: from sagstl2.scottrade.com ([208.219.220.215]) by navgstl1.scottrade.com (SMSSMTP 4.0.0.59) with SMTP id M2004111809571812080 for ; Thu, 18 Nov 2004 09:57:18 -0600 Received: from exchstl1.scottrade.com ([172.28.140.45]) by sagstl2.scottrade.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 18 Nov 2004 09:57:18 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: Query Performance and IOWait Date: Thu, 18 Nov 2004 09:57:17 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Query Performance and IOWait Thread-Index: AcTNhOJDWjPOEaV2S0uRDIR1meRf2wAAVA8w From: "Andrew Janian" To: "Tom Lane" Cc: X-OriginalArrivalTime: 18 Nov 2004 15:57:18.0863 (UTC) FILETIME=[483071F0:01C4CD87] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/286 X-Sequence-Number: 9240 I have run ANALYZE right before running this query. I will run EXPLAIN ANALYZE when I can. I started running the query when = I sent the first email and it is still running. Looke like it longer = than an hour. I will post the results of EXPLAIN ANALYZE in a few hours when I get = them. Thanks for all your help, Andrew -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us] Sent: Thursday, November 18, 2004 9:40 AM To: Andrew Janian Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Query Performance and IOWait=20 "Andrew Janian" writes: > = = = QUERY PLAN > Nested Loop IN Join (cost=3D0.00..34047.29 rows=3D1 width=3D526) > -> Index Scan using mfi_log_time on mb_fix_message = (cost=3D0.00..22231.31 rows=3D2539 width=3D526) > Index Cond: ((msg_log_time > '2004-06-01 00:00:00'::timestamp = without time zone) AND (msg_log_time < '2004-06-01 = 23:59:59.999'::timestamp without time zone)) > Filter: (((msg_message_type)::text =3D '8'::text) AND = (((mb_raw_text)::text ~~ '%39=3D1%'::text) OR ((mb_raw_text)::text ~~ = '%39=3D2%'::text))) > -> Index Scan using mfi_client_ordid on mb_fix_message = (cost=3D0.00..445.56 rows=3D1 width=3D18) > Index Cond: (("outer".msg_client_order_id)::text =3D = (mb_fix_message.msg_client_order_id)::text) > Filter: ((msg_log_time >=3D '2004-06-01 00:00:00'::timestamp = without time zone) AND (msg_log_time < '2004-06-01 13:30:00'::timestamp = without time zone) AND ((msg_message_type)::text =3D 'D'::text) OR = ((msg_message_type)::text =3D 'G'::text)) AND ((mb_ord_type)::text =3D = '1'::text)) > While running, this query produces 100% iowait usage on its processor = and takes a ungodly amount of time (about an hour). This plan looks fairly reasonable if the rowcount estimates are accurate. Have you ANALYZEd the table lately? You might need to bump up the statistics target for the msg_log_time column to improve the quality of the estimates. It would be useful to see EXPLAIN ANALYZE results too (yes I know it'll take you an hour to get them...) regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 18 16:12:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 557F33A4663 for ; Thu, 18 Nov 2004 16:12:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39266-04 for ; Thu, 18 Nov 2004 16:12:15 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id 437963A4570 for ; Thu, 18 Nov 2004 16:12:14 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: query plan question Date: Thu, 18 Nov 2004 11:12:12 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26BAC3@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] query plan question Thread-Index: AcTM2DGrjwh3cQGyRo2p5xmTMtKevwAr9s5g From: "David Parker" To: "Matthew T. O'Connor" Cc: "Tom Lane" , "Jeff" , "Russell Smith" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/287 X-Sequence-Number: 9241 What I think is happening with the missing pg_statistic entries: The install of our application involves a lot of data importing (via JDBC) in one large transaction, which can take up to 30 minutes. (I realize I left out this key piece of info in my original post...) The pg_autovacuum logic is relying on data from pg_stat_all_tables to make the decision about running analyze. As far as I can tell, the data in this view gets updated outside of the transaction, because I saw the numbers growing while I was importing. I saw pg_autovacuum log messages for running analyze on several tables, but no statistics data showed up for these, I assume because the actual data in the table wasn't yet visible to pg_autovacuum because the import transaction had not finished yet. When the import finished, not all of the tables affected by the import were re-visited because they had not bumped up over the threshold again, even though the analyze run for those tables had not generated any stats because of the still-open transaction. Am I making the correct assumptions about the way the various pieces work? Does this scenario make sense? It's easy enough for us to kick off a vacuum/analyze at the end of a long import - but this "mysterious" behavior was bugging me! Thanks. - DAP=20 >-----Original Message----- >From: Matthew T. O'Connor [mailto:matthew@zeut.net]=20 >Sent: Wednesday, November 17, 2004 2:02 PM >To: David Parker >Cc: Tom Lane; Jeff; Russell Smith; pgsql-performance@postgresql.org >Subject: Re: [PERFORM] query plan question > >Well based on the autovacuum log that you attached, all of=20 >those tables=20 >are insert only (at least during the time period included in=20 >the log. =20 >Is that correct? If so, autovacuum will never do a vacuum=20 >(unless required by xid wraparound issues) on those tables. =20 >So this doesn't appear to be an autovacuum problem. I'm not=20 >sure about the missing pg_statistic entries anyone else care=20 >to field that one? > >Matthew > > >David Parker wrote: > >>Thanks. The tables I'm concerned with are named: 'schema', 'usage',=20 >>'usageparameter', and 'flow'. It looks like autovacuum is performing >>analyzes: >> >>% grep "Performing: " logs/.db.tazz.vacuum.log >>[2004-11-17 12:05:58 PM] Performing: ANALYZE=20 >>"public"."scriptlibrary_library" >>[2004-11-17 12:15:59 PM] Performing: ANALYZE=20 >>"public"."scriptlibraryparm" >>[2004-11-17 12:15:59 PM] Performing: ANALYZE "public"."usageparameter" >>[2004-11-17 12:21:00 PM] Performing: ANALYZE "public"."usageproperty" >>[2004-11-17 12:21:00 PM] Performing: ANALYZE "public"."route" >>[2004-11-17 12:21:00 PM] Performing: ANALYZE "public"."usageparameter" >>[2004-11-17 12:21:00 PM] Performing: ANALYZE=20 >>"public"."scriptlibrary_library" >>[2004-11-17 12:26:01 PM] Performing: ANALYZE "public"."usage" >>[2004-11-17 12:26:01 PM] Performing: ANALYZE "public"."usageparameter" >>[2004-11-17 12:31:04 PM] Performing: ANALYZE "public"."usageproperty" >>[2004-11-17 12:36:04 PM] Performing: ANALYZE "public"."route" >>[2004-11-17 12:36:04 PM] Performing: ANALYZE "public"."service_usage" >>[2004-11-17 12:36:04 PM] Performing: ANALYZE "public"."usageparameter" >> >>But when I run the following: >> >>select * from pg_statistic where starelid in (select oid from=20 >pg_class=20 >>where relname in >>('schema','usageparameter','flow','usage')) >> >>it returns no records. Shouldn't it? It doesn't appear to be doing a=20 >>vacuum anywhere, which makes sense because none of these tables have=20 >>over the default threshold of 1000. Are there statistics=20 >which only get=20 >>generated by vacuum? >> >>I've attached a gzip of the pg_autovacuum log file, with -d 3. >> >>Thanks again. >> >>- DAP >> >> >> =20 >> >>>-----Original Message----- >>>From: Matthew T. O'Connor [mailto:matthew@zeut.net] >>>Sent: Wednesday, November 17, 2004 11:41 AM >>>To: David Parker >>>Cc: Tom Lane; Jeff; Russell Smith; pgsql-performance@postgresql.org >>>Subject: Re: [PERFORM] query plan question >>> >>>David Parker wrote: >>> >>> =20 >>> >>>>We're using postgresql 7.4.5. I've only recently put=20 >pg_autovacuum in=20 >>>>place as part of our installation, and I'm basically taking the=20 >>>>defaults. I doubt it's a problem with autovacuum itself, but rather=20 >>>>with my configuration of it. I have some reading to do, so >>>> =20 >>>> >>>any pointers >>> =20 >>> >>>>to existing autovacuum threads would be greatly appreciated! >>>> >>>> =20 >>>> >>>Well the first thing to do is increase the verbosity of the=20 >>>pg_autovacuum logging output. If you use -d2 or higher,=20 >pg_autovacuum=20 >>>will print out a lot of detail on what it thinks the thresholds are=20 >>>and >>>why it is or isn't performing vacuums and analyzes. Attach=20 >>>some of the >>>log and I'll take a look at it. >>> >>> =20 >>> > > From pgsql-hackers-owner@postgresql.org Thu Nov 18 16:43:35 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A50A23A46A9 for ; Thu, 18 Nov 2004 16:43:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50398-08 for ; Thu, 18 Nov 2004 16:43:23 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id DC3143A46DC for ; Thu, 18 Nov 2004 16:43:19 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAIGhC65017520; Thu, 18 Nov 2004 11:43:12 -0500 (EST) To: "David Parker" Cc: pgsql-hackers@postgreSQL.org, Jan Wieck , "Matthew T. O'Connor" Subject: Timing of pgstats updates In-reply-to: <07FDEE0ED7455A48AC42AC2070EDFF7C26BAC3@corpsrv2.tazznetworks.com> References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BAC3@corpsrv2.tazznetworks.com> Comments: In-reply-to "David Parker" message dated "Thu, 18 Nov 2004 11:12:12 -0500" Date: Thu, 18 Nov 2004 11:43:12 -0500 Message-ID: <17519.1100796192@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/639 X-Sequence-Number: 61211 "David Parker" writes: > What I think is happening with the missing pg_statistic entries: > The install of our application involves a lot of data importing (via > JDBC) in one large transaction, which can take up to 30 minutes. (I > realize I left out this key piece of info in my original post...) > The pg_autovacuum logic is relying on data from pg_stat_all_tables to > make the decision about running analyze. As far as I can tell, the data > in this view gets updated outside of the transaction, because I saw the > numbers growing while I was importing. I saw pg_autovacuum log messages > for running analyze on several tables, but no statistics data showed up > for these, I assume because the actual data in the table wasn't yet > visible to pg_autovacuum because the import transaction had not finished > yet. > When the import finished, not all of the tables affected by the import > were re-visited because they had not bumped up over the threshold again, > even though the analyze run for those tables had not generated any stats > because of the still-open transaction. Bingo. The per-table activity stats are sent to the collector whenever the backend waits for a client command. Given a moderately long transaction block doing updates, it's not hard at all to imagine that autovacuum would kick off vacuum and/or analyze while the updating transaction is still in progress. The resulting operation is of course a waste of time. It'd be trivial to adjust postgres.c so that per-table stats are only transmitted when we exit the transaction (basically move the pgstat_report_tabstat call down a couple lines so it's not called if IsTransactionOrTransactionBlock). This seems like a good change to me. Does anyone not like it? regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 18 16:44:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 091943A46BC for ; Thu, 18 Nov 2004 16:44:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51111-09 for ; Thu, 18 Nov 2004 16:44:15 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id 9B2813A3E32 for ; Thu, 18 Nov 2004 16:44:15 +0000 (GMT) Received: from [192.168.1.51] (dsl093-038-087.pdx1.dsl.speakeasy.net [66.93.38.87]) (authenticated bits=0) by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id iAIGiEf2008360; Thu, 18 Nov 2004 08:44:14 -0800 Message-ID: <419CD15B.5070206@commandprompt.com> Date: Thu, 18 Nov 2004 08:44:11 -0800 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Andrew Janian Cc: pgsql-performance@postgresql.org Subject: Re: Query Performance and IOWait References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------020301080108050004070109" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/288 X-Sequence-Number: 9242 This is a multi-part message in MIME format. --------------020301080108050004070109 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello, What is your statistics target? What is your effective_cache_size? Have you tried running the query as a cursor? Sincerely, Joshua D. Drake Andrew Janian wrote: > I have run ANALYZE right before running this query. > > I will run EXPLAIN ANALYZE when I can. I started running the query when I sent the first email and it is still running. Looke like it longer than an hour. > > I will post the results of EXPLAIN ANALYZE in a few hours when I get them. > > Thanks for all your help, > > Andrew > > -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us] > Sent: Thursday, November 18, 2004 9:40 AM > To: Andrew Janian > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Query Performance and IOWait > > > "Andrew Janian" writes: > >> QUERY PLAN >>Nested Loop IN Join (cost=0.00..34047.29 rows=1 width=526) >> -> Index Scan using mfi_log_time on mb_fix_message (cost=0.00..22231.31 rows=2539 width=526) >> Index Cond: ((msg_log_time > '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 23:59:59.999'::timestamp without time zone)) >> Filter: (((msg_message_type)::text = '8'::text) AND (((mb_raw_text)::text ~~ '%39=1%'::text) OR ((mb_raw_text)::text ~~ '%39=2%'::text))) >> -> Index Scan using mfi_client_ordid on mb_fix_message (cost=0.00..445.56 rows=1 width=18) >> Index Cond: (("outer".msg_client_order_id)::text = (mb_fix_message.msg_client_order_id)::text) >> Filter: ((msg_log_time >= '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 13:30:00'::timestamp without time zone) AND ((msg_message_type)::text = 'D'::text) OR ((msg_message_type)::text = 'G'::text)) AND ((mb_ord_type)::text = '1'::text)) > > >>While running, this query produces 100% iowait usage on its processor and takes a ungodly amount of time (about an hour). > > > This plan looks fairly reasonable if the rowcount estimates are > accurate. Have you ANALYZEd the table lately? You might need to > bump up the statistics target for the msg_log_time column to improve > the quality of the estimates. It would be useful to see EXPLAIN > ANALYZE results too (yes I know it'll take you an hour to get them...) > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org -- Command Prompt, Inc., home of PostgreSQL Replication, and plPHP. Postgresql support, programming shared hosting and dedicated hosting. +1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL --------------020301080108050004070109 Content-Type: text/x-vcard; charset=utf-8; name="jd.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jd.vcf" begin:vcard fn:Joshua D. Drake n:Drake;Joshua D. org:Command Prompt, Inc. adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA email;internet:jd@commandprompt.com title:Consultant tel;work:503-667-4564 tel;fax:503-210-0334 note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. x-mozilla-html:FALSE url:http://www.commandprompt.com/ version:2.1 end:vcard --------------020301080108050004070109-- From pgsql-performance-owner@postgresql.org Thu Nov 18 17:09:25 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 733F13A42CF for ; Thu, 18 Nov 2004 17:09:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61230-07 for ; Thu, 18 Nov 2004 17:09:12 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id D850B3A3E32 for ; Thu, 18 Nov 2004 17:09:12 +0000 (GMT) Received: (qmail 5347 invoked from network); 18 Nov 2004 17:09:04 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 18 Nov 2004 17:09:04 -0000 Message-ID: <419CD734.2020301@fastcrypt.com> Date: Thu, 18 Nov 2004 12:09:08 -0500 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Interaction between Free Space Map an alternate location for a database Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/289 X-Sequence-Number: 9243 Can someone explain how the free space map deals with alternate database locations? Given that the free space map is global, and it is ostensibly managing free disk space, how does it deal with tuples across disk locations ? Dave -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561 From pgsql-performance-owner@postgresql.org Thu Nov 18 17:14:08 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 13BA53A46D0 for ; Thu, 18 Nov 2004 17:14:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62838-09 for ; Thu, 18 Nov 2004 17:14:02 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 0BFD33A46D3 for ; Thu, 18 Nov 2004 17:14:02 +0000 (GMT) Received: (qmail 5382 invoked from network); 18 Nov 2004 17:13:56 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 18 Nov 2004 17:13:56 -0000 Message-ID: <419CD858.1000201@fastcrypt.com> Date: Thu, 18 Nov 2004 12:14:00 -0500 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Andrew Janian Cc: pgsql-performance@postgresql.org Subject: Re: Query Performance and IOWait References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/290 X-Sequence-Number: 9244 Andrew, Dell's aren't well known for their disk performance, apparently most of the perc controllers sold with dell's are actually adaptec controllers. Also apparently they do not come with the battery required to use the battery backed up write cache ( In fact according to some Dell won't even sell the battery to you). Also Dell's monitoring software is quite a memory hog. Have you looked at top ?, and also hdparm -Tt /dev/sd? Dave Andrew Janian wrote: >Hello All, > >I have a setup with a Dell Poweredge 2650 with Red Hat and Postgres 7.4.5 with a database with about 27GB of data. The table in question has about 35 million rows. > >I am running the following query: > >SELECT * >FROM mb_fix_message >WHERE msg_client_order_id IN ( > SELECT msg_client_order_id > FROM mb_fix_message > WHERE msg_log_time >= '2004-06-01' > AND msg_log_time < '2004-06-01 13:30:00.000' > AND msg_message_type IN ('D','G') > AND mb_ord_type = '1' > ) > AND msg_log_time > '2004-06-01' > AND msg_log_time < '2004-06-01 23:59:59.999' > AND msg_message_type = '8' > AND (mb_raw_text LIKE '%39=1%' OR mb_raw_text LIKE '%39=2%'); > >with the following plan: > > QUERY PLAN >Nested Loop IN Join (cost=0.00..34047.29 rows=1 width=526) > -> Index Scan using mfi_log_time on mb_fix_message (cost=0.00..22231.31 rows=2539 width=526) > Index Cond: ((msg_log_time > '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 23:59:59.999'::timestamp without time zone)) > Filter: (((msg_message_type)::text = '8'::text) AND (((mb_raw_text)::text ~~ '%39=1%'::text) OR ((mb_raw_text)::text ~~ '%39=2%'::text))) > -> Index Scan using mfi_client_ordid on mb_fix_message (cost=0.00..445.56 rows=1 width=18) > Index Cond: (("outer".msg_client_order_id)::text = (mb_fix_message.msg_client_order_id)::text) > Filter: ((msg_log_time >= '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 13:30:00'::timestamp without time zone) AND ((msg_message_type)::text = 'D'::text) OR ((msg_message_type)::text = 'G'::text)) AND ((mb_ord_type)::text = '1'::text)) > >While running, this query produces 100% iowait usage on its processor and takes a ungodly amount of time (about an hour). > >The postgres settings are as follows: > >shared_buffers = 32768 # min 16, at least max_connections*2, 8KB each >sort_mem = 262144 # min 64, size in KB > >And the /etc/sysctl.conf has: >kernel.shmall = 274235392 >kernel.shmmax = 274235392 > >The system has 4GB of RAM. > >I am pretty sure of these settings, but only from my reading of the docs and others' recommendations online. > >Thanks, > >Andrew Janian >OMS Development >Scottrade Financial Services >(314) 965-1555 x 1513 >Cell: (314) 369-2083 > >---------------------------(end of broadcast)--------------------------- >TIP 7: don't forget to increase your free space map settings > > -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561 From pgsql-performance-owner@postgresql.org Thu Nov 18 18:20:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 395DB3A4778 for ; Thu, 18 Nov 2004 18:20:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87322-02 for ; Thu, 18 Nov 2004 18:20:21 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 8F87A3A4760 for ; Thu, 18 Nov 2004 18:20:21 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6679392; Thu, 18 Nov 2004 10:21:50 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org, pg@fastcrypt.com Subject: Re: Interaction between Free Space Map an alternate location for a database Date: Thu, 18 Nov 2004 10:18:59 -0800 User-Agent: KMail/1.6.2 References: <419CD734.2020301@fastcrypt.com> In-Reply-To: <419CD734.2020301@fastcrypt.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411181018.59933.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/291 X-Sequence-Number: 9245 Dave, > Given that the free space map is global, and it is ostensibly managing > free disk space, how does it deal with tuples across disk locations ? Are you talking Tablespaces? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Nov 18 18:35:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DA9303A46EE for ; Thu, 18 Nov 2004 18:35:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89473-10 for ; Thu, 18 Nov 2004 18:35:16 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id EA9123A3E5E for ; Thu, 18 Nov 2004 18:35:16 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6679436; Thu, 18 Nov 2004 10:36:45 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: Query Performance and IOWait Date: Thu, 18 Nov 2004 10:33:54 -0800 User-Agent: KMail/1.6.2 Cc: "Woody Woodring" , "'Andrew Janian'" References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <200411181033.54786.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/292 X-Sequence-Number: 9246 Woody, > What version of Redhat are you running? =A0 We have found running Enterpr= ise > Update 3 kernel kills our Dell boxes with IOWait, both NFS and local disk > traffic. =A0Update 2 kernel does not seem to have the issue, and we are in > the process of trying Update 4 beta to see if it is better. This is interesting; do you have more to say about it? I've been having s= ome=20 mysterious issues with RHES that I've not been able to pin down. =2D-=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Nov 18 18:38:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E66B03A4787 for ; Thu, 18 Nov 2004 18:38:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93604-02 for ; Thu, 18 Nov 2004 18:38:22 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 386663A4472 for ; Thu, 18 Nov 2004 18:38:22 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAIIcHs7018537; Thu, 18 Nov 2004 13:38:17 -0500 (EST) To: pg@fastcrypt.com Cc: pgsql-performance@postgresql.org Subject: Re: Interaction between Free Space Map an alternate location for a database In-reply-to: <419CD734.2020301@fastcrypt.com> References: <419CD734.2020301@fastcrypt.com> Comments: In-reply-to Dave Cramer message dated "Thu, 18 Nov 2004 12:09:08 -0500" Date: Thu, 18 Nov 2004 13:38:17 -0500 Message-ID: <18536.1100803097@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/293 X-Sequence-Number: 9247 Dave Cramer writes: > Can someone explain how the free space map deals with alternate database > locations? It doesn't really care. It identifies tables by database OID+table OID, and where they happen to sit physically doesn't matter. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 18 18:43:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C55053A47BD for ; Thu, 18 Nov 2004 18:42:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94057-06 for ; Thu, 18 Nov 2004 18:42:52 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id AAFD83A47A9 for ; Thu, 18 Nov 2004 18:42:51 +0000 (GMT) Received: (qmail 5918 invoked from network); 18 Nov 2004 18:42:45 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 18 Nov 2004 18:42:45 -0000 Message-ID: <419CED29.8080904@fastcrypt.com> Date: Thu, 18 Nov 2004 13:42:49 -0500 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Berkus Cc: pgsql-performance@postgresql.org Subject: Re: Interaction between Free Space Map an alternate location References: <419CD734.2020301@fastcrypt.com> <200411181018.59933.josh@agliodbs.com> In-Reply-To: <200411181018.59933.josh@agliodbs.com> Content-Type: multipart/alternative; boundary="------------050209060400040201020905" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.4 tagged_above=0.0 required=5.0 tests=HTML_30_40, HTML_MESSAGE, HTML_TITLE_EMPTY X-Spam-Level: * X-Archive-Number: 200411/294 X-Sequence-Number: 9248 This is a multi-part message in MIME format. --------------050209060400040201020905 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit No, have a look at the create database command there is a clause 'with location' that allows you to set up a separate location for the db Dave Josh Berkus wrote: >Dave, > > > >>Given that the free space map is global, and it is ostensibly managing >>free disk space, how does it deal with tuples across disk locations ? >> >> > >Are you talking Tablespaces? > > > -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561 --------------050209060400040201020905 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit No, have a look at the create database command

there is a clause 'with location' that allows you to set up a separate location for the db

Dave

Josh Berkus wrote:
Dave,

  
Given that the free space map is global, and it is ostensibly managing
free disk space, how does it deal with tuples across disk locations ?
    

Are you talking Tablespaces?

  

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561
--------------050209060400040201020905-- From pgsql-performance-owner@postgresql.org Thu Nov 18 19:05:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 644ED3A4760 for ; Thu, 18 Nov 2004 19:04:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02872-01 for ; Thu, 18 Nov 2004 19:04:41 +0000 (GMT) Received: from iglassmail.istructure.com (mail.istructure.com [24.199.154.122]) by svr1.postgresql.org (Postfix) with ESMTP id 6B99D3A475A for ; Thu, 18 Nov 2004 19:04:41 +0000 (GMT) Received: from iglassnoc3 ([192.168.177.128]) by iglassmail.istructure.com with Microsoft SMTPSVC(6.0.3790.211); Thu, 18 Nov 2004 14:07:20 -0500 From: "Woody Woodring" To: Subject: Re: Query Performance and IOWait Date: Thu, 18 Nov 2004 14:04:38 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook, Build 11.0.6353 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcTNnVyU6f9/RHl+RZ6uOD9oDmOskAAAGKSA In-Reply-To: <200411181033.54786.josh@agliodbs.com> Message-ID: X-OriginalArrivalTime: 18 Nov 2004 19:07:20.0121 (UTC) FILETIME=[D3DE5A90:01C4CDA1] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/295 X-Sequence-Number: 9249 From our experience it is not just a postgres issue, but all IO with the Update 3 kernel. We have a box with Update 3 that queries a remote postgres = database(Running RH7.3, RH3 Update2) and writes to a file on an NFS server. The update = 3 box does half the work with 2-3 times the load as our update 1 and 2 = boxes. Looking at top the box is always above 90% IO Wait on the CPU. When we downgrade the kernel to Update 2 it seems to fix the issue. We several Update 3 boxes that run postgres locally and they all = struggle compared to the Update 2 boxes We have tried the Fedora Core 3 with not much more success and we are = going to try the Update 4 beta kernel next week to see if it is any better. There are several threads on the Taroon mailing list discussing the = issue. Woody -----Original Message----- From: Josh Berkus [mailto:josh@agliodbs.com]=20 Sent: Thursday, November 18, 2004 1:34 PM To: pgsql-performance@postgresql.org Cc: Woody Woodring; 'Andrew Janian' Subject: Re: [PERFORM] Query Performance and IOWait Woody, > What version of Redhat are you running? =A0 We have found running=20 > Enterprise Update 3 kernel kills our Dell boxes with IOWait, both NFS=20 > and local disk traffic. =A0Update 2 kernel does not seem to have the=20 > issue, and we are in the process of trying Update 4 beta to see if it = is better. This is interesting; do you have more to say about it? I've been = having some=20 mysterious issues with RHES that I've not been able to pin down. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-hackers-owner@postgresql.org Thu Nov 18 20:29:52 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2131D3A477A for ; Thu, 18 Nov 2004 20:29:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27289-05 for ; Thu, 18 Nov 2004 20:29:44 +0000 (GMT) Received: from smtp014.mail.yahoo.com (smtp014.mail.yahoo.com [216.136.173.58]) by svr1.postgresql.org (Postfix) with SMTP id C4BC33A47D6 for ; Thu, 18 Nov 2004 20:29:45 +0000 (GMT) Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 with login) by smtp014.mail.yahoo.com with SMTP; 18 Nov 2004 20:29:44 -0000 Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id iAIKTc94040434; Thu, 18 Nov 2004 15:29:39 -0500 (EST) (envelope-from JanWieck@Yahoo.com) Message-ID: <419CF81B.9020406@Yahoo.com> Date: Thu, 18 Nov 2004 14:29:31 -0500 From: Jan Wieck User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.1) Gecko/20040707 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: David Parker , pgsql-hackers@postgreSQL.org, "Matthew T. O'Connor" Subject: Re: Timing of pgstats updates References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BAC3@corpsrv2.tazznetworks.com> <17519.1100796192@sss.pgh.pa.us> In-Reply-To: <17519.1100796192@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/648 X-Sequence-Number: 61220 On 11/18/2004 11:43 AM, Tom Lane wrote: > "David Parker" writes: >> What I think is happening with the missing pg_statistic entries: >> The install of our application involves a lot of data importing (via >> JDBC) in one large transaction, which can take up to 30 minutes. (I >> realize I left out this key piece of info in my original post...) > >> The pg_autovacuum logic is relying on data from pg_stat_all_tables to >> make the decision about running analyze. As far as I can tell, the data >> in this view gets updated outside of the transaction, because I saw the >> numbers growing while I was importing. I saw pg_autovacuum log messages >> for running analyze on several tables, but no statistics data showed up >> for these, I assume because the actual data in the table wasn't yet >> visible to pg_autovacuum because the import transaction had not finished >> yet. > >> When the import finished, not all of the tables affected by the import >> were re-visited because they had not bumped up over the threshold again, >> even though the analyze run for those tables had not generated any stats >> because of the still-open transaction. > > Bingo. The per-table activity stats are sent to the collector whenever > the backend waits for a client command. Given a moderately long > transaction block doing updates, it's not hard at all to imagine that > autovacuum would kick off vacuum and/or analyze while the updating > transaction is still in progress. The resulting operation is of course > a waste of time. > > It'd be trivial to adjust postgres.c so that per-table stats are > only transmitted when we exit the transaction (basically move the > pgstat_report_tabstat call down a couple lines so it's not called if > IsTransactionOrTransactionBlock). > > This seems like a good change to me. Does anyone not like it? > > regards, tom lane Sounds reasonable here. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # From pgsql-performance-owner@postgresql.org Thu Nov 18 19:46:48 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 47C3E3A47A0 for ; Thu, 18 Nov 2004 19:46:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16037-04 for ; Thu, 18 Nov 2004 19:46:43 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 899023A45E7 for ; Thu, 18 Nov 2004 19:46:43 +0000 (GMT) Received: (qmail 6282 invoked from network); 18 Nov 2004 19:46:37 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 18 Nov 2004 19:46:37 -0000 Message-ID: <419CFC21.3080402@fastcrypt.com> Date: Thu, 18 Nov 2004 14:46:41 -0500 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Interaction between Free Space Map an alternate location References: <419CD734.2020301@fastcrypt.com> <18536.1100803097@sss.pgh.pa.us> In-Reply-To: <18536.1100803097@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------000801070606070709080904" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=HTML_20_30, HTML_MESSAGE, HTML_TITLE_EMPTY X-Spam-Level: * X-Archive-Number: 200411/296 X-Sequence-Number: 9250 This is a multi-part message in MIME format. --------------000801070606070709080904 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Ok, so the global part of the fsm is just that it is in shared memory. If certain databases have more free space they will simply take up more of the fsm. There is no cross database movement of tuples. ( I realized this when I tried to form my next question) Dave Tom Lane wrote: >Dave Cramer writes: > > >>Can someone explain how the free space map deals with alternate database >>locations? >> >> > >It doesn't really care. It identifies tables by database OID+table OID, >and where they happen to sit physically doesn't matter. > > regards, tom lane > >---------------------------(end of broadcast)--------------------------- >TIP 7: don't forget to increase your free space map settings > > > > -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561 --------------000801070606070709080904 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Ok, so the global part of the fsm is just that it is in shared memory.  If certain databases have more
free space they will simply take up more of the fsm. There is no cross database movement of tuples.
( I realized this when I tried to form my next question)

Dave

Tom Lane wrote:
Dave Cramer <pg@fastcrypt.com> writes:
  
Can someone explain how the free space map deals with alternate database 
locations?
    

It doesn't really care.  It identifies tables by database OID+table OID,
and where they happen to sit physically doesn't matter.

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


  

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561
--------------000801070606070709080904-- From pgsql-performance-owner@postgresql.org Thu Nov 18 21:10:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CC5903A47E7 for ; Thu, 18 Nov 2004 21:10:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39090-06 for ; Thu, 18 Nov 2004 21:10:35 +0000 (GMT) Received: from mail.trippynames.com (mail.trippynames.com [38.113.223.19]) by svr1.postgresql.org (Postfix) with ESMTP id CE7A43A481E for ; Thu, 18 Nov 2004 21:10:34 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by mail.trippynames.com (Postfix) with ESMTP id 8F957A64A0; Thu, 18 Nov 2004 13:10:32 -0800 (PST) Received: from mail.trippynames.com ([127.0.0.1]) by localhost (rand.nxad.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 01385-09; Thu, 18 Nov 2004 13:10:31 -0800 (PST) Received: from [192.168.123.128] (unknown [38.113.223.82]) by mail.trippynames.com (Postfix) with ESMTP id E0F2BA6379; Thu, 18 Nov 2004 13:10:30 -0800 (PST) In-Reply-To: <20041117040024.GB8838@pobox.com> References: <20041117040024.GB8838@pobox.com> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <45A941C7-39A6-11D9-B82A-000A95C705DC@chittenden.org> Content-Transfer-Encoding: 7bit Cc: pgsql-performance@postgresql.org From: Sean Chittenden Subject: Re: memcached and PostgreSQL Date: Thu, 18 Nov 2004 13:10:28 -0800 To: Michael Adler X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/297 X-Sequence-Number: 9251 > So What does memcached offer pgsql users? It would still seem to offer > the benefit of a multi-machined cache. Ack, I totally missed this thread. Sorry for jumping in late. Basically, memcached and pgmemcache offer a more technically correct way of implementing query caching. MySQL's query caching is a disaster, IMHO. memcached alleviates this load from the database and puts it elsewhere in a more optimized form. The problem with memcached by itself is that you're relying on the application to invalidate the cache. How many different places have to be kept in sync? Using memcached, in its current form, makes relying on the application to be developed correctly with centralized libraries and database access routines. Bah, that's a cluster f#$@ waiting to happen. pgmemcache fixes that though so that you don't have to worry about invalidating the cache in every application/routine. Instead you just centralize that logic in the database and automatically invalidate via triggers. It's working out very well for me. I'd be interested in success stories, fwiw. In the next week or so I'll probably stick this on pgfoundry and build a proper make/release structure. -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Fri Nov 19 14:00:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A6BC63A4AEA for ; Fri, 19 Nov 2004 13:59:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09547-08 for ; Fri, 19 Nov 2004 13:59:47 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.194]) by svr1.postgresql.org (Postfix) with ESMTP id 0E09D3A4AF0 for ; Fri, 19 Nov 2004 13:59:50 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a36so32954rnf for ; Fri, 19 Nov 2004 05:59:50 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=qtM7sKRN0OTqZ1jCmUbWAT9v/e7zPAY81SNf3rhqzJTnBBVYqf8pArb/Rfsqqp/URHTGK5QvIJqPerMG4hoPr+sq6o3jPss+VMpZSjnKnlZAlMnXiCuITxak7FNO7pB6ElwXYNO9NLStCbgdENEo5BWlLM5oe4Jg3y+y9LN1t1g= Received: by 10.39.3.25 with SMTP id f25mr183344rni; Fri, 19 Nov 2004 05:59:50 -0800 (PST) Received: by 10.38.163.22 with HTTP; Fri, 19 Nov 2004 05:59:48 -0800 (PST) Message-ID: <758d5e7f04111905594cf9c9f8@mail.gmail.com> Date: Fri, 19 Nov 2004 14:59:48 +0100 From: Dawid Kuroczko Reply-To: Dawid Kuroczko To: pgsql-performance@postgresql.org Subject: When to bump up statistics? Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200411/298 X-Sequence-Number: 9252 ALTER TABLE foo ALTER COLUMN bar SET STATISTICS n; ..... I wonder what are the implications of using this statement, I know by using, say n=100, ANALYZE will take more time, pg_statistics will be bigger, planner will take longer time, on the other hand it will make better decisions... Etc, etc. I wonder however when it is most uselful to bump it up. Please tell me what you think about it: Is bumping up statistics is only useful for indexed columns? When is it most useful/benefitial to bump them up: 1) huge table with huge number of distinct values (_almost_ unique ;)) 2) huge table with relatively equally distributed values (like each value is in between, say, 30-50 rows). 3) huge table with unequally distributed values (some values are in 1-5 rows, some are in 1000-5000 rows). 4) huge table with small number values (around ~100 distinct values, equally or uneqally distributed). 5) boolean column. I think SET STATISTICS 100 is very useful for case with unequally distributed values, but I wonder what about the other cases. And as a side note -- what are the reasonable bounds for statistics (between 10 and 100?) What are the runtime implications of setting statistics too large -- how much can it affect queries? And finally -- how other RDBMS and RDBM-likes deal with this issue? :) Regards, Dawid From pgsql-performance-owner@postgresql.org Fri Nov 19 15:34:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4DB773A4B67 for ; Fri, 19 Nov 2004 15:34:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42375-10 for ; Fri, 19 Nov 2004 15:34:22 +0000 (GMT) Received: from smtp105.mail.sc5.yahoo.com (smtp105.mail.sc5.yahoo.com [66.163.169.225]) by svr1.postgresql.org (Postfix) with SMTP id 6A77A3A4B58 for ; Fri, 19 Nov 2004 15:34:24 +0000 (GMT) Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 with login) by smtp105.mail.sc5.yahoo.com with SMTP; 19 Nov 2004 15:34:24 -0000 Received: from [172.21.8.18] (ismtp.afilias.com [216.217.55.254]) (authenticated bits=0) by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id iAJFYL94043750; Fri, 19 Nov 2004 10:34:22 -0500 (EST) (envelope-from JanWieck@Yahoo.com) Message-ID: <419E0466.9090409@Yahoo.com> Date: Fri, 19 Nov 2004 09:34:14 -0500 From: Jan Wieck User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.1) Gecko/20040707 X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org, David Parker Subject: Re: sort_mem affect on inserts? References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BA3D@corpsrv2.tazznetworks.com> <200411171407.30795.josh@agliodbs.com> In-Reply-To: <200411171407.30795.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.6 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL X-Spam-Level: * X-Archive-Number: 200411/299 X-Sequence-Number: 9253 On 11/17/2004 5:07 PM, Josh Berkus wrote: > David, > >> I understand that the sort_mem conf setting affects queries with order by, >> etc., and the doc mentions that it is used in create index. Does sort_mem >> affect the updating of indexes, i.e., can the sort_mem setting affect the >> performance of inserts? > > Only if the table has Foriegn Keys whose lookup might require a large sort. > Otherwise, no. > Hmmm ... what type of foreign key lookup would that be? None of the RI generated queries has any order by clause. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # From pgsql-performance-owner@postgresql.org Fri Nov 19 19:19:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DCE9B3A4C2D for ; Fri, 19 Nov 2004 19:19:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22705-08 for ; Fri, 19 Nov 2004 19:19:01 +0000 (GMT) Received: from mail2.m-cam.com (unknown [63.124.102.77]) by svr1.postgresql.org (Postfix) with ESMTP id 1326E3A434E for ; Fri, 19 Nov 2004 19:19:01 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail2.m-cam.com (Postfix) with ESMTP id 84B6B3E8F9 for ; Fri, 19 Nov 2004 14:17:55 -0500 (EST) Received: from mail2.m-cam.com ([127.0.0.1]) by localhost (mail2.m-cam.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01162-10 for ; Fri, 19 Nov 2004 14:17:51 -0500 (EST) Received: from [192.168.1.21] (unknown [192.168.1.21]) by mail2.m-cam.com (Postfix) with ESMTP id 2B0D33E8F8 for ; Fri, 19 Nov 2004 14:17:51 -0500 (EST) Message-ID: <419E471F.6040006@m-cam.com> Date: Fri, 19 Nov 2004 14:18:55 -0500 From: Arshavir Grigorian User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040922 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: index use Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at m-cam.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/300 X-Sequence-Number: 9254 Hi, I have a query that when run on similar tables in 2 different databases either uses the index on the column (primary key) in the where clause or does a full table scan. The structure of the tables is the same, except that the table where the index does not get used has an extra million rows (22mil vs 23mil). The 2 boxes where these database run are very different (Sparc with scsi disks and 2G RAM running Solaris 8 AND a PC with 128M RAM running and an IDE drive running Linux RH9 2.4.20-20.9). I am not sure why that would make a difference, but maybe it does. Also, according to our dba both tables have been analyzed about the same time. Any pointers would be much appreciated. Arshavir WORKS: => explain analyze select num from document where num like 'EP1000000%'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------- Index Scan using document_pkey on document (cost=0.00..5.77 rows=1 width=14) (actual time=0.147..0.166 rows=2 loops=1) Index Cond: (((num)::text >= 'EP1000000'::character varying) AND ((num)::text < 'EP1000001'::character varying)) Filter: ((num)::text ~~ 'EP1000000%'::text) Total runtime: 0.281 ms (4 rows) => \d document Table "public.document" Column | Type | Modifiers -----------+------------------------+----------- num | character varying(30) | not null titl | character varying(500) | isscntry | character varying(50) | issdate | date | filedate | date | appnum | character varying(20) | clnum | integer | exnum | integer | exmnr | character varying(300) | agent | character varying(300) | priodate | date | prionum | character varying(100) | priocntry | character varying(50) | legalstat | integer | Indexes: "document_pkey" primary key, btree (num) Check constraints: "document_legalstat" CHECK (legalstat > 0 AND legalstat < 6) DOES NOT WORK: d5=> EXPLAIN ANALYZE select num from document where num like 'EP1000000%'; QUERY PLAN -------------------------------------------------------------------------------------------------------------- Seq Scan on document (cost=0.00..804355.12 rows=1 width=14) (actual time=97.235..353286.781 rows=2 loops=1) Filter: ((num)::text ~~ 'EP1000000%'::text) Total runtime: 353286.907 ms (3 rows) d5=> \d document Table "public.document" Column | Type | Modifiers -----------+------------------------+----------- num | character varying(30) | not null titl | character varying(500) | isscntry | character varying(50) | issdate | date | filedate | date | clnum | integer | exnum | integer | exmnr | character varying(300) | agent | character varying(300) | priodate | date | prionum | character varying(100) | priocntry | character varying(50) | legalstat | integer | appnum | character varying(20) | Indexes: "document_pkey" primary key, btree (num) Check constraints: "$1" CHECK (legalstat > 0 AND legalstat < 6) From pgsql-performance-owner@postgresql.org Fri Nov 19 20:00:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EF8EA3A4C20 for ; Fri, 19 Nov 2004 20:00:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35616-05 for ; Fri, 19 Nov 2004 20:00:09 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id C078D3A493C for ; Fri, 19 Nov 2004 20:00:09 +0000 (GMT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1CVEvO-0001tR-00 for ; Fri, 19 Nov 2004 21:00:06 +0100 Date: Fri, 19 Nov 2004 21:00:06 +0100 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: index use Message-ID: <20041119200006.GA7170@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <419E471F.6040006@m-cam.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <419E471F.6040006@m-cam.com> X-Operating-System: Linux 2.6.8.1 on a i686 User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/301 X-Sequence-Number: 9255 On Fri, Nov 19, 2004 at 02:18:55PM -0500, Arshavir Grigorian wrote: > The 2 boxes where these database run are very different (Sparc with scsi > disks and 2G RAM running Solaris 8 AND a PC with 128M RAM running and an > IDE drive running Linux RH9 2.4.20-20.9). I am not sure why that would > make a difference, but maybe it does. Are you having different locales on your systems? /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Fri Nov 19 23:28:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8C2A03A4A18 for ; Fri, 19 Nov 2004 22:29:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30359-01 for ; Fri, 19 Nov 2004 22:29:09 +0000 (GMT) Received: from svr4.postgresql.org (unknown [66.98.251.159]) by svr1.postgresql.org (Postfix) with ESMTP id ECFB83A4AF5 for ; Fri, 19 Nov 2004 20:45:56 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr4.postgresql.org (Postfix) with ESMTP id C05CB5AF7E5 for ; Fri, 19 Nov 2004 20:12:03 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAJK9W54014527; Fri, 19 Nov 2004 15:09:32 -0500 (EST) To: Arshavir Grigorian Cc: pgsql-performance@postgresql.org Subject: Re: index use In-reply-to: <419E471F.6040006@m-cam.com> References: <419E471F.6040006@m-cam.com> Comments: In-reply-to Arshavir Grigorian message dated "Fri, 19 Nov 2004 14:18:55 -0500" Date: Fri, 19 Nov 2004 15:09:31 -0500 Message-ID: <14526.1100894971@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/309 X-Sequence-Number: 9263 Arshavir Grigorian writes: > I have a query that when run on similar tables in 2 different databases > either uses the index on the column (primary key) in the where clause or > does a full table scan. The structure of the tables is the same, except > that the table where the index does not get used has an extra million > rows (22mil vs 23mil). I'd say you initialized the second database in a non-C locale. The planner is clearly well aware that the seqscan is going to be expensive, so the explanation has to be that it does not have a usable index available. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Nov 20 00:05:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CA3D63A47F6 for ; Fri, 19 Nov 2004 23:02:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35087-05 for ; Fri, 19 Nov 2004 23:00:58 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 096CF3A4F45 for ; Fri, 19 Nov 2004 21:18:08 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id iAJLI8fq010128 for ; Fri, 19 Nov 2004 21:18:08 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id iAJL43jW006768 for pgsql-performance@postgresql.org; Fri, 19 Nov 2004 21:04:03 GMT From: Chris Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: When to bump up statistics? Date: Fri, 19 Nov 2004 15:23:15 -0500 Organization: cbbrowne Computing Inc Lines: 85 Message-ID: <608y8xfv0s.fsf@dba2.int.libertyrms.com> References: <758d5e7f04111905594cf9c9f8@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Cancel-Lock: sha1:BrlGPwpt+3vfhZsCJrue05APaDM= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.2 tagged_above=0.0 required=5.0 tests=MAILTO_TO_SPAM_ADDR, NO_DNS_FOR_FROM X-Spam-Level: ** X-Archive-Number: 200411/311 X-Sequence-Number: 9265 qnex42@gmail.com (Dawid Kuroczko) writes: > ALTER TABLE foo ALTER COLUMN bar SET STATISTICS n; ..... > > I wonder what are the implications of using this statement, > I know by using, say n=100, ANALYZE will take more time, > pg_statistics will be bigger, planner will take longer time, > on the other hand it will make better decisions... Etc, etc. > > I wonder however when it is most uselful to bump it up. > Please tell me what you think about it: > > Is bumping up statistics is only useful for indexed columns? The main decision changes that result from this would occur then... > When is it most useful/benefitial to bump them up: > > 1) huge table with huge number of distinct values (_almost_ > unique ;)) > > 2) huge table with relatively equally distributed values > (like each value is in between, say, 30-50 rows). > > 3) huge table with unequally distributed values (some > values are in 1-5 rows, some are in 1000-5000 rows). > > 4) huge table with small number values (around ~100 > distinct values, equally or uneqally distributed). A hard and fast rule hasn't emerged, definitely not to distinguish precisely between these cases. There are two effects that come out of changing the numbers: 1. They increase the number of tuples examined. This would pointedly affect cases 3 and 4, increasing the likelihood that the statistics are more representative 2. They increase the number of samples that are kept, increasing the number of items recorded in the histogram. If you have on the order of 100 unique values (it would not be unusual for a company to have 100 "main" customers or suppliers), that allows there to be nearly a bin apiece, which makes estimates _way_ more representative both for common and less common cases amongst the "top 100." Both of those properties are useful for pretty much all of the above cases. > 5) boolean column. Boolean column would more or less indicate SET STATISTICS 2; the only point to having more would be if there was one of the values that almost never occurred so that you'd need to collect more stats to even pick up instances of the "rare" case. A boolean column is seldom much use for indices anyways... > I think SET STATISTICS 100 is very useful for case with unequally > distributed values, but I wonder what about the other cases. And as > a side note -- what are the reasonable bounds for statistics > (between 10 and 100?) If there are, say, 200 unique values, then increasing from 10 to 100 would seem likely to be useful in making the histogram MUCH more representative... > What are the runtime implications of setting statistics too large -- > how much can it affect queries? More stats would mean a bit more time evaluating query plans, but the quality of the plans should be better. > And finally -- how other RDBMS and RDBM-likes deal with this issue? > :) For Oracle and DB/2, the issues are not dissimilar. Oracle somewhat prefers the notion of collecting comprehensive statistics on the whole table, which will be even more costly than PostgreSQL's sampling. -- let name="cbbrowne" and tld="cbbrowne.com" in String.concat "@" [name;tld];; http://www.ntlug.org/~cbbrowne/linuxxian.html A VAX is virtually a computer, but not quite. From pgsql-performance-owner@postgresql.org Fri Nov 19 23:24:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B5DE13A494E for ; Fri, 19 Nov 2004 22:28:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27572-10 for ; Fri, 19 Nov 2004 22:28:38 +0000 (GMT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by svr1.postgresql.org (Postfix) with ESMTP id 95AB03A4ED9 for ; Fri, 19 Nov 2004 20:53:39 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr4.postgresql.org (Postfix) with ESMTP id DF82D5AF6FD for ; Fri, 19 Nov 2004 20:23:43 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6686176; Fri, 19 Nov 2004 12:24:35 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: sort_mem affect on inserts? Date: Fri, 19 Nov 2004 12:25:45 -0800 User-Agent: KMail/1.6.2 Cc: Jan Wieck , David Parker References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BA3D@corpsrv2.tazznetworks.com> <200411171407.30795.josh@agliodbs.com> <419E0466.9090409@Yahoo.com> In-Reply-To: <419E0466.9090409@Yahoo.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411191225.45936.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/307 X-Sequence-Number: 9261 Jan, > Hmmm ... what type of foreign key lookup would that be? None of the RI > generated queries has any order by clause. I was under the impression that work_mem would be used for the index if there was an index for the RI lookup. Wrong? -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Nov 19 22:16:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4632F3A5021 for ; Fri, 19 Nov 2004 22:11:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22312-10 for ; Fri, 19 Nov 2004 22:11:17 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 3B4DE3A2BCC for ; Fri, 19 Nov 2004 20:30:14 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6686196; Fri, 19 Nov 2004 12:26:28 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: index use Date: Fri, 19 Nov 2004 12:27:39 -0800 User-Agent: KMail/1.6.2 Cc: Arshavir Grigorian References: <419E471F.6040006@m-cam.com> In-Reply-To: <419E471F.6040006@m-cam.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411191227.39196.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/303 X-Sequence-Number: 9257 Arshavir, > I have a query that when run on similar tables in 2 different databases > either uses the index on the column (primary key) in the where clause or > does a full table scan. The structure of the tables is the same, except > that the table where the index does not get used has an extra million > rows (22mil vs 23mil). Are both using the same version of PostgreSQL? If so, what version? -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Nov 19 23:26:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 931F63A4AFA for ; Fri, 19 Nov 2004 22:29:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29490-08 for ; Fri, 19 Nov 2004 22:29:11 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id F26BA3A4BBE for ; Fri, 19 Nov 2004 20:52:41 +0000 (GMT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 15A8C3559B; Fri, 19 Nov 2004 12:29:42 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 143813545E; Fri, 19 Nov 2004 12:29:42 -0800 (PST) Date: Fri, 19 Nov 2004 12:29:42 -0800 (PST) From: Stephan Szabo To: Arshavir Grigorian Cc: pgsql-performance@postgresql.org Subject: Re: index use In-Reply-To: <419E471F.6040006@m-cam.com> Message-ID: <20041119122810.X44886@megazone.bigpanda.com> References: <419E471F.6040006@m-cam.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/308 X-Sequence-Number: 9262 On Fri, 19 Nov 2004, Arshavir Grigorian wrote: > Hi, > > I have a query that when run on similar tables in 2 different databases > either uses the index on the column (primary key) in the where clause or > does a full table scan. The structure of the tables is the same, except > that the table where the index does not get used has an extra million > rows (22mil vs 23mil). > > The 2 boxes where these database run are very different (Sparc with scsi > disks and 2G RAM running Solaris 8 AND a PC with 128M RAM running and an > IDE drive running Linux RH9 2.4.20-20.9). I am not sure why that would > make a difference, but maybe it does. Is the second server running in "C" locale or a different locale? The optimization for LIKE to use indexes involves either making an index with a *_pattern_ops operator class or being in "C" locale. From pgsql-performance-owner@postgresql.org Fri Nov 19 22:15:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DB9A53A4C6D for ; Fri, 19 Nov 2004 22:12:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24544-02 for ; Fri, 19 Nov 2004 22:12:11 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id E415A3A3D19 for ; Fri, 19 Nov 2004 20:32:35 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6686229; Fri, 19 Nov 2004 12:31:49 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org, Dawid Kuroczko Subject: Re: When to bump up statistics? Date: Fri, 19 Nov 2004 12:32:59 -0800 User-Agent: KMail/1.6.2 References: <758d5e7f04111905594cf9c9f8@mail.gmail.com> In-Reply-To: <758d5e7f04111905594cf9c9f8@mail.gmail.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411191232.59600.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/302 X-Sequence-Number: 9256 Dawid, > I wonder what are the implications of using this statement, > I know by using, say n=100, ANALYZE will take more time, > pg_statistics will be bigger, planner will take longer time, > on the other hand it will make better decisions... Etc, etc. Yep. And pg_statistics will need to be vacuumed more often. > Is bumping up statistics is only useful for indexed columns? No. It's potentially useful for any queried column. > 1) huge table with huge number of distinct values (_almost_ > unique ;)) Yes. > 2) huge table with relatively equally distributed values > (like each value is in between, say, 30-50 rows). Not usually. > 3) huge table with unequally distributed values (some > values are in 1-5 rows, some are in 1000-5000 rows). Yes. > 4) huge table with small number values (around ~100 > distinct values, equally or uneqally distributed). Not usually, especially if they are equally distributed. > 5) boolean column. Almost never, just as it is seldom useful to index a boolean column. > I think SET STATISTICS 100 is very useful for case with > unequally distributed values, but I wonder what about > the other cases. And as a side note -- what are the > reasonable bounds for statistics (between 10 and 100?) Oh, no, I've used values up to 500 in production, and we've tested up to the max on DBT-3. In my experience, if the default (10) isn't sufficient, you often have to go up to > 250 to get a different plan. > What are the runtime implications of setting statistics > too large -- how much can it affect queries? It won't affect select queries. It will affect ANALYZE time (substantially in the aggregate) and maintenance on the pg_statistics table. > And finally -- how other RDBMS and RDBM-likes deal > with this issue? :) Most don't allow such fine-tuned adjustment. MSSQL, for example, allows only setting it per-table or maybe even database-wide, and on that platform it doesn't seem to have much effect on query plans. Oracle prefers to use HINTS, which are a brute-force method to manage query plans. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Nov 19 22:30:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DFBB33A4A59 for ; Fri, 19 Nov 2004 22:28:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29272-05 for ; Fri, 19 Nov 2004 22:28:47 +0000 (GMT) Received: from mail2.m-cam.com (unknown [63.124.102.77]) by svr1.postgresql.org (Postfix) with ESMTP id B5DB43A4989 for ; Fri, 19 Nov 2004 20:41:23 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail2.m-cam.com (Postfix) with ESMTP id 2DAD73E8F9 for ; Fri, 19 Nov 2004 15:38:52 -0500 (EST) Received: from mail2.m-cam.com ([127.0.0.1]) by localhost (mail2.m-cam.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01344-06 for ; Fri, 19 Nov 2004 15:38:47 -0500 (EST) Received: from [192.168.1.21] (unknown [192.168.1.21]) by mail2.m-cam.com (Postfix) with ESMTP id 5D8C63E8F8 for ; Fri, 19 Nov 2004 15:38:47 -0500 (EST) Message-ID: <419E5A17.4000707@m-cam.com> Date: Fri, 19 Nov 2004 15:39:51 -0500 From: Arshavir Grigorian User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040922 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: index use References: <419E471F.6040006@m-cam.com> In-Reply-To: <419E471F.6040006@m-cam.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at m-cam.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/304 X-Sequence-Number: 9258 Thanks for all the replies. It actually has to do with the locales. The db where the index gets used is running on C vs the the other one that uses en_US.UTF-8. I guess the db with the wrong locale will need to be waxed and recreated with correct locale settings. I wonder if there are any plans to make LIKE work with all locales. Again, many thanks. You guys are great! Arshavir From pgsql-performance-owner@postgresql.org Fri Nov 19 23:14:12 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CD6DC3A4C16 for ; Fri, 19 Nov 2004 22:46:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32929-10 for ; Fri, 19 Nov 2004 22:46:42 +0000 (GMT) Received: from frank.wiles.org (frank.wiles.org [24.124.39.75]) by svr1.postgresql.org (Postfix) with ESMTP id 687143A4F36 for ; Fri, 19 Nov 2004 21:13:20 +0000 (GMT) Received: from kungfu (frank.wiles.org [24.124.39.75]) by frank.wiles.org (8.12.11/8.12.11) with SMTP id iAJLFp2p008077; Fri, 19 Nov 2004 15:15:52 -0600 Date: Fri, 19 Nov 2004 15:13:37 -0600 From: Frank Wiles To: pg@fastcrypt.com Cc: ajanian@scottrade.com, pgsql-performance@postgresql.org Subject: Re: Query Performance and IOWait Message-Id: <20041119151337.477645de.frank@wiles.org> In-Reply-To: <419CD858.1000201@fastcrypt.com> References: <419CD858.1000201@fastcrypt.com> X-Mailer: Sylpheed version 0.9.10 (GTK+ 1.2.10; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/306 X-Sequence-Number: 9260 On Thu, 18 Nov 2004 12:14:00 -0500 Dave Cramer wrote: > Andrew, > > Dell's aren't well known for their disk performance, apparently most > of the perc controllers sold with dell's are actually adaptec > controllers. Also apparently they do not come with the battery > required to use the battery backed up write cache ( In fact according > to some Dell won't even sell the battery to you). Also Dell's > monitoring software is quite a memory hog. > > Have you looked at top ?, and also hdparm -Tt /dev/sd? I haven't seen any PERC controllers that were really Adaptec ones, but I for one quit buying Dell RAID controllers several years ago because of poor Linux support and performance. On one machine (not a PostgreSQL server) we saw a 20% speed improvement by switching to software raid. If you have a test machine, I would suggest moving the data to a box without a RAID controller and see if you get better results. --------------------------------- Frank Wiles http://www.wiles.org --------------------------------- From pgsql-performance-owner@postgresql.org Sat Nov 20 00:05:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ACDEF3A4799 for ; Fri, 19 Nov 2004 23:02:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35159-02 for ; Fri, 19 Nov 2004 23:00:59 +0000 (GMT) Received: from navgstl1.scottrade.com (navgstl1.scottrade.com [208.219.220.247]) by svr1.postgresql.org (Postfix) with SMTP id 29D643A45DD for ; Fri, 19 Nov 2004 21:22:04 +0000 (GMT) Received: from sagstl2.scottrade.com ([208.219.220.215]) by navgstl1.scottrade.com (SMSSMTP 4.0.0.59) with SMTP id M2004111915220328639 for ; Fri, 19 Nov 2004 15:22:03 -0600 Received: from exchstl1.scottrade.com ([172.28.140.45]) by sagstl2.scottrade.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 19 Nov 2004 15:22:02 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Subject: Re: Query Performance and IOWait Date: Fri, 19 Nov 2004 15:22:02 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Query Performance and IOWait Thread-Index: AcTNkgYlGqsLQ1eeTmuBb6y0NEWKgQA68S6g From: "Andrew Janian" To: X-OriginalArrivalTime: 19 Nov 2004 21:22:02.0325 (UTC) FILETIME=[CFA69050:01C4CE7D] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM X-Spam-Level: * X-Archive-Number: 200411/312 X-Sequence-Number: 9266 VGhlIGRhdGEgdGhhdCB3ZSBhcmUgYWNjZXNzaW5nIGlzIHZpYSBRTG9naWMgY2FyZHMgY29ubmVj dGVkIHRvIGFuIEVNQyBDbGFyaW9uLiAgV2UgaGF2ZSB0cmllZCBpdCBvbiBsb2NhbCBTQ1NJIGRp c2tzIHdpdGggdGhlIHNhbWUgKGJhZCkgcmVzdWx0cy4NCg0KV2hlbiB0aGUgbWFjaGluZSBnZXRz IHN0dWNrIGluIGEgMTAwJSBJT1dBSVQgc3RhdGUgaXQgb2Z0ZW4gY3Jhc2hlcyBzb29uIGFmdGVy IHRoYXQuDQoNClRoZSBkaXNrcyBhcmUgZmluZSwgaGF2ZSBiZWVuIHJlcGxhY2VkIGFuZCBjaGVj a2VkLg0KDQpIZXJlIGFyZSBteSByZXN1bHRzIGZyb20gaGRwYXJtIC1UdCAvZGV2L3NkYTEgKHdo aWNoIGlzIHRoZSBFTUMgZGlzayBhcnJheSkNCi9kZXYvc2RhMToNCiBUaW1pbmcgYnVmZmVyLWNh Y2hlIHJlYWRzOiAgIDI5NzYgTUIgaW4gIDIuMDAgc2Vjb25kcyA9IDE0ODguMDAgTUIvc2VjDQog VGltaW5nIGJ1ZmZlcmVkIGRpc2sgcmVhZHM6ICAgNDQgTUIgaW4gIDMuMTMgc2Vjb25kcyA9ICAx NC4wNiBNQi9zZWMNCg0KLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCkZyb206IERhdmUgQ3Jh bWVyIFttYWlsdG86cGdAZmFzdGNyeXB0LmNvbV0NClNlbnQ6IFRodXJzZGF5LCBOb3ZlbWJlciAx OCwgMjAwNCAxMToxNCBBTQ0KVG86IEFuZHJldyBKYW5pYW4NCkNjOiBwZ3NxbC1wZXJmb3JtYW5j ZUBwb3N0Z3Jlc3FsLm9yZw0KU3ViamVjdDogUmU6IFtQRVJGT1JNXSBRdWVyeSBQZXJmb3JtYW5j ZSBhbmQgSU9XYWl0DQoNCg0KQW5kcmV3LA0KDQpEZWxsJ3MgYXJlbid0IHdlbGwga25vd24gZm9y IHRoZWlyIGRpc2sgcGVyZm9ybWFuY2UsIGFwcGFyZW50bHkgbW9zdCBvZiANCnRoZSBwZXJjIGNv bnRyb2xsZXJzIHNvbGQgd2l0aCBkZWxsJ3MgYXJlIGFjdHVhbGx5IGFkYXB0ZWMgY29udHJvbGxl cnMuIA0KQWxzbyBhcHBhcmVudGx5IHRoZXkgZG8gbm90IGNvbWUgd2l0aCB0aGUgYmF0dGVyeSBy ZXF1aXJlZCB0byB1c2UgdGhlIA0KYmF0dGVyeSBiYWNrZWQgdXAgd3JpdGUgY2FjaGUgKCBJbiBm YWN0IGFjY29yZGluZyB0byBzb21lIERlbGwgd29uJ3QgDQpldmVuIHNlbGwgdGhlIGJhdHRlcnkg dG8geW91KS4gQWxzbyBEZWxsJ3MgbW9uaXRvcmluZyBzb2Z0d2FyZSBpcyBxdWl0ZSANCmEgbWVt b3J5IGhvZy4NCg0KSGF2ZSB5b3UgbG9va2VkIGF0IHRvcCA/LCBhbmQgYWxzbyBoZHBhcm0gLVR0 IC9kZXYvc2Q/DQoNCkRhdmUNCg0KQW5kcmV3IEphbmlhbiB3cm90ZToNCg0KPkhlbGxvIEFsbCwN Cj4NCj5JIGhhdmUgYSBzZXR1cCB3aXRoIGEgRGVsbCBQb3dlcmVkZ2UgMjY1MCB3aXRoIFJlZCBI YXQgYW5kIFBvc3RncmVzIDcuNC41IHdpdGggYSBkYXRhYmFzZSB3aXRoIGFib3V0IDI3R0Igb2Yg ZGF0YS4gIFRoZSB0YWJsZSBpbiBxdWVzdGlvbiBoYXMgYWJvdXQgMzUgbWlsbGlvbiByb3dzLg0K Pg0KPkkgYW0gcnVubmluZyB0aGUgZm9sbG93aW5nIHF1ZXJ5Og0KPg0KPlNFTEVDVCAqDQo+RlJP TSBtYl9maXhfbWVzc2FnZQ0KPldIRVJFIG1zZ19jbGllbnRfb3JkZXJfaWQgSU4gKA0KPglTRUxF Q1QgbXNnX2NsaWVudF9vcmRlcl9pZA0KPglGUk9NIG1iX2ZpeF9tZXNzYWdlDQo+CVdIRVJFIG1z Z19sb2dfdGltZSA+PSAnMjAwNC0wNi0wMScNCj4JCUFORCBtc2dfbG9nX3RpbWUgPCAnMjAwNC0w Ni0wMSAxMzozMDowMC4wMDAnDQo+CQlBTkQgbXNnX21lc3NhZ2VfdHlwZSBJTiAoJ0QnLCdHJykN Cj4JCUFORCBtYl9vcmRfdHlwZSA9ICcxJw0KPgkpDQo+CUFORCBtc2dfbG9nX3RpbWUgPiAnMjAw NC0wNi0wMScNCj4JQU5EIG1zZ19sb2dfdGltZSA8ICcyMDA0LTA2LTAxIDIzOjU5OjU5Ljk5OScN Cj4JQU5EIG1zZ19tZXNzYWdlX3R5cGUgPSAnOCcNCj4JQU5EIChtYl9yYXdfdGV4dCBMSUtFICcl Mzk9MSUnIE9SIG1iX3Jhd190ZXh0IExJS0UgJyUzOT0yJScpOw0KPg0KPndpdGggdGhlIGZvbGxv d2luZyBwbGFuOg0KPg0KPiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIFFVRVJZIFBMQU4NCj5OZXN0ZWQgTG9vcCBJTiBKb2luICAoY29zdD0wLjAwLi4zNDA0Ny4y OSByb3dzPTEgd2lkdGg9NTI2KQ0KPiAgLT4gIEluZGV4IFNjYW4gdXNpbmcgbWZpX2xvZ190aW1l IG9uIG1iX2ZpeF9tZXNzYWdlICAoY29zdD0wLjAwLi4yMjIzMS4zMSByb3dzPTI1Mzkgd2lkdGg9 NTI2KQ0KPiAgICAgICBJbmRleCBDb25kOiAoKG1zZ19sb2dfdGltZSA+ICcyMDA0LTA2LTAxIDAw OjAwOjAwJzo6dGltZXN0YW1wIHdpdGhvdXQgdGltZSB6b25lKSBBTkQgKG1zZ19sb2dfdGltZSA8 ICcyMDA0LTA2LTAxIDIzOjU5OjU5Ljk5OSc6OnRpbWVzdGFtcCB3aXRob3V0IHRpbWUgem9uZSkp DQo+ICAgICAgIEZpbHRlcjogKCgobXNnX21lc3NhZ2VfdHlwZSk6OnRleHQgPSAnOCc6OnRleHQp IEFORCAoKChtYl9yYXdfdGV4dCk6OnRleHQgfn4gJyUzOT0xJSc6OnRleHQpIE9SICgobWJfcmF3 X3RleHQpOjp0ZXh0IH5+ICclMzk9MiUnOjp0ZXh0KSkpDQo+ICAtPiAgSW5kZXggU2NhbiB1c2lu ZyBtZmlfY2xpZW50X29yZGlkIG9uIG1iX2ZpeF9tZXNzYWdlICAoY29zdD0wLjAwLi40NDUuNTYg cm93cz0xIHdpZHRoPTE4KQ0KPiAgICAgICBJbmRleCBDb25kOiAoKCJvdXRlciIubXNnX2NsaWVu dF9vcmRlcl9pZCk6OnRleHQgPSAobWJfZml4X21lc3NhZ2UubXNnX2NsaWVudF9vcmRlcl9pZCk6 OnRleHQpDQo+ICAgICAgIEZpbHRlcjogKChtc2dfbG9nX3RpbWUgPj0gJzIwMDQtMDYtMDEgMDA6 MDA6MDAnOjp0aW1lc3RhbXAgd2l0aG91dCB0aW1lIHpvbmUpIEFORCAobXNnX2xvZ190aW1lIDwg JzIwMDQtMDYtMDEgMTM6MzA6MDAnOjp0aW1lc3RhbXAgd2l0aG91dCB0aW1lIHpvbmUpIEFORCAo KG1zZ19tZXNzYWdlX3R5cGUpOjp0ZXh0ID0gJ0QnOjp0ZXh0KSBPUiAoKG1zZ19tZXNzYWdlX3R5 cGUpOjp0ZXh0ID0gJ0cnOjp0ZXh0KSkgQU5EICgobWJfb3JkX3R5cGUpOjp0ZXh0ID0gJzEnOjp0 ZXh0KSkNCj4NCj5XaGlsZSBydW5uaW5nLCB0aGlzIHF1ZXJ5IHByb2R1Y2VzIDEwMCUgaW93YWl0 IHVzYWdlIG9uIGl0cyBwcm9jZXNzb3IgYW5kIHRha2VzIGEgdW5nb2RseSBhbW91bnQgb2YgdGlt ZSAoYWJvdXQgYW4gaG91cikuDQo+DQo+VGhlIHBvc3RncmVzIHNldHRpbmdzIGFyZSBhcyBmb2xs b3dzOg0KPg0KPnNoYXJlZF9idWZmZXJzID0gMzI3NjggICAgICAgICAgIyBtaW4gMTYsIGF0IGxl YXN0IG1heF9jb25uZWN0aW9ucyoyLCA4S0IgZWFjaA0KPnNvcnRfbWVtID0gMjYyMTQ0ICAgICAg ICAgICAgICAgIyBtaW4gNjQsIHNpemUgaW4gS0INCj4NCj5BbmQgdGhlIC9ldGMvc3lzY3RsLmNv bmYgaGFzOg0KPmtlcm5lbC5zaG1hbGwgPSAyNzQyMzUzOTINCj5rZXJuZWwuc2htbWF4ID0gMjc0 MjM1MzkyDQo+DQo+VGhlIHN5c3RlbSBoYXMgNEdCIG9mIFJBTS4NCj4NCj5JIGFtIHByZXR0eSBz dXJlIG9mIHRoZXNlIHNldHRpbmdzLCBidXQgb25seSBmcm9tIG15IHJlYWRpbmcgb2YgdGhlIGRv Y3MgYW5kIG90aGVycycgcmVjb21tZW5kYXRpb25zIG9ubGluZS4NCj4NCj5UaGFua3MsDQo+DQo+ QW5kcmV3IEphbmlhbg0KPk9NUyBEZXZlbG9wbWVudA0KPlNjb3R0cmFkZSBGaW5hbmNpYWwgU2Vy dmljZXMNCj4oMzE0KSA5NjUtMTU1NSB4IDE1MTMNCj5DZWxsOiAoMzE0KSAzNjktMjA4Mw0KPg0K Pi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLShlbmQgb2YgYnJvYWRjYXN0KS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLQ0KPlRJUCA3OiBkb24ndCBmb3JnZXQgdG8gaW5jcmVhc2UgeW91ciBm cmVlIHNwYWNlIG1hcCBzZXR0aW5ncw0KPiAgDQo+DQoNCi0tIA0KRGF2ZSBDcmFtZXINCmh0dHA6 Ly93d3cucG9zdGdyZXNpbnRsLmNvbQ0KNTE5IDkzOSAwMzM2DQpJQ1EjMTQ2NzU1NjENCg0K From pgsql-performance-owner@postgresql.org Fri Nov 19 22:41:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 97BE23A492F for ; Fri, 19 Nov 2004 22:32:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30010-05 for ; Fri, 19 Nov 2004 22:32:45 +0000 (GMT) Received: from web51301.mail.yahoo.com (web51301.mail.yahoo.com [206.190.38.167]) by svr1.postgresql.org (Postfix) with SMTP id 29A033A3D19 for ; Fri, 19 Nov 2004 22:31:23 +0000 (GMT) Received: (qmail 49472 invoked by uid 60001); 19 Nov 2004 22:31:22 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=W4lYflwRYaf1irkr27hTlOGkGBjA9ZxAk9ZB2k49CiNzA2VT6Yt+AQVCvZC7QpWf9iaPvibVEI0lVZjL4UfXhg6ytr4iC1xte7KMdymUjQ69SmbI5DbAT/DYNzjG4H56n15Rxp7G2Ub5MknjxlRX4z99yMfMaiAm+tJT/zqFxUg= ; Message-ID: <20041119223122.49470.qmail@web51301.mail.yahoo.com> Received: from [65.218.182.242] by web51301.mail.yahoo.com via HTTP; Fri, 19 Nov 2004 14:31:22 PST Date: Fri, 19 Nov 2004 14:31:22 -0800 (PST) From: sarlav kumar Subject: help needed -- sequential scan problem To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1225906050-1100903482=:47357" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_20_30, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200411/305 X-Sequence-Number: 9259 --0-1225906050-1100903482=:47357 Content-Type: text/plain; charset=us-ascii Hi All, I am new to Postgres. I have a query which does not use index scan unless I force postgres to use index scan. I dont want to force postgres, unless there is no way of optimizing this query. The query : select m.company_name,m.approved,cu.account_no,mbt.business_name,cda.country, (select count(*) from merchant_purchase mp left join data d on mp.data_id=d.id where mp.merchant_id=m.id and d.status=5) as Trans_count, (select sum(total * 0.01) from merchant_purchase mp left join data d on mp.data_id=d.id where mp.merchant_id=m.id and d.status=5) as Trans_amount, (select count(*) from merchant_purchase mp left join data d on mp.data_id=d.id where d.what=15 and d.status=5 and d.flags=7 and mp.merchant_id=m.id) as Reversal_count from merchant m left join customer cu on cu.id=m.uid left join customerdata cda on cda.uid=cu.id left join merchant_business_types mbt on mbt.id=m.businesstype and exists (select distinct(merchant_id) from merchant_purchase where m.id=merchant_id); First Question: I know the way I have written the first two sub-selects is really bad, as they have the same conditions in the where clause. But I am not sure if there is a way to select two columns in a single sub-select query. When I tried to combine the two sub-select queries, I got an error saying that the sub-select can have only one column. Does anyone know any other efficient way of doing it? Second Question: The query plan is as follows: QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------- Hash Join (cost=901.98..17063.67 rows=619 width=88) (actual time=52.01..5168.09 rows=619 loops=1) Hash Cond: ("outer".businesstype = "inner".id) Join Filter: (subplan) -> Merge Join (cost=900.34..1276.04 rows=619 width=62) (actual time=37.00..97.58 rows=619 loops=1) Merge Cond: ("outer".id = "inner".uid) -> Merge Join (cost=900.34..940.61 rows=619 width=52) (actual time=36.91..54.66 rows=619 loops=1) Merge Cond: ("outer".id = "inner".uid) -> Sort (cost=795.45..810.32 rows=5949 width=17) (actual time=32.59..36.59 rows=5964 loops=1) Sort Key: cu.id -> Seq Scan on customer cu (cost=0.00..422.49 rows=5949 width=17) (actual time=0.02..15.69 rows=5964 loops=1) -> Sort (cost=104.89..106.44 rows=619 width=35) (actual time=4.27..5.10 rows=619 loops=1) Sort Key: m.uid -> Seq Scan on merchant m (cost=0.00..76.19 rows=619 width=35) (actual time=0.04..2.65 rows=619 loops=1) -> Index Scan using customerdata_uid_idx on customerdata cda (cost=0.00..311.85 rows=5914 width=10) (actual time=0.09..27.70 rows=5 919 loops=1) -> Hash (cost=1.51..1.51 rows=51 width=26) (actual time=0.19..0.19 rows=0 loops=1) -> Seq Scan o n merchant_business_types mbt (cost=0.00..1.51 rows=51 width=26) (actual time=0.04..0.12 rows=51 loops=1) SubPlan -> Aggregate (cost=269.89..269.89 rows=1 width=12) (actual time=2.70..2.70 rows=1 loops=619) -> Nested Loop (cost=0.00..269.78 rows=44 width=12) (actual time=2.40..2.69 rows=4 loops=619) Filter: ("inner".status = 5) -> Seq Scan on merchant_purchase mp (cost=0.00..95.39 rows=44 width=4) (actual time=2.37..2.58 rows=6 loops=619) Filter: (merchant_id = $0) -> Index Scan using data_pkey on data d (cost=0.00..3.91 rows=1 width=8) (actual time=0.01..0.01 rows=1 loops=3951) Index Cond: ("outer".data_id = d.id) -> Aggregate (cost=269.89..269.89 rows=1 width=16) (actual time=2.73..2.73 rows=1 loops=619) -> Nested Loop (cost=0.00..269.78 rows=44 width=16) (actual time=2.42..2.70 rows=4 loops=619) Filter: ("inner".status = 5) -> Seq Scan on merchant_purchase m p (cost=0.00..95.39 rows=44 width=8) (actual time=2.39..2.60 rows=6 loops=619) Filter: (merchant_id = $0) -> Index Scan using data_pkey on data d (cost=0.00..3.91 rows=1 width=8) (actual time=0.01..0.01 rows=1 loops=3951) Index Cond: ("outer".data_id = d.id) -> Aggregate (cost=270.12..270.12 rows=1 width=20) (actual time=2.72..2.72 rows=1 loops=619) -> Nested Loop (cost=0.00..270.00 rows=44 width=20) (actual time=2.63..2.72 rows=0 loops=619) Filter: (("inner".what = 15) AND ("inner".status = 5) AND ("inner".flags = 7)) -> Seq Scan on merchant_purchase mp (cost=0.00..95.39 rows=44 width=4) (actual time=2.40..2.62 rows=6 loops=619) Filter: (merchant_id = $0) -> Index Scan using data_pkey on data d (cost=0.00..3.91 rows=1 width=16) (actual time=0.01..0.01 rows=1 loops=3951) Index Cond: ("outer".data_id = d.id) -> Unique (cost=0.00..113.14 rows=4 width=4) (actual time=0.02..0.02 rows=0 loops=598) -> Index Scan using merchant_purchase_merchant_id_idx on merchant_purchase (cost=0.00..113.02 rows=44 width=4) (actual time=0.01. .0.01 rows=0 loops=598) Index Cond: ($0 = merchant_id) Total runtime: 5170.37 msec (5.170 sec) (42 rows) As you can see, there are many sequential scans in the query plan. Postgres is not using the index defined, even though it leads to better performance(0.2 sec!! when i force index scan) Is there something wrong in my query that makes postgres use seq scan as opposed to index scan?? Any help would be really appreciated. Thanks for you time and help! Saranya --------------------------------- Do you Yahoo!? Discover all that�s new in My Yahoo! --0-1225906050-1100903482=:47357 Content-Type: text/html; charset=us-ascii
Hi All,
 
I am new to Postgres.
 
I have a query which does not use index scan unless I force postgres to use index scan. I dont want to force postgres, unless there is no way of optimizing this query.
 
The query :
 
select m.company_name,m.approved,cu.account_no,mbt.business_name,cda.country,
(select count(*) from merchant_purchase mp left join data d on mp.data_id=d.id where mp.merchant_id=m.id and d.status=5) as Trans_count,
(select sum(total * 0.01) from merchant_purchase mp left join data d on mp.data_id=d.id where mp.merchant_id=m.id and d.status=5) as Trans_amount,
(select count(*) from merchant_purchase mp left join data d on mp.data_id=d.id where d.what=15 and d.status=5 and d.flags=7 and mp.merchant_id=m.id) as Reversal_count
from merchant m
left join customer cu on cu.id=m.uid
left join customerdata cda on cda.uid=cu.id
left join merchant_business_types mbt on mbt.id=m.businesstype and
exists (select distinct(merchant_id) from merchant_purchase where m.id=merchant_id);
 
First Question: I know the way I have written the first two sub-selects is really bad, as they have the same conditions in the where clause. But I am not sure if there is a way to select two columns in a single sub-select query. When I tried to combine the two sub-select queries, I got an error saying that the sub-select can have only one column. Does anyone know any other efficient way of doing it?
 
Second Question: The query plan is as follows:
 
 QUERY PLAN                                                     
                       
-------------------------------------------------------------------------------------------------------------------------------- Hash Join  (cost=901.98..17063.67 rows=619 width=88) (actual time=52.01..5168.09 rows=619 loops=1)
   Hash Cond: ("outer".businesstype = "inner".id)
   Join Filter: (subplan)
   ->  Merge Join  (cost=900.34..1276.04 rows=619 width=62) (actual time=37.00..97.58 rows=619 loops=1)
         Merge Cond: ("outer".id = "inner".uid)
         ->  Merge Join  (cost=900.34..940.61 rows=619 width=52) (actual time=36.91..54.66 rows=619 loops=1)
               Merge Cond: ("outer".id = "inner".uid)
               ->  Sort  (cost=795.45..810.32 rows=5949 width=17) (actual time=32.59..36.59 rows=5964 loops=1)
                     Sort Key: cu.id
                     ->  Seq Scan on customer cu  (cost=0.00..422.49 rows=5949 width=17) (actual time=0.02..15.69 rows=5964 loops=1)
               ->  Sort  (cost=104.89..106.44 rows=619 width=35) (actual time=4.27..5.10 rows=619 loops=1)
                     Sort Key: m.uid
                     ->  Seq Scan on merchant m  (cost=0.00..76.19 rows=619 width=35) (actual time=0.04..2.65 rows=619 loops=1)
         ->  Index Scan using customerdata_uid_idx on customerdata cda  (cost=0.00..311.85 rows=5914 width=10) (actual time=0.09..27.70 rows=5
919 loops=1)
   ->  Hash  (cost=1.51..1.51 rows=51 width=26) (actual time=0.19..0.19 rows=0 loops=1)
         ->  Seq Scan o n merchant_business_types mbt  (cost=0.00..1.51 rows=51 width=26) (actual time=0.04..0.12 rows=51 loops=1)
   SubPlan
     ->  Aggregate  (cost=269.89..269.89 rows=1 width=12) (actual time=2.70..2.70 rows=1 loops=619)
           ->  Nested Loop  (cost=0.00..269.78 rows=44 width=12) (actual time=2.40..2.69 rows=4 loops=619)
                 Filter: ("inner".status = 5)
                 ->  Seq Scan on merchant_purchase mp  (cost=0.00..95.39 rows=44 width=4) (actual time=2.37..2.58 rows=6 loops=619)
                       Filter: (merchant_id = $0)
                 ->  Index Scan using data_pkey on data d  (cost=0.00..3.91 rows=1 width=8) (actual time=0.01..0.01 rows=1 loops=3951)
                       Index Cond: ("outer".data_id = d.id)
     ->  Aggregate  (cost=269.89..269.89 rows=1 width=16) (actual time=2.73..2.73 rows=1 loops=619)
           ->  Nested Loop  (cost=0.00..269.78 rows=44 width=16) (actual time=2.42..2.70 rows=4 loops=619)
                 Filter: ("inner".status = 5)
                 ->  Seq Scan on merchant_purchase m p  (cost=0.00..95.39 rows=44 width=8) (actual time=2.39..2.60 rows=6 loops=619)
                       Filter: (merchant_id = $0)
                 ->  Index Scan using data_pkey on data d  (cost=0.00..3.91 rows=1 width=8) (actual time=0.01..0.01 rows=1 loops=3951)
                       Index Cond: ("outer".data_id = d.id)
     ->  Aggregate  (cost=270.12..270.12 rows=1 width=20) (actual time=2.72..2.72 rows=1 loops=619)
           ->  Nested Loop  (cost=0.00..270.00 rows=44 width=20) (actual time=2.63..2.72 rows=0 loops=619)
                 Filter: (("inner".what = 15) AND ("inner".status = 5) AND ("inner".flags = 7))
                 ->  Seq Scan on merchant_purchase mp  (cost=0.00..95.39 rows=44 width=4) (actual time=2.40..2.62 rows=6 loops=619)
                       Filter: (merchant_id = $0)
                 ->  Index Scan using data_pkey on data d  (cost=0.00..3.91 rows=1 width=16) (actual time=0.01..0.01 rows=1 loops=3951)
                       Index Cond: ("outer".data_id = d.id)
     ->  Unique  (cost=0.00..113.14 rows=4 width=4) (actual time=0.02..0.02 rows=0 loops=598)
           ->  Index Scan using merchant_purchase_merchant_id_idx on merchant_purchase  (cost=0.00..113.02 rows=44 width=4) (actual time=0.01.
.0.01 rows=0 loops=598)
                 Index Cond: ($0 = merchant_id)
 Total runtime: 5170.37 msec (5.170 sec)
(42 rows)
 
As you can see, there are many sequential scans in the query plan. Postgres is not using the index defined, even though it leads to better performance(0.2 sec!! when i force index scan)
 
Is there something wrong in my query that makes postgres use seq scan as opposed to index scan?? Any help would be really appreciated.
 
Thanks for you time and help!
Saranya


Do you Yahoo!?
Discover all that�s new in My Yahoo! --0-1225906050-1100903482=:47357-- From pgsql-performance-owner@postgresql.org Sat Nov 20 00:04:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D13F53A4AF9 for ; Fri, 19 Nov 2004 23:24:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41002-09 for ; Fri, 19 Nov 2004 23:24:22 +0000 (GMT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by svr1.postgresql.org (Postfix) with ESMTP id 8D7393A4E0B for ; Fri, 19 Nov 2004 23:24:10 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr4.postgresql.org (Postfix) with ESMTP id 55DA85AF7F3 for ; Fri, 19 Nov 2004 22:32:53 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: tablespace + RAM disk? Date: Fri, 19 Nov 2004 17:32:11 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26BBB3@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: tablespace + RAM disk? Thread-Index: AcTOh5ykmUoLqIEISWuJmH2aQXOGSQ== From: "David Parker" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/310 X-Sequence-Number: 9264 We are using 7.4.5 on Solaris 9.=20 We have a couple tables (holding information about network sessions, for = instance) which don't need to persist beyond the life of the server, but = while the server is running they are heavily hit, insert/update/delete. Temporary tables won't work for us because they are per-connection, and = we are using a thread pool, and session data could be accessed from = multiple connections. Would 8.0 tablespaces, with a tablespace placed on a RAM disk be a = potential solution for this? I have used RAM disks for disk caches in = the past, but I don't know if there are any special issues with defining = a tablespace that way. Thanks. - DAP -------------------------------------------------------------------------= --------- David Parker Tazz Networks (401) 709-5130 =A0 From pgsql-performance-owner@postgresql.org Sat Nov 20 00:32:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 12C123A2BB9 for ; Sat, 20 Nov 2004 00:32:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61029-03 for ; Sat, 20 Nov 2004 00:32:45 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 119393A3B0D for ; Sat, 20 Nov 2004 00:32:45 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6687181; Fri, 19 Nov 2004 16:34:16 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: tablespace + RAM disk? Date: Fri, 19 Nov 2004 16:35:26 -0800 User-Agent: KMail/1.6.2 Cc: "David Parker" References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BBB3@corpsrv2.tazznetworks.com> In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C26BBB3@corpsrv2.tazznetworks.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411191635.26919.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/313 X-Sequence-Number: 9267 David, > We have a couple tables (holding information about network sessions, for > instance) which don't need to persist beyond the life of the server, but > while the server is running they are heavily hit, insert/update/delete. See the thread this last week on Memcached for a cheaper solution. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sat Nov 20 01:34:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8FC323A2B4C for ; Sat, 20 Nov 2004 01:34:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73239-07 for ; Sat, 20 Nov 2004 01:34:22 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id 033C53A202D for ; Sat, 20 Nov 2004 01:34:22 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: tablespace + RAM disk? Date: Fri, 19 Nov 2004 20:34:22 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26BBC6@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] tablespace + RAM disk? Thread-Index: AcTOmHTtrli9m1ALSkajbSMHsp8j4wACHs5w From: "David Parker" To: , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/314 X-Sequence-Number: 9268 Oh! I sort of started paying attention to that in the middle...and couldn't make head or tail out of it. Will search back to the beginning.... Thanks. - DAP >-----Original Message----- >From: Josh Berkus [mailto:josh@agliodbs.com]=20 >Sent: Friday, November 19, 2004 7:35 PM >To: pgsql-performance@postgresql.org >Cc: David Parker >Subject: Re: [PERFORM] tablespace + RAM disk? > >David, > >> We have a couple tables (holding information about network sessions,=20 >> for >> instance) which don't need to persist beyond the life of the server,=20 >> but while the server is running they are heavily hit,=20 >insert/update/delete. > >See the thread this last week on Memcached for a cheaper solution. > >-- >--Josh > >Josh Berkus >Aglio Database Solutions >San Francisco > From pgsql-performance-owner@postgresql.org Sat Nov 20 04:19:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C1E7A3A4B67 for ; Sat, 20 Nov 2004 04:18:56 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15373-07 for ; Sat, 20 Nov 2004 04:18:52 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id C93C23A49DA for ; Sat, 20 Nov 2004 04:18:50 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: tablespace + RAM disk? Date: Fri, 19 Nov 2004 23:18:51 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26BBCB@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] tablespace + RAM disk? Thread-Index: AcTOmHTtrli9m1ALSkajbSMHsp8j4wACHs5wAAVoFuA= From: "David Parker" To: , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/315 X-Sequence-Number: 9269 But, I'm also still interested in the answer to my question: is there any reason you could not put an 8.0 tablespace on a RAM disk?=20 I can imagine doing it by having an initdb run at startup somehow, with the idea that having a mix of tablespaces in a database would make this harder, but I haven't read enough about tablespaces yet. The problem with trying to mix a RAM tablespace with a persistent tablespace would seem to be that you would have to recreate select data files at system startup before you could start the database. That's why an initdb seems cleaner to me, but...I should stop talking and go read about tablespaces and memcached. I'd be interested to hear if anybody has tried this. And I will also check out memcached, too, of course. Thanks for the pointer. - DAP >-----Original Message----- >From: pgsql-performance-owner@postgresql.org=20 >[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of=20 >David Parker >Sent: Friday, November 19, 2004 8:34 PM >To: josh@agliodbs.com; pgsql-performance@postgresql.org >Subject: Re: [PERFORM] tablespace + RAM disk? > >Oh! I sort of started paying attention to that in the=20 >middle...and couldn't make head or tail out of it. Will search=20 >back to the beginning.... > >Thanks. > >- DAP > >>-----Original Message----- >>From: Josh Berkus [mailto:josh@agliodbs.com] >>Sent: Friday, November 19, 2004 7:35 PM >>To: pgsql-performance@postgresql.org >>Cc: David Parker >>Subject: Re: [PERFORM] tablespace + RAM disk? >> >>David, >> >>> We have a couple tables (holding information about network=20 >sessions,=20 >>> for >>> instance) which don't need to persist beyond the life of=20 >the server,=20 >>> but while the server is running they are heavily hit, >>insert/update/delete. >> >>See the thread this last week on Memcached for a cheaper solution. >> >>-- >>--Josh >> >>Josh Berkus >>Aglio Database Solutions >>San Francisco >> > >---------------------------(end of=20 >broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster > From pgsql-performance-owner@postgresql.org Sat Nov 20 05:20:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 193043A1D8A for ; Sat, 20 Nov 2004 05:20:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28242-10 for ; Sat, 20 Nov 2004 05:19:51 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7EE0D3A49DA for ; Sat, 20 Nov 2004 05:19:50 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAK5JkXK016680; Sat, 20 Nov 2004 00:19:46 -0500 (EST) To: sarlav kumar Cc: pgsql-performance@postgresql.org Subject: Re: help needed -- sequential scan problem In-reply-to: <20041119223122.49470.qmail@web51301.mail.yahoo.com> References: <20041119223122.49470.qmail@web51301.mail.yahoo.com> Comments: In-reply-to sarlav kumar message dated "Fri, 19 Nov 2004 14:31:22 -0800" Date: Sat, 20 Nov 2004 00:19:46 -0500 Message-ID: <16679.1100927986@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/316 X-Sequence-Number: 9270 sarlav kumar writes: > I have a query which does not use index scan unless I force postgres to use index scan. I dont want to force postgres, unless there is no way of optimizing this query. The major issue seems to be in the sub-selects: > -> Seq Scan on merchant_purchase mp (cost=0.00..95.39 rows=44 width=4) (actual time=2.37..2.58 rows=6 loops=619) > Filter: (merchant_id = $0) where the estimated row count is a factor of 7 too high. If the estimated row count were even a little lower, it'd probably have gone for an indexscan. You might get some results from increasing the statistics target for merchant_purchase.merchant_id. If that doesn't help, I'd think about reducing random_page_cost a little bit. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Nov 20 09:36:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 24F103A4A26 for ; Sat, 20 Nov 2004 09:36:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76840-07 for ; Sat, 20 Nov 2004 09:36:37 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.199]) by svr1.postgresql.org (Postfix) with ESMTP id 46EC93A3AFE for ; Sat, 20 Nov 2004 09:36:38 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a36so101209rnf for ; Sat, 20 Nov 2004 01:36:38 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=IJjWyZSRPsMcdPdY+o8DoiKUB1uZ5tJAUIAj7lrmpimE4ocmAsFB5NPVyO1X8m+/aDWXMyxR9eIdPRuNkZbzsp5bQQ2u84xDvxYhaBubiAbglWkOsPgz7WQpPoUk67m0Jv2Ya1JjT8BGBCU8gEO3NAlvTeXr3ze+5rT7ZxnG+pI= Received: by 10.38.77.37 with SMTP id z37mr77428rna; Sat, 20 Nov 2004 01:36:38 -0800 (PST) Received: by 10.38.163.22 with HTTP; Sat, 20 Nov 2004 01:36:38 -0800 (PST) Message-ID: <758d5e7f04112001361e517820@mail.gmail.com> Date: Sat, 20 Nov 2004 10:36:38 +0100 From: Dawid Kuroczko Reply-To: Dawid Kuroczko To: pgsql-performance@postgresql.org Subject: Re: tablespace + RAM disk? In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C26BBCB@corpsrv2.tazznetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BBCB@corpsrv2.tazznetworks.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200411/317 X-Sequence-Number: 9271 On Fri, 19 Nov 2004 23:18:51 -0500, David Parker wrote: > But, I'm also still interested in the answer to my question: is there > any reason you could not put an 8.0 tablespace on a RAM disk? > > I can imagine doing it by having an initdb run at startup somehow, with > the idea that having a mix of tablespaces in a database would make this > harder, but I haven't read enough about tablespaces yet. The problem > with trying to mix a RAM tablespace with a persistent tablespace would > seem to be that you would have to recreate select data files at system > startup before you could start the database. That's why an initdb seems > cleaner to me, but...I should stop talking and go read about tablespaces > and memcached. I think there might be a problem with recovery after crash. I haven't tested it but I guess pgsql would complain that databases which existed before crash (or even server reboot) no longer exist. And I see two options, either it would complain loudly and continue, or simply fail... Unless there would be option to mark database/schema/table as non-PITR-logged (since data is expendable and can be easily recreated)... :) Having tablespaces on RAM disks (like tmpfs), hmm, it could be useful, say to put TEMPORARY tables there. Since they will be gone nonetheless, its a nice place for them. Side question: Do TEMPORARY tables operations end up in PITR log? Regards, Dawid PS: To pgmemchache I go! From pgsql-performance-owner@postgresql.org Sat Nov 20 14:18:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 19F3C3A4CB7 for ; Sat, 20 Nov 2004 14:18:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 37425-10 for ; Sat, 20 Nov 2004 14:18:05 +0000 (GMT) Received: from mail.logi-track.com (burro.logi-track.com [213.239.193.212]) by svr1.postgresql.org (Postfix) with ESMTP id 3FD143A4CFF for ; Sat, 20 Nov 2004 14:18:07 +0000 (GMT) Received: from kingfisher.intern.logi-track.com (p5088F44C.dip0.t-ipconnect.de [80.136.244.76]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logi-track.com (Postfix) with ESMTP id 5638430033; Sat, 20 Nov 2004 15:18:01 +0100 (CET) Received: from kingfisher.intern.logi-track.com (localhost [127.0.0.1]) by kingfisher.intern.logi-track.com (Postfix) with SMTP id 550F8AB0D0; Sat, 20 Nov 2004 15:17:13 +0100 (CET) Date: Sat, 20 Nov 2004 15:17:10 +0100 From: Markus Schaber To: PostgreSQL Performance List Subject: Index usage for sorted query Message-ID: <20041120151710.695f4de5@kingfisher.intern.logi-track.com> Organization: logi-track ag, =?ISO-8859-15?Q?z=FCrich?= X-Mailer: Sylpheed-Claws 0.9.12b (GTK+ 1.2.10; i386-pc-linux-gnu) X-Face: Nx5T&>Nj$VrVPv}sC3IL&)TqHHOKCz/|)R$i"*r@w0{*I6w; UNU_hdl1J4NI_m{IMztq=>cmM}1gCLbAF+9\#CGkG8}Y{x%SuQ>1#t:; Z(|\qdd[i]HStki~#w1$TPF}:0w-7"S\Ev|_a$K Index Scan using streets_name_idx on streets (cost=3D0.00..2857177.= 57 rows=3D937059 width=3D290) Index Cond: ((cd)::text =3D 'ca'::text) And I have, beside others, the following index: =BBstreets_name_idx=AB btree (cd, l_postcode) As the query plan shows, my postgresql 7.4 does fine on using the index for the WHERE clause. But as it fetches all the rows through the index, why doesn't it recognize that, fetching this way, the rows are already sorted by l_postcode? As I have a larger set of data, it nearly breaks down our developer machine every time we do this, as it always creates a temporary copy of the large amount of data to sort it (setting sort_mem higher makes it swap, setting it lower makes it thrashing disk directly). Is Postgresql 8 more intelligend in this case? Thanks for your hints, Markus=20 --=20 markus schaber | dipl. informatiker logi-track ag | rennweg 14-16 | ch 8001 z=FCrich phone +41-43-888 62 52 | fax +41-43-888 62 53 mailto:schabios@logi-track.com | www.logi-track.com From pgsql-performance-owner@postgresql.org Sat Nov 20 16:11:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 063F43A4327 for ; Sat, 20 Nov 2004 16:11:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65760-02 for ; Sat, 20 Nov 2004 16:11:06 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 81A623A428F for ; Sat, 20 Nov 2004 16:11:03 +0000 (GMT) Received: (qmail 6603 invoked from network); 20 Nov 2004 17:11:27 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 20 Nov 2004 17:11:27 +0100 To: "Markus Schaber" , "PostgreSQL Performance List" Subject: Re: Index usage for sorted query References: <20041120151710.695f4de5@kingfisher.intern.logi-track.com> Message-ID: Date: Sat, 20 Nov 2004 17:12:43 +0100 From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <20041120151710.695f4de5@kingfisher.intern.logi-track.com> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/319 X-Sequence-Number: 9273 Instead of : > WHERE cd='ca' ORDER BY l_postcode; Write : > WHERE cd='ca' ORDER BY cd, l_postcode; You have a multicolumn index, so you should specify a multicolumn sort exactly the same as your index, and the planner will get it. From pgsql-performance-owner@postgresql.org Sat Nov 20 16:48:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5B7A63A4DA0 for ; Sat, 20 Nov 2004 16:48:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72911-06 for ; Sat, 20 Nov 2004 16:48:21 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 70ED43A4D89 for ; Sat, 20 Nov 2004 16:48:21 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAKGmGYJ021433; Sat, 20 Nov 2004 11:48:17 -0500 (EST) To: Markus Schaber Cc: PostgreSQL Performance List Subject: Re: Index usage for sorted query In-reply-to: <20041120151710.695f4de5@kingfisher.intern.logi-track.com> References: <20041120151710.695f4de5@kingfisher.intern.logi-track.com> Comments: In-reply-to Markus Schaber message dated "Sat, 20 Nov 2004 15:17:10 +0100" Date: Sat, 20 Nov 2004 11:48:16 -0500 Message-ID: <21432.1100969296@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/320 X-Sequence-Number: 9274 Markus Schaber writes: > But as it fetches all the rows through the index, why doesn't it > recognize that, fetching this way, the rows are already sorted by > l_postcode? Tell it to "ORDER BY cd, l_postcode". > Is Postgresql 8 more intelligend in this case? No. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Nov 21 01:42:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 47FE43A4ECF for ; Sun, 21 Nov 2004 01:42:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03974-10 for ; Sun, 21 Nov 2004 01:42:35 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id C1E7E3A4ECB for ; Sun, 21 Nov 2004 01:42:38 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6690860; Sat, 20 Nov 2004 17:44:09 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: tablespace + RAM disk? Date: Sat, 20 Nov 2004 11:38:43 -0800 User-Agent: KMail/1.6.2 Cc: "David Parker" References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BBCB@corpsrv2.tazznetworks.com> In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C26BBCB@corpsrv2.tazznetworks.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411201138.43162.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=DATE_IN_PAST_06_12 X-Spam-Level: X-Archive-Number: 200411/321 X-Sequence-Number: 9275 David, > But, I'm also still interested in the answer to my question: is there > any reason you could not put an 8.0 tablespace on a RAM disk? Some people have *talked* about trying it, but nobody yet has reported back. I can see a few potential problems: 1) The query planner would not be aware, and could not be made aware short of hacking the source, that one tablespace has different access speeds than the others; 2) After a crash, you might be unable to recover that tablespace, and PG would refuse to bring the system back up without it. However, the best thing to do is to try it. Good luck, and do a write-up for us! -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun Nov 21 01:43:08 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 731963A4ED0 for ; Sun, 21 Nov 2004 01:42:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06329-01 for ; Sun, 21 Nov 2004 01:42:36 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 5B78B3A4ECC for ; Sun, 21 Nov 2004 01:42:39 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6690861; Sat, 20 Nov 2004 17:44:09 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: index use Date: Sat, 20 Nov 2004 11:40:53 -0800 User-Agent: KMail/1.6.2 Cc: Arshavir Grigorian References: <419E471F.6040006@m-cam.com> <419E5A17.4000707@m-cam.com> In-Reply-To: <419E5A17.4000707@m-cam.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411201140.53466.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=DATE_IN_PAST_06_12 X-Spam-Level: X-Archive-Number: 200411/322 X-Sequence-Number: 9276 Arshavir, > Thanks for all the replies. It actually has to do with the locales. The > db where the index gets used is running on C vs the the other one that > uses en_US.UTF-8. I guess the db with the wrong locale will need to be > waxed and recreated with correct locale settings. I wonder if there are > any plans to make LIKE work with all locales. I thought there were some fixes for this in 8.0, but I can't find anything in the release notes. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun Nov 21 14:48:03 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 112B93A4A4C for ; Sun, 21 Nov 2004 14:48:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66875-07 for ; Sun, 21 Nov 2004 14:47:52 +0000 (GMT) Received: from sue.samurai.com (sue.samurai.com [205.207.28.74]) by svr1.postgresql.org (Postfix) with ESMTP id 509343A3E29 for ; Sun, 21 Nov 2004 14:47:55 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by sue.samurai.com (Postfix) with ESMTP id BA80B19798; Sun, 21 Nov 2004 09:47:55 -0500 (EST) Received: from sue.samurai.com ([127.0.0.1]) by localhost (sue.samurai.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 19009-02-6; Sun, 21 Nov 2004 09:47:54 -0500 (EST) Received: from [220.101.3.90] (r220-101-3-90.cpe.unwired.net.au [220.101.3.90]) by sue.samurai.com (Postfix) with ESMTP id 4E728197B1; Sun, 21 Nov 2004 09:47:53 -0500 (EST) Message-ID: <41A0AAA5.9080303@samurai.com> Date: Mon, 22 Nov 2004 01:48:05 +1100 From: Neil Conway User-Agent: Mozilla Thunderbird 0.9 (Macintosh/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dawid Kuroczko Cc: pgsql-performance@postgresql.org Subject: Re: tablespace + RAM disk? References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BBCB@corpsrv2.tazznetworks.com> <758d5e7f04112001361e517820@mail.gmail.com> In-Reply-To: <758d5e7f04112001361e517820@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/323 X-Sequence-Number: 9277 Dawid Kuroczko wrote: > Side question: Do TEMPORARY tables operations end up in PITR log? No. -Neil From pgsql-performance-owner@postgresql.org Sun Nov 21 14:51:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 60B2B3A4CA4 for ; Sun, 21 Nov 2004 14:51:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67389-09 for ; Sun, 21 Nov 2004 14:51:45 +0000 (GMT) Received: from sue.samurai.com (sue.samurai.com [205.207.28.74]) by svr1.postgresql.org (Postfix) with ESMTP id 075423A4C97 for ; Sun, 21 Nov 2004 14:51:49 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by sue.samurai.com (Postfix) with ESMTP id E1279197C5; Sun, 21 Nov 2004 09:51:49 -0500 (EST) Received: from sue.samurai.com ([127.0.0.1]) by localhost (sue.samurai.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 19154-02-4; Sun, 21 Nov 2004 09:51:49 -0500 (EST) Received: from [220.101.3.90] (r220-101-3-90.cpe.unwired.net.au [220.101.3.90]) by sue.samurai.com (Postfix) with ESMTP id 0F7E5197C1; Sun, 21 Nov 2004 09:51:46 -0500 (EST) Message-ID: <41A0AB8E.4040301@samurai.com> Date: Mon, 22 Nov 2004 01:51:58 +1100 From: Neil Conway User-Agent: Mozilla Thunderbird 0.9 (Macintosh/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org, Jan Wieck , David Parker Subject: Re: sort_mem affect on inserts? References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BA3D@corpsrv2.tazznetworks.com> <200411171407.30795.josh@agliodbs.com> <419E0466.9090409@Yahoo.com> <200411191225.45936.josh@agliodbs.com> In-Reply-To: <200411191225.45936.josh@agliodbs.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/324 X-Sequence-Number: 9278 Josh Berkus wrote: > I was under the impression that work_mem would be used for the index if there > was an index for the RI lookup. Wrong? Yes -- work_mem is not used for doing index scans, whether for RI lookups or otherwise. -Neil From pgsql-performance-owner@postgresql.org Mon Nov 22 04:15:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 389B43A1D89 for ; Mon, 22 Nov 2004 04:15:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62763-07 for ; Mon, 22 Nov 2004 04:15:52 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 29EFD3A5117 for ; Mon, 22 Nov 2004 04:15:49 +0000 (GMT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id iAM4Fh908507; Sun, 21 Nov 2004 23:15:43 -0500 (EST) From: Bruce Momjian Message-Id: <200411220415.iAM4Fh908507@candle.pha.pa.us> Subject: Re: memcached and PostgreSQL In-Reply-To: <200411171307.06584.josh@agliodbs.com> To: josh@agliodbs.com Date: Sun, 21 Nov 2004 23:15:43 -0500 (EST) Cc: pgsql-performance@postgresql.org, Michael Adler , Darcy Buskermolen X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/325 X-Sequence-Number: 9279 Josh Berkus wrote: > Michael, > > > Still, it seems like a convenient way to maintain cache coherency, > > assuming that your application doesn't already have a clean way to do > > that. > > Precisely. The big problem with memory caching is the cache getting out of > sync with the database. Updating the cache through database triggers helps > ameliorate that. > > However, our inability to pass messages with NOTIFY somewhat limits the the > utility of this solution Sean wants "on commit triggers", but there's some > major issues to work out with that. Passing messages with NOTIFY would be > easier and almost as good. The big concern I have about memcache is that because it controls storage external to the database there is no way to guarantee the cache is consistent with the database. This is similar to sending email in a trigger or on commit where you can't be certain you send email always and only on a commit. In the database, we mark everything we do with a transaction id and mark the transaction id as committed in on operation. I see no way to do that with memcache. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Mon Nov 22 04:29:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 84BD23A5116 for ; Mon, 22 Nov 2004 04:29:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66994-03 for ; Mon, 22 Nov 2004 04:29:02 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 6190A3A50C4 for ; Mon, 22 Nov 2004 04:29:01 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6694457; Sun, 21 Nov 2004 20:30:31 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: memcached and PostgreSQL Date: Sun, 21 Nov 2004 20:27:15 -0800 User-Agent: KMail/1.6.2 Cc: Bruce Momjian References: <200411220415.iAM4Fh908507@candle.pha.pa.us> In-Reply-To: <200411220415.iAM4Fh908507@candle.pha.pa.us> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <200411212027.15554.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/326 X-Sequence-Number: 9280 Bruce, > The big concern I have about memcache is that because it controls > storage external to the database there is no way to guarantee the cache > is consistent with the database. =A0This is similar to sending email in a > trigger or on commit where you can't be certain you send email always > and only on a commit. Well, some things ... ON COMMIT triggers, or messages with NOTIFY, would=20 improve the accuracy by cutting down on cached aborted transactions. =20 However, caching is of necessity imperfect. Caching is a trade-off; great= er=20 access speed vs. perfect consistency (and any durability). There are cas= es=20 where the access speed is more important than the consistency (or the=20 durability). The answer is to use memcached judiciously and be prepared t= o=20 account for minor inconsistencies. =20 =46or that matter, as with other forms of cumulative asynchronous materiali= zed=20 view, it would be advisable to nightly re-build copies of data stored in=20 memcached from scratch during system slow time, assuming that the data in=20 memcached corresponds to a real table. Where memcached does not correspond= =20 to a real table (session keys, for example), it is not a concern at all. =2D-=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Nov 22 04:55:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6C8A13A5134 for ; Mon, 22 Nov 2004 04:55:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73842-02 for ; Mon, 22 Nov 2004 04:55:31 +0000 (GMT) Received: from mail.trippynames.com (mail.trippynames.com [38.113.223.19]) by svr1.postgresql.org (Postfix) with ESMTP id 32A3C3A5133 for ; Mon, 22 Nov 2004 04:55:30 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by mail.trippynames.com (Postfix) with ESMTP id 4AE12A525C; Sun, 21 Nov 2004 20:55:28 -0800 (PST) Received: from mail.trippynames.com ([127.0.0.1]) by localhost (rand.nxad.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 39808-02; Sun, 21 Nov 2004 20:55:26 -0800 (PST) Received: from [192.168.1.2] (dsl081-069-073.sfo1.dsl.speakeasy.net [64.81.69.73]) by mail.trippynames.com (Postfix) with ESMTP id 63E64A6D35; Sun, 21 Nov 2004 20:55:24 -0800 (PST) In-Reply-To: <200411220415.iAM4Fh908507@candle.pha.pa.us> References: <200411220415.iAM4Fh908507@candle.pha.pa.us> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: josh@agliodbs.com, Darcy Buskermolen , pgsql-performance@postgresql.org, Michael Adler From: Sean Chittenden Subject: Re: memcached and PostgreSQL Date: Sun, 21 Nov 2004 20:55:16 -0800 To: Bruce Momjian X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/327 X-Sequence-Number: 9281 > The big concern I have about memcache is that because it controls > storage external to the database there is no way to guarantee the cache > is consistent with the database. I've found that letting applications add data to memcache and then letting the database replace or delete keys seems to be the best approach to minimize exactly this issue. Having two clients update the cache is risky. Using triggers or using NOTIFY + tailing logs makes this much more bullet proof. > This is similar to sending email in a trigger or on commit where you > can't be certain you send email always > and only on a commit. While this is certainly a possibility, it's definitely closer to the exception and not the normal instance. > In the database, we mark everything we do with a transaction id and > mark > the transaction id as committed in on operation. I see no way to do > that with memcache. Correct. With an ON COMMIT trigger, it'll be easier to have a 100% accurate cache. That said, memcache does exist out side of the database so it's theoretically impossible to guarantee that the two are 100% in sync. pgmemcache goes a long way towards facilitating that the cache is in sync with the database, but it certainly doesn't guarantee it's in sync. That being said, I haven't had any instances of it not being in sync since using pgmemcache (I'm quite proud of this, to be honest *grin*). For critical operations such as financial transactions, however, I advise going to the database unless you're willing to swallow the financial cost of cache discrepancies. -sc -- Sean Chittenden From pgsql-hackers-owner@postgresql.org Wed Nov 24 04:34:50 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 787ED3A50C4 for ; Mon, 22 Nov 2004 07:33:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08394-09 for ; Mon, 22 Nov 2004 07:33:16 +0000 (GMT) Received: from corbeanca.iqm.ro (unknown [82.76.19.39]) by svr1.postgresql.org (Postfix) with ESMTP id 7157E3A4228 for ; Mon, 22 Nov 2004 07:33:16 +0000 (GMT) Received: from saabxp (Constantinescu [192.168.1.8]) by corbeanca.iqm.ro (8.12.11/8.12.11) with ESMTP id iAM7akZ2008229 for ; Mon, 22 Nov 2004 09:36:47 +0200 Message-Id: <200411220736.iAM7akZ2008229@corbeanca.iqm.ro> Reply-To: From: "Constantin Teodorescu" To: Subject: Big number of schemas (3500) into a single database Date: Mon, 22 Nov 2004 09:44:04 +0200 Organization: IQM MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0000_01C4D077.CEAEE2F0" X-Mailer: Microsoft Office Outlook, Build 11.0.6353 Thread-Index: AcTQZrKuyY0K5KEWSc+w2Bt2tbE6MA== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_50_60, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200411/881 X-Sequence-Number: 61453 This is a multipart message in MIME format, containing the original message body and a footer added by BitDefender --=-bd-boundary-WcPO17Pe3gfNcAL2 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0000_01C4D077.CEAEE2F0" This is a multi-part message in MIME format. ------=_NextPart_000_0000_01C4D077.CEAEE2F0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello to everybody again, thought you didn't hear any news from me for a very long time, the news are good :-) I'm still here and promoting PostgreSQL. I am involved in the developing of a big romanian project for the vets that will put Linux & PostgreSQL on 3500 computers in the whole country, linked together with dial-up connections that will keep track of the animal movements. The central database (also PostgreSLQ) will hold billions of records with animal events (births, movements, slaughter and so on) and my question is: If I will choose to keep a mirror of every workstation database in a separate schema in the central database that mean that I will have 3500 different schemas. Is there any limit or any barrier that could stop this kind of approach or make things go slower? Constantin Teodorescu Ancient PgAccess developer P.S. Please Cc: me at teo@flex.ro ------=_NextPart_000_0000_01C4D077.CEAEE2F0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hello to everybody = again,

 

thought you didn’t hear any news from me for a = very long time, the news are good J

I’m still here and promoting = PostgreSQL.

 

I am involved in the developing of a big romanian = project for the vets that will put Linux & PostgreSQL on 3500 computers in = the whole country, linked together with dial-up connections that will keep = track of the animal movements.

 

The central database (also PostgreSLQ) will hold = billions of records with animal events (births, movements, slaughter and so on) and = my question is:

 

If I will choose to keep a mirror of every = workstation database in a separate schema in the central database that mean that I = will have 3500 different schemas.

Is there any limit or any barrier that could stop = this kind of approach or make things go slower?

 

Constantin Teodorescu

Ancient PgAccess = developer

 

P.S. Please Cc: me at teo@flex.ro

 

------=_NextPart_000_0000_01C4D077.CEAEE2F0-- --=-bd-boundary-WcPO17Pe3gfNcAL2 Content-Type: text/plain; name="BitDefender.txt" Content-Disposition: inline; filename="BitDefender.txt" -- This message was scanned for spam and viruses by BitDefender For more information please visit http://linux.bitdefender.com/ --=-bd-boundary-WcPO17Pe3gfNcAL2-- From pgsql-performance-owner@postgresql.org Mon Nov 22 08:01:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8F2103A5199 for ; Mon, 22 Nov 2004 08:00:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18511-02 for ; Mon, 22 Nov 2004 08:00:12 +0000 (GMT) Received: from mta2.wss.scd.yahoo.com (mta2.wss.scd.yahoo.com [66.218.85.33]) by svr1.postgresql.org (Postfix) with ESMTP id 28B4C3A5194 for ; Mon, 22 Nov 2004 08:00:10 +0000 (GMT) Received: from milter1.wss.scd.yahoo.com (66.218.85.48) by mta2.wss.scd.yahoo.com (7.0.016) id 4159445501C6DF73; Sun, 21 Nov 2004 23:59:59 -0800 Received: from [192.168.1.150] (pcp02661651pcs.malvrn01.pa.comcast.net [68.83.50.134]) (authenticated bits=0) by milter1.wss.scd.yahoo.com (8.13.1/8.13.1) with ESMTP id iAM7x2lW093828; Sun, 21 Nov 2004 23:59:03 -0800 (PST) In-Reply-To: References: <200411220415.iAM4Fh908507@candle.pha.pa.us> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <659B27BE-3C5C-11D9-8252-000A958A3956@patrickbkelly.org> Content-Transfer-Encoding: 7bit Cc: Michael Adler , Darcy Buskermolen , josh@agliodbs.com, pgsql-performance@postgresql.org, Bruce Momjian From: Patrick B Kelly Subject: Re: memcached and PostgreSQL Date: Mon, 22 Nov 2004 02:59:12 -0500 To: Sean Chittenden X-Mailer: Apple Mail (2.619) X-Originating-IP: [68.83.50.134] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/328 X-Sequence-Number: 9282 On Nov 21, 2004, at 11:55 PM, Sean Chittenden wrote: > >> This is similar to sending email in a trigger or on commit where you >> can't be certain you send email always >> and only on a commit. > > While this is certainly a possibility, it's definitely closer to the > exception and not the normal instance. While an exception, this is a very real possibility in day to day operations. The absence of any feedback or balancing mechanism between the database and cache makes it impossible to know that they are in sync and even a small error percentage multiplied over time will lead to an ever increasing likelihood of error. More dangerous is that this discrepancy will NOT always be apparent because without active verification of the correctness of the cache, we will not know about any errors unless the error grows to an obvious point. The errors may cause material damage long before they become obvious. This is a common failure pattern with caches. Patrick B. Kelly ------------------------------------------------------ http://patrickbkelly.org From pgsql-performance-owner@postgresql.org Mon Nov 22 12:28:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 05DEF3A5241 for ; Mon, 22 Nov 2004 12:28:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98826-09 for ; Mon, 22 Nov 2004 12:28:13 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 563DA3A522F for ; Mon, 22 Nov 2004 12:28:14 +0000 (GMT) Received: (qmail 22714 invoked from network); 22 Nov 2004 13:28:39 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 22 Nov 2004 13:28:39 +0100 To: pgsql-performance@postgresql.org Subject: Re: memcached and PostgreSQL References: <200411220415.iAM4Fh908507@candle.pha.pa.us> <659B27BE-3C5C-11D9-8252-000A958A3956@patrickbkelly.org> Message-ID: Date: Mon, 22 Nov 2004 13:30:04 +0100 From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <659B27BE-3C5C-11D9-8252-000A958A3956@patrickbkelly.org> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/329 X-Sequence-Number: 9283 > While an exception, this is a very real possibility in day to day > operations. The absence of any feedback or balancing mechanism between > the database and cache makes it impossible to know that they are in sync > and even a small error percentage multiplied over time will lead to an > ever increasing likelihood of error. Sure, but there are applications where it does not matter, and these applications are othen loading the database... think about displaying forum posts, products list in a web store, and especially category trees, top N queries... for all these, it does not matter if the data is a bit stale. For instance, a very popular forum will be cached, which is very important. In this case I think it is acceptable if a new post does not appear instantly. Of course, when inserting or updating data in the database, the primary keys and other important data should be fetched from the database and not the cache, which supposes a bit of application logic (for instance, in a forum, the display page should query the cache, but the "post message" page should query the database directly). Memcache can also save the database from update-heavy tasks like user session management. In that case sessions can be stored entirely in memory. ON COMMIT triggers would be very useful. > More dangerous is that this discrepancy will NOT always be apparent > because without active verification of the correctness of the cache, we > will not know about any errors unless the error grows to an obvious > point. > The errors may cause material damage long before they become obvious. > This is a common failure pattern with caches. This is why it would be dangerous to fetch referential integrity data from the cache... this fits your "banking" example for instance. From pgsql-performance-owner@postgresql.org Mon Nov 22 15:02:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C87093A5286 for ; Mon, 22 Nov 2004 15:02:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53159-03 for ; Mon, 22 Nov 2004 15:01:44 +0000 (GMT) Received: from mail.logi-track.com (www.logi-track.com [213.239.193.212]) by svr1.postgresql.org (Postfix) with ESMTP id 6D4493A5294 for ; Mon, 22 Nov 2004 15:01:47 +0000 (GMT) Received: from kingfisher.intern.logi-track.com (J2c74.j.pppool.de [85.74.44.116]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logi-track.com (Postfix) with ESMTP id 74C1D3053B; Mon, 22 Nov 2004 16:01:47 +0100 (CET) Received: from kingfisher.intern.logi-track.com (localhost [127.0.0.1]) by kingfisher.intern.logi-track.com (Postfix) with SMTP id A0A2916DDF6; Mon, 22 Nov 2004 16:01:16 +0100 (CET) Date: Mon, 22 Nov 2004 16:01:15 +0100 From: Markus Schaber To: =?ISO-8859-15?Q?Pierre-Fr=E9d=E9ric?= Caillaud Cc: "PostgreSQL Performance List" Subject: Re: Index usage for sorted query Message-ID: <20041122160115.30cced7b@kingfisher.intern.logi-track.com> In-Reply-To: References: <20041120151710.695f4de5@kingfisher.intern.logi-track.com> Organization: logi-track ag, =?ISO-8859-15?Q?z=FCrich?= X-Mailer: Sylpheed-Claws 0.9.12b (GTK+ 1.2.10; i386-pc-linux-gnu) X-Face: Nx5T&>Nj$VrVPv}sC3IL&)TqHHOKCz/|)R$i"*r@w0{*I6w; UNU_hdl1J4NI_m{IMztq=>cmM}1gCLbAF+9\#CGkG8}Y{x%SuQ>1#t:; Z(|\qdd[i]HStki~#w1$TPF}:0w-7"S\Ev|_a$K wrote: > > WHERE cd=3D'ca' ORDER BY l_postcode; >=20 > Write : >=20 > > WHERE cd=3D'ca' ORDER BY cd, l_postcode; >=20 > You have a multicolumn index, so you should specify a multicolumn sort =20 > exactly the same as your index, and the planner will get it. Thanks, that seems to help. Seems weird to order by a column that is all the same value, but well, why not :-) Thanks a lot, Markus --=20 markus schaber | dipl. informatiker logi-track ag | rennweg 14-16 | ch 8001 z=FCrich phone +41-43-888 62 52 | fax +41-43-888 62 53 mailto:schabios@logi-track.com | www.logi-track.com From pgsql-performance-owner@postgresql.org Mon Nov 22 15:21:00 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CE2F13A529D for ; Mon, 22 Nov 2004 15:20:56 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61132-02 for ; Mon, 22 Nov 2004 15:20:15 +0000 (GMT) Received: from vt-pe2550-001.VANTAGE.vantage.com (sol.vantage.com [64.80.203.242]) by svr1.postgresql.org (Postfix) with ESMTP id 220313A52B5 for ; Mon, 22 Nov 2004 15:20:15 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Query Performance and IOWait Date: Mon, 22 Nov 2004 10:20:14 -0500 Message-ID: <4BAFBB6B9CC46F41B2AD7D9F4BBAF78501D6D283@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Query Performance and IOWait Thread-Index: AcTNkgYlGqsLQ1eeTmuBb6y0NEWKgQA68S6gAIokShA= From: "Anjan Dave" To: "Andrew Janian" , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/331 X-Sequence-Number: 9285 Check the linux-dell list for more...The PERC3/Di cards are specifically Adaptec, not most. PERC4/DC is LSI Megaraid. Unless you buy the cheaper version, most will come with battery. -anjan=20 -----Original Message----- From: Andrew Janian [mailto:ajanian@scottrade.com]=20 Sent: Friday, November 19, 2004 4:22 PM To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Query Performance and IOWait The data that we are accessing is via QLogic cards connected to an EMC Clarion. We have tried it on local SCSI disks with the same (bad) results. When the machine gets stuck in a 100% IOWAIT state it often crashes soon after that. The disks are fine, have been replaced and checked. Here are my results from hdparm -Tt /dev/sda1 (which is the EMC disk array) /dev/sda1: Timing buffer-cache reads: 2976 MB in 2.00 seconds =3D 1488.00 = MB/sec Timing buffered disk reads: 44 MB in 3.13 seconds =3D 14.06 MB/sec -----Original Message----- From: Dave Cramer [mailto:pg@fastcrypt.com] Sent: Thursday, November 18, 2004 11:14 AM To: Andrew Janian Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Query Performance and IOWait Andrew, Dell's aren't well known for their disk performance, apparently most of=20 the perc controllers sold with dell's are actually adaptec controllers.=20 Also apparently they do not come with the battery required to use the=20 battery backed up write cache ( In fact according to some Dell won't=20 even sell the battery to you). Also Dell's monitoring software is quite=20 a memory hog. Have you looked at top ?, and also hdparm -Tt /dev/sd? Dave Andrew Janian wrote: >Hello All, > >I have a setup with a Dell Poweredge 2650 with Red Hat and Postgres 7.4.5 with a database with about 27GB of data. The table in question has about 35 million rows. > >I am running the following query: > >SELECT * >FROM mb_fix_message >WHERE msg_client_order_id IN ( > SELECT msg_client_order_id > FROM mb_fix_message > WHERE msg_log_time >=3D '2004-06-01' > AND msg_log_time < '2004-06-01 13:30:00.000' > AND msg_message_type IN ('D','G') > AND mb_ord_type =3D '1' > ) > AND msg_log_time > '2004-06-01' > AND msg_log_time < '2004-06-01 23:59:59.999' > AND msg_message_type =3D '8' > AND (mb_raw_text LIKE '%39=3D1%' OR mb_raw_text LIKE '%39=3D2%'); > >with the following plan: > > QUERY PLAN >Nested Loop IN Join (cost=3D0.00..34047.29 rows=3D1 width=3D526) > -> Index Scan using mfi_log_time on mb_fix_message (cost=3D0.00..22231.31 rows=3D2539 width=3D526) > Index Cond: ((msg_log_time > '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 23:59:59.999'::timestamp without time zone)) > Filter: (((msg_message_type)::text =3D '8'::text) AND (((mb_raw_text)::text ~~ '%39=3D1%'::text) OR ((mb_raw_text)::text ~~ '%39=3D2%'::text))) > -> Index Scan using mfi_client_ordid on mb_fix_message (cost=3D0.00..445.56 rows=3D1 width=3D18) > Index Cond: (("outer".msg_client_order_id)::text =3D (mb_fix_message.msg_client_order_id)::text) > Filter: ((msg_log_time >=3D '2004-06-01 00:00:00'::timestamp without time zone) AND (msg_log_time < '2004-06-01 13:30:00'::timestamp without time zone) AND ((msg_message_type)::text =3D 'D'::text) OR ((msg_message_type)::text =3D 'G'::text)) AND ((mb_ord_type)::text =3D '1'::text)) > >While running, this query produces 100% iowait usage on its processor and takes a ungodly amount of time (about an hour). > >The postgres settings are as follows: > >shared_buffers =3D 32768 # min 16, at least max_connections*2, 8KB each >sort_mem =3D 262144 # min 64, size in KB > >And the /etc/sysctl.conf has: >kernel.shmall =3D 274235392 >kernel.shmmax =3D 274235392 > >The system has 4GB of RAM. > >I am pretty sure of these settings, but only from my reading of the docs and others' recommendations online. > >Thanks, > >Andrew Janian >OMS Development >Scottrade Financial Services >(314) 965-1555 x 1513 >Cell: (314) 369-2083 > >---------------------------(end of broadcast)--------------------------- >TIP 7: don't forget to increase your free space map settings > =20 > --=20 Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561 ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings From pgsql-performance-owner@postgresql.org Mon Nov 22 19:41:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3EB253A5344 for ; Mon, 22 Nov 2004 19:41:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48997-03 for ; Mon, 22 Nov 2004 19:41:29 +0000 (GMT) Received: from web51302.mail.yahoo.com (web51302.mail.yahoo.com [206.190.38.168]) by svr1.postgresql.org (Postfix) with SMTP id AEE023A5345 for ; Mon, 22 Nov 2004 19:41:28 +0000 (GMT) Received: (qmail 8042 invoked by uid 60001); 22 Nov 2004 19:41:26 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=Tmg+w1RbeyklAUXGXbroh1T8Qmf646GlwkNI5fyG65Oq82O8amJG1EdSD+txv2vOAM7huJ8YGCp6AwanMF5ZoNxHX+mr1VE2JFS6PG+BxID73BH3QDk8mNa3BYmtyHzvDbwV8fdqxj3u6TVX3+ZE2izS+JWLIkw9pUPLM4uRvN8= ; Message-ID: <20041122194125.8040.qmail@web51302.mail.yahoo.com> Received: from [65.218.182.242] by web51302.mail.yahoo.com via HTTP; Mon, 22 Nov 2004 11:41:25 PST Date: Mon, 22 Nov 2004 11:41:25 -0800 (PST) From: sarlav kumar Subject: Re: help needed -- sequential scan problem To: pgsql-performance@postgresql.org In-Reply-To: <16679.1100927986@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1772108165-1101152485=:7758" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=HTML_FONTCOLOR_BLUE, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200411/332 X-Sequence-Number: 9286 --0-1772108165-1101152485=:7758 Content-Type: text/plain; charset=us-ascii Hi Tom, Thanks for the help, Tom. >The major issue seems to be in the sub-selects: > -> Seq Scan on merchant_purchase mp (cost=0.00..95.39 rows=44 width=4) (actual time=2.37..2.58 rows=6 loops=619) > Filter: (merchant_id = $0) >where the estimated row count is a factor of 7 too high. If the >estimated row count were even a little lower, it'd probably have gone >for an indexscan. I understand that the sub-selects are taking up most of the time as they do a sequential scan on the tables. >You might get some results from increasing the >statistics target for merchant_purchase.merchant_id. Do I have to use vacuum analyze to update the statistics? If so, I have already tried that and it doesn't seem to help. >If that doesn't help, I'd think about reducing random_page_cost a little bit. I am sorry, I am not aware of what random_page_cost is, as I am new to Postgres. What does it signify and how do I reduce random_page_cost? Thanks, Saranya __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --0-1772108165-1101152485=:7758 Content-Type: text/html; charset=us-ascii
Hi Tom,
 
Thanks for the help, Tom.
 
>The major issue seems to be in the sub-selects:

> -> Seq Scan on merchant_purchase mp (cost=0.00..95.39 rows=44 width=4) (actual time=2.37..2.58 rows=6 loops=619)
> Filter: (merchant_id = $0)
>where the estimated row count is a factor of 7 too high. If the
>estimated row count were even a little lower, it'd probably have gone
>for an indexscan.
 
I understand that the sub-selects are taking up most of the time as they do a sequential scan on the tables. 
 
 >You might get some results from increasing the
>statistics target for merchant_purchase.merchant_id.
 
Do I have to use vacuum analyze to update the statistics? If so, I have already tried that and it doesn't seem to help.
 
>If that doesn't help, I'd think about reducing random_page_cost a little bit.
 
I am sorry, I am not aware of what random_page_cost is, as I am new to Postgres. What does it signify and how do I reduce random_page_cost?

Thanks,
Saranya

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com --0-1772108165-1101152485=:7758-- From pgsql-performance-owner@postgresql.org Mon Nov 22 19:55:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 97FFF3A5335 for ; Mon, 22 Nov 2004 19:55:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52034-08 for ; Mon, 22 Nov 2004 19:54:55 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 620273A4032 for ; Mon, 22 Nov 2004 19:54:55 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6697277; Mon, 22 Nov 2004 11:56:26 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: help needed -- sequential scan problem Date: Mon, 22 Nov 2004 11:57:38 -0800 User-Agent: KMail/1.6.2 Cc: sarlav kumar References: <20041122194125.8040.qmail@web51302.mail.yahoo.com> In-Reply-To: <20041122194125.8040.qmail@web51302.mail.yahoo.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <200411221157.38900.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/333 X-Sequence-Number: 9287 Sarlav, > I am sorry, I am not aware of what random_page_cost is, as I am new to > Postgres. What does it signify and how do I reduce random_page_cost? It's a parameter in your postgresql.conf file. After you test it, you will want to change it there and reload the server (pg_ctl reload). However, you can test it on an individual connection: SET random_page_cost=2.5 (the default is 4.0) -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Nov 22 19:58:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B5B783A5353 for ; Mon, 22 Nov 2004 19:58:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53384-08 for ; Mon, 22 Nov 2004 19:58:23 +0000 (GMT) Received: from web51302.mail.yahoo.com (web51302.mail.yahoo.com [206.190.38.168]) by svr1.postgresql.org (Postfix) with SMTP id 403BF3A534B for ; Mon, 22 Nov 2004 19:58:10 +0000 (GMT) Received: (qmail 14072 invoked by uid 60001); 22 Nov 2004 19:58:01 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=LXEmHC9gRDQ2aoGxcNuUBPJnbSfVALFZD0ZE/7Cr+b1VkntPF0MZj3SmSZwcFIdxgrvB4pxjg3Scp1ZYhNdFXUZsj8A6sLuMwSe5fsgb2c/+N9UexDdLiIHc8X4Cph/YxfV9qTGWDdsodG86RQtyjVZO/qhvqRrwI8dmHmYLrQc= ; Message-ID: <20041122195801.14066.qmail@web51302.mail.yahoo.com> Received: from [65.218.182.242] by web51302.mail.yahoo.com via HTTP; Mon, 22 Nov 2004 11:58:01 PST Date: Mon, 22 Nov 2004 11:58:01 -0800 (PST) From: sarlav kumar Subject: Re: help needed -- sequential scan problem To: pgsql-performance@postgresql.org Cc: sarlav kumar In-Reply-To: <200411221157.38900.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-366798334-1101153481=:13699" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200411/334 X-Sequence-Number: 9288 --0-366798334-1101153481=:13699 Content-Type: text/plain; charset=us-ascii Hi Josh, Can you tell me in what way it affects performance? And How do I decide what value to set for the random_page_cost? Does it depend on any other factors? Thanks, Saranya Josh Berkus wrote: Sarlav, > I am sorry, I am not aware of what random_page_cost is, as I am new to > Postgres. What does it signify and how do I reduce random_page_cost? It's a parameter in your postgresql.conf file. After you test it, you will want to change it there and reload the server (pg_ctl reload). However, you can test it on an individual connection: SET random_page_cost=2.5 (the default is 4.0) -- --Josh Josh Berkus Aglio Database Solutions San Francisco __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --0-366798334-1101153481=:13699 Content-Type: text/html; charset=us-ascii

Hi Josh,
 
Can you tell me in what way it affects performance? And How do I decide what value to set for the random_page_cost? Does it depend on any  other factors?
 
Thanks,
Saranya

Josh Berkus <josh@agliodbs.com> wrote:
Sarlav,

> I am sorry, I am not aware of what random_page_cost is, as I am new to
> Postgres. What does it signify and how do I reduce random_page_cost?

It's a parameter in your postgresql.conf file. After you test it, you will
want to change it there and reload the server (pg_ctl reload).

However, you can test it on an individual connection:
SET random_page_cost=2.5
(the default is 4.0)

--
--Josh

Josh Berkus
Aglio Database Solutions
San Francisco

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com --0-366798334-1101153481=:13699-- From pgsql-performance-owner@postgresql.org Mon Nov 22 19:59:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 79D103A535B for ; Mon, 22 Nov 2004 19:59:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55160-04 for ; Mon, 22 Nov 2004 19:59:11 +0000 (GMT) Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) by svr1.postgresql.org (Postfix) with ESMTP id 3461D3A5366 for ; Mon, 22 Nov 2004 19:59:10 +0000 (GMT) Received: from wp2000 ([157.157.160.117] [157.157.160.117]) by quasar.skima.is; Mon, 22 Nov 2004 19:59:04 Z Message-Id: <013401c4d0ce$15e276e0$0100000a@wp2000> From: "gnari" To: "sarlav kumar" , References: <20041122194125.8040.qmail@web51302.mail.yahoo.com> Subject: Re: help needed -- sequential scan problem Date: Mon, 22 Nov 2004 20:01:42 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/335 X-Sequence-Number: 9289 From: "sarlav kumar" > [Tom:] > >You might get some results from increasing the > >statistics target for merchant_purchase.merchant_id. > > Do I have to use vacuum analyze to update the statistics? If so, I have already tried that and it doesn't seem to help. alter table merchant_purchase alter column merchant_id set statistics 500; analyze merchant_purchase; > > >If that doesn't help, I'd think about reducing random_page_cost a little bit. > > I am sorry, I am not aware of what random_page_cost is, as I am new to Postgres. What does it signify and how do I reduce random_page_cost? set random_page_cost = 3; explain analyse if it is an improvement, consider setting the value in your postgresql.conf, but remember that this may affect other queries too. gnari From pgsql-performance-owner@postgresql.org Mon Nov 22 20:32:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 354B93A5289 for ; Mon, 22 Nov 2004 20:32:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66196-07 for ; Mon, 22 Nov 2004 20:32:40 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.196]) by svr1.postgresql.org (Postfix) with ESMTP id A87873A535E for ; Mon, 22 Nov 2004 20:32:40 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 40so171056wri for ; Mon, 22 Nov 2004 12:32:41 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=ahbHVd9I8ax0ecezZxR6MXSwJI+7YorvDNSmjBkMfgsCfqtWo4R72Skuy0nlJK3M6x1/V7+tv0cGeQJe4sWERRyoh98Y53YL3dqQyeP5hBiE/Wz3yyhWs94E4XUPyVYNHen1lmbmIpTohkUYkp0D2rP9Eb3bTwDmt/6CQcu5B1U= Received: by 10.54.17.5 with SMTP id 5mr869794wrq; Mon, 22 Nov 2004 12:32:40 -0800 (PST) Received: by 10.54.20.23 with HTTP; Mon, 22 Nov 2004 12:32:40 -0800 (PST) Message-ID: <1dc7f0e30411221232603c4617@mail.gmail.com> Date: Mon, 22 Nov 2004 15:32:40 -0500 From: Alexandre Leclerc Reply-To: Alexandre Leclerc To: PERFORM Subject: Data type to use for primary key Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/336 X-Sequence-Number: 9290 Good day, I'm asking myself if there is a performance issue in using an integer of varchar(24) PRIMARY KEY in a product table. I've read that there is no speed issue in the query, but that the only performance issue is the database size of copying the key in other tables that require it. My product_id is copied in orders, jobs, and other specific tables. What is the common approach? Should I use directly the product_code as my ID, or use a sequantial number for speed? (I did the same for the company_id, this is a 'serial' and not the shor name of the customer. I just don't know what is usually done. Right now I did the following: CREATE TABLE design.products ( product_id serial PRIMARY KEY, company_id integer NOT NULL REFERENCES sales.companies ON UPDATE CASCADE, product_code varchar(24) NOT NULL, ... CONSTRAINT product_code_already_used_for_this_company UNIQUE (company_id, product_code) ); CREATE TABLE sales.companies ( company_id integer PRIMARY KEY, company_name varchar(48) NOT NULL UNIQUE, ... ); The company_id is also copied in many tables like product, contacts, etc. Thank you very much for any good pointers on this 'already seen' issue. -- Alexandre Leclerc From pgsql-performance-owner@postgresql.org Mon Nov 22 21:38:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3093F3A5335 for ; Mon, 22 Nov 2004 21:38:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87530-09 for ; Mon, 22 Nov 2004 21:38:13 +0000 (GMT) Received: from ms-smtp-03-eri0.ohiordc.rr.com (ms-smtp-03-smtplb.ohiordc.rr.com [65.24.5.137]) by svr1.postgresql.org (Postfix) with ESMTP id 98E903A4406 for ; Mon, 22 Nov 2004 21:38:13 +0000 (GMT) Received: from enzo.mascari.com (dhcp065-024-156-214.columbus.rr.com [65.24.156.214]) by ms-smtp-03-eri0.ohiordc.rr.com (8.12.10/8.12.7) with ESMTP id iAMLc7wZ021576 for ; Mon, 22 Nov 2004 16:38:10 -0500 (EST) Received: from [192.168.2.1] (ferrari.mascari.com [192.168.2.1]) by enzo.mascari.com (8.12.8/8.12.8) with ESMTP id iAMLc597025394 for ; Mon, 22 Nov 2004 16:38:05 -0500 Message-ID: <41A25C3B.3040608@mascari.com> Date: Mon, 22 Nov 2004 16:38:03 -0500 From: Mike Mascari User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Slow execution time when querying view with WHERE clause Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mascari-MailScanner-Information: Please contact the ISP for more information X-Mascari-MailScanner: Found to be clean X-Mascari-MailScanner-SpamCheck: not spam, SpamAssassin (score=0, required 6, autolearn=not spam) X-MailScanner-From: mascarm@mascari.com X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/337 X-Sequence-Number: 9291 I have the following view: create or replace view market.p_areas as select a.* from _areas a where a.area in ( select b.area from _bins b, _inventories i, _offers o, _pricemembers p where b.bin = i.bin and i.inventory = o.inventory and o.pricegroup = p.pricegroup and p.buyer in ( select s.store from _stores s, _webusers w where w.webuser = getWebuser() and w.company = s.company union select s.store from _stores s, _companies c where s.company = c.company and c.companyid = 'DEFAULT' ) ); When I query the view without a where clause I get: explain analyze select * from p_areas; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Hash Join (cost=1273.12..1276.31 rows=47 width=163) (actual time=438.739..439.574 rows=34 loops=1) Hash Cond: ("outer".area = "inner".area) -> Seq Scan on _areas a (cost=0.00..2.48 rows=48 width=163) (actual time=0.015..0.169 rows=48 loops=1) -> Hash (cost=1273.01..1273.01 rows=47 width=8) (actual time=438.532..438.532 rows=0 loops=1) -> HashAggregate (cost=1273.01..1273.01 rows=47 width=8) (actual time=438.286..438.395 rows=34 loops=1) -> Hash Join (cost=558.53..1266.68 rows=2532 width=8) (actual time=160.923..416.968 rows=5264 loops=1) Hash Cond: ("outer".bin = "inner".bin) -> Hash Join (cost=544.02..1207.86 rows=2531 width=8) (actual time=156.097..356.560 rows=5264 loops=1) Hash Cond: ("outer".inventory = "inner".inventory) -> Seq Scan on _inventories i (cost=0.00..265.96 rows=11396 width=16) (actual time=0.010..44.047 rows=11433 loops=1) -> Hash (cost=537.14..537.14 rows=2751 width=8) (actual time=155.891..155.891 rows=0 loops=1) -> Hash Join (cost=13.96..537.14 rows=2751 width=8) (actual time=11.967..136.598 rows=5264 loops=1) Hash Cond: ("outer".pricegroup = "inner".pricegroup) -> Seq Scan on _offers o (cost=0.00..379.24 rows=15524 width=16) (actual time=0.008..50.335 rows=15599 loops=1) -> Hash (cost=13.94..13.94 rows=9 width=8) (actual time=11.861..11.861 rows=0 loops=1) -> Hash IN Join (cost=8.74..13.94 rows=9 width=8) (actual time=10.801..11.801 rows=12 loops=1) Hash Cond: ("outer".buyer = "inner".store) -> Seq Scan on _pricemembers p (cost=0.00..4.07 rows=207 width=16) (actual time=0.011..0.548 rows=207 loops=1) -> Hash (cost=8.72..8.72 rows=8 width=8) (actual time=10.687..10.687 rows=0 loops=1) -> Subquery Scan "IN_subquery" (cost=8.60..8.72 rows=8 width=8) (actual time=10.645..10.654 rows=1 loops=1) -> Unique (cost=8.60..8.64 rows=8 width=8) (actual time=10.631..10.636 rows=1 loops=1) -> Sort (cost=8.60..8.62 rows=8 width=8) (actual time=10.625..10.627 rows=1 loops=1) Sort Key: store -> Append (cost=2.86..8.48 rows=8 width=8) (actual time=10.529..10.583 rows=1 loops=1) -> Subquery Scan "*SELECT* 1" (cost=2.86..5.15 rows=5 width=8) (actual time=10.222..10.222 rows=0 loops=1) -> Hash Join (cost=2.86..5.10 rows=5 width=8) (actual time=10.214..10.214 rows=0 loops=1) Hash Cond: ("outer".company = "inner".company) -> Seq Scan on _stores s (cost=0.00..2.13 rows=13 width=16) (actual time=0.019..0.059 rows=13 loops=1) -> Hash (cost=2.85..2.85 rows=1 width=8) (actual time=10.031..10.031 rows=0 loops=1) -> Seq Scan on _webusers w (cost=0.00..2.85 rows=1 width=8) (actual time=10.023..10.023 rows=0 loops=1) Filter: (webuser = getwebuser()) -> Subquery Scan "*SELECT* 2" (cost=1.08..3.33 rows=3 width=8) (actual time=0.298..0.349 rows=1 loops=1) -> Hash Join (cost=1.08..3.30 rows=3 width=8) (actual time=0.287..0.335 rows=1 loops=1) Hash Cond: ("outer".company = "inner".company) -> Seq Scan on _stores s (cost=0.00..2.13 rows=13 width=16) (actual time=0.008..0.048 rows=13 loops=1) -> Hash (cost=1.07..1.07 rows=1 width=8) (actual time=0.111..0.111 rows=0 loops=1) -> Seq Scan on _companies c (cost=0.00..1.07 rows=1 width=8) (actual time=0.059..0.080 rows=1 loops=1) Filter: ((companyid)::text = 'DEFAULT'::text) -> Hash (cost=13.01..13.01 rows=601 width=16) (actual time=4.735..4.735 rows=0 loops=1) -> Seq Scan on _bins b (cost=0.00..13.01 rows=601 width=16) (actual time=0.054..2.846 rows=601 loops=1) Total runtime: 441.685 ms (41 rows) --- When I query the view with a simple filter, I get: explain analyze select * from p_areas where deactive is null; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Nested Loop IN Join (cost=8.60..524.28 rows=1 width=163) (actual time=1023.291..20025.620 rows=34 loops=1) Join Filter: ("outer".area = "inner".area) -> Seq Scan on _areas a (cost=0.00..2.48 rows=1 width=163) (actual time=0.037..0.804 rows=48 loops=1) Filter: (deactive IS NULL) -> Nested Loop (cost=8.60..25530.60 rows=2532 width=8) (actual time=0.345..402.775 rows=3408 loops=48) -> Nested Loop (cost=8.60..16893.61 rows=2531 width=8) (actual time=0.304..264.929 rows=3408 loops=48) -> Merge Join (cost=8.60..2912.00 rows=2751 width=8) (actual time=0.258..120.841 rows=3408 loops=48) Merge Cond: ("outer".pricegroup = "inner".pricegroup) -> Nested Loop IN Join (cost=8.60..1837.73 rows=9 width=8) (actual time=0.216..4.612 rows=8 loops=48) Join Filter: ("outer".buyer = "inner".store) -> Index Scan using i_pricemembers3 on _pricemembers p (cost=0.00..10.96 rows=207 width=16) (actual time=0.022..1.045 rows=138 loops=48) -> Subquery Scan "IN_subquery" (cost=8.60..8.72 rows=8 width=8) (actual time=0.011..0.017 rows=1 loops=6606) -> Unique (cost=8.60..8.64 rows=8 width=8) (actual time=0.006..0.010 rows=1 loops=6606) -> Sort (cost=8.60..8.62 rows=8 width=8) (actual time=0.003..0.004 rows=1 loops=6606) Sort Key: store -> Append (cost=2.86..8.48 rows=8 width=8) (actual time=7.667..7.757 rows=1 loops=1) -> Subquery Scan "*SELECT* 1" (cost=2.86..5.15 rows=5 width=8) (actual time=7.362..7.362 rows=0 loops=1) -> Hash Join (cost=2.86..5.10 rows=5 width=8) (actual time=7.355..7.355 rows=0 loops=1) Hash Cond: ("outer".company = "inner".company) -> Seq Scan on _stores s (cost=0.00..2.13 rows=13 width=16) (actual time=0.013..0.054 rows=13 loops=1) -> Hash (cost=2.85..2.85 rows=1 width=8) (actual time=7.163..7.163 rows=0 loops=1) -> Seq Scan on _webusers w (cost=0.00..2.85 rows=1 width=8) (actual time=7.154..7.154 rows=0 loops=1) Filter: (webuser = getwebuser()) -> Subquery Scan "*SELECT* 2" (cost=1.08..3.33 rows=3 width=8) (actual time=0.295..0.381 rows=1 loops=1) -> Hash Join (cost=1.08..3.30 rows=3 width=8) (actual time=0.286..0.368 rows=1 loops=1) Hash Cond: ("outer".company = "inner".company) -> Seq Scan on _stores s (cost=0.00..2.13 rows=13 width=16) (actual time=0.008..0.080 rows=13 loops=1) -> Hash (cost=1.07..1.07 rows=1 width=8) (actual time=0.116..0.116 rows=0 loops=1) -> Seq Scan on _companies c (cost=0.00..1.07 rows=1 width=8) (actual time=0.062..0.083 rows=1 loops=1) Filter: ((companyid)::text = 'DEFAULT'::text) -> Index Scan using i_offers4 on _offers o (cost=0.00..1007.93 rows=15524 width=16) (actual time=0.023..67.183 rows=10049 loops=48) -> Index Scan using i_inventories1 on _inventories i (cost=0.00..5.07 rows=1 width=16) (actual time=0.025..0.029 rows=1 loops=163561) Index Cond: (i.inventory = "outer".inventory) -> Index Scan using i_bins1 on _bins b (cost=0.00..3.40 rows=1 width=16) (actual time=0.021..0.026 rows=1 loops=163561) Index Cond: (b.bin = "outer".bin) Total runtime: 20027.414 ms (36 rows) --- That's a slow-down on execution time by a factor of 50, even though the row count was the same: 34. In fact, it's MUCH faster to do: create temporary table foo as select * from p_areas; select * from foo where deactive is null; The database has been analyzed. Any tips would be greatly appreciated. Mike Mascari P.S.: I turned off word-wrap in my mail client for this post. Is that the right thing to do for analyze output? From pgsql-performance-owner@postgresql.org Mon Nov 22 21:46:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 079C73A5335 for ; Mon, 22 Nov 2004 21:46:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92435-01 for ; Mon, 22 Nov 2004 21:46:19 +0000 (GMT) Received: from ms-smtp-02-eri0.ohiordc.rr.com (ms-smtp-02-smtplb.ohiordc.rr.com [65.24.5.136]) by svr1.postgresql.org (Postfix) with ESMTP id A853D3A4407 for ; Mon, 22 Nov 2004 21:46:17 +0000 (GMT) Received: from enzo.mascari.com (dhcp065-024-156-214.columbus.rr.com [65.24.156.214]) by ms-smtp-02-eri0.ohiordc.rr.com (8.12.10/8.12.7) with ESMTP id iAMLkEJl004111 for ; Mon, 22 Nov 2004 16:46:14 -0500 (EST) Received: from [192.168.2.1] (ferrari.mascari.com [192.168.2.1]) by enzo.mascari.com (8.12.8/8.12.8) with ESMTP id iAMLkB97025595; Mon, 22 Nov 2004 16:46:11 -0500 Message-ID: <41A25E20.2050503@mascari.com> Date: Mon, 22 Nov 2004 16:46:08 -0500 From: Mike Mascari User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mike Mascari Cc: pgsql-performance@postgresql.org Subject: Re: Slow execution time when querying view with WHERE clause References: <41A25C3B.3040608@mascari.com> In-Reply-To: <41A25C3B.3040608@mascari.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mascari-MailScanner-Information: Please contact the ISP for more information X-Mascari-MailScanner: Found to be clean X-Mascari-MailScanner-SpamCheck: not spam, SpamAssassin (score=0, required 6, autolearn=not spam) X-MailScanner-From: mascarm@mascari.com X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/338 X-Sequence-Number: 9292 Mike Mascari wrote: > I have the following view: > > create or replace view market.p_areas as > select a.* > from _areas a > where a.area in ( > select b.area > from _bins b, _inventories i, _offers o, _pricemembers p > where b.bin = i.bin and > i.inventory = o.inventory and > o.pricegroup = p.pricegroup and > p.buyer in ( > select s.store > from _stores s, _webusers w > where w.webuser = getWebuser() and > w.company = s.company > union > select s.store > from _stores s, _companies c > where s.company = c.company and > c.companyid = 'DEFAULT' > ) > ); ... I failed to report the version: select version(); PostgreSQL 7.4.5 on i686-pc-linux-gnu, compiled by GCC i686-pc-linux-gnu-gcc (GCC) 3.4.0 20040204 (prerelease) Sorry. Mike Mascari From pgsql-hackers-win32-owner@postgresql.org Mon Nov 22 22:07:31 2004 X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9E2833A43BA; Mon, 22 Nov 2004 22:07:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99868-03; Mon, 22 Nov 2004 22:07:15 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 7AA183A5391; Mon, 22 Nov 2004 22:07:07 +0000 (GMT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: scalability issues on win32 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Mon, 22 Nov 2004 17:07:05 -0500 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7532@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: scalability issues on win32 Thread-Index: AcTQ35kgtmXZkwayTlSWXbp+xqPyjQ== From: "Merlin Moncure" To: Cc: "PostgreSQL Win32 port list" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/85 X-Sequence-Number: 2484 Following is the promised writeup in performance related issues comparing win32 with linux x86 and linux x86-64. Unfortunately, the 64 bit portion of the test is not yet completed and won't be for a bit. However there are some telling things about the win32/linux comparison. If you are considering deploying postgres in a win32 environment read on... =20 First a description of the client app: Our company develops an ERP/CRM written in cobol which we are porting to run on PostgreSQL. Part of this porting effort was development of an ISAM 'driver' for our app to allow it to store/fetch data from the database in place of a traditional file system, which is complete. For those of you unfamiliar with COBOL/ISAM, applications written with it have a 'one record at a time' mentality, such the application tends to spam the server with queries of the select * from t where k =3D k1 variety. Our driver creates stored procedures as necessary and uses ExecParams wherever possible to cut down on server CPU time, which is a precious resource in our case. Over time we plan to gradually redeploy our application logic to make better use of the sql server's server side power. Our application is very rarely i/o bound because we will make sure our server has enough memory so that the data will be rarely, if ever, *not* run from the cache. A good benchmark of our application performance is the time it takes to read the entire bill of materials for a product. This is a recursive read of about 2500 records in the typical case (2408 in the test case). Test platform: Pentium 4 3.06 GHz/HT 10k SATA Raptor 1Gb memory Windows XP Pro SP2/Redhat Fedora 3 (64 bit results coming soon) BOM traversal for product ***** (1 user):=20 win32: runtime: 3.34 sec avg cpu load: 60% redhat: runtime: 3.46 sec avg cpu load: 20% Well, win32 wins this test. There is some variability in the results meaning for a single user scenario there is basically no difference between win32 and linux in execution time. However the cpu load is much lower for linux which spells problems for win32 with multiple users: BOM traversal for product ***** (6 users): win32: runtime (each): 7.29 sec avg cpu load: 100% redhat: runtime (each): 4.56 sec avg cpu load: 90% Here, the win32 problems with cpu load start to manifest. The cpu meter stays pegged at 100% while the redhat hand around 90%. The difference in times is telling. The third and final test is what I call the query 'surprise' factor, IOW surprise! your query takes forever! The test involves a combination of the previous test with a query with a couple of joins that returns about 15k records. On both redhat/win32, the query takes about .35 seconds to execute on a unloaded server...remember that figure. Item List generation while 6 clients generating BOM for multiple products: Redhat: 2.5 seconds Win32: 155 seconds (!) Here the win32 server is showing real problems. Also, the query execution time is really variable, in some cases not returning until the 6 workhorse processes completed their tasks. The linux server by contrast ran slower but never ran over 4 seconds after multiple runs. Also, on the purely subjective side, the linux server 'feels' faster and considerably more responsive under load, even under much higher load. Comments/Suggestions? Merlin From pgsql-performance-owner@postgresql.org Mon Nov 22 23:04:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 215843A1EC4 for ; Mon, 22 Nov 2004 23:04:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12667-10 for ; Mon, 22 Nov 2004 23:04:20 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 2A3DB3A1D98 for ; Mon, 22 Nov 2004 23:04:20 +0000 (GMT) Received: (qmail 18500 invoked from network); 23 Nov 2004 00:04:46 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 23 Nov 2004 00:04:46 +0100 To: pgsql-performance@postgresql.org Subject: Re: Data type to use for primary key References: <1dc7f0e30411221232603c4617@mail.gmail.com> Message-ID: Date: Tue, 23 Nov 2004 00:06:13 +0100 From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <1dc7f0e30411221232603c4617@mail.gmail.com> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/340 X-Sequence-Number: 9294 > What is the common approach? Should I use directly the product_code as > my ID, or use a sequantial number for speed? (I did the same for the > company_id, this is a 'serial' and not the shor name of the customer. > I just don't know what is usually done. Use a serial : - you can change product_code for a product easily - you can pass around integers easier around, in web forms for instance, you don't have to ask 'should I escape this string ?' - it's faster - it uses less space - if one day you must manage products from another source whose product_code overlap yours, you won't have problems - you can generate them with a serial uniquely and easily From pgsql-performance-owner@postgresql.org Mon Nov 22 23:13:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 42DB43A1D95 for ; Mon, 22 Nov 2004 23:13:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18620-06 for ; Mon, 22 Nov 2004 23:13:31 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id AFD373A1D8E for ; Mon, 22 Nov 2004 23:13:32 +0000 (GMT) Received: (qmail 18860 invoked from network); 23 Nov 2004 00:13:59 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 23 Nov 2004 00:13:59 +0100 Date: Tue, 23 Nov 2004 00:15:26 +0100 To: pgsql-performance@postgresql.org Subject: Re: scalability issues on win32 References: <6EE64EF3AB31D5448D0007DD34EEB3412A7532@Herge.rcsinc.local> From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A7532@Herge.rcsinc.local> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/341 X-Sequence-Number: 9295 > Test platform: > Pentium 4 3.06 GHz/HT > 10k SATA Raptor > 1Gb memory > Windows XP Pro SP2/Redhat Fedora 3 (64 bit results coming soon) Could you please add information about... - filesystems ? - windows configured as "network server" or as "desktop box" ? - virtual memory In my experience you MUST deactivate virtual memory on a Windows box to avoid catastrophic competition between virtual memory and disk cache - respective pgsql configurations (buffers...) identical ? - explain analyze for the two, identical ? - client on same machine or via network (100Mb ? 1G ?) - size of the data set involved in query - first query time after boot (with nothing in the cache), and times for the next disk-cached runs ? - are the N users doing the same query or exercising different parts of the dataset ? You don't do any writes in your test do you ? Just big SELECTs ? From pgsql-performance-owner@postgresql.org Mon Nov 22 23:26:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C29DE3A22F7 for ; Mon, 22 Nov 2004 23:26:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24796-02 for ; Mon, 22 Nov 2004 23:26:09 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.200]) by svr1.postgresql.org (Postfix) with ESMTP id AF5D23A1D98 for ; Mon, 22 Nov 2004 23:26:08 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 36so228772wri for ; Mon, 22 Nov 2004 15:26:05 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=s7ZgKawebFhryuQESoRLwevFH39LwEEEgpzA91HSBLKmRWap1YBXMBXrLDdXqLAKh8VCbsgpi1vp9Tabxi61qMdUS0KUP8LZBYFD82F/6hmtvnZ4FlUXj0UQY/yfsGQHsBojnt8jGGmBdzhyrCCVLvyWTcqKQK30HERqRuqkMS4= Received: by 10.54.20.74 with SMTP id 74mr920274wrt; Mon, 22 Nov 2004 15:26:01 -0800 (PST) Received: by 10.54.20.23 with HTTP; Mon, 22 Nov 2004 15:26:00 -0800 (PST) Message-ID: <1dc7f0e304112215265f6ba487@mail.gmail.com> Date: Mon, 22 Nov 2004 18:26:00 -0500 From: Alexandre Leclerc Reply-To: Alexandre Leclerc To: pgsql-performance@postgresql.org Subject: Re: Data type to use for primary key In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable References: <1dc7f0e30411221232603c4617@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/342 X-Sequence-Number: 9296 Mr Caillaud, Merci! Many points you bring were also my toughts. I was asking myself really this was the way to go. I'm happy to see that my view of the problem was good. Encore merci! (Thanks again!) On Tue, 23 Nov 2004 00:06:13 +0100, Pierre-Fr=E9d=E9ric Caillaud wrote: >=20 > > What is the common approach? Should I use directly the product_code as > > my ID, or use a sequantial number for speed? (I did the same for the > > company_id, this is a 'serial' and not the shor name of the customer. > > I just don't know what is usually done. >=20 > Use a serial : > - you can change product_code for a product easily > - you can pass around integers easier around, in web forms for in= stance, > you don't have to ask 'should I escape this string ?' > - it's faster > - it uses less space > - if one day you must manage products from another source whose > product_code overlap yours, you won't have problems > - you can generate them with a serial uniquely and easily >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if you= r > joining column's datatypes do not match >=20 --=20 Alexandre Leclerc From pgsql-performance-owner@postgresql.org Tue Nov 23 00:52:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D63B23A2B10 for ; Tue, 23 Nov 2004 00:52:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44210-09 for ; Tue, 23 Nov 2004 00:52:11 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 8D4C53A1D8C for ; Tue, 23 Nov 2004 00:52:13 +0000 (GMT) Received: from [64.81.245.111] (account josh@agliodbs.com HELO temoku.sf.agliodbs.com) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6698260; Mon, 22 Nov 2004 16:53:44 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org, Alexandre Leclerc Subject: Re: Data type to use for primary key Date: Mon, 22 Nov 2004 16:54:56 -0800 User-Agent: KMail/1.6.2 References: <1dc7f0e30411221232603c4617@mail.gmail.com> In-Reply-To: <1dc7f0e30411221232603c4617@mail.gmail.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200411221654.56673.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/343 X-Sequence-Number: 9297 Alexandre, > What is the common approach? Should I use directly the product_code as > my ID, or use a sequantial number for speed? (I did the same for the > company_id, this is a 'serial' and not the shor name of the customer. > I just don't know what is usually done. Don't use SERIAL just because it's there. Ideally, you *want* to use the product_code if you can. It's your natural key and a natural key is always superior to a surrogate key all other things being equal. Unfortunately, all other things are NOT equal. Here's the reasons why you'd use a surrogate key (i.e. SERIAL): 1) because the product code is a large text string (i.e. > 10bytes) and you will have many millions of records, so having it as an FK in other tables will add significantly to the footprint of the database; 2) because product codes get blanket changes frequently, where thousands of them pet re-mapped to new codes, and the ON CASCADE UPDATE slow performance will kill your database; 3) Because every other table in the database has a SERIAL key and consistency reduces errors; 4) or because your interface programmers get annoyed with using different types of keys for different tables and multicolumn keys. If none of the above is true (and I've had it not be, in some tables and some databases) then you want to stick with your "natural key", the product_code. -- --Josh Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Nov 23 01:05:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 191C73A3AEE for ; Tue, 23 Nov 2004 01:05:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49732-03 for ; Tue, 23 Nov 2004 01:05:29 +0000 (GMT) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5B4263A3B0E for ; Tue, 23 Nov 2004 01:05:31 +0000 (GMT) Received: from dyn-70-236.tor.dsl.tht.net (dyn-70-236.tor.dsl.tht.net [134.22.70.236]) by tht.net (Postfix) with ESMTP id DC6EE76AB7; Mon, 22 Nov 2004 20:05:35 -0500 (EST) Subject: Re: Data type to use for primary key From: Rod Taylor To: josh@agliodbs.com Cc: Postgresql Performance , Alexandre Leclerc In-Reply-To: <200411221654.56673.josh@agliodbs.com> References: <1dc7f0e30411221232603c4617@mail.gmail.com> <200411221654.56673.josh@agliodbs.com> Content-Type: text/plain Date: Mon, 22 Nov 2004 20:03:11 -0500 Message-Id: <1101171791.44437.7.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/344 X-Sequence-Number: 9298 On Mon, 2004-11-22 at 16:54 -0800, Josh Berkus wrote: > Alexandre, > > > What is the common approach? Should I use directly the product_code as > > my ID, or use a sequantial number for speed? (I did the same for the > > company_id, this is a 'serial' and not the shor name of the customer. > > I just don't know what is usually done. > > Don't use SERIAL just because it's there. Ideally, you *want* to use the > product_code if you can. It's your natural key and a natural key is always > superior to a surrogate key all other things being equal. It would be nice if PostgreSQL had some form of transparent surrogate keying in the background which would automatically run around and replace your real data with SERIAL integers. It could use a lookup table for conversions between the surrogate and real values so the user never knows that it's done, a bit like ENUM. Then we could all use the real values with no performance issues for 1) because it's an integer in the background, and 2) because a cascade only touches a single tuple in the lookup table. -- From pgsql-performance-owner@postgresql.org Tue Nov 23 02:18:25 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A3F753A3B4B for ; Tue, 23 Nov 2004 02:18:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64316-06 for ; Tue, 23 Nov 2004 02:18:04 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 0FB1D3A3B43 for ; Tue, 23 Nov 2004 02:18:06 +0000 (GMT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id iAN2I5o22567; Mon, 22 Nov 2004 21:18:05 -0500 (EST) From: Bruce Momjian Message-Id: <200411230218.iAN2I5o22567@candle.pha.pa.us> Subject: Re: memcached and PostgreSQL In-Reply-To: To: =?ISO-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Date: Mon, 22 Nov 2004 21:18:05 -0500 (EST) Cc: pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UNKNOWN-8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/345 X-Sequence-Number: 9299 Pierre-Fr�d�ric Caillaud wrote: > > > While an exception, this is a very real possibility in day to day > > operations. The absence of any feedback or balancing mechanism between > > the database and cache makes it impossible to know that they are in sync > > and even a small error percentage multiplied over time will lead to an > > ever increasing likelihood of error. > > Sure, but there are applications where it does not matter, and these > applications are othen loading the database... think about displaying > forum posts, products list in a web store, and especially category trees, > top N queries... for all these, it does not matter if the data is a bit > stale. For instance, a very popular forum will be cached, which is very > important. In this case I think it is acceptable if a new post does not > appear instantly. My point was that there are two failure cases --- one where the cache is slightly out of date compared to the db server --- these are cases where the cache update is slightly before/after the commit. The second is where the cache update happens and the commit later fails, or the commit happens and the cache update never happens. In these cases the cache is out of date for the amount of time you cache the data and not expire it. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-hackers-win32-owner@postgresql.org Tue Nov 23 02:26:28 2004 X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C58603A3B13; Tue, 23 Nov 2004 02:26:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66773-08; Tue, 23 Nov 2004 02:26:06 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 992373A3B03; Tue, 23 Nov 2004 02:26:08 +0000 (GMT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id iAN2Q6i25020; Mon, 22 Nov 2004 21:26:06 -0500 (EST) From: Bruce Momjian Message-Id: <200411230226.iAN2Q6i25020@candle.pha.pa.us> Subject: Re: scalability issues on win32 In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A7532@Herge.rcsinc.local> To: Merlin Moncure Date: Mon, 22 Nov 2004 21:26:05 -0500 (EST) Cc: pgsql-performance@postgresql.org, PostgreSQL Win32 port list X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/87 X-Sequence-Number: 2486 This was an intersting Win32/linux comparison. I expected Linux to scale better, but I was surprised how poorly XP scaled. It reinforces our perception that Win32 is for low traffic servers. --------------------------------------------------------------------------- Merlin Moncure wrote: > Following is the promised writeup in performance related issues > comparing win32 with linux x86 and linux x86-64. Unfortunately, the 64 > bit portion of the test is not yet completed and won't be for a bit. > However there are some telling things about the win32/linux comparison. > If you are considering deploying postgres in a win32 environment read > on... > > First a description of the client app: > Our company develops an ERP/CRM written in cobol which we are porting to > run on PostgreSQL. Part of this porting effort was development of an > ISAM 'driver' for our app to allow it to store/fetch data from the > database in place of a traditional file system, which is complete. > > For those of you unfamiliar with COBOL/ISAM, applications written with > it have a 'one record at a time' mentality, such the application tends > to spam the server with queries of the select * from t where k = k1 > variety. Our driver creates stored procedures as necessary and uses > ExecParams wherever possible to cut down on server CPU time, which is a > precious resource in our case. Over time we plan to gradually redeploy > our application logic to make better use of the sql server's server side > power. Our application is very rarely i/o bound because we will make > sure our server has enough memory so that the data will be rarely, if > ever, *not* run from the cache. > > A good benchmark of our application performance is the time it takes to > read the entire bill of materials for a product. This is a recursive > read of about 2500 records in the typical case (2408 in the test case). > > Test platform: > Pentium 4 3.06 GHz/HT > 10k SATA Raptor > 1Gb memory > Windows XP Pro SP2/Redhat Fedora 3 (64 bit results coming soon) > > BOM traversal for product ***** (1 user): > win32: runtime: 3.34 sec avg cpu load: 60% > redhat: runtime: 3.46 sec avg cpu load: 20% > > Well, win32 wins this test. There is some variability in the results > meaning for a single user scenario there is basically no difference > between win32 and linux in execution time. However the cpu load is much > lower for linux which spells problems for win32 with multiple users: > > BOM traversal for product ***** (6 users): > win32: runtime (each): 7.29 sec avg cpu load: 100% > redhat: runtime (each): 4.56 sec avg cpu load: 90% > > Here, the win32 problems with cpu load start to manifest. The cpu meter > stays pegged at 100% while the redhat hand around 90%. The difference > in times is telling. > > The third and final test is what I call the query 'surprise' factor, IOW > surprise! your query takes forever! The test involves a combination of > the previous test with a query with a couple of joins that returns about > 15k records. On both redhat/win32, the query takes about .35 seconds to > execute on a unloaded server...remember that figure. > > > > Item List generation while 6 clients generating BOM for multiple > products: > Redhat: 2.5 seconds > Win32: 155 seconds (!) > > Here the win32 server is showing real problems. Also, the query > execution time is really variable, in some cases not returning until the > 6 workhorse processes completed their tasks. The linux server by > contrast ran slower but never ran over 4 seconds after multiple runs. > > Also, on the purely subjective side, the linux server 'feels' faster and > considerably more responsive under load, even under much higher load. > > Comments/Suggestions? > > Merlin > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-performance-owner@postgresql.org Tue Nov 23 06:02:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 45A6D3A3C22 for ; Tue, 23 Nov 2004 06:02:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22944-06 for ; Tue, 23 Nov 2004 06:02:31 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 2EA883A3C74 for ; Tue, 23 Nov 2004 06:02:31 +0000 (GMT) Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6699151; Mon, 22 Nov 2004 22:04:01 -0800 From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: Data type to use for primary key Date: Mon, 22 Nov 2004 22:00:41 -0800 User-Agent: KMail/1.6.2 Cc: Rod Taylor , Alexandre Leclerc References: <1dc7f0e30411221232603c4617@mail.gmail.com> <200411221654.56673.josh@agliodbs.com> <1101171791.44437.7.camel@home> In-Reply-To: <1101171791.44437.7.camel@home> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <200411222200.41729.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/347 X-Sequence-Number: 9301 Rod, > It would be nice if PostgreSQL had some form of transparent surrogate > keying in the background which would automatically run around and > replace your real data with SERIAL integers. It could use a lookup table > for conversions between the surrogate and real values so the user never > knows that it's done, a bit like ENUM. Then we could all use the real > values with no performance issues for 1) because it's an integer in the > background, and 2) because a cascade only touches a single tuple in the > lookup table. Sybase does this, and it's a feature I would dearly love to emulate. You can just refer to another table, without specifying the column, as an FK and it will create an invisible hashed key. This is the type of functionality Codd was advocating -- invisible, implementation-automated surrogate keys -- in the mid 90's (don't have a paper citation at the moment). So you'd just do: create table client_contacts ( fname text not null, lname text not null, client foriegn key clients, position text, notes text ); and the "client" column would create an invisible hashed key that would drag in the relevant row from the clients table; thus a: select * from client_contacts would actually show the whole record from clients as well. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Nov 23 08:38:12 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3F3C53A3C7C for ; Tue, 23 Nov 2004 08:38:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58016-08 for ; Tue, 23 Nov 2004 08:37:57 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 513343A2BB0 for ; Tue, 23 Nov 2004 08:37:57 +0000 (GMT) Received: (qmail 19454 invoked from network); 23 Nov 2004 09:38:23 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 23 Nov 2004 09:38:23 +0100 To: pgsql-performance@postgresql.org Subject: Re: Data type to use for primary key References: <1dc7f0e30411221232603c4617@mail.gmail.com> <200411221654.56673.josh@agliodbs.com> <1101171791.44437.7.camel@home> <200411222200.41729.josh@agliodbs.com> Message-ID: From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Tue, 23 Nov 2004 09:39:52 +0100 In-Reply-To: <200411222200.41729.josh@agliodbs.com> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/348 X-Sequence-Number: 9302 >> It would be nice if PostgreSQL had some form of transparent surrogate >> keying in the background which would automatically run around and >> replace your real data with SERIAL integers. It could use a lookup table There is still table inheritance, but it's not really the same. From pgsql-hackers-win32-owner@postgresql.org Tue Nov 23 10:19:48 2004 X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 800B73A3D4A; Tue, 23 Nov 2004 10:19:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87121-07; Tue, 23 Nov 2004 10:19:34 +0000 (GMT) Received: from smartmx-07.inode.at (smartmx-07.inode.at [213.229.60.39]) by svr1.postgresql.org (Postfix) with ESMTP id A77CE3A3D3C; Tue, 23 Nov 2004 10:19:35 +0000 (GMT) Received: from [62.99.252.218] (port=61184 helo=[192.168.0.2]) by smartmx-07.inode.at with esmtp (Exim 4.34) id 1CWXlk-0001IJ-Th; Tue, 23 Nov 2004 11:19:33 +0100 Message-ID: <41A30EB4.50501@x-ray.at> Date: Tue, 23 Nov 2004 11:19:32 +0100 From: Reini Urban User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.8a4) Gecko/20040927 X-Accept-Language: de, en MIME-Version: 1.0 To: Merlin Moncure Cc: pgsql-performance@postgresql.org, PostgreSQL Win32 port list Subject: Re: scalability issues on win32 References: <6EE64EF3AB31D5448D0007DD34EEB3412A7532@Herge.rcsinc.local> In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A7532@Herge.rcsinc.local> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/89 X-Sequence-Number: 2488 Merlin Moncure schrieb: > Following is the promised writeup in performance related issues > comparing win32 with linux x86 and linux x86-64. Unfortunately, the 64 > bit portion of the test is not yet completed and won't be for a bit. > However there are some telling things about the win32/linux comparison. > If you are considering deploying postgres in a win32 environment read > on... > > First a description of the client app: > Our company develops an ERP/CRM written in cobol which we are porting to > run on PostgreSQL. Part of this porting effort was development of an > ISAM 'driver' for our app to allow it to store/fetch data from the > database in place of a traditional file system, which is complete. > > For those of you unfamiliar with COBOL/ISAM, applications written with > it have a 'one record at a time' mentality, such the application tends > to spam the server with queries of the select * from t where k = k1 > variety. Our driver creates stored procedures as necessary and uses > ExecParams wherever possible to cut down on server CPU time, which is a > precious resource in our case. Over time we plan to gradually redeploy > our application logic to make better use of the sql server's server side > power. Our application is very rarely i/o bound because we will make > sure our server has enough memory so that the data will be rarely, if > ever, *not* run from the cache. > > A good benchmark of our application performance is the time it takes to > read the entire bill of materials for a product. This is a recursive > read of about 2500 records in the typical case (2408 in the test case). I always knew that COBOL ultimativly looses, but it's always refreshing to get confirmation from time to time :) > Test platform: > Pentium 4 3.06 GHz/HT > 10k SATA Raptor > 1Gb memory > Windows XP Pro SP2/Redhat Fedora 3 (64 bit results coming soon) > > BOM traversal for product ***** (1 user): > win32: runtime: 3.34 sec avg cpu load: 60% > redhat: runtime: 3.46 sec avg cpu load: 20% Where did you get the win32 "avg cpu load" number from? AFAIK there's no getloadavg() for windows. At least I tried hard to find one, because I want to add a comparable figure to cygwin core. emacs, coreutils, make and others would need desperately need it, not to speak of servers and real-time apps. Did you read it from taskman, or did you come up with your self-written solution? In taskman there's afaik no comparable figure. But there should be some perfmon api, which would do the trick. Overview: http://www.wilsonmar.com/1perfmon.htm#TaskManager "The load average (LA) is the average number of processes (the sum of the run queue length and the number of jobs currently running) that are ready to run, but are waiting for access to a busy CPU." And thanks for the overview! -- Reini Urban http://xarch.tu-graz.ac.at/home/rurban/ From pgsql-hackers-win32-owner@postgresql.org Tue Nov 23 10:36:26 2004 X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3F4A03A3D2D; Tue, 23 Nov 2004 10:36:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92579-08; Tue, 23 Nov 2004 10:35:54 +0000 (GMT) Received: from anchor-post-36.mail.demon.net (anchor-post-36.mail.demon.net [194.217.242.86]) by svr1.postgresql.org (Postfix) with ESMTP id 44C553A3AF8; Tue, 23 Nov 2004 10:35:55 +0000 (GMT) Received: from mailgate.vale-housing.co.uk ([194.217.48.34] helo=ratbert.vale-housing.co.uk) by anchor-post-36.mail.demon.net with esmtp (Exim 4.42) id 1CWY1b-000MyU-K8; Tue, 23 Nov 2004 10:35:55 +0000 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: scalability issues on win32 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Date: Tue, 23 Nov 2004 10:35:54 -0000 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [pgsql-hackers-win32] scalability issues on win32 Thread-Index: AcTRBeAbNzp8hwlNRw2Aje7H/8x+CQAQS1aA From: "Dave Page" To: "Bruce Momjian" , "Merlin Moncure" Cc: , "PostgreSQL Win32 port list" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/90 X-Sequence-Number: 2489 =20 > -----Original Message----- > From: pgsql-hackers-win32-owner@postgresql.org=20 > [mailto:pgsql-hackers-win32-owner@postgresql.org] On Behalf=20 > Of Bruce Momjian > Sent: 23 November 2004 02:26 > To: Merlin Moncure > Cc: pgsql-performance@postgresql.org; PostgreSQL Win32 port list > Subject: Re: [pgsql-hackers-win32] scalability issues on win32 >=20 >=20 > This was an intersting Win32/linux comparison. I expected=20 > Linux to scale better, but I was surprised how poorly XP=20 > scaled. It reinforces our perception that Win32 is for low=20 > traffic servers. That's a bit harsh given the lack of any further investigation so far isn't it? Win32 can run perfectly well with other DBMSs with hundreds of users. Any chance you can profile your test runs Merlin? Regards, Dave. From pgsql-hackers-win32-owner@postgresql.org Tue Nov 23 13:05:42 2004 X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 142383A3E30; Tue, 23 Nov 2004 13:05:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40974-02; Tue, 23 Nov 2004 13:05:25 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id A2CAA3A3E0D; Tue, 23 Nov 2004 13:05:27 +0000 (GMT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: scalability issues on win32 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Tue, 23 Nov 2004 08:05:27 -0500 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7533@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [pgsql-hackers-win32] scalability issues on win32 Thread-Index: AcTRRe3JfqRf6+63Rje7dTUqTbh6XQAFjYBA From: "Merlin Moncure" To: "Reini Urban" Cc: , "PostgreSQL Win32 port list" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/91 X-Sequence-Number: 2490 Reini Urban wrote: > Merlin Moncure schrieb: > > A good benchmark of our application performance is the time it takes to > > read the entire bill of materials for a product. This is a recursive > > read of about 2500 records in the typical case (2408 in the test case). >=20 > I always knew that COBOL ultimativly looses, but it's always refreshing > to get confirmation from time to time :) Heh. It's important to make the distinction between COBOL, which is just a language, and ISAM, which is a data delivery system. You could, for example, pair COBOL with SQL with good results, (in fact, we plan to). But yes, many legacy COBOL apps were written with assumptions about the system architecture that are no longer valid. > Where did you get the win32 "avg cpu load" number from? AFAIK there's no > getloadavg() for windows. At least I tried hard to find one, because I > want to add a comparable figure to cygwin core. emacs, coreutils, make > and others would need desperately need it, not to speak of servers and > real-time apps. I just eyeballed it :-). So consider the load averages anecdotal, although they are quite stable. However it is quite striking that with the same application code the win32 load average was 2-3 times higher. I also left out the dual processor results, because I did not have time to test them on linux. However, sadly the 2nd processor adds very little extras horsepower to the server. I'm hoping linux will be better. Merlin From pgsql-performance-owner@postgresql.org Tue Nov 23 14:59:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E3A1C3A3ECD for ; Tue, 23 Nov 2004 14:59:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76475-06 for ; Tue, 23 Nov 2004 14:59:35 +0000 (GMT) Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by svr1.postgresql.org (Postfix) with ESMTP id 1C02A3A3EEA for ; Tue, 23 Nov 2004 14:59:38 +0000 (GMT) Received: (qmail 1136 invoked from network); 23 Nov 2004 14:59:38 -0000 Received: from mail.kinesis-cem.com (HELO pdarley) ([64.81.9.230]) (envelope-sender ) by mail6.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 23 Nov 2004 14:59:37 -0000 From: "Peter Darley" To: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= , Subject: Re: Data type to use for primary key Date: Tue, 23 Nov 2004 06:59:42 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/350 X-Sequence-Number: 9304 All, Well, you should still escape any strings you're getting from a web page so you can ensure you're not subject to a SQL insert attack, even if you're expecting integers. Thanks, Peter Darley -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Pierre-Fr�d�ric Caillaud Sent: Monday, November 22, 2004 3:06 PM To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Data type to use for primary key > What is the common approach? Should I use directly the product_code as > my ID, or use a sequantial number for speed? (I did the same for the > company_id, this is a 'serial' and not the shor name of the customer. > I just don't know what is usually done. Use a serial : - you can change product_code for a product easily - you can pass around integers easier around, in web forms for instance, you don't have to ask 'should I escape this string ?' - it's faster - it uses less space - if one day you must manage products from another source whose product_code overlap yours, you won't have problems - you can generate them with a serial uniquely and easily ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match From pgsql-hackers-win32-owner@postgresql.org Tue Nov 23 15:06:38 2004 X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 631C53A3E55; Tue, 23 Nov 2004 15:06:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77916-10; Tue, 23 Nov 2004 15:06:22 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 6CFBA3A3F2F; Tue, 23 Nov 2004 15:06:24 +0000 (GMT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id iANF6HU09225; Tue, 23 Nov 2004 10:06:17 -0500 (EST) From: Bruce Momjian Message-Id: <200411231506.iANF6HU09225@candle.pha.pa.us> Subject: Re: scalability issues on win32 In-Reply-To: To: Dave Page Date: Tue, 23 Nov 2004 10:06:17 -0500 (EST) Cc: Merlin Moncure , pgsql-performance@postgresql.org, PostgreSQL Win32 port list X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/93 X-Sequence-Number: 2492 Dave Page wrote: > > > > -----Original Message----- > > From: pgsql-hackers-win32-owner@postgresql.org > > [mailto:pgsql-hackers-win32-owner@postgresql.org] On Behalf > > Of Bruce Momjian > > Sent: 23 November 2004 02:26 > > To: Merlin Moncure > > Cc: pgsql-performance@postgresql.org; PostgreSQL Win32 port list > > Subject: Re: [pgsql-hackers-win32] scalability issues on win32 > > > > > > This was an intersting Win32/linux comparison. I expected > > Linux to scale better, but I was surprised how poorly XP > > scaled. It reinforces our perception that Win32 is for low > > traffic servers. > > That's a bit harsh given the lack of any further investigation so far > isn't it? Win32 can run perfectly well with other DBMSs with hundreds of > users. The general opinion of server users is that you need 2-4 more Win32 servers to do the same work as one Unix-like server. That and the difficulty of automated administration and security problems is what is preventing Win32 from making greater inroads into the server marketplace. Of course these are just generalizations. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-hackers-win32-owner@postgresql.org Tue Nov 23 16:26:12 2004 X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 531DF3A3F52; Tue, 23 Nov 2004 16:25:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10751-05; Tue, 23 Nov 2004 16:25:54 +0000 (GMT) Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) by svr1.postgresql.org (Postfix) with ESMTP id 8400E3A3F57; Tue, 23 Nov 2004 16:25:53 +0000 (GMT) Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) by mx-2.sollentuna.net (Postfix) with ESMTP id 81CD78F282; Tue, 23 Nov 2004 17:25:50 +0100 (CET) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Subject: Re: scalability issues on win32 Date: Tue, 23 Nov 2004 17:25:50 +0100 Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE4761F6@algol.sollentuna.se> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [pgsql-hackers-win32] scalability issues on win32 Thread-Index: AcTRcHtk5V6iR+TVT4CDqC8CCmPsWAACD6hg From: "Magnus Hagander" To: "Bruce Momjian" , "Dave Page" Cc: "Merlin Moncure" , , "PostgreSQL Win32 port list" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/94 X-Sequence-Number: 2493 > > > This was an intersting Win32/linux comparison. I expected=20 > Linux to=20 > > > scale better, but I was surprised how poorly XP scaled. It=20 > > > reinforces our perception that Win32 is for low traffic servers. > >=20 > > That's a bit harsh given the lack of any further=20 > investigation so far=20 > > isn't it? Win32 can run perfectly well with other DBMSs=20 > with hundreds=20 > > of users. >=20 > The general opinion of server users is that you need 2-4 more=20 > Win32 servers to do the same work as one Unix-like server. =20 > That and the difficulty of automated administration and=20 > security problems is what is preventing Win32 from making=20 > greater inroads into the server marketplace. >=20 > Of course these are just generalizations. Is this for Postgresql Cygwin? You surely can't mean "for all server tasks" - if so, I would say that's *way* off. There is a difference, but it's more along the line of single-digit percentage in my experience - provided you config your machines reasonably, of course. (In my experience, Win32 MSSQLServer often outperforms postgresql on Linux. Granted you can tweak postgresql up to higher speeds, but MS does most of that tweaking automatically... Talking of tweaking a lot more specific than just raising the memory limits from the installation default, of course) I do agree on the automated administration though... It's a major PITA. //Magnus From pgsql-performance-owner@postgresql.org Tue Nov 23 16:30:12 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 638713A3F95 for ; Tue, 23 Nov 2004 16:30:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12700-09 for ; Tue, 23 Nov 2004 16:29:46 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.199]) by svr1.postgresql.org (Postfix) with ESMTP id EA5083A3F59 for ; Tue, 23 Nov 2004 16:29:46 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 40so221736wri for ; Tue, 23 Nov 2004 08:29:45 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=nRyMLE3lXHkgOk+DhCzLLFYvmp/1t9LN9HbDtFRI9TW+IiOGyxT07+RL8RyRzASGCoz9qQox2BwRSyBTKlxPySWvMqJbo9vaXSbgSzm/9H5E9LY42wINnkKeYWdUBXjxy++bTKPuYwN5zJevNLjhrTjfjUnP+LxFPgQuBSl+JFM= Received: by 10.54.20.74 with SMTP id 74mr92119wrt; Tue, 23 Nov 2004 08:29:45 -0800 (PST) Received: by 10.54.20.6 with HTTP; Tue, 23 Nov 2004 08:29:45 -0800 (PST) Message-ID: <1dc7f0e30411230829bd1ed@mail.gmail.com> Date: Tue, 23 Nov 2004 11:29:45 -0500 From: Alexandre Leclerc Reply-To: Alexandre Leclerc To: pgsql-performance@postgresql.org Subject: Re: Data type to use for primary key In-Reply-To: <200411221654.56673.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <1dc7f0e30411221232603c4617@mail.gmail.com> <200411221654.56673.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/353 X-Sequence-Number: 9307 On Mon, 22 Nov 2004 16:54:56 -0800, Josh Berkus wrote: > Alexandre, > > > What is the common approach? Should I use directly the product_code as > > my ID, or use a sequantial number for speed? (I did the same for the > > company_id, this is a 'serial' and not the shor name of the customer. > > I just don't know what is usually done. > > Don't use SERIAL just because it's there. Ideally, you *want* to use the > product_code if you can. It's your natural key and a natural key is always > superior to a surrogate key all other things being equal. > > Unfortunately, all other things are NOT equal. Here's the reasons why you'd > use a surrogate key (i.e. SERIAL): > > 1) because the product code is a large text string (i.e. > 10bytes) and you > will have many millions of records, so having it as an FK in other tables > will add significantly to the footprint of the database; Thanks for those tips. I'll print and keep them. So in my case, the product_code being varchar(24) is: 4 bytes + string size (so possibly up to 24) = possible 28 bytes. I did the good thing using a serial. For my shorter keys (4 bytes + up to 6 char) I will use the natural key. This is interesting, because this is what I did right now. The "transparent surrogate keying" proposal that is discussed bellow in the thread is a very good idea. It would be nice to see that. It would be easier for the DB admin and the coder; the moment this is not slowing the system. : ) Best regards. -- Alexandre Leclerc From pgsql-performance-owner@postgresql.org Tue Nov 23 16:43:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 37AB43A3F9C for ; Tue, 23 Nov 2004 16:43:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17815-05 for ; Tue, 23 Nov 2004 16:43:33 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 1ED043A3FAE for ; Tue, 23 Nov 2004 16:43:31 +0000 (GMT) Received: (qmail 9741 invoked from network); 23 Nov 2004 17:43:57 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 23 Nov 2004 17:43:57 +0100 To: pgsql-performance@postgresql.org Subject: Re: Data type to use for primary key References: Message-ID: Date: Tue, 23 Nov 2004 17:45:27 +0100 From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/354 X-Sequence-Number: 9308 > All, > Well, you should still escape any strings you're getting from a web > page so > you can ensure you're not subject to a SQL insert attack, even if you're > expecting integers. > Thanks, > Peter Darley Well, your framework should do this for you : "integer" specified in your database object class description "%d" appears in in your generated queries (or you put it in your hand written queries) => if the parameter is not an integer, an exception is thrown, then catched, then an error page is displayed... Or, just casting to int should throw an exception... Forms should be validated, but hidden parameters in links are OK imho to display an error page if they are incorrect, after all, if the user edits the get or post parameters, well... From pgsql-performance-owner@postgresql.org Tue Nov 23 17:07:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 27AA03A3F77 for ; Tue, 23 Nov 2004 17:07:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98826-01 for ; Tue, 23 Nov 2004 17:06:45 +0000 (GMT) Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) by svr1.postgresql.org (Postfix) with ESMTP id 8E7373A3F81 for ; Tue, 23 Nov 2004 17:06:44 +0000 (GMT) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: [pgsql-hackers-win32] scalability issues on win32 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Date: Tue, 23 Nov 2004 12:06:47 -0500 Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7535@Herge.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [pgsql-hackers-win32] scalability issues on win32 Thread-Index: AcTRcHtk5V6iR+TVT4CDqC8CCmPsWAACD6hgAAE8W9A= From: "Merlin Moncure" To: "Magnus Hagander" Cc: , "Bruce Momjian" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/355 X-Sequence-Number: 9309 > Is this for Postgresql Cygwin? You surely can't mean "for all server > tasks" - if so, I would say that's *way* off. There is a difference, but > it's more along the line of single-digit percentage in my experience - > provided you config your machines reasonably, of course. >=20 > (In my experience, Win32 MSSQLServer often outperforms postgresql on > Linux. Granted you can tweak postgresql up to higher speeds, but MS does > most of that tweaking automatically... Talking of tweaking a lot more > specific than just raising the memory limits from the installation > default, of course) I agree with Magnus. Specifically, I suspect there is some sort of resource contention going on that is driving up the cpu load when the queries follow certain patterns. This resource contention could be happening in the win32 port code (likely ipc), the mingw api, or inside the o/s itself. Other servers, namely apache, sql server and a host of others do not have this problem. Merlin From pgsql-performance-owner@postgresql.org Tue Nov 23 17:20:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 12BCE3A3FFA for ; Tue, 23 Nov 2004 17:20:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19843-01 for ; Tue, 23 Nov 2004 17:20:21 +0000 (GMT) Received: from jinx.internetstaff.com (unknown [63.214.174.241]) by svr1.postgresql.org (Postfix) with ESMTP id 556573A3FEF for ; Tue, 23 Nov 2004 17:20:20 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by jinx.internetstaff.com (Postfix) with ESMTP id E5AD14BC32F; Tue, 23 Nov 2004 10:20:18 -0700 (MST) Received: from jinx.internetstaff.com ([127.0.0.1]) by localhost (jinx [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 22049-01-63; Tue, 23 Nov 2004 10:20:08 -0700 (MST) Received: from blackbox.vcommerce.com (unknown [65.161.175.253]) by jinx.internetstaff.com (Postfix) with ESMTP id EBA6B4BC270; Tue, 23 Nov 2004 10:20:07 -0700 (MST) Subject: Re: Some quick Opteron 32-bit/64-bit results From: Cott Lang To: William Yu Cc: pgsql-performance@postgresql.org In-Reply-To: References: <87vfc78ug1.fsf@stark.xeocode.com> Content-Type: text/plain Date: Tue, 23 Nov 2004 10:20:07 -0700 Message-Id: <1101230407.5440.8.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-3) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at internetstaff.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/356 X-Sequence-Number: 9310 I ran quite a few file system benchmarks in RHAS x86-64 and FC2 x86-64 on a Sun V40z - I did see very consistent 50% improvements in bonnie++ moving from RHAS to FC2 with ext2/ext3 on SAN. On Sun, 2004-11-14 at 23:51 -0800, William Yu wrote: > Greg Stark wrote: > > William Yu writes: > > > > > >>Biggest speedup I've found yet is the backup process (PG_DUMP --> GZIP). 100% > >>faster in 64-bit mode. This drastic speed might be more the result of 64-bit > >>GZIP though as I've seen benchmarks in the past showing encryption/compression > >>running 2 or 3 times faster in 64-bit mode versus 32-bit. > > > > > > Isn't this a major kernel bump too? So a different scheduler, different IO > > scheduler, etc? > > > > I'm sure there's some speedup due to the kernel bump. I really didn't > have the patience to even burn the FC2 32-bit CDs much less install both > 32-bit & 64-bit FC2 in order to have a more accurate baseline comparison. > > However, that being said -- when you see huge speed increases like 50% > 100% for dump+gzip, it's doubtful the kernel/process scheduler/IO > scheduler could have made that drastic of a difference. Maybe somebody > else who has done a 2.4 -> 2.6 upgrade can give us a baseline to > subtract from my numbers. > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Tue Nov 23 17:54:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 54F063A3F0E for ; Tue, 23 Nov 2004 17:54:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17070-02 for ; Tue, 23 Nov 2004 17:54:14 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id CC8ED3A3F81 for ; Tue, 23 Nov 2004 17:54:10 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iANHs6gu028238; Tue, 23 Nov 2004 12:54:06 -0500 (EST) To: Mike Mascari Cc: pgsql-performance@postgresql.org Subject: Re: Slow execution time when querying view with WHERE clause In-reply-to: <41A25C3B.3040608@mascari.com> References: <41A25C3B.3040608@mascari.com> Comments: In-reply-to Mike Mascari message dated "Mon, 22 Nov 2004 16:38:03 -0500" Date: Tue, 23 Nov 2004 12:54:05 -0500 Message-ID: <28237.1101232445@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/357 X-Sequence-Number: 9311 Mike Mascari writes: > When I query the view with a simple filter, I get: > explain analyze select * from p_areas where deactive is null; The problem seems to be here: > -> Seq Scan on _areas a (cost=0.00..2.48 rows=1 width=163) (actual time=0.037..0.804 rows=48 loops=1) > Filter: (deactive IS NULL) Why is it so completely off about the selectivity of the IS NULL clause? Are you sure you ANALYZEd this table recently? regards, tom lane From pgsql-hackers-win32-owner@postgresql.org Tue Nov 23 20:12:49 2004 X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 991983A2B21; Tue, 23 Nov 2004 20:12:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22898-09; Tue, 23 Nov 2004 20:12:26 +0000 (GMT) Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by svr1.postgresql.org (Postfix) with ESMTP id 4E2123A4019; Tue, 23 Nov 2004 20:12:24 +0000 (GMT) Received: from mailgate.vale-housing.co.uk ([194.217.48.34] helo=ratbert.vale-housing.co.uk) by anchor-post-34.mail.demon.net with esmtp (Exim 4.42) id 1CWh1S-000GxT-FD; Tue, 23 Nov 2004 20:12:22 +0000 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: scalability issues on win32 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Date: Tue, 23 Nov 2004 20:12:21 -0000 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [pgsql-hackers-win32] scalability issues on win32 Thread-Index: AcTRbf79ZoyPcP3LTgOyxOYRfXfepgAKXhtA From: "Dave Page" To: "Bruce Momjian" Cc: "Merlin Moncure" , , "PostgreSQL Win32 port list" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/96 X-Sequence-Number: 2495 =20 > -----Original Message----- > From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]=20 > Sent: 23 November 2004 15:06 > To: Dave Page > Cc: Merlin Moncure; pgsql-performance@postgresql.org;=20 > PostgreSQL Win32 port list > Subject: Re: [pgsql-hackers-win32] scalability issues on win32 >=20 > The general opinion of server users is that you need 2-4 more=20 > Win32 servers to do the same work as one Unix-like server. =20 > That and the difficulty of automated administration and=20 > security problems is what is preventing Win32 from making=20 > greater inroads into the server marketplace. >=20 > Of course these are just generalizations. I'd rather avoid an OS advocacy war here, but if I'm honest, with group policy and other tools such as SUS, I find that my Windows servers are actually easier to administer than the Linux ones (I have about a 50-50 mix at work). Perhaps that's because I favour Slackware though? As for the 2-4 servers quote, I find that a little on the high side. I agree that generally you might expect a little more performance from an equivalent Linux system on the same hardware, but in my practical experience the difference is far less than you suggest. Regards, Dave. From pgsql-performance-owner@postgresql.org Tue Nov 23 22:20:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8AEF63A41C0 for ; Tue, 23 Nov 2004 22:20:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13679-03 for ; Tue, 23 Nov 2004 22:20:47 +0000 (GMT) Received: from mail.trippynames.com (mail.trippynames.com [38.113.223.19]) by svr1.postgresql.org (Postfix) with ESMTP id D6BE73A41AC for ; Tue, 23 Nov 2004 22:20:49 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by mail.trippynames.com (Postfix) with ESMTP id 62A08A6DAF; Tue, 23 Nov 2004 14:20:47 -0800 (PST) Received: from mail.trippynames.com ([127.0.0.1]) by localhost (rand.nxad.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 87074-07; Tue, 23 Nov 2004 14:20:37 -0800 (PST) Received: from [192.168.1.3] (dsl081-069-073.sfo1.dsl.speakeasy.net [64.81.69.73]) by mail.trippynames.com (Postfix) with ESMTP id 32085A2567; Tue, 23 Nov 2004 14:20:37 -0800 (PST) In-Reply-To: <200411230218.iAN2I5o22567@candle.pha.pa.us> References: <200411230218.iAN2I5o22567@candle.pha.pa.us> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: =?ISO-8859-1?Q?Pierre-Fr=E9d=E9ric_Caillaud?= , pgsql-performance@postgresql.org From: Sean Chittenden Subject: Re: memcached and PostgreSQL Date: Tue, 23 Nov 2004 14:20:34 -0800 To: Bruce Momjian X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/358 X-Sequence-Number: 9312 > My point was that there are two failure cases --- one where the cache > is > slightly out of date compared to the db server --- these are cases > where > the cache update is slightly before/after the commit. I was thinking about this and ways to minimize this even further. Have memcache clients add data and have a policy to have the database only delete data. This sets the database up as the bottleneck again, but then you have a degree of transactionality that couldn't be previously achieved with the database issuing replace commands. For example: 1) client checks the cache for data and gets a cache lookup failure 2) client beings transaction 3) client SELECTs data from the database 4) client adds the key to the cache 5) client commits transaction This assumes that the client won't rollback or have a transaction failure. Again, in 50M transactions, I doubt one of them would fail (sure, it's possible, but that's a symptom of bigger problems: memcached isn't an RDBMS). The update case being: 1) client begins transaction 2) client updates data 3) database deletes record from memcache 4) client commits transaction 5) client adds data to memcache > The second is > where the cache update happens and the commit later fails, or the > commit > happens and the cache update never happens. Having pgmemcache delete, not replace data addresses this second issue. -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Wed Nov 24 02:21:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 386483A41E0 for ; Wed, 24 Nov 2004 02:04:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 68677-01 for ; Wed, 24 Nov 2004 02:04:24 +0000 (GMT) Received: from ms-smtp-04-eri0.ohiordc.rr.com (ms-smtp-04-smtplb.ohiordc.rr.com [65.24.5.138]) by svr1.postgresql.org (Postfix) with ESMTP id D29293A41D3 for ; Wed, 24 Nov 2004 02:04:26 +0000 (GMT) Received: from enzo.mascari.com (dhcp065-024-156-214.columbus.rr.com [65.24.156.214]) by ms-smtp-04-eri0.ohiordc.rr.com (8.12.10/8.12.7) with ESMTP id iAO24NHH007892; Tue, 23 Nov 2004 21:04:23 -0500 (EST) Received: from [192.168.2.1] (ferrari.mascari.com [192.168.2.1]) by enzo.mascari.com (8.12.8/8.12.8) with ESMTP id iAO24H97000987; Tue, 23 Nov 2004 21:04:18 -0500 Message-ID: <41A3EC1F.6040706@mascari.com> Date: Tue, 23 Nov 2004 21:04:15 -0500 From: Mike Mascari User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Slow execution time when querying view with WHERE clause References: <41A25C3B.3040608@mascari.com> <28237.1101232445@sss.pgh.pa.us> In-Reply-To: <28237.1101232445@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mascari-MailScanner-Information: Please contact the ISP for more information X-Mascari-MailScanner: Found to be clean X-Mascari-MailScanner-SpamCheck: not spam, SpamAssassin (score=0, required 6, autolearn=not spam) X-MailScanner-From: mascarm@mascari.com X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/359 X-Sequence-Number: 9313 Tom Lane wrote: > Mike Mascari writes: > >>When I query the view with a simple filter, I get: > > >>explain analyze select * from p_areas where deactive is null; > > > The problem seems to be here: > > >> -> Seq Scan on _areas a (cost=0.00..2.48 rows=1 width=163) (actual time=0.037..0.804 rows=48 loops=1) >> Filter: (deactive IS NULL) > > > Why is it so completely off about the selectivity of the IS NULL clause? > Are you sure you ANALYZEd this table recently? Yes. I just did: [estore@lexus] vacuum full analyze; VACUUM [estore@lexus] explain analyze select * from p_areas where deactive is null; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Nested Loop IN Join (cost=8.62..512.47 rows=1 width=162) (actual time=1143.969..21811.417 rows=37 loops=1) Join Filter: ("outer".area = "inner".area) -> Seq Scan on _areas a (cost=0.00..2.49 rows=1 width=162) (actual time=0.037..1.673 rows=49 loops=1) Filter: (deactive IS NULL) -> Nested Loop (cost=8.62..25740.20 rows=2681 width=8) (actual time=1.172..429.501 rows=3566 loops=49) -> Nested Loop (cost=8.62..16674.93 rows=2680 width=8) (actual time=1.125..281.570 rows=3566 loops=49) -> Merge Join (cost=8.62..3012.72 rows=2778 width=8) (actual time=0.876..128.908 rows=3566 loops=49) Merge Cond: ("outer".pricegroup = "inner".pricegroup) -> Nested Loop IN Join (cost=8.62..1929.41 rows=9 width=8) (actual time=0.613..5.504 rows=9 loops=49) Join Filter: ("outer".buyer = "inner".store) -> Index Scan using i_pricemembers3 on _pricemembers p (cost=0.00..11.13 rows=217 width=16) (actual time=0.403..1.476 rows=142 loops=49) -> Subquery Scan "IN_subquery" (cost=8.62..8.74 rows=8 width=8) (actual time=0.013..0.019 rows=1 loops=6950) -> Unique (cost=8.62..8.66 rows=8 width=8) (actual time=0.007..0.010 rows=1 loops=6950) -> Sort (cost=8.62..8.64 rows=8 width=8) (actual time=0.003..0.004 rows=1 loops=6950) Sort Key: store -> Append (cost=2.87..8.50 rows=8 width=8) (actual time=8.394..8.446 rows=1 loops=1) -> Subquery Scan "*SELECT* 1" (cost=2.87..5.17 rows=5 width=8) (actual time=8.112..8.112 rows=0 loops=1) -> Hash Join (cost=2.87..5.12 rows=5 width=8) (actual time=8.106..8.106 rows=0 loops=1) Hash Cond: ("outer".company = "inner".company) -> Seq Scan on _stores s (cost=0.00..2.13 rows=13 width=16) (actual time=0.014..0.052 rows=13 loops=1) -> Hash (cost=2.87..2.87 rows=1 width=8) (actual time=7.878..7.878 rows=0 loops=1) -> Seq Scan on _webusers w (cost=0.00..2.87 rows=1 width=8) (actual time=7.868..7.868 rows=0 loops=1) Filter: (webuser = getwebuser()) -> Subquery Scan "*SELECT* 2" (cost=1.08..3.33 rows=3 width=8) (actual time=0.273..0.322 rows=1 loops=1) -> Hash Join (cost=1.08..3.30 rows=3 width=8) (actual time=0.263..0.308 rows=1 loops=1) Hash Cond: ("outer".company = "inner".company) -> Seq Scan on _stores s (cost=0.00..2.13 rows=13 width=16) (actual time=0.008..0.042 rows=13 loops=1) -> Hash (cost=1.07..1.07 rows=1 width=8) (actual time=0.093..0.093 rows=0 loops=1) -> Seq Scan on _companies c (cost=0.00..1.07 rows=1 width=8) (actual time=0.061..0.081 rows=1 loops=1) Filter: ((companyid)::text = 'DEFAULT'::text) -> Index Scan using i_offers4 on _offers o (cost=0.00..1014.76 rows=16298 width=16) (actual time=0.244..72.742 rows=10433 loops=49) -> Index Scan using i_inventories1 on _inventories i (cost=0.00..4.91 rows=1 width=16) (actual time=0.025..0.029 rows=1 loops=174715) Index Cond: (i.inventory = "outer".inventory) -> Index Scan using i_bins1 on _bins b (cost=0.00..3.37 rows=1 width=16) (actual time=0.022..0.027 rows=1 loops=174715) Index Cond: (b.bin = "outer".bin) Total runtime: 21813.209 ms _areas looks like: [estore@lexus] \d _areas Table "temporal._areas" Column | Type | Modifiers --------------------+--------------------------+------------------------ area | bigint | not null store | bigint | not null name | character varying(32) | not null description | character varying(64) | not null email | character varying(48) | not null phoneno | character varying(16) | not null requisition_device | bigint | not null inventory_device | bigint | not null receive_device | bigint | not null invoice_device | bigint | not null activation_device | bigint | not null active | timestamp with time zone | not null default now() deactive | timestamp with time zone | Indexes: "i_areas1" unique, btree (area) "i_areas2" unique, btree (store, name) WHERE (deactive IS NULL) "i_areas3" btree (store, name) Triggers: t_areas1 BEFORE INSERT OR DELETE OR UPDATE ON _areas FOR EACH ROW EXECUTE PROCEDURE ri_areas() Note that if I disable nestedloop plans, I get: [estore@lexus] explain analyze select * from p_areas where deactive is null; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Hash Join (cost=1456.90..1457.15 rows=1 width=162) (actual time=423.273..424.156 rows=37 loops=1) Hash Cond: ("outer".area = "inner".area) -> HashAggregate (cost=1454.40..1454.40 rows=48 width=8) (actual time=422.192..422.334 rows=37 loops=1) -> Hash Join (cost=582.79..1447.70 rows=2681 width=8) (actual time=188.687..406.584 rows=5694 loops=1) Hash Cond: ("outer".bin = "inner".bin) -> Hash Join (cost=568.07..1386.07 rows=2680 width=8) (actual time=182.756..358.441 rows=5694 loops=1) Hash Cond: ("outer".inventory = "inner".inventory) -> Seq Scan on _inventories i (cost=0.00..280.04 rows=12004 width=16) (actual time=0.013..38.221 rows=12004 loops=1) -> Hash (cost=561.12..561.12 rows=2778 width=8) (actual time=182.543..182.543 rows=0 loops=1) -> Hash Join (cost=14.13..561.12 rows=2778 width=8) (actual time=9.854..160.963 rows=5694 loops=1) Hash Cond: ("outer".pricegroup = "inner".pricegroup) -> Seq Scan on _offers o (cost=0.00..396.98 rows=16298 width=16) (actual time=0.011..58.422 rows=16298 loops=1) -> Hash (cost=14.10..14.10 rows=9 width=8) (actual time=9.728..9.728 rows=0 loops=1) -> Hash IN Join (cost=8.76..14.10 rows=9 width=8) (actual time=8.616..9.657 rows=13 loops=1) Hash Cond: ("outer".buyer = "inner".store) -> Seq Scan on _pricemembers p (cost=0.00..4.17 rows=217 width=16) (actual time=0.011..0.565 rows=217 loops=1) -> Hash (cost=8.74..8.74 rows=8 width=8) (actual time=8.465..8.465 rows=0 loops=1) -> Subquery Scan "IN_subquery" (cost=8.62..8.74 rows=8 width=8) (actual time=8.446..8.455 rows=1 loops=1) -> Unique (cost=8.62..8.66 rows=8 width=8) (actual time=8.430..8.435 rows=1 loops=1) -> Sort (cost=8.62..8.64 rows=8 width=8) (actual time=8.424..8.426 rows=1 loops=1) Sort Key: store -> Append (cost=2.87..8.50 rows=8 width=8) (actual time=8.004..8.058 rows=1 loops=1) -> Subquery Scan "*SELECT* 1" (cost=2.87..5.17 rows=5 width=8) (actual time=7.710..7.710 rows=0 loops=1) -> Hash Join (cost=2.87..5.12 rows=5 width=8) (actual time=7.701..7.701 rows=0 loops=1) Hash Cond: ("outer".company = "inner".company) -> Seq Scan on _stores s (cost=0.00..2.13 rows=13 width=16) (actual time=0.013..0.052 rows=13 loops=1) -> Hash (cost=2.87..2.87 rows=1 width=8) (actual time=7.486..7.486 rows=0 loops=1) -> Seq Scan on _webusers w (cost=0.00..2.87 rows=1 width=8) (actual time=7.478..7.478 rows=0 loops=1) Filter: (webuser = getwebuser()) -> Subquery Scan "*SELECT* 2" (cost=1.08..3.33 rows=3 width=8) (actual time=0.284..0.336 rows=1 loops=1) -> Hash Join (cost=1.08..3.30 rows=3 width=8) (actual time=0.274..0.321 rows=1 loops=1) Hash Cond: ("outer".company = "inner".company) -> Seq Scan on _stores s (cost=0.00..2.13 rows=13 width=16) (actual time=0.008..0.046 rows=13 loops=1) -> Hash (cost=1.07..1.07 rows=1 width=8) (actual time=0.096..0.096 rows=0 loops=1) -> Seq Scan on _companies c (cost=0.00..1.07 rows=1 width=8) (actual time=0.064..0.083 rows=1 loops=1) Filter: ((companyid)::text = 'DEFAULT'::text) -> Hash (cost=13.18..13.18 rows=618 width=16) (actual time=5.849..5.849 rows=0 loops=1) -> Seq Scan on _bins b (cost=0.00..13.18 rows=618 width=16) (actual time=0.027..3.554 rows=618 loops=1) -> Hash (cost=2.49..2.49 rows=1 width=162) (actual time=0.960..0.960 rows=0 loops=1) -> Seq Scan on _areas a (cost=0.00..2.49 rows=1 width=162) (actual time=0.033..0.197 rows=49 loops=1) Filter: (deactive IS NULL) Total runtime: 427.390 ms Thanks! Mike Mascari From pgsql-hackers-win32-owner@postgresql.org Wed Nov 24 04:39:23 2004 X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7E6923A427D; Wed, 24 Nov 2004 04:39:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88444-10; Wed, 24 Nov 2004 04:39:08 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id C889A3A42AE; Wed, 24 Nov 2004 04:39:05 +0000 (GMT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id iAO4cwb20073; Tue, 23 Nov 2004 23:38:58 -0500 (EST) From: Bruce Momjian Message-Id: <200411240438.iAO4cwb20073@candle.pha.pa.us> Subject: Re: scalability issues on win32 In-Reply-To: To: Dave Page Date: Tue, 23 Nov 2004 23:38:58 -0500 (EST) Cc: Merlin Moncure , pgsql-performance@postgresql.org, PostgreSQL Win32 port list X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/97 X-Sequence-Number: 2496 Dave Page wrote: > > > > -----Original Message----- > > From: Bruce Momjian [mailto:pgman@candle.pha.pa.us] > > Sent: 23 November 2004 15:06 > > To: Dave Page > > Cc: Merlin Moncure; pgsql-performance@postgresql.org; > > PostgreSQL Win32 port list > > Subject: Re: [pgsql-hackers-win32] scalability issues on win32 > > > > The general opinion of server users is that you need 2-4 more > > Win32 servers to do the same work as one Unix-like server. > > That and the difficulty of automated administration and > > security problems is what is preventing Win32 from making > > greater inroads into the server marketplace. > > > > Of course these are just generalizations. > > I'd rather avoid an OS advocacy war here, but if I'm honest, with group > policy and other tools such as SUS, I find that my Windows servers are > actually easier to administer than the Linux ones (I have about a 50-50 > mix at work). Perhaps that's because I favour Slackware though? > > As for the 2-4 servers quote, I find that a little on the high side. I > agree that generally you might expect a little more performance from an > equivalent Linux system on the same hardware, but in my practical > experience the difference is far less than you suggest. I have never run the tests myself. I am just quoting what I have heard, and maybe that information is a few years old. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 From pgsql-hackers-owner@postgresql.org Wed Nov 24 05:33:05 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0C3033A42B5 for ; Wed, 24 Nov 2004 05:33:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 96382-05 for ; Wed, 24 Nov 2004 05:32:50 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id E51E53A41A6 for ; Wed, 24 Nov 2004 05:32:49 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAO5WgKZ004294; Wed, 24 Nov 2004 00:32:42 -0500 (EST) To: teo@flex.ro Cc: pgsql-hackers@postgresql.org Subject: Re: Big number of schemas (3500) into a single database In-reply-to: <200411220736.iAM7akZ2008229@corbeanca.iqm.ro> References: <200411220736.iAM7akZ2008229@corbeanca.iqm.ro> Comments: In-reply-to "Constantin Teodorescu" message dated "Mon, 22 Nov 2004 09:44:04 +0200" Date: Wed, 24 Nov 2004 00:32:42 -0500 Message-ID: <4293.1101274362@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/886 X-Sequence-Number: 61458 "Constantin Teodorescu" writes: > If I will choose to keep a mirror of every workstation database in a > separate schema in the central database that mean that I will have 3500 > different schemas. > Is there any limit or any barrier that could stop this kind of approach or > make things go slower? Would you need to put them all into "search_path" at once? I'm not sure what the scaling issues might be for long search_paths, but I wouldn't be surprised if it's bad. But as long as you don't do that, I don't believe there will be any problems. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 24 05:40:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F12D43A41E0 for ; Wed, 24 Nov 2004 05:40:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12061-03 for ; Wed, 24 Nov 2004 05:40:45 +0000 (GMT) Received: from web50002.mail.yahoo.com (web50002.mail.yahoo.com [206.190.38.17]) by svr1.postgresql.org (Postfix) with SMTP id 3599A3A4308 for ; Wed, 24 Nov 2004 05:40:44 +0000 (GMT) Received: (qmail 88467 invoked by uid 60001); 24 Nov 2004 05:40:43 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=uzGpLHEcw6FMyBwx98VzVHJUgVomYnQqU77sFQe04ZacybOY0WoTTC1uDYoVE/+QFLFOQWRTNQSwWgDPUI8S+fhzOyMLDTR21QaCvZZrjvymHe5aKYXXrIzRNFS3o53T30iUshAWnHeapCgxmrC4cpb61U0BzNaJpr1KWvjI8og= ; Message-ID: <20041124054043.88464.qmail@web50002.mail.yahoo.com> Received: from [200.93.192.137] by web50002.mail.yahoo.com via HTTP; Tue, 23 Nov 2004 23:40:43 CST Date: Tue, 23 Nov 2004 23:40:43 -0600 (CST) From: Jaime Casanova Subject: Re: Slow execution time when querying view with WHERE clause To: pgsql-performance@postgresql.org In-Reply-To: <41A3EC1F.6040706@mascari.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/361 X-Sequence-Number: 9315 --- Mike Mascari escribi�: > Tom Lane wrote: > > Mike Mascari writes: > > > >>When I query the view with a simple filter, I get: > > > > > >>explain analyze select * from p_areas where > deactive is null; > > > > > > The problem seems to be here: > > > > > >> -> Seq Scan on _areas a (cost=0.00..2.48 > rows=1 width=163) (actual time=0.037..0.804 rows=48 > loops=1) > >> Filter: (deactive IS NULL) > > > > > > Why is it so completely off about the selectivity > of the IS NULL clause? null values are not indexable, is that your question? If it is your question then create a partial index with where deactive is null. regards, Jaime Casanova _________________________________________________________ Do You Yahoo!? Informaci�n de Estados Unidos y Am�rica Latina, en Yahoo! Noticias. Vis�tanos en http://noticias.espanol.yahoo.com From pgsql-performance-owner@postgresql.org Wed Nov 24 06:12:03 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E958D3A41A6 for ; Wed, 24 Nov 2004 06:12:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29720-08 for ; Wed, 24 Nov 2004 06:11:50 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 91B963A42CF for ; Wed, 24 Nov 2004 06:11:49 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAO6Bmw6004594; Wed, 24 Nov 2004 01:11:48 -0500 (EST) To: Jaime Casanova Cc: pgsql-performance@postgresql.org Subject: Re: Slow execution time when querying view with WHERE clause In-reply-to: <20041124054043.88464.qmail@web50002.mail.yahoo.com> References: <20041124054043.88464.qmail@web50002.mail.yahoo.com> Comments: In-reply-to Jaime Casanova message dated "Tue, 23 Nov 2004 23:40:43 -0600" Date: Wed, 24 Nov 2004 01:11:48 -0500 Message-ID: <4593.1101276708@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/362 X-Sequence-Number: 9316 Jaime Casanova writes: > Tom Lane wrote: >> Why is it so completely off about the selectivity >> of the IS NULL clause? > null values are not indexable, is that your question? Uh, no. The problem is that the IS NULL condition matched all 48 rows of the table, but the planner thought it would only match one row. This is definitely covered by the pg_stats statistics, and with only 48 live rows there couldn't possibly have been any sampling error, so what the heck went wrong there? regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 24 06:31:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4863E3A42F3 for ; Wed, 24 Nov 2004 06:31:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32333-10 for ; Wed, 24 Nov 2004 06:31:29 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id D706B3A41A6 for ; Wed, 24 Nov 2004 06:31:28 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAO6VNk4004739; Wed, 24 Nov 2004 01:31:25 -0500 (EST) To: Mike Mascari Cc: pgsql-performance@postgresql.org Subject: Re: Slow execution time when querying view with WHERE clause In-reply-to: <41A42409.7080704@mascari.com> References: <41A25C3B.3040608@mascari.com> <28237.1101232445@sss.pgh.pa.us> <41A42409.7080704@mascari.com> Comments: In-reply-to Mike Mascari message dated "Wed, 24 Nov 2004 01:02:49 -0500" Date: Wed, 24 Nov 2004 01:31:23 -0500 Message-ID: <4738.1101277883@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/363 X-Sequence-Number: 9317 Mike Mascari writes: > Tom Lane wrote: >> Why is it so completely off about the selectivity of the IS NULL clause? > I think this is a bug in ANALYZE not constructing statistics for columns > whose data is entirely NULL: Um ... doh ... analyze.c about line 1550: /* We can only compute valid stats if we found some non-null values. */ if (nonnull_cnt > 0) ... There's a bit of an epistemological issue here: if we didn't actually find any nonnull values in our sample, is it legitimate to assume that the column is entirely null? On the other hand, if we find only "3" in our sample we will happily assume the column contains only "3", so I dunno why we are discriminating against null. This seems like a case that just hasn't come up before. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 24 06:51:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 48B3C3A42FE for ; Wed, 24 Nov 2004 06:51:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41132-02 for ; Wed, 24 Nov 2004 06:51:33 +0000 (GMT) Received: from bluebamboo.ph (unknown [202.175.252.53]) by svr1.postgresql.org (Postfix) with ESMTP id 6A8913A434E for ; Wed, 24 Nov 2004 06:51:30 +0000 (GMT) Received: from irridescens ([192.168.0.180]) by bluebamboo.ph (8.11.6/8.11.6) with ESMTP id iAO6qXi19938 for ; Wed, 24 Nov 2004 14:52:34 +0800 From: "BBI Edwin Punzalan" To: Subject: FW: Index usage Date: Wed, 24 Nov 2004 14:52:07 +0800 Message-ID: <001401c4d1f2$1df5df00$b400a8c0@bluebamboo.ph> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/364 X-Sequence-Number: 9318 Hi everyone, Can anyone please explain postgres' behavior on our index. I did the following query tests on our database: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D db=3D# create index chatlogs_date_idx on chatlogs (date); CREATE db=3D# explain select date from chatlogs where date>=3D'11/23/04'; NOTICE: QUERY PLAN: Index Scan using chatlogs_date_idx on chatlogs (cost=3D0.00..144.11 = rows=3D36 width=3D4) EXPLAIN db=3D# explain select date from chatlogs where date>=3D'10/23/04'; NOTICE: QUERY PLAN: Seq Scan on chatlogs (cost=3D0.00..23938.06 rows=3D253442 width=3D4) EXPLAIN=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Date's datatype is date. Its just odd that I just change the actual = date of search and the index is not being used anymore. From pgsql-performance-owner@postgresql.org Wed Nov 24 06:53:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3A8943A434E for ; Wed, 24 Nov 2004 06:53:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39533-05 for ; Wed, 24 Nov 2004 06:52:56 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id 6D81D3A4322 for ; Wed, 24 Nov 2004 06:52:56 +0000 (GMT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1CWr1J-0001O5-00; Wed, 24 Nov 2004 01:52:53 -0500 To: Alexandre Leclerc Cc: pgsql-performance@postgresql.org Subject: Re: Data type to use for primary key References: <1dc7f0e30411221232603c4617@mail.gmail.com> <200411221654.56673.josh@agliodbs.com> <1dc7f0e30411230829bd1ed@mail.gmail.com> In-Reply-To: <1dc7f0e30411230829bd1ed@mail.gmail.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 24 Nov 2004 01:52:52 -0500 Message-ID: <87hdnfwxff.fsf@stark.xeocode.com> Lines: 37 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/365 X-Sequence-Number: 9319 Alexandre Leclerc writes: > Thanks for those tips. I'll print and keep them. So in my case, the > product_code being varchar(24) is: > 4 bytes + string size (so possibly up to 24) = possible 28 bytes. I > did the good thing using a serial. For my shorter keys (4 bytes + up > to 6 char) I will use the natural key. Realize that space usage is really only part of the issue. If you ever have two records with the same natural key or a record whose natural key has changed you'll be in for a world of hurt if you use the natural key as the primary key in your database. Basically I never use natural keys except when they're arbitrarily chosen values defined by the application itself. Situations where I've used varchars instead of integer keys are things like: . Individual privileges grantable in a security system. (things like "VIEWUSER" "EDITUSER" privileges) . Reference tables for one letter codes used to indicate the type of object represented by the record. Actually I see one interesting exception to my policy in my current database schema. And I don't think I would do this one differently given the choice either. The primary key of the postal code table is the postal code. (postal codes are up here in the great white north like zip codes down there.) This could hurt if they ever reuse an old previously retired postal code, which isn't an entirely impossible case. As far as I know it hasn't happened yet though. And it's just so much more convenient having the postal code handy instead of having to join against another table to look it up. -- greg From pgsql-performance-owner@postgresql.org Wed Nov 24 07:16:47 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2A4063A4327 for ; Wed, 24 Nov 2004 07:16:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46993-04 for ; Wed, 24 Nov 2004 07:16:34 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0AD343A4334 for ; Wed, 24 Nov 2004 07:16:32 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAO7GFgb005060; Wed, 24 Nov 2004 02:16:15 -0500 (EST) To: Greg Stark Cc: Alexandre Leclerc , pgsql-performance@postgresql.org Subject: Re: Data type to use for primary key In-reply-to: <87hdnfwxff.fsf@stark.xeocode.com> References: <1dc7f0e30411221232603c4617@mail.gmail.com> <200411221654.56673.josh@agliodbs.com> <1dc7f0e30411230829bd1ed@mail.gmail.com> <87hdnfwxff.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "24 Nov 2004 01:52:52 -0500" Date: Wed, 24 Nov 2004 02:16:15 -0500 Message-ID: <5059.1101280575@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/366 X-Sequence-Number: 9320 Greg Stark writes: > This could hurt if they ever reuse an old previously retired postal code, > which isn't an entirely impossible case. As far as I know it hasn't happened > yet though. One would suppose that the guys who are in charge of this point at Canada Post consider the postal code to be their primary key, and are no more eager to reuse one than you are to see it reused. Basically this comes down to "I'm going to use some externally supplied primary key as my primary key. Do I trust the upstream DBA to know what a primary key is?" regards, tom lane From pgsql-performance-owner@postgresql.org Wed Nov 24 07:35:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B66BC3A4363 for ; Wed, 24 Nov 2004 07:35:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51455-06 for ; Wed, 24 Nov 2004 07:35:03 +0000 (GMT) Received: from usbb-lacimss2.unisys.com (usbb-lacimss2.unisys.com [192.63.108.52]) by svr1.postgresql.org (Postfix) with ESMTP id 898A73A435B for ; Wed, 24 Nov 2004 07:35:03 +0000 (GMT) Received: from usbb-lacgw2.lac.uis.unisys.com ([129.226.160.22]unverified) by usbb-lacimss2 with InterScan Messaging Security Suite; Wed, 24 Nov 2004 02:38:57 -0500 Received: from usbb-lacgw2.lac.uis.unisys.com ([129.226.160.25]) by usbb-lacgw2.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.211); Wed, 24 Nov 2004 02:34:44 -0500 Received: from gbmk-eugw1.eu.uis.unisys.com ([129.221.133.28]) by usbb-lacgw2.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.211); Wed, 24 Nov 2004 02:34:44 -0500 Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by gbmk-eugw1.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.47); Wed, 24 Nov 2004 07:34:42 +0000 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: FW: Index usage Date: Wed, 24 Nov 2004 08:34:41 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] FW: Index usage Thread-Index: AcTR9KGXs27OC6pBTRGiw83/qM6ETwAAlTJQ From: "Leeuw van der, Tim" To: "BBI Edwin Punzalan" , X-OriginalArrivalTime: 24 Nov 2004 07:34:42.0256 (UTC) FILETIME=[0FEDE500:01C4D1F8] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/367 X-Sequence-Number: 9321 Well you just selected a whole lot more rows... What's the total number = of rows in the table? In general, what I remember from reading on the list, is that when = there's no upper bound on a query like this, the planner is more likely = to choose a seq. scan than an index scan. Try to give your query an upper bound like: select date from chatlogs where date>=3D'11/23/04' and date < = '12/31/99'; select date from chatlogs where date>=3D'10/23/04' and date < = '12/31/99'; This should make it easier for the planner to give a proper estimate of = the number of rows returned. If it doesn't help yet, please post = 'explain analyze' output rather than 'explain' output, for it allows = much better investigation into why the planner chooses what it chooses. cheers, --Tim -----Original Message----- From: pgsql-performance-owner@postgresql.org = [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of BBI Edwin = Punzalan Sent: Wednesday, November 24, 2004 7:52 AM To: pgsql-performance@postgresql.org Subject: [PERFORM] FW: Index usage Hi everyone, Can anyone please explain postgres' behavior on our index. I did the following query tests on our database: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D db=3D# create index chatlogs_date_idx on chatlogs (date); CREATE db=3D# explain select date from chatlogs where date>=3D'11/23/04'; NOTICE: QUERY PLAN: Index Scan using chatlogs_date_idx on chatlogs (cost=3D0.00..144.11 = rows=3D36 width=3D4) EXPLAIN db=3D# explain select date from chatlogs where date>=3D'10/23/04'; NOTICE: QUERY PLAN: Seq Scan on chatlogs (cost=3D0.00..23938.06 rows=3D253442 width=3D4) EXPLAIN=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Date's datatype is date. Its just odd that I just change the actual = date of search and the index is not being used anymore. ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Wed Nov 24 08:07:12 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 954683A433F for ; Wed, 24 Nov 2004 08:07:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61058-04 for ; Wed, 24 Nov 2004 08:07:06 +0000 (GMT) Received: from bluebamboo.ph (unknown [202.175.252.53]) by svr1.postgresql.org (Postfix) with ESMTP id D00CB3A436D for ; Wed, 24 Nov 2004 08:07:04 +0000 (GMT) Received: from irridescens ([192.168.0.180]) by bluebamboo.ph (8.11.6/8.11.6) with ESMTP id iAO882i28819 for ; Wed, 24 Nov 2004 16:08:06 +0800 From: "BBI Edwin Punzalan" To: Subject: FW: FW: Index usage Date: Wed, 24 Nov 2004 16:07:37 +0800 Message-ID: <001d01c4d1fc$ab997060$b400a8c0@bluebamboo.ph> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/368 X-Sequence-Number: 9322 Thanks, Tim. I tried adding an upper limit and its still the same as follows: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D db=3D# explain analyze select date from chatlogs where = date>=3D'11/24/04'; NOTICE: QUERY PLAN: Index Scan using chatlogs_date_idx on chatlogs (cost=3D0.00..145.72 = rows=3D37 width=3D4) (actual time=3D0.18..239.69 rows=3D10737 loops=3D1) Total runtime: 246.22 msec EXPLAIN db=3D# explain analyze select date from chatlogs where = date>=3D'11/23/04' and date<'11/24/04'; NOTICE: QUERY PLAN: Seq Scan on chatlogs (cost=3D0.00..24763.19 rows=3D9200 width=3D4) = (actual time=3D0.44..4447.01 rows=3D13029 loops=3D1) Total runtime: 4455.56 msec EXPLAIN db=3D# explain analyze select date from chatlogs where = date>=3D'11/23/04' and date<'11/25/04'; NOTICE: QUERY PLAN: Seq Scan on chatlogs (cost=3D0.00..24763.19 rows=3D9200 width=3D4) = (actual time=3D0.45..4268.00 rows=3D23787 loops=3D1) Total runtime: 4282.81 msec =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D How come a query on the current date filter uses an index and the others does not? This makes indexing to speed up queries quite difficult. -----Original Message----- From: Leeuw van der, Tim [mailto:tim.leeuwvander@nl.unisys.com]=20 Sent: Wednesday, November 24, 2004 3:35 PM To: BBI Edwin Punzalan; pgsql-performance@postgresql.org Subject: RE: [PERFORM] FW: Index usage Well you just selected a whole lot more rows... What's the total number = of rows in the table? In general, what I remember from reading on the list, is that when = there's no upper bound on a query like this, the planner is more likely to = choose a seq. scan than an index scan. Try to give your query an upper bound = like: select date from chatlogs where date>=3D'11/23/04' and date < = '12/31/99'; select date from chatlogs where date>=3D'10/23/04' and date < = '12/31/99'; This should make it easier for the planner to give a proper estimate of = the number of rows returned. If it doesn't help yet, please post 'explain analyze' output rather than 'explain' output, for it allows much better investigation into why the planner chooses what it chooses. cheers, --Tim -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of BBI Edwin Punzalan Sent: Wednesday, November 24, 2004 7:52 AM To: pgsql-performance@postgresql.org Subject: [PERFORM] FW: Index usage Hi everyone, Can anyone please explain postgres' behavior on our index. I did the following query tests on our database: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D db=3D# create index chatlogs_date_idx on chatlogs (date); CREATE db=3D# explain select date from chatlogs where date>=3D'11/23/04'; NOTICE: QUERY PLAN: Index Scan using chatlogs_date_idx on chatlogs (cost=3D0.00..144.11 = rows=3D36 width=3D4) EXPLAIN db=3D# explain select date from chatlogs where date>=3D'10/23/04'; NOTICE: QUERY PLAN: Seq Scan on chatlogs (cost=3D0.00..23938.06 rows=3D253442 width=3D4) EXPLAIN=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Date's datatype is date. Its just odd that I just change the actual = date of search and the index is not being used anymore. ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Wed Nov 24 08:14:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D8D703A4364 for ; Wed, 24 Nov 2004 08:14:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62990-06 for ; Wed, 24 Nov 2004 08:14:28 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id 3F1DA3A41A6 for ; Wed, 24 Nov 2004 08:14:28 +0000 (GMT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1CWsI6-0000mY-00; Wed, 24 Nov 2004 03:14:18 -0500 To: Tom Lane Cc: Greg Stark , Alexandre Leclerc , pgsql-performance@postgresql.org Subject: Re: Data type to use for primary key References: <1dc7f0e30411221232603c4617@mail.gmail.com> <200411221654.56673.josh@agliodbs.com> <1dc7f0e30411230829bd1ed@mail.gmail.com> <87hdnfwxff.fsf@stark.xeocode.com> <5059.1101280575@sss.pgh.pa.us> In-Reply-To: <5059.1101280575@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 24 Nov 2004 03:14:17 -0500 Message-ID: <87zn174qau.fsf@stark.xeocode.com> Lines: 46 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/369 X-Sequence-Number: 9323 Tom Lane writes: > Greg Stark writes: > > This could hurt if they ever reuse an old previously retired postal code, > > which isn't an entirely impossible case. As far as I know it hasn't happened > > yet though. > > One would suppose that the guys who are in charge of this point at > Canada Post consider the postal code to be their primary key, and > are no more eager to reuse one than you are to see it reused. Well, they may eventually be forced to. For the same sort of hierarchic issue that causes the "shortage" of IPv4 address space even though there's far less than 4 billion hosts online. But as far as I can see today the only postal codes that are being retired are rural areas that are being developed and have blocks of codes assigned instead of having a single broad code. > Basically this comes down to "I'm going to use some externally supplied > primary key as my primary key. Do I trust the upstream DBA to know what > a primary key is?" Well there's another issue here I think. Often people see something that looks unique and is clearly intended to be a primary key and think "aha, nice primary key" but they miss a subtle distinction between what the external primary key represents and what their data model is tracking. The typical example is social security numbers. SSNs are a perfectly reasonable primary key -- as long as you're tracking Social Security accounts, not people. Most people in the US have exactly one SS account, so people often think it looks like a primary key for people. In fact not everyone has a Social Security account (aliens who have never worked in the US, or for that matter people who have never been in the US) and others have had multiple Social Security accounts (victims of identity theft). Another example that comes to mind is the local telephone company. When I changed my phone number they created a new account without telling me, because their billing system's primary key for accounts is... the phone number. So all my automated bill payments started disappearing into the black hole of the old account and my new account went negative. I wonder what they do for customers who buy services from them but don't have a telephone line. -- greg From pgsql-performance-owner@postgresql.org Wed Nov 24 08:32:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F2DEB3A4380 for ; Wed, 24 Nov 2004 08:32:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 68389-05 for ; Wed, 24 Nov 2004 08:32:12 +0000 (GMT) Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) by svr1.postgresql.org (Postfix) with ESMTP id 16A353A4344 for ; Wed, 24 Nov 2004 08:32:08 +0000 (GMT) Received: from wp2000 ([157.157.176.239] [157.157.176.239]) by quasar.skima.is; Wed, 24 Nov 2004 08:32:01 Z Message-Id: <001101c4d200$6fbe6c40$0100000a@wp2000> From: "gnari" To: "BBI Edwin Punzalan" , References: <001d01c4d1fc$ab997060$b400a8c0@bluebamboo.ph> Subject: Re: FW: Index usage Date: Wed, 24 Nov 2004 08:34:38 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/370 X-Sequence-Number: 9324 From: "BBI Edwin Punzalan" > db=# explain analyze select date from chatlogs where date>='11/23/04' and > date<'11/25/04'; > NOTICE: QUERY PLAN: > > Seq Scan on chatlogs (cost=0.00..24763.19 rows=9200 width=4) (actual > time=0.45..4268.00 rows=23787 loops=1) > Total runtime: 4282.81 msec > ============== > > How come a query on the current date filter uses an index and the others > does not? This makes indexing to speed up queries quite difficult. have you ANALYZED the table lately ? what version postgres are you using ? gnari From pgsql-performance-owner@postgresql.org Wed Nov 24 09:40:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D02423A200F for ; Wed, 24 Nov 2004 09:40:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 87544-10 for ; Wed, 24 Nov 2004 09:40:01 +0000 (GMT) Received: from 163.com (unknown [202.108.44.204]) by svr1.postgresql.org (Postfix) with SMTP id CF48F3A1D89 for ; Wed, 24 Nov 2004 09:39:55 +0000 (GMT) Received: from sanqian (unknown [219.137.110.95]) by 192.168.1.204 (Coremail) with SMTP id wUCwvvdWpEG6VbwE.1 for ; Wed, 24 Nov 2004 17:40:12 +0800 (CST) X-Originating-IP: [219.137.110.95] From: "songtebo" To: pgsql-performance@postgresql.org Subject: Unsubscribe X-mailer: Foxmail 4.2 [cn] Mime-Version: 1.0 Content-Type: text/plain; charset="GB2312" Content-Transfer-Encoding: 7bit Date: Wed, 24 Nov 2004 17:36:56 +0800 Message-Id: <20041124093955.CF48F3A1D89@svr1.postgresql.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.3 tagged_above=0.0 required=5.0 tests=BLANK_LINES_70_80, DNS_FROM_RFCI_DSN X-Spam-Level: ** X-Archive-Number: 200411/371 X-Sequence-Number: 9325 Unsubscribe From pgsql-performance-owner@postgresql.org Wed Nov 24 09:43:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 907C83A3B94 for ; Wed, 24 Nov 2004 09:43:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92335-01 for ; Wed, 24 Nov 2004 09:43:20 +0000 (GMT) Received: from bluebamboo.ph (unknown [202.175.252.53]) by svr1.postgresql.org (Postfix) with ESMTP id 85B9D3A3B62 for ; Wed, 24 Nov 2004 09:43:20 +0000 (GMT) Received: from irridescens ([192.168.0.180]) by bluebamboo.ph (8.11.6/8.11.6) with ESMTP id iAO9iHi31430; Wed, 24 Nov 2004 17:44:17 +0800 From: "BBI Edwin Punzalan" To: "'gnari'" , Subject: Re: FW: Index usage Date: Wed, 24 Nov 2004 17:43:52 +0800 Message-ID: <000501c4d20a$1b842ed0$b400a8c0@bluebamboo.ph> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 In-Reply-To: <001101c4d200$6fbe6c40$0100000a@wp2000> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/372 X-Sequence-Number: 9326 Yes, the database is being vacuum-ed and analyzed on a daily basis. Our version is 7.2.1 -----Original Message----- From: gnari [mailto:gnari@simnet.is] Sent: Wednesday, November 24, 2004 4:35 PM To: BBI Edwin Punzalan; pgsql-performance@postgresql.org Subject: Re: [PERFORM] FW: Index usage From: "BBI Edwin Punzalan" > db=# explain analyze select date from chatlogs where date>='11/23/04' > and date<'11/25/04'; > NOTICE: QUERY PLAN: > > Seq Scan on chatlogs (cost=0.00..24763.19 rows=9200 width=4) (actual > time=0.45..4268.00 rows=23787 loops=1) Total runtime: 4282.81 msec > ============== > > How come a query on the current date filter uses an index and the > others does not? This makes indexing to speed up queries quite > difficult. have you ANALYZED the table lately ? what version postgres are you using ? gnari From pgsql-performance-owner@postgresql.org Wed Nov 24 10:17:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5C4103A3B9F for ; Wed, 24 Nov 2004 10:17:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99131-09 for ; Wed, 24 Nov 2004 10:16:54 +0000 (GMT) Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by svr1.postgresql.org (Postfix) with ESMTP id 67B163A3AD4 for ; Wed, 24 Nov 2004 10:16:55 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-33.mail.demon.net with esmtp (Exim 4.42) id 1CWuCk-000O8t-A9; Wed, 24 Nov 2004 10:16:54 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 23BC31652B; Wed, 24 Nov 2004 10:16:53 +0000 (GMT) Message-ID: <41A45F95.70206@archonet.com> Date: Wed, 24 Nov 2004 10:16:53 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: BBI Edwin Punzalan Cc: pgsql-performance@postgresql.org Subject: Re: FW: FW: Index usage References: <001d01c4d1fc$ab997060$b400a8c0@bluebamboo.ph> In-Reply-To: <001d01c4d1fc$ab997060$b400a8c0@bluebamboo.ph> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/373 X-Sequence-Number: 9327 BBI Edwin Punzalan wrote: > Thanks, Tim. > > I tried adding an upper limit and its still the same as follows: > > ============== > db=# explain analyze select date from chatlogs where date>='11/24/04'; > NOTICE: QUERY PLAN: > > Index Scan using chatlogs_date_idx on chatlogs (cost=0.00..145.72 rows=37 > width=4) (actual time=0.18..239.69 rows=10737 loops=1) > Total runtime: 246.22 msec > > EXPLAIN > db=# explain analyze select date from chatlogs where date>='11/23/04' and > date<'11/24/04'; > NOTICE: QUERY PLAN: > > Seq Scan on chatlogs (cost=0.00..24763.19 rows=9200 width=4) (actual > time=0.44..4447.01 rows=13029 loops=1) > Total runtime: 4455.56 msec We have two issues here 1. In the first example it only picks an index because it thinks it is going to get 37 rows, it actually gets 10737 2. It's taking 4455ms to run a seq-scan but only 246ms to run an index-scan over 10737 rows (and then fetch the rows too). Questions: 1. How many rows do you have in chatlogs? 2. Is this the only problem you are experiencing, or just one from many? 3. Have you tuned any configuration settings? e.g. as suggested in: http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Wed Nov 24 10:39:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 87FCA3A3B0F for ; Wed, 24 Nov 2004 10:39:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 09089-08 for ; Wed, 24 Nov 2004 10:39:27 +0000 (GMT) Received: from bluebamboo.ph (unknown [202.175.252.53]) by svr1.postgresql.org (Postfix) with ESMTP id EAB453A3D33 for ; Wed, 24 Nov 2004 10:39:25 +0000 (GMT) Received: from irridescens ([192.168.0.180]) by bluebamboo.ph (8.11.6/8.11.6) with ESMTP id iAOAeHi00566; Wed, 24 Nov 2004 18:40:20 +0800 From: "BBI Edwin Punzalan" To: "'Richard Huxton'" Cc: Subject: Re: FW: FW: Index usage Date: Wed, 24 Nov 2004 18:39:52 +0800 Message-ID: <000701c4d211$f039bfd0$b400a8c0@bluebamboo.ph> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 In-Reply-To: <41A45F95.70206@archonet.com> x-mimeole: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/374 X-Sequence-Number: 9328 Hi. 1) chatlogs rows increases every now and then (its in a live environment) and currently have 538,696 rows 2) this is the only problem we experienced. So far, all our other indexes are being used correctly. 3) I don't remember tuning any post-installation configuration of our postgreSQL except setting fsync to false. Thanks for taking a look at our problem. :D -----Original Message----- From: Richard Huxton [mailto:dev@archonet.com] Sent: Wednesday, November 24, 2004 6:17 PM To: BBI Edwin Punzalan Cc: pgsql-performance@postgresql.org Subject: Re: FW: [PERFORM] FW: Index usage BBI Edwin Punzalan wrote: > Thanks, Tim. > > I tried adding an upper limit and its still the same as follows: > > ============== > db=# explain analyze select date from chatlogs where date>='11/24/04'; > NOTICE: QUERY PLAN: > > Index Scan using chatlogs_date_idx on chatlogs (cost=0.00..145.72 > rows=37 > width=4) (actual time=0.18..239.69 rows=10737 loops=1) > Total runtime: 246.22 msec > > EXPLAIN > db=# explain analyze select date from chatlogs where date>='11/23/04' > and date<'11/24/04'; > NOTICE: QUERY PLAN: > > Seq Scan on chatlogs (cost=0.00..24763.19 rows=9200 width=4) (actual > time=0.44..4447.01 rows=13029 loops=1) Total runtime: 4455.56 msec We have two issues here 1. In the first example it only picks an index because it thinks it is going to get 37 rows, it actually gets 10737 2. It's taking 4455ms to run a seq-scan but only 246ms to run an index-scan over 10737 rows (and then fetch the rows too). Questions: 1. How many rows do you have in chatlogs? 2. Is this the only problem you are experiencing, or just one from many? 3. Have you tuned any configuration settings? e.g. as suggested in: http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Wed Nov 24 11:02:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C660B3A3E4F for ; Wed, 24 Nov 2004 11:02:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18039-09 for ; Wed, 24 Nov 2004 11:02:11 +0000 (GMT) Received: from anchor-post-36.mail.demon.net (anchor-post-36.mail.demon.net [194.217.242.86]) by svr1.postgresql.org (Postfix) with ESMTP id B917E3A3E44 for ; Wed, 24 Nov 2004 11:02:12 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-36.mail.demon.net with esmtp (Exim 4.42) id 1CWuuW-000Kss-M3; Wed, 24 Nov 2004 11:02:09 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id B940D170B0; Wed, 24 Nov 2004 11:02:06 +0000 (GMT) Message-ID: <41A46A2E.8030606@archonet.com> Date: Wed, 24 Nov 2004 11:02:06 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: BBI Edwin Punzalan Cc: pgsql-performance@postgresql.org Subject: Re: FW: FW: Index usage References: <000701c4d211$f039bfd0$b400a8c0@bluebamboo.ph> In-Reply-To: <000701c4d211$f039bfd0$b400a8c0@bluebamboo.ph> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/375 X-Sequence-Number: 9329 BBI Edwin Punzalan wrote: > Hi. > > 1) chatlogs rows increases every now and then (its in a live environment) > and currently have 538,696 rows OK, so as a rule of thumb I'd say if you were fetching less than 5000 rows it's bound to use an index. If more than 50,000 always use a seqscan, otherwise it'll depend on configuration settings. It looks like you settings are suggesting the cost of an index-scan vs seq-scan are greater than they are. > 2) this is the only problem we experienced. So far, all our other indexes > are being used correctly. Good. > 3) I don't remember tuning any post-installation configuration of our > postgreSQL except setting fsync to false. So long as you know why this can cause data loss. It won't affect this problem. Read that performance article I linked to in the last message, it's written by two people who know what they're talking about. The standard configuration settings are designed to work on any machine, not provide good performance. Work through the basics there and we can look at random_page_cost etc. if it's still causing you problems. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Wed Nov 24 13:19:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 28B9B3A40B3 for ; Wed, 24 Nov 2004 13:19:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62953-07 for ; Wed, 24 Nov 2004 13:19:02 +0000 (GMT) Received: from cucafera.cmima.csic.es (cucafera.cmima.csic.es [161.111.136.34]) by svr1.postgresql.org (Postfix) with ESMTP id 3218F3A4067 for ; Wed, 24 Nov 2004 13:19:03 +0000 (GMT) Received: from [161.111.136.39] (haddock.cmima.csic.es [161.111.136.39]) (authenticated bits=0) by cucafera.cmima.csic.es (8.13.1/8.13.1) with ESMTP id iAODENfY001917 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT); Wed, 24 Nov 2004 14:14:23 +0100 Subject: Postgres vs. MySQL From: Evilio del Rio To: dspam-users@networkdweebs.com Cc: pgsql-performance@postgresql.org Content-Type: text/plain Organization: CMIMA-CSIC Message-Id: <1101302058.338.74.camel@haddock.cmima.csic.es> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Wed, 24 Nov 2004 14:14:18 +0100 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/376 X-Sequence-Number: 9330 Hi, I have installed the dspam filter (http://www.nuclearelephant.com/projects/dspam) on our mail server (RedHat 7.3 Linux with sendmail 8.13 and procmail). I have ~300 users with a quite low traffic of 4000 messages/day. So it's a quite common platform/environment, nothing spectacular. First time(s) I tried the Postgres interface that was already installed for other applications. Whenever I begin to train and/or filter messages throug dspam the performance is incredibly bad. First messages are ok but soon the filter time begins to increase to about 30 seconds or more! ...so I looked for some optimization both for the linux kernel and the postgres server. Nothing has work for me. I always have the same behavior. For isolation purposes I started using another server just to hold the dspam database and nothing else. No matter what I do: postgres gets slower and slower with each new message fed or filtered. Several strategies have failed: newest RPMs from postgresql.org, pg_autovacuum, etc. I finally tried the MySQL driver. I have started using this tool right now for dspam, so I am a newcomer in MySQL. The result: after some preparation in configuring some parameters for mysqld (with the "QuickStart" Guide from mysql.com) all works fine! It's incredible! the same servers, the same messages, the same dspam compilation (well each one with the corresponding --with-storage-driver=*sql_drv). Postgres is getting worst than 30s/message and MySQL process the same in less than a second. I can surrender the Postgres server by just corpus-feeding one single short message to each user (it takes hours to process 300 users!). On the other hand, MySQL only takes a few minutes to process the same batch. I do not want to make flame over Postgres (I have always prefered it for its capabilities) but I am absolutely impressed by MySQL (I have seen the light!) Please, could anyone explain me this difference? Is Postgres that bad? Is MySQL that good? Am I the only one to have observed this behavior? TIA. Cheers, ---------------------------------------------------------------- Evilio Jose del Rio Silvan Centre Mediterrani d'Investigacions edelrio@cmima.csic.es Marines i Ambientals "Microsoft sells you Windows, Linux gives you the whole house" - Anonymous From pgsql-performance-owner@postgresql.org Wed Nov 24 14:16:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 12C203A3FFC for ; Wed, 24 Nov 2004 14:16:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85490-04 for ; Wed, 24 Nov 2004 14:16:17 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id 1E4EB3A3FF8 for ; Wed, 24 Nov 2004 14:16:19 +0000 (GMT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1CWxwN-0007Zt-00 for ; Wed, 24 Nov 2004 15:16:15 +0100 Date: Wed, 24 Nov 2004 15:16:15 +0100 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Postgres vs. MySQL Message-ID: <20041124141615.GB28960@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <1101302058.338.74.camel@haddock.cmima.csic.es> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1101302058.338.74.camel@haddock.cmima.csic.es> X-Operating-System: Linux 2.6.8.1 on a i686 User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/377 X-Sequence-Number: 9331 On Wed, Nov 24, 2004 at 02:14:18PM +0100, Evilio del Rio wrote: > It's incredible! the same servers, the same messages, the same dspam > compilation (well each one with the corresponding > --with-storage-driver=*sql_drv). Postgres is getting worst than > 30s/message and MySQL process the same in less than a second. AFAIK dspam is heavily optimized for MySQL and not optimized for PostgreSQL at all; I believe there would be significant performance boosts available by "fixing" dspam. Example queries that are slow, as well as table schemas, would probably help a lot in tracking down the problems. /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Wed Nov 24 14:27:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 375173A41E5 for ; Wed, 24 Nov 2004 14:27:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86980-08 for ; Wed, 24 Nov 2004 14:27:07 +0000 (GMT) Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by svr1.postgresql.org (Postfix) with ESMTP id 0838D3A41B1 for ; Wed, 24 Nov 2004 14:27:09 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 4.42) id 1CWy6u-000FtD-9K; Wed, 24 Nov 2004 14:27:09 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id A265C16A3C; Wed, 24 Nov 2004 14:27:07 +0000 (GMT) Message-ID: <41A49A3A.7010007@archonet.com> Date: Wed, 24 Nov 2004 14:27:06 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Evilio del Rio Cc: pgsql-performance@postgresql.org Subject: Re: Postgres vs. MySQL References: <1101302058.338.74.camel@haddock.cmima.csic.es> In-Reply-To: <1101302058.338.74.camel@haddock.cmima.csic.es> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/378 X-Sequence-Number: 9332 Evilio del Rio wrote: > Please, could anyone explain me this difference? > Is Postgres that bad? > Is MySQL that good? > Am I the only one to have observed this behavior? Do you have any record of configuration, system hardware, usage patterns, queries executed? If you can tell us what you tried (and why) then we might be able to help, otherwise there's not much information here. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Wed Nov 24 14:58:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9212D3A2B31 for ; Wed, 24 Nov 2004 14:58:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98109-10 for ; Wed, 24 Nov 2004 14:58:03 +0000 (GMT) Received: from leda.steelsun.com (dsl093-240-204.ral1.dsl.speakeasy.net [66.93.240.204]) by svr1.postgresql.org (Postfix) with ESMTP id 514E13A41A5 for ; Wed, 24 Nov 2004 14:58:06 +0000 (GMT) Received: from leda.steelsun.com (localhost [127.0.0.1]) by leda.steelsun.com (8.12.11/8.12.8) with ESMTP id iAOEvqW3022484; Wed, 24 Nov 2004 09:57:52 -0500 Received: from localhost (cfowler@localhost) by leda.steelsun.com (8.12.11/8.12.11/Submit) with ESMTP id iAOEvqsl022481; Wed, 24 Nov 2004 09:57:52 -0500 X-Authentication-Warning: leda.steelsun.com: cfowler owned process doing -bs Date: Wed, 24 Nov 2004 09:57:52 -0500 (EST) From: Christian Fowler X-X-Sender: cfowler@leda.steelsun.com To: Evilio del Rio Cc: postgresql performance list Subject: Re: Postgres vs. MySQL In-Reply-To: <1101302058.338.74.camel@haddock.cmima.csic.es> Message-ID: References: <1101302058.338.74.camel@haddock.cmima.csic.es> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/379 X-Sequence-Number: 9333 As for performance, lots of others will probably volunteer tips and techniques. In my experience, properly written and tuned applications will show only minor speed differences. I have seen several open-source apps that "support postgres" but are not well tested on it. Query optimization can cause orders of magnitude performance differences. It sounds maybe dspam is in this bucket? > > Please, could anyone explain me this difference? > Is Postgres that bad? > Is MySQL that good? > Am I the only one to have observed this behavior? I made a little chart about these about a year ago: http://www.tikipro.org/wiki/index.php?page=DatabaseComparison If speed is what you need, and data integrity / safety is not, then MySQL may be a good choice. (Aggregate statistics tables and other such calculated denormalizations). IMHO, if all you need is dpsam running *now*, then I'd say MySQL might be good choice. If you ever need to run a DB application where data integrity is mission critical, then postgres is the top of my list. [ \ / [ >X< Christian Fowler | spider AT viovio.com [ / \ http://www.viovio.com | http://www.tikipro.org From pgsql-performance-owner@postgresql.org Wed Nov 24 15:39:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1907B3A41F4 for ; Wed, 24 Nov 2004 15:39:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13578-01 for ; Wed, 24 Nov 2004 15:39:09 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.198]) by svr1.postgresql.org (Postfix) with ESMTP id C34F93A41A8 for ; Wed, 24 Nov 2004 15:39:11 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 40so44309wri for ; Wed, 24 Nov 2004 07:39:03 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=kRoTSsyfke093nhM9IADaMKAXOtKLZQ9lOMTAa43LJMi/bGaeYCbTa6tMJEFj4Neeq5xE4vmI6t/Ra9SWIKZ9w2m5QWBveIsDjNWXG3jZ3EFoAdtDN11+Q/lGbBDrA91Z23Er5tGlWLIS3kKa6NOq2P86RqzGc8sLGxsNGJPDpg= Received: by 10.54.19.4 with SMTP id 4mr3731wrs; Wed, 24 Nov 2004 07:39:03 -0800 (PST) Received: by 10.54.20.6 with HTTP; Wed, 24 Nov 2004 07:39:03 -0800 (PST) Message-ID: <1dc7f0e30411240739394eb6e9@mail.gmail.com> Date: Wed, 24 Nov 2004 10:39:03 -0500 From: Alexandre Leclerc Reply-To: Alexandre Leclerc To: pgsql-performance@postgresql.org Subject: Re: Data type to use for primary key In-Reply-To: <87hdnfwxff.fsf@stark.xeocode.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <1dc7f0e30411221232603c4617@mail.gmail.com> <200411221654.56673.josh@agliodbs.com> <1dc7f0e30411230829bd1ed@mail.gmail.com> <87hdnfwxff.fsf@stark.xeocode.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/380 X-Sequence-Number: 9334 On 24 Nov 2004 01:52:52 -0500, Greg Stark wrote: > Alexandre Leclerc writes: > > > Thanks for those tips. I'll print and keep them. So in my case, the > > product_code being varchar(24) is: > > 4 bytes + string size (so possibly up to 24) = possible 28 bytes. I > > did the good thing using a serial. For my shorter keys (4 bytes + up > > to 6 char) I will use the natural key. > > Realize that space usage is really only part of the issue. Thank you for this additionnal information. This will help out in the futur. In my situation this is a good thing to have integer key where I decided to have them. Event if I was obliged to add UNIQUE constraints to some other columns. I think they call this "candidate key" and it's still 3NF (whatever; but only if my db is correctly organised)... I try to be logical and efficient for good performance. But in the end, the time (the db will get bigger) and good EXPLAIN ANALYSE commands will help fine tuning later! This will give me more experience at that point. > Actually I see one interesting exception to my policy in my current database > schema. And I don't think I would do this one differently given the choice > either. The primary key of the postal code table is the postal code. (postal > codes are up here in the great white north like zip codes down there.) (I do understand this one, living in the province of Quebec. ;) And the great white north is still not arrived; end november! - Still, not very exceptionnal.) Regards. -- Alexandre Leclerc From pgsql-performance-owner@postgresql.org Wed Nov 24 15:57:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 410753A4297 for ; Wed, 24 Nov 2004 15:57:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27829-09 for ; Wed, 24 Nov 2004 15:57:36 +0000 (GMT) Received: from hosting.commandprompt.com (128.commandprompt.com [207.173.200.128]) by svr1.postgresql.org (Postfix) with ESMTP id 2E6133A4211 for ; Wed, 24 Nov 2004 15:57:39 +0000 (GMT) Received: from [192.168.1.20] (clbb-248.saw.net [64.146.135.248]) (authenticated bits=0) by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id iAOFvIaW018341; Wed, 24 Nov 2004 07:57:18 -0800 Message-ID: <41A4AF4C.60404@commandprompt.com> Date: Wed, 24 Nov 2004 07:57:00 -0800 From: "Joshua D. Drake" User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Evilio del Rio Cc: dspam-users@networkdweebs.com, pgsql-performance@postgresql.org Subject: Re: Postgres vs. MySQL References: <1101302058.338.74.camel@haddock.cmima.csic.es> In-Reply-To: <1101302058.338.74.camel@haddock.cmima.csic.es> Content-Type: multipart/mixed; boundary="------------020407090801000804040300" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/381 X-Sequence-Number: 9335 This is a multi-part message in MIME format. --------------020407090801000804040300 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Evilio del Rio wrote: >Hi, > >I have installed the dspam filter >(http://www.nuclearelephant.com/projects/dspam) on our mail server >(RedHat 7.3 Linux with sendmail 8.13 and procmail). I have ~300 users >with a quite low traffic of 4000 messages/day. So it's a quite common >platform/environment, nothing spectacular. > > > The problem is definately dspam. We have been through their code. The new version is much, much better than the older one but I am sure there is more work to be done. The first version we installed suffered from a well known problem: It would use smallint/bigint but would not cast or quote the where clauses and thus PostgreSQL would never use the indexes. It was also missing several indexes on appropriate columns. We offered some advice and we know that some of it was taken but we don't know which. Sincerely, Joshua D. Drake -- Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC Postgresql support, programming shared hosting and dedicated hosting. +1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com PostgreSQL Replicator -- production quality replication for PostgreSQL --------------020407090801000804040300 Content-Type: text/x-vcard; charset=utf-8; name="jd.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="jd.vcf" begin:vcard fn:Joshua Drake n:Drake;Joshua org:Command Prompt, Inc. adr:;;PO Box 215 ;Cascade Locks;OR;97014;US email;internet:jd@commandprompt.com title:Consultant tel;work:503-667-4564 tel;fax:503-210-0334 x-mozilla-html:FALSE url:http://www.commandprompt.com version:2.1 end:vcard --------------020407090801000804040300-- From pgsql-performance-owner@postgresql.org Wed Nov 24 16:06:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E684E3A41F4 for ; Wed, 24 Nov 2004 16:06:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32595-10 for ; Wed, 24 Nov 2004 16:06:26 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) by svr1.postgresql.org (Postfix) with ESMTP id 4C47F3A41BD for ; Wed, 24 Nov 2004 16:06:25 +0000 (GMT) Received: by flake.decibel.org (Postfix, from userid 1001) id B4B3D1C90B; Wed, 24 Nov 2004 16:06:23 +0000 (GMT) Date: Wed, 24 Nov 2004 10:06:23 -0600 From: "Jim C. Nasby" To: Sean Chittenden Cc: Bruce Momjian , Pierre-Fr?d?ric Caillaud , pgsql-performance@postgresql.org Subject: Re: memcached and PostgreSQL Message-ID: <20041124160623.GC41545@decibel.org> References: <200411230218.iAN2I5o22567@candle.pha.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/382 X-Sequence-Number: 9336 If instead of a select you do a select for update I think this would be transaction safe. Nothing would be able to modify the data in the database between when you do the SELECT and when you commit. If the transaction fails the value in memcached will be correct. Also, it's not clear if you're doing an update here or not... If you're doing an update then this wouldn't work. You'd want to do your update, then re-insert the value into memcached outside of the update transaction. On Tue, Nov 23, 2004 at 02:20:34PM -0800, Sean Chittenden wrote: > >My point was that there are two failure cases --- one where the cache > >is > >slightly out of date compared to the db server --- these are cases > >where > >the cache update is slightly before/after the commit. > > I was thinking about this and ways to minimize this even further. Have > memcache clients add data and have a policy to have the database only > delete data. This sets the database up as the bottleneck again, but > then you have a degree of transactionality that couldn't be previously > achieved with the database issuing replace commands. For example: > > 1) client checks the cache for data and gets a cache lookup failure > 2) client beings transaction > 3) client SELECTs data from the database > 4) client adds the key to the cache > 5) client commits transaction > > This assumes that the client won't rollback or have a transaction > failure. Again, in 50M transactions, I doubt one of them would fail > (sure, it's possible, but that's a symptom of bigger problems: > memcached isn't an RDBMS). > > The update case being: > > 1) client begins transaction > 2) client updates data > 3) database deletes record from memcache > 4) client commits transaction > 5) client adds data to memcache > > >The second is > >where the cache update happens and the commit later fails, or the > >commit > >happens and the cache update never happens. > > Having pgmemcache delete, not replace data addresses this second issue. > -sc > > -- > Sean Chittenden > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Wed Nov 24 16:26:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 842A33A42A6 for ; Wed, 24 Nov 2004 16:26:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45564-06 for ; Wed, 24 Nov 2004 16:26:33 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id D53703A42D3 for ; Wed, 24 Nov 2004 16:26:17 +0000 (GMT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1CWzyA-00083c-00 for ; Wed, 24 Nov 2004 17:26:14 +0100 Date: Wed, 24 Nov 2004 17:26:14 +0100 From: "Steinar H. Gunderson" To: postgresql performance list Subject: Re: Postgres vs. MySQL Message-ID: <20041124162614.GB30845@uio.no> Mail-Followup-To: postgresql performance list References: <1101302058.338.74.camel@haddock.cmima.csic.es> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux 2.6.8.1 on a i686 User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/383 X-Sequence-Number: 9337 On Wed, Nov 24, 2004 at 09:57:52AM -0500, Christian Fowler wrote: > As for performance, lots of others will probably volunteer tips and > techniques. In my experience, properly written and tuned applications will > show only minor speed differences. I have seen several open-source apps > that "support postgres" but are not well tested on it. Query optimization > can cause orders of magnitude performance differences. Definitely. My favourite is Request Tracker (we use 2.x, although 3.x is the latest version), which used something like 5-600 queries (all seqscans since the database schema only had an ordinary index on the varchar fields in question, and the queries were automatically searching on LOWER(field) to emulate MySQL's case-insensitivity on varchar fields) for _every_ page shown. Needless to say, the web interface was dog slow -- some index manipulation and a few bugfixes (they had some kind of cache layer which would eliminate 98% of the queries, but for some reason was broken for non-MySQL databases) later, and we were down to 3-4 index scans, a few orders of magnitude faster. :-) /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-performance-owner@postgresql.org Wed Nov 24 17:12:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C73003A4326 for ; Wed, 24 Nov 2004 17:12:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73882-01 for ; Wed, 24 Nov 2004 17:12:03 +0000 (GMT) Received: from web50001.mail.yahoo.com (web50001.mail.yahoo.com [206.190.38.16]) by svr1.postgresql.org (Postfix) with SMTP id EB1FB3A41B9 for ; Wed, 24 Nov 2004 17:12:00 +0000 (GMT) Received: (qmail 85487 invoked by uid 60001); 24 Nov 2004 17:11:57 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=KmQ4EpfoB/ak5bLDqd58g3otnBRVocaPlw+Yv2Ooqov7/bbGruTG+v+UQg3FHU+66vv/B//9s35rP9cTden8fYfLuf9B0W7lQ0Fq9S3+XF+9r4lwsxph6dLRwZc8gi/vxR5dH3hk51JtmSzf3YLWQyZGuAoXFr4HBwlVd0EgPcc= ; Message-ID: <20041124171156.85485.qmail@web50001.mail.yahoo.com> Received: from [69.65.137.210] by web50001.mail.yahoo.com via HTTP; Wed, 24 Nov 2004 11:11:56 CST Date: Wed, 24 Nov 2004 11:11:56 -0600 (CST) From: Jaime Casanova Subject: Re: [PERFORMANCE] Big number of schemas (3500) into a single database To: performance pgsql In-Reply-To: <4293.1101274362@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/384 X-Sequence-Number: 9338 --- Tom Lane escribi�: > "Constantin Teodorescu" writes: > > If I will choose to keep a mirror of every > > workstation database in a > > separate schema in the central database that mean > > that I will have 3500 different schemas. > > > Is there any limit or any barrier that could stop > > this kind of approach or make things go slower? > > Would you need to put them all into "search_path" at > once? > > I'm not sure what the scaling issues might be for > long search_paths, but I wouldn't be surprised if > it's bad. But as long as you don't do that, > I don't believe there will be any problems. > if i do a select with fully qualified table names it will search in the search_path or it will go directly to the schema? Just for know. regards, Jaime Casanova _________________________________________________________ Do You Yahoo!? Informaci�n de Estados Unidos y Am�rica Latina, en Yahoo! Noticias. Vis�tanos en http://noticias.espanol.yahoo.com From pgsql-performance-owner@postgresql.org Wed Nov 24 17:37:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 33FE93A43B9 for ; Wed, 24 Nov 2004 17:37:28 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85200-04 for ; Wed, 24 Nov 2004 17:37:15 +0000 (GMT) Received: from web54301.mail.yahoo.com (web54301.mail.yahoo.com [68.142.225.143]) by svr1.postgresql.org (Postfix) with SMTP id 1B6423A43D7 for ; Wed, 24 Nov 2004 17:37:00 +0000 (GMT) Received: (qmail 2443 invoked by uid 60001); 24 Nov 2004 17:36:59 -0000 Message-ID: <20041124173659.2441.qmail@web54301.mail.yahoo.com> Received: from [158.109.36.173] by web54301.mail.yahoo.com via HTTP; Wed, 24 Nov 2004 18:36:59 CET Date: Wed, 24 Nov 2004 18:36:59 +0100 (CET) From: sdfasdfas sdfasdfs Subject: "Group By " index usage To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/385 X-Sequence-Number: 9339 I have a table with this index: create index ARTISTS_NAME on ARTISTS ( lower(AR_NAME) ); Te index is over a colum with this definition: AR_NAME VARCHAR(256) null, I want to optimize this query: select * from artists where lower(ar_name) like lower('a%') order by lower(ar_name) limit 20; I think the planner should use the index i have. But the result of the explain command is: explain analyze select * from artists where lower(ar_name) like lower('a%') order by lower(ar_name) limit 20; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------ Limit (cost=20420.09..20420.14 rows=20 width=360) (actual time=2094.13..2094.19 rows=20 loops=1) -> Sort (cost=20420.09..20433.52 rows=5374 width=360) (actual time=2094.13..2094.16 rows=21 loops=1) Sort Key: lower((ar_name)::text) -> Index Scan using artists_name on artists (cost=0.00..19567.09 rows=5374 width=360) (actual time=0.11..1391.97 rows=59047 loops=1) Index Cond: ((lower((ar_name)::text) >= 'a'::text) AND (lower((ar_name)::text) < 'b'::text)) Filter: (lower((ar_name)::text) ~~ 'a%'::text) Total runtime: 2098.62 msec (7 rows) The "ORDER BY" clause is not using the index!. I don't know why. I have the locale configured to C, and the index works well with the "like" operator. �Could you help me? I am really lost. ______________________________________________ Renovamos el Correo Yahoo!: �100 MB GRATIS! Nuevos servicios, m�s seguridad http://correo.yahoo.es From pgsql-performance-owner@postgresql.org Wed Nov 24 17:55:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B68F43A43EE for ; Wed, 24 Nov 2004 17:55:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90233-08 for ; Wed, 24 Nov 2004 17:55:33 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id B2A483A43D5 for ; Wed, 24 Nov 2004 17:55:27 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAOHtNtT010878; Wed, 24 Nov 2004 12:55:23 -0500 (EST) To: sdfasdfas sdfasdfs Cc: pgsql-performance@postgresql.org Subject: Re: "Group By " index usage In-reply-to: <20041124173659.2441.qmail@web54301.mail.yahoo.com> References: <20041124173659.2441.qmail@web54301.mail.yahoo.com> Comments: In-reply-to sdfasdfas sdfasdfs message dated "Wed, 24 Nov 2004 18:36:59 +0100" Date: Wed, 24 Nov 2004 12:55:23 -0500 Message-ID: <10877.1101318923@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/386 X-Sequence-Number: 9340 sdfasdfas sdfasdfs writes: > I have a table with this index: > create index ARTISTS_NAME on ARTISTS ( > lower(AR_NAME) > ); > Te index is over a colum with this definition: > AR_NAME VARCHAR(256) null, > I want to optimize this query: > select * from artists where lower(ar_name) like > lower('a%') order by lower(ar_name) limit 20; > I think the planner should use the index i have. Update to 7.4, or declare the column as TEXT instead of VARCHAR. Older versions aren't very bright about situations involving implicit coercions. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Nov 25 05:57:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BDDA43A43FD for ; Wed, 24 Nov 2004 18:05:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90931-10 for ; Wed, 24 Nov 2004 18:05:30 +0000 (GMT) Received: from [63.148.146.2] (tiger.marketingsolutionsinc.com [63.148.146.2]) by svr1.postgresql.org (Postfix) with SMTP id 492F83A43F8 for ; Wed, 24 Nov 2004 18:05:29 +0000 (GMT) Received: from mail.marketingsolutionsinc.com by [63.148.146.2] via smtpd (for svr1.postgresql.org [200.46.204.71]) with SMTP; 24 Nov 2004 18:05:29 UT Received: (qmail 30334 invoked from network); 24 Nov 2004 18:05:31 -0000 Received: from unknown (HELO tiger2.marketingsolutionsinc.com) (192.168.1.28) by 0 with SMTP; 24 Nov 2004 18:05:31 -0000 Message-Id: <6.0.1.1.0.20041124114556.04b7cc80@mail.marketingsolutionsinc.com> Received: from no.name.available by tiger2.marketingsolutionsinc.com via smtpd (for mail.marketingsolutionsinc.com [192.168.2.5]) with SMTP; 24 Nov 2004 18:05:27 UT X-Sender: bstewart@mail.marketingsolutionsinc.com X-Mailer: QUALCOMM Windows Eudora Version 6.0.1.1 Date: Wed, 24 Nov 2004 11:58:06 -0600 To: pgsql-performance@postgresql.org From: Bo Stewart Subject: Hardware purchase question Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=MSGID_FROM_MTA_HEADER X-Spam-Level: X-Archive-Number: 200411/391 X-Sequence-Number: 9345 We currently are utilizing postgresql on 2 servers with the following configuration: 2 - 2.4 Ghz Xeon processors 4GB ram 4 36gb 10000rpm scsi drives configured for raid 10 We started out with one server and as we became IO bound we added the second. We are currently considering purchasing another identical server to go along with these. In addition to this we are also considering a scsi attached storage device in the 10 - 14 drive range configured for raid 10 in place of the onboard 4 drives we currently have. Daily about 30% of our data gets updated with about 2% new data. Our query load is about 60% reads and 40% writes currently. My question is what type of performance gains can I expect on average from swapping from 4 disk raid 10 to 14 disk raid 10? Could I expect to see 40 - 50% better throughput. The servers listed above are the dell 2650's which have perc 3 controllers. I have seen on this list where they are know for not performing well. So any suggestions for an attached scsi device would be greatly appreciated. Also, any thoughts on fibre channel storage devices? Thank You, Bo Stewart From pgsql-performance-owner@postgresql.org Wed Nov 24 19:10:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 49EF33A1EC1 for ; Wed, 24 Nov 2004 19:10:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41932-02 for ; Wed, 24 Nov 2004 19:10:16 +0000 (GMT) Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) by svr1.postgresql.org (Postfix) with ESMTP id E93983A1D8D for ; Wed, 24 Nov 2004 19:10:13 +0000 (GMT) Received: from wp2000 ([157.157.176.239] [157.157.176.239]) by quasar.skima.is; Wed, 24 Nov 2004 19:10:04 Z Message-Id: <002701c4d259$91b7a330$0100000a@wp2000> From: "gnari" To: "BBI Edwin Punzalan" , References: <000501c4d20a$1b842ed0$b400a8c0@bluebamboo.ph> Subject: Re: FW: Index usage Date: Wed, 24 Nov 2004 19:12:41 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/387 X-Sequence-Number: 9341 From: "BBI Edwin Punzalan" > > Yes, the database is being vacuum-ed and analyzed on a daily basis. > then you should consider increating the statistics on the date column, as the estimates were a bit off in the plan > Our version is 7.2.1 upgrade time ? gnari From pgsql-performance-owner@postgresql.org Wed Nov 24 22:51:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 871033A3E91 for ; Wed, 24 Nov 2004 22:51:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 13370-02 for ; Wed, 24 Nov 2004 22:51:18 +0000 (GMT) Received: from ms-smtp-01-eri0.ohiordc.rr.com (ms-smtp-01-smtplb.ohiordc.rr.com [65.24.5.135]) by svr1.postgresql.org (Postfix) with ESMTP id 958243A43D4 for ; Wed, 24 Nov 2004 22:51:19 +0000 (GMT) Received: from enzo.mascari.com (dhcp065-024-156-214.columbus.rr.com [65.24.156.214]) by ms-smtp-01-eri0.ohiordc.rr.com (8.12.10/8.12.7) with ESMTP id iAOMpFlv025355; Wed, 24 Nov 2004 17:51:16 -0500 (EST) Received: from [192.168.2.1] (ferrari.mascari.com [192.168.2.1]) by enzo.mascari.com (8.12.8/8.12.8) with ESMTP id iAOMpE97007747; Wed, 24 Nov 2004 17:51:14 -0500 Message-ID: <41A51061.30805@mascari.com> Date: Wed, 24 Nov 2004 17:51:13 -0500 From: Mike Mascari User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Slow execution time when querying view with WHERE clause References: <41A25C3B.3040608@mascari.com> <28237.1101232445@sss.pgh.pa.us> <41A42409.7080704@mascari.com> <4738.1101277883@sss.pgh.pa.us> In-Reply-To: <4738.1101277883@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mascari-MailScanner-Information: Please contact the ISP for more information X-Mascari-MailScanner: Found to be clean X-Mascari-MailScanner-SpamCheck: not spam, SpamAssassin (score=0, required 6, autolearn=not spam) X-MailScanner-From: mascarm@mascari.com X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/388 X-Sequence-Number: 9342 Tom Lane wrote: > Um ... doh ... analyze.c about line 1550: > > /* We can only compute valid stats if we found some non-null values. */ > if (nonnull_cnt > 0) > ... > > There's a bit of an epistemological issue here: if we didn't actually > find any nonnull values in our sample, is it legitimate to assume that > the column is entirely null? On the other hand, if we find only "3" in > our sample we will happily assume the column contains only "3", so I > dunno why we are discriminating against null. This seems like a case > that just hasn't come up before. Will this discriminatory policy toward null end for 8.0? Mike Mascari From pgsql-performance-owner@postgresql.org Thu Nov 25 01:18:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DD9643A442C for ; Thu, 25 Nov 2004 01:18:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48689-08 for ; Thu, 25 Nov 2004 01:18:22 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id 52D3E3A1D8D for ; Thu, 25 Nov 2004 01:18:24 +0000 (GMT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1CX8H9-0001DE-00 for ; Thu, 25 Nov 2004 02:18:23 +0100 Date: Thu, 25 Nov 2004 02:18:23 +0100 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Postgres vs. MySQL Message-ID: <20041125011823.GA4640@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <1101302058.338.74.camel@haddock.cmima.csic.es> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1101302058.338.74.camel@haddock.cmima.csic.es> X-Operating-System: Linux 2.6.8.1 on a i686 User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/389 X-Sequence-Number: 9343 On Wed, Nov 24, 2004 at 02:14:18PM +0100, Evilio del Rio wrote: > I have installed the dspam filter > (http://www.nuclearelephant.com/projects/dspam) on our mail server > (RedHat 7.3 Linux with sendmail 8.13 and procmail). I have ~300 users > with a quite low traffic of 4000 messages/day. So it's a quite common > platform/environment, nothing spectacular. We just had a case just like this on #postgresql. The (somewhat surprising) solution was increasing the statistics target on the "token" column to something like 200, which makes the planner choose an index scan instead of a sequential scan. For the people who did not follow the case: The culprit is a query like SELECT * FROM table WHERE token IN ('346369873476346', '4376376034', ...) (token is a numeric(20,0)) With one entry in the IN (), the cost of an index scan was estimated to 4.77; with ten entries, it was about 48, but with 574 entries the estimated cost was 513565 (!!), making the planner prefer an index scan to 574 consecutive index scans. Upping the statistics target made the planner estimate the cost to about ~4000, and thus select the index scan, which was two orders of magnitude faster. BTW, this case was with PostgreSQL 7.4.6, not 7.3 as the poster here is reporting. /* Steinar */ -- Homepage: http://www.sesse.net/ From pgsql-general-owner@postgresql.org Thu Nov 25 06:01:39 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 501253A4543 for ; Thu, 25 Nov 2004 06:01:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28773-01 for ; Thu, 25 Nov 2004 06:00:58 +0000 (GMT) Received: from gatekeeper.gmanetwork.com (mailhost.gmanetwork.com [61.9.4.50]) by svr1.postgresql.org (Postfix) with ESMTP id B29103A4531 for ; Thu, 25 Nov 2004 06:00:45 +0000 (GMT) Received: from gmanmi.tv (mailhost.gmanmi.tv [192.168.6.3]) by gatekeeper.gmanetwork.com (8.12.8/8.12.8) with ESMTP id iAP60XBV031205 for ; Thu, 25 Nov 2004 14:00:33 +0800 Received: (qmail 15183 invoked by uid 107); 25 Nov 2004 06:00:33 -0000 Received: from mail.gmanmi.tv (HELO jerome.gmanmi.tv) (192.168.6.3) by mail.gmanmi.tv with SMTP; 25 Nov 2004 06:00:33 -0000 From: JM Reply-To: jerome@gmanmi.tv To: pgsql-performance@postgresql.org Subject: HELP speed up my Postgres Date: Thu, 25 Nov 2004 14:00:32 +0800 User-Agent: KMail/1.5.4 Cc: pgsql-general@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200411251400.32752.jerome@gmanmi.tv> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/1248 X-Sequence-Number: 69328 Hi ALL, Ive been using postgres for 3 years and now we are having problems with its performance. Here are some givens.. We have 260 subscription tables per Database. We have 2 databases. Our main client has given us 250,000 mobile numbers to deactivate. -- We we are experiencing 91,000 mobile numbers to deactive it took a week to finish for 1 DB only the second DB is still in the process of deactivating Algorithm to deactivate: we loaded all subscription tables names into a table we loaded all mobile numbers to deactivate into a table SQL: update SUBSCRIPTIONTABLE set ACTIVEFLAG='Y' where mobile_num in (select mobile_num from LOADED_MOBILE_NUMBERS) the script was made is "C" COFIG FILE: # This is ARA nmimain tcpip_socket = true max_connections = 150 superuser_reserved_connections = 2 port = 5433 shared_buffers = 45600 sort_mem = 40000 max_locks_per_transaction=128 #fsync = true #wal_sync_method = fsync # # Locale settings # # (initialized by initdb -- may be changed) LC_MESSAGES = 'en_US.UTF-8' LC_MONETARY = 'en_US.UTF-8' LC_NUMERIC = 'en_US.UTF-8' LC_TIME = 'en_US.UTF-8' .. DB is being vaccumed every week my box is running on a DUAL Xeon, 15K RPM with 2 G Mem. that box is running 2 instances of PG DB. TIA, From pgsql-general-owner@postgresql.org Thu Nov 25 06:12:40 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B28493A4564 for ; Thu, 25 Nov 2004 06:12:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31554-02 for ; Thu, 25 Nov 2004 06:12:31 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.203]) by svr1.postgresql.org (Postfix) with ESMTP id 4FCCD3A4544 for ; Thu, 25 Nov 2004 06:12:29 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 71so513886wra for ; Wed, 24 Nov 2004 22:12:26 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=nyrzOSQh9eAh1cyyRndYERyRvAH4nOOm6DLKG6JdQwZTJvSe3BBFk9Iz4UKmvrmnKivjHQsoZ84ZN/rbeSy1gjf97fb4xbMJPSQS1UQVwY712kUjUzMaN9H1J/uxNp1xFBgfd5bGmmx2L4hJG3BA8Vamntqba8Mmrla7HpufsL4= Received: by 10.54.18.35 with SMTP id 35mr12074wrr; Wed, 24 Nov 2004 22:12:18 -0800 (PST) Received: by 10.54.50.31 with HTTP; Wed, 24 Nov 2004 22:12:18 -0800 (PST) Message-ID: <77b69d2104112422126218b407@mail.gmail.com> Date: Thu, 25 Nov 2004 11:42:18 +0530 From: "Vishal Kashyap @ [SaiHertz]" Reply-To: "Vishal Kashyap @ [SaiHertz]" To: jerome@gmanmi.tv Subject: Re: [PERFORM] HELP speed up my Postgres Cc: pgsql-performance@postgresql.org, pgsql-general@postgresql.org In-Reply-To: <200411251400.32752.jerome@gmanmi.tv> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <200411251400.32752.jerome@gmanmi.tv> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/1249 X-Sequence-Number: 69329 Dear JM , > Ive been using postgres for 3 years and now we are having problems with its PostgrSQL version please -- With Best Regards, Vishal Kashyap. Lead Software Developer, http://saihertz.com, http://vishalkashyap.tk From pgsql-general-owner@postgresql.org Thu Nov 25 06:30:51 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 526C13A4564 for ; Thu, 25 Nov 2004 06:30:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34003-05 for ; Thu, 25 Nov 2004 06:30:07 +0000 (GMT) Received: from gatekeeper.gmanetwork.com (mailhost.gmanetwork.com [61.9.4.50]) by svr1.postgresql.org (Postfix) with ESMTP id A48353A4529 for ; Thu, 25 Nov 2004 06:30:05 +0000 (GMT) Received: from gmanmi.tv (mailhost.gmanmi.tv [192.168.6.3]) by gatekeeper.gmanetwork.com (8.12.8/8.12.8) with ESMTP id iAP6U4BV032660 for ; Thu, 25 Nov 2004 14:30:04 +0800 Received: (qmail 18673 invoked by uid 107); 25 Nov 2004 06:30:04 -0000 Received: from mail.gmanmi.tv (HELO jerome.gmanmi.tv) (192.168.6.3) by mail.gmanmi.tv with SMTP; 25 Nov 2004 06:30:04 -0000 From: JM Reply-To: jerome@gmanmi.tv To: "Vishal Kashyap @ [SaiHertz]" Subject: Re: [PERFORM] HELP speed up my Postgres Date: Thu, 25 Nov 2004 14:29:48 +0800 User-Agent: KMail/1.5.4 Cc: pgsql-performance@postgresql.org, pgsql-general@postgresql.org References: <200411251400.32752.jerome@gmanmi.tv> <77b69d2104112422126218b407@mail.gmail.com> In-Reply-To: <77b69d2104112422126218b407@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200411251429.48440.jerome@gmanmi.tv> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/1250 X-Sequence-Number: 69330 PG Version 7.3.4 On Thursday 25 November 2004 14:12, Vishal Kashyap @ [SaiHertz] wrote: > Dear JM , > > > Ive been using postgres for 3 years and now we are having > > problems with its > > PostgrSQL version please From pgsql-general-owner@postgresql.org Thu Nov 25 06:40:10 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E1D8D3A3F98 for ; Thu, 25 Nov 2004 06:40:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34426-08 for ; Thu, 25 Nov 2004 06:39:55 +0000 (GMT) Received: from millenium.mst.co.jp (unknown [210.230.185.241]) by svr1.postgresql.org (Postfix) with ESMTP id 05DE13A448E for ; Thu, 25 Nov 2004 06:39:54 +0000 (GMT) Received: from mst1x5r347kymb (lc12114 [192.168.1.114]) by millenium.mst.co.jp (8.11.6p2/3.7W) with SMTP id iAP6diZ25901; Thu, 25 Nov 2004 15:39:44 +0900 Message-ID: <002001c4d2b9$bba0b230$7201a8c0@mst1x5r347kymb> From: "Iain" To: Cc: References: <200411251400.32752.jerome@gmanmi.tv> Subject: Re: [PERFORM] HELP speed up my Postgres Date: Thu, 25 Nov 2004 15:40:57 +0900 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/1251 X-Sequence-Number: 69331 > SQL: > update SUBSCRIPTIONTABLE set ACTIVEFLAG='Y' where mobile_num in (select > mobile_num from LOADED_MOBILE_NUMBERS) Could you try using UPDATE ... FROM (SELECT ....) AS .. style syntax? About 20 minutes ago, I changed a 8 minute update to an most instant by doing that. regards Iain From pgsql-general-owner@postgresql.org Thu Nov 25 06:55:55 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2A74A3A44A9; Thu, 25 Nov 2004 06:55:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40635-03; Thu, 25 Nov 2004 06:55:44 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id F0C083A3F98; Thu, 25 Nov 2004 06:55:42 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAP6tPJr025494; Thu, 25 Nov 2004 01:55:25 -0500 (EST) To: jerome@gmanmi.tv Cc: "Vishal Kashyap @ [SaiHertz]" , pgsql-performance@postgresql.org, pgsql-general@postgresql.org Subject: Re: [PERFORM] HELP speed up my Postgres In-reply-to: <200411251429.48440.jerome@gmanmi.tv> References: <200411251400.32752.jerome@gmanmi.tv> <77b69d2104112422126218b407@mail.gmail.com> <200411251429.48440.jerome@gmanmi.tv> Comments: In-reply-to JM message dated "Thu, 25 Nov 2004 14:29:48 +0800" Date: Thu, 25 Nov 2004 01:55:25 -0500 Message-ID: <25493.1101365725@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/1252 X-Sequence-Number: 69332 JM writes: > PG Version 7.3.4 Avoid the "IN (subselect)" construct then. 7.4 is the first release that can optimize that in any real sense. regards, tom lane From pgsql-general-owner@postgresql.org Thu Nov 25 07:06:43 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 74E003A3C83; Thu, 25 Nov 2004 07:06:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43568-05; Thu, 25 Nov 2004 07:06:28 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 06B443A4492; Thu, 25 Nov 2004 07:06:28 +0000 (GMT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 045FC2506C; Thu, 25 Nov 2004 15:06:25 +0800 (WST) Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id DA69D2506B; Thu, 25 Nov 2004 15:06:24 +0800 (WST) Message-ID: <41A58473.5020106@familyhealth.com.au> Date: Thu, 25 Nov 2004 15:06:27 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: jerome@gmanmi.tv Cc: pgsql-performance@postgresql.org, pgsql-general@postgresql.org Subject: Re: [PERFORM] HELP speed up my Postgres References: <200411251400.32752.jerome@gmanmi.tv> In-Reply-To: <200411251400.32752.jerome@gmanmi.tv> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/1254 X-Sequence-Number: 69334 > update SUBSCRIPTIONTABLE set ACTIVEFLAG='Y' where mobile_num in (select > mobile_num from LOADED_MOBILE_NUMBERS) Change to: update SUBSCRIPTIONTABLE set ACTIVEFLAG='Y' where exists (select 1 from LOADED_MOBILE_NUMBERS lmn where lmn.mobile_num=SUBSCRIPTIONTABLE.mobile_num); That should run a lot faster. Make sure you have indexes on both mobile_num columns. Chris From pgsql-general-owner@postgresql.org Thu Nov 25 06:57:09 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9B6C43A451A; Thu, 25 Nov 2004 06:57:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38749-10; Thu, 25 Nov 2004 06:56:52 +0000 (GMT) Received: from mailhub1.une.edu.au (mailhub.une.edu.au [129.180.1.122]) by svr1.postgresql.org (Postfix) with ESMTP id 427893A456D; Thu, 25 Nov 2004 06:56:51 +0000 (GMT) Received: from icarus.une.edu.au (icarus.une.edu.au [129.180.47.120]) by mailhub1.une.edu.au (Postfix) with ESMTP id 04F9E7F71; Thu, 25 Nov 2004 17:56:50 +1100 (EST) Received: from kgb ([129.180.47.225]) by icarus.une.edu.au (8.12.8/8.12.8) with SMTP id iAP6umT4026463; Thu, 25 Nov 2004 17:56:49 +1100 Date: Thu, 25 Nov 2004 18:08:30 +1100 From: Klint Gore To: jerome@gmanmi.tv Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] HELP speed up my Postgres In-Reply-To: <200411251400.32752.jerome@gmanmi.tv> References: <200411251400.32752.jerome@gmanmi.tv> Message-Id: <41A584EE111.0263KG@129.180.47.120> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver 1.25.06 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/1253 X-Sequence-Number: 69333 On Thu, 25 Nov 2004 14:00:32 +0800, JM wrote: > update SUBSCRIPTIONTABLE set ACTIVEFLAG='Y' where mobile_num in (select > mobile_num from LOADED_MOBILE_NUMBERS) does loaded_mobile_numbers have a primary key or index on mobile_num? same for subscriptiontable? have you analyzed both tables? is mobile_num the same type in both tables? how does this query compare? update SUBSCRIPTIONTABLE set ACTIVEFLAG='Y' from loaded_mobile_numbers where subscriptiontable.mobile_num = LOADED_MOBILE_NUMBERS.mobile_num klint. +---------------------------------------+-----------------+ : Klint Gore : "Non rhyming : : EMail : kg@kgb.une.edu.au : slang - the : : Snail : A.B.R.I. : possibilities : : Mail University of New England : are useless" : : Armidale NSW 2351 Australia : L.J.J. : : Fax : +61 2 6772 5376 : : +---------------------------------------+-----------------+ From pgsql-general-owner@postgresql.org Thu Nov 25 09:21:25 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 43CA73A464A for ; Thu, 25 Nov 2004 09:21:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73970-07 for ; Thu, 25 Nov 2004 09:21:10 +0000 (GMT) Received: from mx1.mail.ru (mx1.mail.ru [194.67.23.121]) by svr1.postgresql.org (Postfix) with ESMTP id 9939A3A4635 for ; Thu, 25 Nov 2004 09:21:10 +0000 (GMT) Received: from [62.133.163.106] (port=3917 helo=ws5) by mx1.mail.ru with asmtp id 1CXFoK-000J6Q-00; Thu, 25 Nov 2004 12:21:08 +0300 Message-ID: <077301c4d2d0$1608ea10$191716ac@ws5> From: "Anatoly Okishev" To: Cc: "pgsql-general" References: <200411251400.32752.jerome@gmanmi.tv> Subject: Re: HELP speed up my Postgres Date: Thu, 25 Nov 2004 14:21:00 +0500 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Spam: Not detected X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=2.0 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS, UPPERCASE_50_75 X-Spam-Level: ** X-Archive-Number: 200411/1257 X-Sequence-Number: 69337 > SQL: > update SUBSCRIPTIONTABLE set ACTIVEFLAG='Y' where mobile_num in (select > mobile_num from LOADED_MOBILE_NUMBERS) You can try this: update SUBSCRIPTIONTABLE, LOADED_MOBILE_NUMBERS set SUBSCRIPTIONTABLE.ACTIVEFLAG='Y' where LOADED_MOBILE_NUMBERS.mobile_num=SUBSCRIPTIONTABLE.mobile_num Anatoly. From pgsql-general-owner@postgresql.org Thu Nov 25 09:38:11 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 72EF13A464D for ; Thu, 25 Nov 2004 09:38:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 82011-01 for ; Thu, 25 Nov 2004 09:37:54 +0000 (GMT) Received: from mail.aknet.kg (ns1.aknet.kg [212.112.96.1]) by svr1.postgresql.org (Postfix) with ESMTP id ECB633A45DB for ; Thu, 25 Nov 2004 09:37:50 +0000 (GMT) Received: (qmail 6446 invoked by uid 91); 25 Nov 2004 09:37:43 -0000 Received: from 212.112.107.15 by mail.aknet.kg (envelope-from , uid 82) with qmail-scanner-1.23st (spamassassin: 2.64. perlscan: 1.23st. Clear:RC:1(212.112.107.15):. Processed in 0.030865 secs); 25 Nov 2004 09:37:43 -0000 X-Qmail-Scanner-Mail-From: skyer@on.kg via mail.aknet.kg X-Qmail-Scanner: 1.23st (Clear:RC:1(212.112.107.15):. Processed in 0.030865 secs Process 6441) Received: from unknown (HELO MainComputer) (212.112.107.15) by mail.aknet.kg with SMTP; 25 Nov 2004 09:37:42 -0000 Date: Thu, 25 Nov 2004 14:37:40 +0300 From: "ON.KG" X-Mailer: The Bat! (v2.01) Reply-To: "ON.KG" Organization: UnCLouds X-Priority: 3 (Normal) Message-ID: <9414883125.20041125143740@on.kg> To: pgsql-general@postgresql.org Subject: Trigger before insert In-Reply-To: <41A584EE111.0263KG@129.180.47.120> References: <200411251400.32752.jerome@gmanmi.tv> <41A584EE111.0263KG@129.180.47.120> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=UPPERCASE_50_75 X-Spam-Level: * X-Archive-Number: 200411/1261 X-Sequence-Number: 69341 Hi all, =================================== CREATE FUNCTION trigger_test_func() RETURNS trigger AS ' DECLARE cnt int4; BEGIN SELECT INTO cnt COUNT(*) FROM table_test WHERE ip = new.ip; IF cnt > 50 THEN -- THERE THE "INSERT" HAS TO BE STOPED END IF; RETURN new; END;' LANGUAGE 'plpgsql'; CREATE TRIGGER trigger_test BEFORE INSERT ON table_test FOR EACH ROW EXECUTE PROCEDURE trigger_test_func(); =================================== How could i stop Inserting record into table by some condition? Thanx! From pgsql-performance-owner@postgresql.org Thu Nov 25 12:38:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 726603A4548 for ; Thu, 25 Nov 2004 12:38:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41299-08 for ; Thu, 25 Nov 2004 12:38:33 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id C62CB3A4565 for ; Thu, 25 Nov 2004 12:38:33 +0000 (GMT) Received: (qmail 18550 invoked from network); 25 Nov 2004 12:38:19 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 25 Nov 2004 12:38:19 -0000 Message-ID: <41A5D23F.3020705@fastcrypt.com> Date: Thu, 25 Nov 2004 07:38:23 -0500 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Steinar H. Gunderson" Cc: postgresql performance list Subject: Re: Postgres vs. MySQL References: <1101302058.338.74.camel@haddock.cmima.csic.es> <20041124162614.GB30845@uio.no> In-Reply-To: <20041124162614.GB30845@uio.no> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/400 X-Sequence-Number: 9354 I did some work on RT wrt Postgres for a company and found that their was lots of room for improvement particularly if you are linking requests. The latest RT code hopefully has fixes as a result of this work. Dave Steinar H. Gunderson wrote: >On Wed, Nov 24, 2004 at 09:57:52AM -0500, Christian Fowler wrote: > > >>As for performance, lots of others will probably volunteer tips and >>techniques. In my experience, properly written and tuned applications will >>show only minor speed differences. I have seen several open-source apps >>that "support postgres" but are not well tested on it. Query optimization >>can cause orders of magnitude performance differences. >> >> > >Definitely. My favourite is Request Tracker (we use 2.x, although 3.x is the >latest version), which used something like 5-600 queries (all seqscans since >the database schema only had an ordinary index on the varchar fields in >question, and the queries were automatically searching on LOWER(field) to >emulate MySQL's case-insensitivity on varchar fields) for _every_ page shown. >Needless to say, the web interface was dog slow -- some index manipulation >and a few bugfixes (they had some kind of cache layer which would eliminate >98% of the queries, but for some reason was broken for non-MySQL databases) >later, and we were down to 3-4 index scans, a few orders of magnitude faster. >:-) > >/* Steinar */ > > -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561 From pgsql-general-owner@postgresql.org Thu Nov 25 12:55:08 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CB26E3A457E for ; Thu, 25 Nov 2004 12:54:52 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46879-02 for ; Thu, 25 Nov 2004 12:54:47 +0000 (GMT) Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net [194.217.242.88]) by svr1.postgresql.org (Postfix) with ESMTP id 974223A451C for ; Thu, 25 Nov 2004 12:54:50 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-30.mail.demon.net with esmtp (Exim 4.42) id 1CXJ95-000PSg-29; Thu, 25 Nov 2004 12:54:47 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id A03A5158FC; Thu, 25 Nov 2004 12:54:46 +0000 (GMT) Message-ID: <41A5D616.4090308@archonet.com> Date: Thu, 25 Nov 2004 12:54:46 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "ON.KG" Cc: pgsql-general@postgresql.org Subject: Re: Trigger before insert References: <200411251400.32752.jerome@gmanmi.tv> <41A584EE111.0263KG@129.180.47.120> <9414883125.20041125143740@on.kg> In-Reply-To: <9414883125.20041125143740@on.kg> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/1274 X-Sequence-Number: 69354 ON.KG wrote: > > How could i stop Inserting record into table by some condition? RETURN null when using a before trigger. Or raise an exception to abort the whole transaction. -- Richard Huxton Archonet Ltd From pgsql-general-owner@postgresql.org Thu Nov 25 13:03:01 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 790183A4493 for ; Thu, 25 Nov 2004 13:02:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49979-04 for ; Thu, 25 Nov 2004 13:02:51 +0000 (GMT) Received: from mail.aknet.kg (aknet.kg [212.112.96.1]) by svr1.postgresql.org (Postfix) with ESMTP id CA1053A3F56 for ; Thu, 25 Nov 2004 13:02:49 +0000 (GMT) Received: (qmail 23264 invoked by uid 91); 25 Nov 2004 13:02:43 -0000 Received: from 212.112.107.15 by mail.aknet.kg (envelope-from , uid 82) with qmail-scanner-1.23st (spamassassin: 2.64. perlscan: 1.23st. Clear:RC:1(212.112.107.15):. Processed in 0.041283 secs); 25 Nov 2004 13:02:43 -0000 X-Qmail-Scanner-Mail-From: skyer@on.kg via mail.aknet.kg X-Qmail-Scanner: 1.23st (Clear:RC:1(212.112.107.15):. Processed in 0.041283 secs Process 23254) Received: from unknown (HELO MainComputer) (212.112.107.15) by mail.aknet.kg with SMTP; 25 Nov 2004 13:02:43 -0000 Date: Thu, 25 Nov 2004 18:02:40 +0300 From: "ON.KG" X-Mailer: The Bat! (v2.01) Reply-To: "ON.KG" Organization: UnCLouds X-Priority: 3 (Normal) Message-ID: <11127183609.20041125180240@on.kg> To: Richard Huxton Cc: pgsql-general@postgresql.org Subject: Re: Trigger before insert In-Reply-To: <41A5D616.4090308@archonet.com> References: <200411251400.32752.jerome@gmanmi.tv> <41A584EE111.0263KG@129.180.47.120> <9414883125.20041125143740@on.kg> <41A5D616.4090308@archonet.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/1275 X-Sequence-Number: 69355 Hi! >> How could i stop Inserting record into table by some condition? RH> RETURN null when using a before trigger. Or raise an exception to abort RH> the whole transaction. Thanx ;) RETURN NULL works so as i need From pgsql-performance-owner@postgresql.org Thu Nov 25 20:35:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D7F5D3A4790 for ; Thu, 25 Nov 2004 20:35:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41256-06 for ; Thu, 25 Nov 2004 20:35:14 +0000 (GMT) Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) by svr1.postgresql.org (Postfix) with ESMTP id 9B2503A470D for ; Thu, 25 Nov 2004 20:35:15 +0000 (GMT) Received: from [192.168.1.2] (unknown [192.168.1.2]) by server.gpdnet.co.uk (Postfix) with ESMTP id 0CDEBFBBB7 for ; Thu, 25 Nov 2004 20:35:30 +0000 (GMT) Message-ID: <41A6420D.2030307@gpdnet.co.uk> Date: Thu, 25 Nov 2004 20:35:25 +0000 From: Gary Doades User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Postgres backend using huge amounts of ram Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/401 X-Sequence-Number: 9355 How much RAM can a single postgres backend use? I've just loaded a moderately sized dataset into postgres and was applying RI constraints to the tables (using pgadmin on windows). Part way though I noticed the (single) postgres backend had shot up to using 300+ MB of my RAM! The two tables are: create table reqt_dates ( reqt_date_id serial, reqt_id integer not null, reqt_date date not null, primary key (reqt_date_id) ) without oids; and create table booking_plan ( booking_plan_id serial, reqt_date_id integer not null, booking_id integer not null, booking_date date not null, datetime_from timestamp not null, datetime_to timestamp not null, primary key (booking_plan_id) ) without oids; and I was was trying to do: alter table booking_plan add foreign key ( reqt_date_id ) references reqt_dates ( reqt_date_id ) on delete cascade; Since I can't get an explain of what the alter table was doing I used this: select count(*) from booking_plan,reqt_dates where booking_plan.reqt_date_id = reqt_dates.reqt_date_id and sure enough this query caused the backend to use 300M RAM. The plan for this was: QUERY PLAN Aggregate (cost=37.00..37.00 rows=1 width=0) (actual time=123968.000..123968.000 rows=1 loops=1) -> Hash Join (cost=15.50..36.50 rows=1000 width=0) (actual time=10205.000..120683.000 rows=1657709 loops=1) Hash Cond: ("outer".reqt_date_id = "inner".reqt_date_id) -> Seq Scan on booking_plan (cost=0.00..15.00 rows=1000 width=4) (actual time=10.000..4264.000 rows=1657709 loops=1) -> Hash (cost=15.00..15.00 rows=1000 width=4) (actual time=10195.000..10195.000 rows=0 loops=1) -> Seq Scan on reqt_dates (cost=0.00..15.00 rows=1000 width=4) (actual time=0.000..6607.000 rows=2142184 loops=1) Total runtime: 124068.000 ms I then analysed the database. Note, there are no indexes at this stage except the primary keys. the same query then gave: QUERY PLAN Aggregate (cost=107213.17..107213.17 rows=1 width=0) (actual time=57002.000..57002.000 rows=1 loops=1) -> Hash Join (cost=35887.01..106384.32 rows=1657709 width=0) (actual time=9774.000..54046.000 rows=1657709 loops=1) Hash Cond: ("outer".reqt_date_id = "inner".reqt_date_id) -> Seq Scan on booking_plan (cost=0.00..22103.55 rows=1657709 width=4) (actual time=10.000..19648.000 rows=1657709 loops=1) -> Hash (cost=24355.92..24355.92 rows=2142184 width=4) (actual time=9674.000..9674.000 rows=0 loops=1) -> Seq Scan on reqt_dates (cost=0.00..24355.92 rows=2142184 width=4) (actual time=0.000..4699.000 rows=2142184 loops=1) Total runtime: 57002.000 ms This is the same set of hash joins, BUT the backend only used 30M of private RAM. Platform is Windows XP, Postgres 8.0 beta 5 shared_buffers = 4000 work_mem = 8192 Any explanations? Thanks, Gary. From pgsql-performance-owner@postgresql.org Fri Nov 26 01:37:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 61C693A2C42 for ; Fri, 26 Nov 2004 01:37:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47003-07 for ; Fri, 26 Nov 2004 01:37:41 +0000 (GMT) Received: from mail1.catalyst.net.nz (godel.catalyst.net.nz [202.49.159.12]) by svr1.postgresql.org (Postfix) with ESMTP id D85E23A485A for ; Fri, 26 Nov 2004 01:37:41 +0000 (GMT) Received: from leibniz.catalyst.net.nz ([202.49.159.7] helo=lamb.mcmillan.net.nz) by mail1.catalyst.net.nz with asmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1CXV2v-0008Gc-Sr; Fri, 26 Nov 2004 14:37:14 +1300 Received: from lamb.mcmillan.net.nz (lamb.mcmillan.net.nz [127.0.0.1]) by lamb.mcmillan.net.nz (Postfix) with ESMTP id 333A0AD98586; Fri, 26 Nov 2004 14:37:13 +1300 (NZDT) Subject: Re: Postgres vs. DSpam From: Andrew McMillan To: Evilio del Rio Cc: dspam-users@networkdweebs.com, pgsql-performance@postgresql.org In-Reply-To: <1101302058.338.74.camel@haddock.cmima.csic.es> References: <1101302058.338.74.camel@haddock.cmima.csic.es> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-wR/iCt8as4Gijcm9DmHX" Date: Fri, 26 Nov 2004 14:37:12 +1300 Message-Id: <1101433032.16058.57.camel@lamb.mcmillan.net.nz> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/402 X-Sequence-Number: 9356 --=-wR/iCt8as4Gijcm9DmHX Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2004-11-24 at 14:14 +0100, Evilio del Rio wrote: > Hi, >=20 > I have installed the dspam filter > (http://www.nuclearelephant.com/projects/dspam) on our mail server > (RedHat 7.3 Linux with sendmail 8.13 and procmail). I have ~300 users > with a quite low traffic of 4000 messages/day. So it's a quite common > platform/environment, nothing spectacular. I am using DSpam with PostgreSQL here. I have a daily job that cleans the DSpam database up, as follows: DELETE FROM dspam_token_data WHERE (innocent_hits*2) + spam_hits < 5 AND CURRENT_DATE - last_hit > 60; DELETE FROM dspam_token_data WHERE innocent_hits =3D 1 AND CURRENT_DATE - last_hit > 30; DELETE FROM dspam_token_data WHERE CURRENT_DATE - last_hit > 180; DELETE FROM dspam_signature_data WHERE CURRENT_DATE - created_on > 14; VACUUM dspam_token_data; VACUUM dspam_signature_data; I also occasionally do a "VACUUM FULL ANALYZE;" on the database as well. In all honesty though, I think that MySQL is better suited to DSpam than PostgreSQL is. > Please, could anyone explain me this difference? > Is Postgres that bad? > Is MySQL that good? > Am I the only one to have observed this behavior? I believe that what DSpam does that is not well-catered for in the way PostgreSQL operates, is that it does very frequent updates to rows in (eventually) quite large tables. In PostgreSQL the UPDATE will result internally in a new record being written, with the old record being marked as deleted. That old record won't be re-used until after a VACUUM has run, and this means that the on-disk tables will have a lot of dead rows in them quite quickly. The reason that PostgreSQL operates this way, is a direct result of the way transactional support is implemented, and it may well change in a version or two. It's got better over the last few versions, with things like pg_autovacuum, but that approach still doesn't suit some types of database updating. Cheers, Andrew. ------------------------------------------------------------------------- Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St DDI: +64(4)803-2201 MOB: +64(272)DEBIAN OFFICE: +64(4)499-2267 These PRESERVES should be FORCE-FED to PENTAGON OFFICIALS!! ------------------------------------------------------------------------- --=-wR/iCt8as4Gijcm9DmHX Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQBBpojIjJA0f48GgBIRAqcXAKDGj27hi4//BWPmcOoLjHlOZnKsZwCgujXn nht6Z8+fs6Yv8Ou6MVMVhm4= =qwcj -----END PGP SIGNATURE----- --=-wR/iCt8as4Gijcm9DmHX-- From pgsql-performance-owner@postgresql.org Fri Nov 26 03:25:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 474DD3A4922 for ; Fri, 26 Nov 2004 03:25:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91877-06 for ; Fri, 26 Nov 2004 03:25:26 +0000 (GMT) Received: from sue.samurai.com (sue.samurai.com [205.207.28.74]) by svr1.postgresql.org (Postfix) with ESMTP id 7669F3A4912 for ; Fri, 26 Nov 2004 03:25:29 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by sue.samurai.com (Postfix) with ESMTP id A8C56197F3; Thu, 25 Nov 2004 22:25:30 -0500 (EST) Received: from sue.samurai.com ([127.0.0.1]) by localhost (sue.samurai.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 26317-02; Thu, 25 Nov 2004 22:25:29 -0500 (EST) Received: from fjgateway (unknown [61.88.101.19]) by sue.samurai.com (Postfix) with ESMTP id 165EC197F2; Thu, 25 Nov 2004 22:25:27 -0500 (EST) Subject: Re: Postgres vs. DSpam From: Neil Conway To: Andrew McMillan Cc: Evilio del Rio , dspam-users@networkdweebs.com, pgsql-performance@postgresql.org In-Reply-To: <1101433032.16058.57.camel@lamb.mcmillan.net.nz> References: <1101302058.338.74.camel@haddock.cmima.csic.es> <1101433032.16058.57.camel@lamb.mcmillan.net.nz> Content-Type: text/plain Date: Fri, 26 Nov 2004 14:25:25 +1100 Message-Id: <1101439525.12697.11.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/403 X-Sequence-Number: 9357 On Fri, 2004-11-26 at 14:37 +1300, Andrew McMillan wrote: > In PostgreSQL the UPDATE will result > internally in a new record being written, with the old record being > marked as deleted. That old record won't be re-used until after a > VACUUM has run, and this means that the on-disk tables will have a lot > of dead rows in them quite quickly. Not necessarily: yes, you need a VACUUM to begin reusing the space consumed by expired tuples, but that does not mean "tables will have a lot of dead rows in them quite quickly". VACUUM does not block concurrent database activity, so you can run it as frequently as you'd like (and as your database workload requires). There is a tradeoff between the space consumed by expired tuple versions and the I/O required to do a VACUUM -- it's up to the PG admin to decide what the right balance for their database is (pg_autovacuum et al. can help make this decision). > The reason that PostgreSQL operates this way, is a direct result of the > way transactional support is implemented, and it may well change in a > version or two. I doubt it. -Neil From pgsql-general-owner@postgresql.org Fri Nov 26 08:28:55 2004 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6B38E3A49E8 for ; Fri, 26 Nov 2004 08:28:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 55596-01 for ; Fri, 26 Nov 2004 08:28:37 +0000 (GMT) Received: from gatekeeper.gmanetwork.com (mailhost.gmanetwork.com [61.9.4.50]) by svr1.postgresql.org (Postfix) with ESMTP id B86633A4902 for ; Fri, 26 Nov 2004 08:28:34 +0000 (GMT) Received: from gmanmi.tv (mailhost.gmanmi.tv [192.168.6.3]) by gatekeeper.gmanetwork.com (8.12.8/8.12.8) with ESMTP id iAQ8SWBV007462 for ; Fri, 26 Nov 2004 16:28:32 +0800 Received: (qmail 32145 invoked by uid 107); 26 Nov 2004 08:28:32 -0000 Received: from mail.gmanmi.tv (HELO jerome.gmanmi.tv) (192.168.6.3) by mail.gmanmi.tv with SMTP; 26 Nov 2004 08:28:32 -0000 From: Jerome Macaranas To: Christopher Kings-Lynne Subject: Re: [PERFORM] HELP speed up my Postgres Date: Fri, 26 Nov 2004 16:28:31 +0800 User-Agent: KMail/1.5.4 Cc: pgsql-performance@postgresql.org, pgsql-general@postgresql.org References: <200411251400.32752.jerome@gmanmi.tv> <41A58473.5020106@familyhealth.com.au> In-Reply-To: <41A58473.5020106@familyhealth.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200411261628.31249.jerome@gmanmi.tv> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=EXCUSE_16 X-Spam-Level: X-Archive-Number: 200411/1314 X-Sequence-Number: 69394 it did.. thanks.. generally a weeks process turned out to be less than a day.. On Thursday 25 November 2004 15:06, Christopher Kings-Lynne wrote: > > update SUBSCRIPTIONTABLE set ACTIVEFLAG='Y' where mobile_num in (select > > mobile_num from LOADED_MOBILE_NUMBERS) > > Change to: > > update SUBSCRIPTIONTABLE set ACTIVEFLAG='Y' where exists (select 1 from > LOADED_MOBILE_NUMBERS lmn where > lmn.mobile_num=SUBSCRIPTIONTABLE.mobile_num); > > That should run a lot faster. > > Make sure you have indexes on both mobile_num columns. > > Chris > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html -- Jerome Macaranas Systems/Network Administrator GMA New Media, Inc. Phone: (632) 9254627 loc 202 Fax: (632) 9284553 Mobile: (632) 918-9336819 jerome@gmanmi.tv Sanity is the playground for the unimaginative. DISCLAIMER: This Message may contain confidential information intended only for the use of the addressee named above. If you are not the intended recipient of this message you are hereby notified that any use, dissemination, distribution or reproduction of this message is prohibited. If you received this message in error please notify your Mail Administrator and delete this message immediately. Any views expressed in this message are those of the individual sender and may not necessarily reflect the views of GMA New Media, Inc. From pgsql-performance-owner@postgresql.org Fri Nov 26 09:12:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 514C43A44BC for ; Fri, 26 Nov 2004 09:12:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 70108-02 for ; Fri, 26 Nov 2004 09:12:18 +0000 (GMT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id 4CBA83A4336 for ; Fri, 26 Nov 2004 09:12:19 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 4.42) id 1CXc9L-000AY5-5T; Fri, 26 Nov 2004 09:12:20 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 5D695163F8; Fri, 26 Nov 2004 09:12:16 +0000 (GMT) Message-ID: <41A6F36F.80805@archonet.com> Date: Fri, 26 Nov 2004 09:12:15 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Gary Doades Cc: pgsql-performance@postgresql.org Subject: Re: Postgres backend using huge amounts of ram References: <41A6420D.2030307@gpdnet.co.uk> In-Reply-To: <41A6420D.2030307@gpdnet.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/405 X-Sequence-Number: 9359 Gary Doades wrote: > How much RAM can a single postgres backend use? > > I've just loaded a moderately sized dataset into postgres and was > applying RI constraints to the tables (using pgadmin on windows). Part > way though I noticed the (single) postgres backend had shot up to using > 300+ MB of my RAM! Oops - guess that's why they call it a Beta. My first guess was a queue of pending foreign-key checks or triggers etc. but then you go on to say... > Since I can't get an explain of what the alter table was doing I used this: > > select count(*) from booking_plan,reqt_dates where > booking_plan.reqt_date_id = reqt_dates.reqt_date_id > > and sure enough this query caused the backend to use 300M RAM. The plan > for this was: [snip] > I then analysed the database. Note, there are no indexes at this stage > except the primary keys. > > the same query then gave: [snip] > This is the same set of hash joins, BUT the backend only used 30M of > private RAM. I'm guessing in the first case that the default estimate of 1000 rows in a table means PG chooses to do the join in RAM. Once it knows there are a lot of rows it can tell not to do so. However, I thought PG was supposed to spill to disk when the memory required exceeded config-file limits. If you could reproduce a simple test case I'm sure someone would be interested in squashing this bug. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Fri Nov 26 17:13:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2F7E03A4A81 for ; Fri, 26 Nov 2004 17:13:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75735-05 for ; Fri, 26 Nov 2004 17:13:34 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id B52663A4984 for ; Fri, 26 Nov 2004 17:13:33 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: time to stop tuning? Date: Fri, 26 Nov 2004 12:13:32 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26BDD2@corpsrv2.tazznetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: time to stop tuning? Thread-Index: AcTT20FynHUCtt1OSlyEls3uKXau7g== From: "David Parker" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/406 X-Sequence-Number: 9360 We have a network application in which many clients will be executing a = mix of select/insert/update/deletes on a central postgres 7.4.5 = database, running on Solaris 9 running on dual 2.3 ghz Xeons, with 2 gig = of RAM and a RAID 10 disk. The test database is about 400 meg in size. We have tuned the postgresql.conf parameters to the point where we are = confident we have enough memory for shared buffers and for sorting. We = are still tuning SQL statements, but we're pretty sure the big wins have = been achieved. We are maxing out on the backend with 30 postmaster processes, each = taking up about 2.5-3% of the CPU. We have tested mounting the whole = database in /tmp, hence in memory, and it has made no difference in = performance, so it seems we are purely CPU bound at this point. About 70% of our time is spent in selects, and another 25% spent in = inserts/updates of a single table (about 10% out of the selects % is = against this table). Now, our application client is not doing nearly enough of it's own = caching, so a lot the work the database is doing currently is redundant, = and we are working on the client, but in the meantime we have to squeeze = as much as we can from the backend. After that long intro, I have a couple of questions: 1) Given that the data is all cached, what can we do to make sure that = postgres is generating the most efficient plans in this case? We have bumped up = effective_cache_size, but it had no effect. Also, what would the most efficient plan for in-memory data look = like? I mean, does one still look for the normal stuff - index usage, etc., or are seqscans = what we should be looking for? I've seen some stuff about updating statistics targets for specific = tables, but I'm not sure I=20 understand it, and don't know if something like that applies in this = case. I can supply some specific plans, if that would help (this email = is already too long...). 2) We have SQL test environment where we just run the SQL statements = executed by the clients (culled from the log file) in psql. In our test = environment, the same set of SQL statements runs 4X faster that the = times achieved in the test that generated our source log file. Obviously = there was a bigger load on the machine in the full test, but I'm = wondering if there are any particular diagnostics that I should be = looking at to ferret out contention. I haven't seen anything that looked = suspicious in pg_locks, but it's difficult to interpret that data when = the database is under load (at least for someone of my limited = experience). I suspect the ultimate answer to our problem will be: 1) aggressive client-side caching 2) SQL tuning 3) more backend hardware But I would grateful to hear any tips/anecdotes/experiences that others = might have from tuning similar applications. Thanks! - DAP -------------------------------------------------------------------------= --------- David Parker Tazz Networks (401) 709-5130 =A0 From pgsql-performance-owner@postgresql.org Sat Nov 27 17:54:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DEB143A4AB8 for ; Fri, 26 Nov 2004 18:31:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43559-09 for ; Fri, 26 Nov 2004 18:31:36 +0000 (GMT) Received: from server2.sitesell.com (server2.sitesell.com [216.95.221.3]) by svr1.postgresql.org (Postfix) with SMTP id 3566C3A4792 for ; Fri, 26 Nov 2004 18:31:35 +0000 (GMT) Received: (qmail 7637 invoked from network); 26 Nov 2004 18:31:31 -0000 Received: from dyn-70-236.tor.dsl.tht.net (134.22.70.236) by server2.sitesell.com with SMTP; 26 Nov 2004 18:31:31 -0000 Subject: Re: time to stop tuning? From: Rod Taylor To: David Parker Cc: Postgresql Performance In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C26BDD2@corpsrv2.tazznetworks.com> References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BDD2@corpsrv2.tazznetworks.com> Content-Type: text/plain Date: Fri, 26 Nov 2004 13:29:19 -0500 Message-Id: <1101493759.44437.302.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/411 X-Sequence-Number: 9365 On Fri, 2004-11-26 at 12:13 -0500, David Parker wrote: > > I suspect the ultimate answer to our problem will be: > > 1) aggressive client-side caching > 2) SQL tuning > 3) more backend hardware #0 might actually be using connection pooling and using cached query plans (PREPARE), disabling the statistics daemon, etc. For the plans, send us EXPLAIN ANALYZE output for each of the common queries. If you can try it, I'd give a try at FreeBSD or a newer Linux on your system instead of Solaris. Older versions of Solaris had not received the same amount of attention for Intel hardware as the BSDs and Linux have and I would imagine (having not tested it recently) that this is still true for 32bit Intel. Another interesting test might be to limit the number of simultaneous connections to 8 instead of 30 (client side connection retry) after client side connection pooling via pgpool or similar has been installed. Please report back with your findings. -- Rod Taylor From pgsql-performance-owner@postgresql.org Fri Nov 26 19:04:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0D4233A4ABA for ; Fri, 26 Nov 2004 19:04:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15007-06 for ; Fri, 26 Nov 2004 19:04:38 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3CC7E3A49EC for ; Fri, 26 Nov 2004 19:04:37 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAQJ4ZYT010505; Fri, 26 Nov 2004 14:04:36 -0500 (EST) To: "David Parker" Cc: pgsql-performance@postgresql.org Subject: Re: time to stop tuning? In-reply-to: <07FDEE0ED7455A48AC42AC2070EDFF7C26BDD2@corpsrv2.tazznetworks.com> References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BDD2@corpsrv2.tazznetworks.com> Comments: In-reply-to "David Parker" message dated "Fri, 26 Nov 2004 12:13:32 -0500" Date: Fri, 26 Nov 2004 14:04:35 -0500 Message-ID: <10504.1101495875@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/407 X-Sequence-Number: 9361 "David Parker" writes: > 1) Given that the data is all cached, what can we do to make sure that > postgres is generating the most efficient plans in this case? We have > bumped up effective_cache_size, but it had no effect. If you're willing to bet on everything being in RAM all the time, dropping random_page_cost to 1 would be a theoretically sound thing to do. In any case you should look at reducing it considerably from the default setting of 4. Something that might also be interesting is to try increasing all the cpu_xxx cost factors, on the theory that since the unit of measurement (1 sequential page fetch) relates to an action involving no actual I/O, the relative costs of invoking an operator, etc, should be rated higher than when you expect actual I/O. I'm not real confident that this would make things better --- you might find that any improvement would be swamped by the low accuracy with which we model CPU costs (such as the assumption that every operator costs the same to evaluate). But it's worth some experimentation. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Nov 26 19:16:15 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 59BC53A4AD3 for ; Fri, 26 Nov 2004 19:16:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18503-03 for ; Fri, 26 Nov 2004 19:16:10 +0000 (GMT) Received: from corpsrv2.tazznetworks.com (wsip-66-210-115-146.ri.ri.cox.net [66.210.115.146]) by svr1.postgresql.org (Postfix) with ESMTP id 8B71C3A3BA2 for ; Fri, 26 Nov 2004 19:16:10 +0000 (GMT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C4D3EC.62EAF887" Subject: Re: time to stop tuning? Date: Fri, 26 Nov 2004 14:16:09 -0500 Message-ID: <07FDEE0ED7455A48AC42AC2070EDFF7C26BDDF@corpsrv2.tazznetworks.com> X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] time to stop tuning? Thread-Index: AcTT5ijpwhjnp87oT7WOcx8gGdo2WQABKB6A From: "David Parker" To: "Rod Taylor" Cc: "Postgresql Performance" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/408 X-Sequence-Number: 9362 This is a multi-part message in MIME format. ------_=_NextPart_001_01C4D3EC.62EAF887 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi. Thanks for responding. As it happens, the client-side already has a connection pool.=20 We need statistics enabled so that autovacuum can run (without autovacuum running our updates begin to kill us pretty quickly). Moving off of Solaris 9 isn't an option, even for the purposes of comparison, unfortunately. On limiting the client side connections: we've been gradually pushing up the client-side connection pool and threads, and have seen steady improvement in our throughput up to the current barrier we have reached. I guess the idea would be that backing off on the connections would allow each operation to finish faster, but that hasn't been the observed behavior so far.=20 I've attached the plans for the 4 queries that represent ~35% of our load. These are run against the same dataset, but without any other load. Another big query basically requires a test to be runnning because the data is transient, and I can't run that at the moment. The times for the individual queries is really fine - it's just they are called 3 times for every logical "unit of work" on the client side, so they are called thousands of times in a given test (hence the need for client caching). Thanks. - DAP >-----Original Message----- >From: Rod Taylor [mailto:rbt@sitesell.com]=20 >Sent: Friday, November 26, 2004 1:29 PM >To: David Parker >Cc: Postgresql Performance >Subject: Re: [PERFORM] time to stop tuning? > >On Fri, 2004-11-26 at 12:13 -0500, David Parker wrote: >>=20 >> I suspect the ultimate answer to our problem will be: >>=20 >> 1) aggressive client-side caching >> 2) SQL tuning >> 3) more backend hardware > >#0 might actually be using connection pooling and using cached=20 >query plans (PREPARE), disabling the statistics daemon, etc. > >For the plans, send us EXPLAIN ANALYZE output for each of the=20 >common queries. > >If you can try it, I'd give a try at FreeBSD or a newer Linux=20 >on your system instead of Solaris. Older versions of Solaris=20 >had not received the same amount of attention for Intel=20 >hardware as the BSDs and Linux have and I would imagine=20 >(having not tested it recently) that this is still true for=20 >32bit Intel. > >Another interesting test might be to limit the number of=20 >simultaneous connections to 8 instead of 30 (client side=20 >connection retry) after client side connection pooling via=20 >pgpool or similar has been installed. > >Please report back with your findings. >-- >Rod Taylor > > ------_=_NextPart_001_01C4D3EC.62EAF887 Content-Type: text/plain; name="plan.txt" Content-Transfer-Encoding: base64 Content-Description: plan.txt Content-Disposition: attachment; filename="plan.txt" ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBRVUVSWSBQTEFOICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQogTmVzdGVkIExvb3AgIChjb3N0PTIuMzgu LjEwLjkzIHJvd3M9MSB3aWR0aD05MykgKGFjdHVhbCB0aW1lPTAuNTAxLi4wLjUyMiByb3dzPTEg bG9vcHM9MSkKICAgSm9pbiBGaWx0ZXI6IChzdWJwbGFuKQogICAtPiAgSGFzaCBKb2luICAoY29z dD0xLjA2Li4yLjE1IHJvd3M9MSB3aWR0aD0zNikgKGFjdHVhbCB0aW1lPTAuMDk3Li4wLjEwOSBy b3dzPTEgbG9vcHM9MSkKICAgICAgICAgSGFzaCBDb25kOiAoIm91dGVyIi5pZCA9ICJpbm5lciIu ZGV2aWNldHlwZSkKICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIGRldmljZXR5cGUgZHQgIChjb3N0 PTAuMDAuLjEuMDUgcm93cz01IHdpZHRoPTM2KSAoYWN0dWFsIHRpbWU9MC4wMDMuLjAuMDA5IHJv d3M9NSBsb29wcz0xKQogICAgICAgICAtPiAgSGFzaCAgKGNvc3Q9MS4wNi4uMS4wNiByb3dzPTEg d2lkdGg9MzYpIChhY3R1YWwgdGltZT0wLjAzNy4uMC4wMzcgcm93cz0wIGxvb3BzPTEpCiAgICAg ICAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBkZXZpY2UgZCAgKGNvc3Q9MC4wMC4uMS4wNiByb3dz PTEgd2lkdGg9MzYpIChhY3R1YWwgdGltZT0wLjAxOC4uMC4wMjEgcm93cz0xIGxvb3BzPTEpCiAg ICAgICAgICAgICAgICAgICAgIEZpbHRlcjogKChuYW1lKTo6dGV4dCA9ICdwZXJmdG9vbEJBUyc6 OnRleHQpCiAgIC0+ICBIYXNoIEpvaW4gIChjb3N0PTEuMzEuLjYuMTEgcm93cz0yIHdpZHRoPTEy OSkgKGFjdHVhbCB0aW1lPTAuMTcyLi4wLjI1MyByb3dzPTIgbG9vcHM9MSkKICAgICAgICAgSGFz aCBDb25kOiAoIm91dGVyIi5kZXZpY2VydWxlID0gImlubmVyIi5pZCkKICAgICAgICAgLT4gIFNl cSBTY2FuIG9uIGRldmljZXNjcmlwdCBkcyAgKGNvc3Q9MC4wMC4uNC41NSByb3dzPTQ0IHdpZHRo PTE2NSkgKGFjdHVhbCB0aW1lPTAuMDA3Li4wLjA3NCByb3dzPTQ0IGxvb3BzPTEpCiAgICAgICAg ICAgICAgIEZpbHRlcjogKChzY3JpcHR0eXBlKTo6dGV4dCA9ICdDTEknOjp0ZXh0KQogICAgICAg ICAtPiAgSGFzaCAgKGNvc3Q9MS4zMS4uMS4zMSByb3dzPTEgd2lkdGg9MzYpIChhY3R1YWwgdGlt ZT0wLjA2NS4uMC4wNjUgcm93cz0wIGxvb3BzPTEpCiAgICAgICAgICAgICAgIC0+ICBTZXEgU2Nh biBvbiBkZXZpY2VydWxlIGRyICAoY29zdD0wLjAwLi4xLjMxIHJvd3M9MSB3aWR0aD0zNikgKGFj dHVhbCB0aW1lPTAuMDA4Li4wLjAyMSByb3dzPTEgbG9vcHM9MSkKICAgICAgICAgICAgICAgICAg ICAgRmlsdGVyOiAoKG5hbWUpOjp0ZXh0ID0gJzI1NmtfZG93bnN0cmVhbSc6OnRleHQpCiAgIFN1 YlBsYW4KICAgICAtPiAgU2VxIFNjYW4gb24gZGV2aWNlc2NyaXB0X2RldmljZXR5cGUgZHNkdCAg KGNvc3Q9MC4wMC4uMi42MiByb3dzPTEwIHdpZHRoPTM2KSAoYWN0dWFsIHRpbWU9MC4wMDUuLjAu MDUzIHJvd3M9MTggbG9vcHM9MikKICAgICAgICAgICBGaWx0ZXI6IChwb3NzZXNzaW9uID0gJDAp CiBUb3RhbCBydW50aW1lOiAwLjY0NyBtcwooMTkgcm93cykKCiAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFFVRVJZIFBMQU4gICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCi0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tCiBIYXNoIEpvaW4gIChjb3N0PTIuMTYuLjMuMjUgcm93cz0xIHdpZHRoPTMzNCkgKGFjdHVh bCB0aW1lPTAuMDg0Li4wLjA5NiByb3dzPTEgbG9vcHM9MSkKICAgSGFzaCBDb25kOiAoIm91dGVy Ii5pZCA9ICJpbm5lciIuZGV2aWNldHlwZSkKICAgLT4gIFNlcSBTY2FuIG9uIGRldmljZXR5cGUg ZHQgIChjb3N0PTAuMDAuLjEuMDUgcm93cz01IHdpZHRoPTY3KSAoYWN0dWFsIHRpbWU9MC4wMDIu LjAuMDA3IHJvd3M9NSBsb29wcz0xKQogICAtPiAgSGFzaCAgKGNvc3Q9Mi4xNi4uMi4xNiByb3dz PTEgd2lkdGg9MzM5KSAoYWN0dWFsIHRpbWU9MC4wNjYuLjAuMDY2IHJvd3M9MCBsb29wcz0xKQog ICAgICAgICAtPiAgSGFzaCBKb2luICAoY29zdD0xLjA2Li4yLjE2IHJvd3M9MSB3aWR0aD0zMzkp IChhY3R1YWwgdGltZT0wLjA0Ny4uMC4wNjIgcm93cz0xIGxvb3BzPTEpCiAgICAgICAgICAgICAg IEhhc2ggQ29uZDogKCJvdXRlciIuZGV2aWNlID0gImlubmVyIi5pZCkKICAgICAgICAgICAgICAg LT4gIFNlcSBTY2FuIG9uIG1nbXRwcm90b2NvbCBtcCAgKGNvc3Q9MC4wMC4uMS4wNiByb3dzPTUg d2lkdGg9MzI3KSAoYWN0dWFsIHRpbWU9MC4wMDQuLjAuMDEwIHJvd3M9NSBsb29wcz0xKQogICAg ICAgICAgICAgICAgICAgICBGaWx0ZXI6ICgoInR5cGUiKTo6dGV4dCA9ICdDTEknOjp0ZXh0KQog ICAgICAgICAgICAgICAtPiAgSGFzaCAgKGNvc3Q9MS4wNi4uMS4wNiByb3dzPTEgd2lkdGg9ODQp IChhY3R1YWwgdGltZT0wLjAyNC4uMC4wMjQgcm93cz0wIGxvb3BzPTEpCiAgICAgICAgICAgICAg ICAgICAgIC0+ICBTZXEgU2NhbiBvbiBkZXZpY2UgZCAgKGNvc3Q9MC4wMC4uMS4wNiByb3dzPTEg d2lkdGg9ODQpIChhY3R1YWwgdGltZT0wLjAxNy4uMC4wMTkgcm93cz0xIGxvb3BzPTEpCiAgICAg ICAgICAgICAgICAgICAgICAgICAgIEZpbHRlcjogKChpcGFkZHJlc3MpOjp0ZXh0ID0gJzEwLjEu MTAuNjAnOjp0ZXh0KQogVG90YWwgcnVudGltZTogMC4xNzYgbXMKKDEyIHJvd3MpCgogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBRVUVSWSBQTEFO ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAot LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLQogSGFzaCBKb2luICAoY29zdD0xLjMxLi4zLjc3IHJvd3M9MiB3aWR0aD0xNikgKGFjdHVh bCB0aW1lPTAuMTE3Li4wLjE3NCByb3dzPTEgbG9vcHM9MSkKICAgSGFzaCBDb25kOiAoIm91dGVy Ii5kZXZpY2VydWxlID0gImlubmVyIi5pZCkKICAgLT4gIFNlcSBTY2FuIG9uIGRldnJ1bGVwYXJh bWV0ZXIgZHJwICAoY29zdD0wLjAwLi4yLjI5IHJvd3M9Mjkgd2lkdGg9NTIpIChhY3R1YWwgdGlt ZT0wLjAwNC4uMC4wMzQgcm93cz0yOSBsb29wcz0xKQogICAtPiAgSGFzaCAgKGNvc3Q9MS4zMS4u MS4zMSByb3dzPTEgd2lkdGg9MzYpIChhY3R1YWwgdGltZT0wLjAzNS4uMC4wMzUgcm93cz0wIGxv b3BzPTEpCiAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBkZXZpY2VydWxlIGRyICAoY29zdD0wLjAw Li4xLjMxIHJvd3M9MSB3aWR0aD0zNikgKGFjdHVhbCB0aW1lPTAuMDE2Li4wLjAzMCByb3dzPTEg bG9vcHM9MSkKICAgICAgICAgICAgICAgRmlsdGVyOiAoKG5hbWUpOjp0ZXh0ID0gJzI1NmtfZG93 bnN0cmVhbSc6OnRleHQpCiBUb3RhbCBydW50aW1lOiAwLjIyMSBtcwooNyByb3dzKQoKICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBRVUVSWSBQTEFO ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0K IEhhc2ggSm9pbiAgKGNvc3Q9MS4wNi4uMi4xNSByb3dzPTEgd2lkdGg9MTQpIChhY3R1YWwgdGlt ZT0wLjA1My4uMC4wNTMgcm93cz0wIGxvb3BzPTEpCiAgIEhhc2ggQ29uZDogKCJvdXRlciIuZGV2 aWNldHlwZSA9ICJpbm5lciIuaWQpCiAgIC0+ICBTZXEgU2NhbiBvbiBkZXZpY2UgZCAgKGNvc3Q9 MC4wMC4uMS4wNSByb3dzPTUgd2lkdGg9NTApIChhY3R1YWwgdGltZT0wLjAwMi4uMC4wMDggcm93 cz01IGxvb3BzPTEpCiAgIC0+ICBIYXNoICAoY29zdD0xLjA2Li4xLjA2IHJvd3M9MSB3aWR0aD0z NikgKGFjdHVhbCB0aW1lPTAuMDE3Li4wLjAxNyByb3dzPTAgbG9vcHM9MSkKICAgICAgICAgLT4g IFNlcSBTY2FuIG9uIGRldmljZXR5cGUgZHQgIChjb3N0PTAuMDAuLjEuMDYgcm93cz0xIHdpZHRo PTM2KSAoYWN0dWFsIHRpbWU9MC4wMTUuLjAuMDE1IHJvd3M9MCBsb29wcz0xKQogICAgICAgICAg ICAgICBGaWx0ZXI6ICgodmVuZG9yKTo6dGV4dCA9ICdQLUN1YmUnOjp0ZXh0KQogVG90YWwgcnVu dGltZTogMC4xMDIgbXMKKDcgcm93cykK ------_=_NextPart_001_01C4D3EC.62EAF887-- From pgsql-performance-owner@postgresql.org Fri Nov 26 19:25:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9C9503A4ABB for ; Fri, 26 Nov 2004 19:25:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20523-06 for ; Fri, 26 Nov 2004 19:25:39 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8D0F63A4ADB for ; Fri, 26 Nov 2004 19:25:39 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAQJPZc2010677; Fri, 26 Nov 2004 14:25:35 -0500 (EST) To: Gary Doades Cc: pgsql-performance@postgresql.org Subject: Re: Postgres backend using huge amounts of ram In-reply-to: <41A6420D.2030307@gpdnet.co.uk> References: <41A6420D.2030307@gpdnet.co.uk> Comments: In-reply-to Gary Doades message dated "Thu, 25 Nov 2004 20:35:25 +0000" Date: Fri, 26 Nov 2004 14:25:34 -0500 Message-ID: <10676.1101497134@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/409 X-Sequence-Number: 9363 Gary Doades writes: > I've just loaded a moderately sized dataset into postgres and was > applying RI constraints to the tables (using pgadmin on windows). Part > way though I noticed the (single) postgres backend had shot up to using > 300+ MB of my RAM! > Since I can't get an explain of what the alter table was doing I used this: [ looks in code... ] The test query for an ALTER ADD FOREIGN KEY looks like SELECT fk.keycols FROM ONLY relname fk LEFT OUTER JOIN ONLY pkrelname pk ON (pk.pkkeycol1=fk.keycol1 [AND ...]) WHERE pk.pkkeycol1 IS NULL AND (fk.keycol1 IS NOT NULL [AND ...]) It's also worth noting that work_mem is temporarily set to maintenance_work_mem, which you didn't tell us the value of: /* * Temporarily increase work_mem so that the check query can be * executed more efficiently. It seems okay to do this because the * query is simple enough to not use a multiple of work_mem, and one * typically would not have many large foreign-key validations * happening concurrently. So this seems to meet the criteria for * being considered a "maintenance" operation, and accordingly we use * maintenance_work_mem. */ > I then analysed the database. ... > This is the same set of hash joins, BUT the backend only used 30M of > private RAM. My recollection is that hash join chooses hash table partitions partly on the basis of the estimated number of input rows. Since the estimate was way off, the actual table size got out of hand a bit :-( regards, tom lane From pgsql-performance-owner@postgresql.org Fri Nov 26 19:42:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BE4823A4B02 for ; Fri, 26 Nov 2004 19:42:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44182-09 for ; Fri, 26 Nov 2004 19:42:42 +0000 (GMT) Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) by svr1.postgresql.org (Postfix) with ESMTP id F27A63A4ACB for ; Fri, 26 Nov 2004 19:42:41 +0000 (GMT) Received: from [192.168.1.2] (unknown [192.168.1.2]) by server.gpdnet.co.uk (Postfix) with ESMTP id DC46FFBBB7; Fri, 26 Nov 2004 19:42:56 +0000 (GMT) Message-ID: <41A7873A.7000202@gpdnet.co.uk> Date: Fri, 26 Nov 2004 19:42:50 +0000 From: Gary Doades User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Postgres backend using huge amounts of ram References: <41A6420D.2030307@gpdnet.co.uk> <10676.1101497134@sss.pgh.pa.us> In-Reply-To: <10676.1101497134@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/410 X-Sequence-Number: 9364 Tom Lane wrote: > > It's also worth noting that work_mem is temporarily set to > maintenance_work_mem, which you didn't tell us the value of: > It's left at the default. (16384). This would be OK if that is all it used for this type of thing. > > > My recollection is that hash join chooses hash table partitions partly > on the basis of the estimated number of input rows. Since the estimate > was way off, the actual table size got out of hand a bit :-( A bit!! The really worrying bit is that a normal (ish) query also exhibited the same behaviour. I'm a bit worried that if the stats get a bit out of date so that the estimate is off, as in this case, a few backends trying to get this much RAM will see the server grind to a halt. Is this a fixable bug? It seems a fairly high priority, makes the server go away, type bug to me. If you need the test data, I could zip the two tables up and send them somewhere.... Thanks, Gary. From pgsql-performance-owner@postgresql.org Sat Nov 27 17:54:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B83C23A4B0F for ; Fri, 26 Nov 2004 20:35:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16502-08 for ; Fri, 26 Nov 2004 20:35:34 +0000 (GMT) Received: from malasada.lava.net (malasada.lava.net [64.65.64.17]) by svr1.postgresql.org (Postfix) with ESMTP id C586A3A4B07 for ; Fri, 26 Nov 2004 20:35:32 +0000 (GMT) Received: by malasada.lava.net (Postfix, from userid 102) id F0017153882; Fri, 26 Nov 2004 10:35:31 -1000 (HST) Date: Fri, 26 Nov 2004 10:35:31 -1000 From: Clifton Royston To: Evilio del Rio Cc: dspam-users@networkdweebs.com, pgsql-performance@postgresql.org Subject: Re: [dspam-users] Postgres vs. MySQL Message-ID: <20041126203531.GC8991@tikitechnologies.com> References: <1101302058.338.74.camel@haddock.cmima.csic.es> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1101302058.338.74.camel@haddock.cmima.csic.es> User-Agent: Mutt/1.4.2i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/413 X-Sequence-Number: 9367 On Wed, Nov 24, 2004 at 02:14:18PM +0100, Evilio del Rio wrote: > I have installed the dspam filter > (http://www.nuclearelephant.com/projects/dspam) on our mail server > (RedHat 7.3 Linux with sendmail 8.13 and procmail). I have ~300 users > with a quite low traffic of 4000 messages/day. So it's a quite common > platform/environment, nothing spectacular. > > First time(s) I tried the Postgres interface that was already installed > for other applications. Whenever I begin to train and/or filter > messages throug dspam the performance is incredibly bad. First messages > are ok but soon the filter time begins to increase to about 30 seconds > or more! > > ...so I looked for some optimization both for the linux kernel and the > postgres server. Nothing has work for me. I always have the same > behavior. For isolation purposes I started using another server just to > hold the dspam database and nothing else. No matter what I do: postgres > gets slower and slower with each new message fed or filtered. I know *somewhere* I recently read something indicating a critical configuration change for DSPAM + Postgres, but don't think I've seen it mentioned on this list. Possibly it is in the UPGRADING instructions for 3.2.1, or in a README file there. At any rate, it mentioned that it was essential to make some change to the table layout used by previous versions of DSPAM, and then Postgres would run many times faster. Unfortunately I no longer have 3.2.1 installed on my system, so I can't tell you if it was in there or somewhere else. -- Clifton -- Clifton Royston -- cliftonr@tikitechnologies.com Tiki Technologies Lead Programmer/Software Architect Did you ever fly a kite in bed? Did you ever walk with ten cats on your head? Did you ever milk this kind of cow? Well we can do it. We know how. If you never did, you should. These things are fun, and fun is good. -- Dr. Seuss From pgsql-performance-owner@postgresql.org Sat Nov 27 17:54:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AEF1A3A4B04 for ; Fri, 26 Nov 2004 21:50:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51041-09 for ; Fri, 26 Nov 2004 21:50:52 +0000 (GMT) Received: from server2.sitesell.com (server2.sitesell.com [216.95.221.3]) by svr1.postgresql.org (Postfix) with SMTP id D62043A4B41 for ; Fri, 26 Nov 2004 21:50:52 +0000 (GMT) Received: (qmail 14939 invoked from network); 26 Nov 2004 21:50:51 -0000 Received: from dyn-70-236.tor.dsl.tht.net (134.22.70.236) by server2.sitesell.com with SMTP; 26 Nov 2004 21:50:51 -0000 Subject: Re: time to stop tuning? From: Rod Taylor To: David Parker Cc: Postgresql Performance In-Reply-To: <07FDEE0ED7455A48AC42AC2070EDFF7C26BDDF@corpsrv2.tazznetworks.com> References: <07FDEE0ED7455A48AC42AC2070EDFF7C26BDDF@corpsrv2.tazznetworks.com> Content-Type: text/plain Date: Fri, 26 Nov 2004 16:48:40 -0500 Message-Id: <1101505720.13382.2.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/412 X-Sequence-Number: 9366 > On limiting the client side connections: we've been gradually pushing up > the client-side connection pool and threads, and have seen steady > improvement in our throughput up to the current barrier we have reached. Very well.. Sometimes more simultaneous workers helps, other times it hinders. > I've attached the plans for the 4 queries that represent ~35% of our > load. These are run against the same dataset, but without any other > load. Another big query basically requires a test to be runnning because Those aren't likely from your production system as there isn't any data in those tables and the queries took less than 1ms. -- Rod Taylor From pgsql-performance-owner@postgresql.org Sat Nov 27 17:54:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C3BC23A4BBF for ; Sat, 27 Nov 2004 02:10:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06183-09 for ; Sat, 27 Nov 2004 02:09:51 +0000 (GMT) Received: from midgard.osss.net (unknown [216.32.91.68]) by svr1.postgresql.org (Postfix) with ESMTP id BDE123A4BB9 for ; Sat, 27 Nov 2004 02:09:53 +0000 (GMT) Received: (qmail 9143 invoked by uid 81); 26 Nov 2004 18:11:13 -0800 Received: from 206.63.123.15 (SquirrelMail authenticated user cshobe@osss.net); by osss.net with HTTP; Fri, 26 Nov 2004 18:11:13 -0800 (PST) Message-ID: <35118.206.63.123.15.1101521473.squirrel@206.63.123.15> In-Reply-To: <20041126203531.GC8991@tikitechnologies.com> References: <1101302058.338.74.camel@haddock.cmima.csic.es> <20041126203531.GC8991@tikitechnologies.com> Date: Fri, 26 Nov 2004 18:11:13 -0800 (PST) Subject: Re: [dspam-users] Postgres vs. MySQL From: "Casey Allen Shobe" To: "Clifton Royston" Cc: "Evilio del Rio" , dspam-users@networkdweebs.com, pgsql-performance@postgresql.org User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/414 X-Sequence-Number: 9368 I posted about this a couple days ago on dspam-dev... I am using DSpam with PostgreSQL, and like you discovered the horrible performance. The reason is because the default PostgreSQL query planner settings determine that a sequence scan will be more efficient than an index scan, which is wrong. To correct this behavior, adjust the query planner settings for the appropriate table/column with this command: alter table "dspam_token_data" alter "token" set statistics 200; analyze; Let me know if it help you. It worked wonders for me. -- Casey Allen Shobe cshobe@osss.net On Fri, November 26, 2004 12:35 pm, Clifton Royston said: > On Wed, Nov 24, 2004 at 02:14:18PM +0100, Evilio del Rio wrote: >> I have installed the dspam filter >> (http://www.nuclearelephant.com/projects/dspam) on our mail server >> (RedHat 7.3 Linux with sendmail 8.13 and procmail). I have ~300 users >> with a quite low traffic of 4000 messages/day. So it's a quite common >> platform/environment, nothing spectacular. >> >> First time(s) I tried the Postgres interface that was already installed >> for other applications. Whenever I begin to train and/or filter >> messages throug dspam the performance is incredibly bad. First messages >> are ok but soon the filter time begins to increase to about 30 seconds >> or more! >> >> ...so I looked for some optimization both for the linux kernel and the >> postgres server. Nothing has work for me. I always have the same >> behavior. For isolation purposes I started using another server just to >> hold the dspam database and nothing else. No matter what I do: postgres >> gets slower and slower with each new message fed or filtered. > > I know *somewhere* I recently read something indicating a critical > configuration change for DSPAM + Postgres, but don't think I've seen it > mentioned on this list. Possibly it is in the UPGRADING instructions > for 3.2.1, or in a README file there. At any rate, it mentioned that > it was essential to make some change to the table layout used by previous > versions of DSPAM, and then Postgres would run many times faster. > > Unfortunately I no longer have 3.2.1 installed on my system, so I can't > tell you if it was in there or somewhere else. > > -- Clifton > > -- > Clifton Royston -- cliftonr@tikitechnologies.com > Tiki Technologies Lead Programmer/Software Architect > Did you ever fly a kite in bed? Did you ever walk with ten cats on your > head? > Did you ever milk this kind of cow? Well we can do it. We know how. > If you never did, you should. These things are fun, and fun is good. > -- Dr. > Seuss > From pgsql-performance-owner@postgresql.org Sat Nov 27 17:59:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BA51E3A4CDF for ; Sat, 27 Nov 2004 10:14:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49469-09 for ; Sat, 27 Nov 2004 10:14:36 +0000 (GMT) Received: from mail.bouton.name (ns.bouton.name [70.85.16.101]) by svr1.postgresql.org (Postfix) with ESMTP id 646863A4CC8 for ; Sat, 27 Nov 2004 10:14:37 +0000 (GMT) Received: from [82.227.97.166] (server.bouton.name [82.227.97.166]) by mail.bouton.name (Postfix) with ESMTP id 603CBB8BB; Sat, 27 Nov 2004 11:14:33 +0100 (CET) Message-ID: <41A85386.8070407@bouton.name> Date: Sat, 27 Nov 2004 11:14:30 +0100 From: Lionel Bouton User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Casey Allen Shobe Cc: Clifton Royston , Evilio del Rio , dspam-users@networkdweebs.com, pgsql-performance@postgresql.org Subject: Re: [dspam-users] Postgres vs. MySQL References: <1101302058.338.74.camel@haddock.cmima.csic.es> <20041126203531.GC8991@tikitechnologies.com> <35118.206.63.123.15.1101521473.squirrel@206.63.123.15> In-Reply-To: <35118.206.63.123.15.1101521473.squirrel@206.63.123.15> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/415 X-Sequence-Number: 9369 Casey Allen Shobe wrote the following on 11/27/04 03:11 : >I posted about this a couple days ago on dspam-dev... > >I am using DSpam with PostgreSQL, and like you discovered the horrible >performance. The reason is because the default PostgreSQL query planner >settings determine that a sequence scan will be more efficient than an >index scan, which is wrong. To correct this behavior, adjust the query >planner settings for the appropriate table/column with this command: > >alter table "dspam_token_data" alter "token" set statistics 200; analyze; > >Let me know if it help you. It worked wonders for me. > > > In tum mode, this could help too (I'm currently testing it) : CREATE INDEX id_token_data_sumhits ON dspam_token_data ((spam_hits + innocent_hits)); Indeed each UPDATE on dspam_token_data in TUM is done with : WHERE ... AND spam_hits + innocent_hits < 50 From pgsql-performance-owner@postgresql.org Sat Nov 27 18:46:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E39163A4DF2 for ; Sat, 27 Nov 2004 18:46:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89465-08 for ; Sat, 27 Nov 2004 18:46:40 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) by svr1.postgresql.org (Postfix) with ESMTP id CA1323A4DFB for ; Sat, 27 Nov 2004 18:46:40 +0000 (GMT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 307E731912; Sat, 27 Nov 2004 19:46:40 +0100 (MET) From: Christopher Browne X-Newsgroups: pgsql.performance Subject: Re: [dspam-users] Postgres vs. MySQL Date: Sat, 27 Nov 2004 13:43:15 -0500 Organization: cbbrowne Computing Inc Lines: 41 Message-ID: References: <1101302058.338.74.camel@haddock.cmima.csic.es> <20041126203531.GC8991@tikitechnologies.com> <35118.206.63.123.15.1101521473.squirrel@206.63.123.15> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Cancel-Lock: sha1:wj48rZ6BBt0OmlCQ5F/j6gRBm8A= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/416 X-Sequence-Number: 9370 Martha Stewart called it a Good Thing when cshobe@osss.net ("Casey Allen Shobe") wrote: > I posted about this a couple days ago on dspam-dev... > > I am using DSpam with PostgreSQL, and like you discovered the horrible > performance. The reason is because the default PostgreSQL query planner > settings determine that a sequence scan will be more efficient than an > index scan, which is wrong. To correct this behavior, adjust the query > planner settings for the appropriate table/column with this command: > > alter table "dspam_token_data" alter "token" set statistics 200; analyze; > > Let me know if it help you. It worked wonders for me. That makes a great deal of sense; the number of tokens are likely to be rather larger than 10, and are likely to be quite unevenly distributed. That fits with the need you found to collect more statistics on that column. Other cases where it seems plausible that it would be worthwhile to do the same: alter table dspam_signature_data alter signature set statistics 200; alter table dspam_neural_data alter node set statistics 200; alter table dspam_neural_decisions alter signature set statistics 200; Lionel's suggestion of having a functional index on dspam_token_data (innocent_hits + spam_hits) also seems likely to be helpful. Along with that, it might prove necessary to alter stats on dspam_token_data thus: alter table dspam_token_data alter innocent_hits set statistics 200; alter table dspam_token_data alter spam_hits set statistics 200; None of these changes are likely to make things materially worse; if they do help, they'll help rather a lot. -- (format nil "~S@~S" "cbbrowne" "gmail.com") http://www.ntlug.org/~cbbrowne/nonrdbms.html Rules of the Evil Overlord #112. "I will not rely entirely upon "totally reliable" spells that can be neutralized by relatively inconspicuous talismans." From pgsql-performance-owner@postgresql.org Mon Nov 29 21:51:12 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F18F23A51FB for ; Mon, 29 Nov 2004 21:51:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93609-01 for ; Mon, 29 Nov 2004 21:50:56 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) by svr1.postgresql.org (Postfix) with ESMTP id 754A23A51E1 for ; Mon, 29 Nov 2004 21:50:57 +0000 (GMT) Received: by flake.decibel.org (Postfix, from userid 1001) id A29931C8FD; Mon, 29 Nov 2004 15:50:56 -0600 (CST) Date: Mon, 29 Nov 2004 15:50:56 -0600 From: "Jim C. Nasby" To: Andrew McMillan Cc: Evilio del Rio , dspam-users@networkdweebs.com, pgsql-performance@postgresql.org Subject: Re: Postgres vs. DSpam Message-ID: <20041129215056.GZ41545@decibel.org> References: <1101302058.338.74.camel@haddock.cmima.csic.es> <1101433032.16058.57.camel@lamb.mcmillan.net.nz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1101433032.16058.57.camel@lamb.mcmillan.net.nz> X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/417 X-Sequence-Number: 9371 FWIW, those queries won't be able to use an index. A better WHERE clause would be: AND last_hit < CURRENT_DATE - 60 On Fri, Nov 26, 2004 at 02:37:12PM +1300, Andrew McMillan wrote: > On Wed, 2004-11-24 at 14:14 +0100, Evilio del Rio wrote: > > Hi, > > > > I have installed the dspam filter > > (http://www.nuclearelephant.com/projects/dspam) on our mail server > > (RedHat 7.3 Linux with sendmail 8.13 and procmail). I have ~300 users > > with a quite low traffic of 4000 messages/day. So it's a quite common > > platform/environment, nothing spectacular. > > I am using DSpam with PostgreSQL here. I have a daily job that cleans > the DSpam database up, as follows: > > DELETE FROM dspam_token_data > WHERE (innocent_hits*2) + spam_hits < 5 > AND CURRENT_DATE - last_hit > 60; > > DELETE FROM dspam_token_data > WHERE innocent_hits = 1 > AND CURRENT_DATE - last_hit > 30; > > DELETE FROM dspam_token_data > WHERE CURRENT_DATE - last_hit > 180; > > DELETE FROM dspam_signature_data > WHERE CURRENT_DATE - created_on > 14; > > VACUUM dspam_token_data; > > VACUUM dspam_signature_data; > > > > I also occasionally do a "VACUUM FULL ANALYZE;" on the database as well. > > > In all honesty though, I think that MySQL is better suited to DSpam than > PostgreSQL is. > > > > Please, could anyone explain me this difference? > > Is Postgres that bad? > > Is MySQL that good? > > Am I the only one to have observed this behavior? > > I believe that what DSpam does that is not well-catered for in the way > PostgreSQL operates, is that it does very frequent updates to rows in > (eventually) quite large tables. In PostgreSQL the UPDATE will result > internally in a new record being written, with the old record being > marked as deleted. That old record won't be re-used until after a > VACUUM has run, and this means that the on-disk tables will have a lot > of dead rows in them quite quickly. > > The reason that PostgreSQL operates this way, is a direct result of the > way transactional support is implemented, and it may well change in a > version or two. It's got better over the last few versions, with things > like pg_autovacuum, but that approach still doesn't suit some types of > database updating. > > Cheers, > Andrew. > ------------------------------------------------------------------------- > Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington > WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St > DDI: +64(4)803-2201 MOB: +64(272)DEBIAN OFFICE: +64(4)499-2267 > These PRESERVES should be FORCE-FED to PENTAGON OFFICIALS!! > ------------------------------------------------------------------------- > -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Tue Nov 30 15:17:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 517C73A52C6 for ; Tue, 30 Nov 2004 13:30:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16403-02 for ; Tue, 30 Nov 2004 13:30:39 +0000 (GMT) Received: from plab.ku.dk (plab.ku.dk [130.225.107.20]) by svr1.postgresql.org (Postfix) with ESMTP id 4F3383A51A1 for ; Tue, 30 Nov 2004 13:30:41 +0000 (GMT) Received: from plab.ku.dk (localhost [127.0.0.1]) by plab.ku.dk (Postfix) with SMTP id 3B86B5A18C for ; Tue, 30 Nov 2004 14:30:38 +0100 (CET) Received: by plab.ku.dk (Postfix, from userid 1003) id 9A9635A18A; Tue, 30 Nov 2004 14:30:37 +0100 (CET) Mime-version: 1.0 Content-type: text/plain; charset="koi8-r" Content-transfer-encoding: 8bit Keywords: 2001334874 X-Comment-To: Josh Berkus To: pgsql-performance@postgresql.org Subject: VACUUM ANALYZE downgrades performance From: Dmitry Karasik Date: 30 Nov 2004 14:30:37 +0100 In-Reply-To: Josh Berkus's message of "Wed, 17 Nov 2004 15:23:41 -0800" Message-ID: <84fz2ra2gy.fsf_-_@plab.ku.dk> Lines: 33 X-Mailer: Gnus v5.7/Emacs 20.7 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/418 X-Sequence-Number: 9372 Hi all, On v7.4.5 I noticed downgrade in the planner, namely favoring sequential scan over index scan. The proof: create table a ( a integer); create index aidx on a(a); explain analyze select * from a where a = 0; -- Index Scan using aidx on a (cost=0.00..17.07 rows=5 width=4) (actual -- time=0.029..0.029 rows=0 loops=1) -- Index Cond: (a = 0) vacuum analyze; explain analyze select * from a where a = 0; -- Seq Scan on a (cost=0.00..0.00 rows=1 width=4) (actual time=0.009..0.009 -- rows=0 loops=1) -- Filter: (a = 0) I do realize that there might be reasons why this happens over an empty table, but what is way worse that when the table starts actually to fill, the seq scan is still there, and the index is simply not used. How that could be so ...mmm... shortsighted, and what is more important, how to avoid this? I hope the answer is not 'run vacuum analyze each 5 seconds'. -- Sincerely, Dmitry Karasik --- catpipe Systems ApS *BSD solutions, consulting, development www.catpipe.net +45 7021 0050 From pgsql-performance-owner@postgresql.org Tue Nov 30 15:33:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9D4CB3A537B for ; Tue, 30 Nov 2004 15:33:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63840-06 for ; Tue, 30 Nov 2004 15:32:58 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.200]) by svr1.postgresql.org (Postfix) with ESMTP id 12D2B3A5235 for ; Tue, 30 Nov 2004 15:33:01 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a36so539544rnf for ; Tue, 30 Nov 2004 07:33:01 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=Z6IPR1NCOp2sbJYIZuNcwOw99U7GYSNRPPCcTkQcd9FVNdLI2t9odNwPQl3ccmJ+z4IgLZ8j4WOpLzjwQcs9GJNcHDkROt26Bn9f/3YdnWxZ09KSdFg2Ws9K06gB5gDrayhSbR8AXWTcMG/WoaY6/yWyqt/btl6qj6RawO5Lt2E= Received: by 10.38.164.65 with SMTP id m65mr521945rne; Tue, 30 Nov 2004 07:33:01 -0800 (PST) Received: by 10.38.126.16 with HTTP; Tue, 30 Nov 2004 07:33:01 -0800 (PST) Message-ID: Date: Tue, 30 Nov 2004 10:33:01 -0500 From: Mike Rylander Reply-To: Mike Rylander To: Dmitry Karasik , pgsql-performance@postgresql.org Subject: Re: VACUUM ANALYZE downgrades performance In-Reply-To: <84fz2ra2gy.fsf_-_@plab.ku.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <84fz2ra2gy.fsf_-_@plab.ku.dk> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/419 X-Sequence-Number: 9373 On 30 Nov 2004 14:30:37 +0100, Dmitry Karasik wrote: > > Hi all, > > On v7.4.5 I noticed downgrade in the planner, namely favoring > sequential scan over index scan. The proof: > > create table a ( a integer); > create index aidx on a(a); > explain analyze select * from a where a = 0; > -- Index Scan using aidx on a (cost=0.00..17.07 rows=5 width=4) (actual > -- time=0.029..0.029 rows=0 loops=1) > -- Index Cond: (a = 0) > vacuum analyze; > explain analyze select * from a where a = 0; > -- Seq Scan on a (cost=0.00..0.00 rows=1 width=4) (actual time=0.009..0.009 > -- rows=0 loops=1) > -- Filter: (a = 0) Looks to me like the seq scan is a better plan. The "actual time" went down. > > I do realize that there might be reasons why this happens over an empty > table, but what is way worse that when the table starts actually to fill, > the seq scan is still there, and the index is simply not used. How > that could be so ...mmm... shortsighted, and what is more important, > how to avoid this? I hope the answer is not 'run vacuum analyze each 5 seconds'. > See this thread (http://archives.postgresql.org/pgsql-hackers/2004-11/msg00985.php and http://archives.postgresql.org/pgsql-hackers/2004-11/msg01080.php) for an ongoing discussion of the issue. -- Mike Rylander mrylander@gmail.com GPLS -- PINES Development Database Developer http://open-ils.org From pgsql-performance-owner@postgresql.org Tue Nov 30 15:37:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C311D3A45C5 for ; Tue, 30 Nov 2004 15:37:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66098-09 for ; Tue, 30 Nov 2004 15:37:34 +0000 (GMT) Received: from stubee.d2hosting.net (d2hosting.net [66.70.41.160]) by svr1.postgresql.org (Postfix) with ESMTP id A24873A538C for ; Tue, 30 Nov 2004 15:37:36 +0000 (GMT) Received: from [127.0.0.1] (stubee.d2hosting.net [66.70.41.160]) by stubee.d2hosting.net (8.11.6/linuxconf) with ESMTP id iAUFbZj04378; Tue, 30 Nov 2004 09:37:35 -0600 Message-ID: <41AC94CC.1020602@idigx.com> Date: Tue, 30 Nov 2004 09:42:04 -0600 From: Thomas Swan User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dmitry Karasik Cc: pgsql-performance@postgresql.org Subject: Re: VACUUM ANALYZE downgrades performance References: <84fz2ra2gy.fsf_-_@plab.ku.dk> In-Reply-To: <84fz2ra2gy.fsf_-_@plab.ku.dk> X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/420 X-Sequence-Number: 9374 On 11/30/2004 7:30 AM Dmitry Karasik said:: >Hi all, > >On v7.4.5 I noticed downgrade in the planner, namely favoring >sequential scan over index scan. The proof: > > create table a ( a integer); > create index aidx on a(a); > explain analyze select * from a where a = 0; > -- Index Scan using aidx on a (cost=0.00..17.07 rows=5 width=4) (actual > -- time=0.029..0.029 rows=0 loops=1) > -- Index Cond: (a = 0) > vacuum analyze; > explain analyze select * from a where a = 0; > -- Seq Scan on a (cost=0.00..0.00 rows=1 width=4) (actual time=0.009..0.009 > -- rows=0 loops=1) > -- Filter: (a = 0) > >I do realize that there might be reasons why this happens over an empty >table, but what is way worse that when the table starts actually to fill, >the seq scan is still there, and the index is simply not used. How >that could be so ...mmm... shortsighted, and what is more important, >how to avoid this? I hope the answer is not 'run vacuum analyze each 5 seconds'. > > > Look at the ACTUAL TIME. It dropped from 0.029ms (using the index scan) to 0.009ms (using a sequential scan.) Index scans are not always faster, and the planner/optimizer knows this. VACUUM ANALYZE is best run when a large proportion of data has been updated/loaded or in the off hours to refresh the statistics on large datasets. From pgsql-performance-owner@postgresql.org Tue Nov 30 16:05:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 14D9B3A53D7 for ; Tue, 30 Nov 2004 16:05:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77651-05 for ; Tue, 30 Nov 2004 16:05:07 +0000 (GMT) Received: from mailer.unicite.fr.netcentrex.net (mailer.fr.netcentrex.net [62.161.167.249]) by svr1.postgresql.org (Postfix) with ESMTP id C12903A45FE for ; Tue, 30 Nov 2004 16:05:04 +0000 (GMT) Received: from akira ([192.168.101.228]) by mailer.unicite.fr.netcentrex.net with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id 42CY1482; Tue, 30 Nov 2004 17:05:02 +0100 From: "Alban Medici (NetCentrex)" To: Subject: Re: "Group By " index usage Date: Tue, 30 Nov 2004 17:04:58 +0100 Organization: NetCentrex MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook, Build 11.0.6353 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Thread-Index: AcTSTV0hpVsTKePKSd2jm5XGApe98wEqOQSQ In-Reply-To: <20041124173659.2441.qmail@web54301.mail.yahoo.com> Message-Id: <20041130160504.C12903A45FE@svr1.postgresql.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/421 X-Sequence-Number: 9375 Did you test with ILIKE instead of lower LIKE lower ? -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of sdfasdfas sdfasdfs Sent: mercredi 24 novembre 2004 18:37 To: pgsql-performance@postgresql.org Subject: [PERFORM] "Group By " index usage I have a table with this index: create index ARTISTS_NAME on ARTISTS ( lower(AR_NAME) ); Te index is over a colum with this definition: AR_NAME VARCHAR(256) null, I want to optimize this query: select * from artists where lower(ar_name) like lower('a%') order by lower(ar_name) limit 20; I think the planner should use the index i have. But the result of the explain command is: explain analyze select * from artists where lower(ar_name) like lower('a%') order by lower(ar_name) limit 20; =20 QUERY PLAN =20 -------------------------------------------------------------------------= --- --------------------------------------------------------------------- Limit (cost=3D20420.09..20420.14 rows=3D20 width=3D360) (actual time=3D2094.13..2094.19 rows=3D20 loops=3D1) -> Sort (cost=3D20420.09..20433.52 rows=3D5374 width=3D360) (actual time=3D2094.13..2094.16 rows=3D21 loops=3D1) Sort Key: lower((ar_name)::text) -> Index Scan using artists_name on artists (cost=3D0.00..19567.09 rows=3D5374 width=3D360) (actual time=3D0.11..1391.97 rows=3D59047 loops=3D1) Index Cond: ((lower((ar_name)::text) >=3D 'a'::text) AND (lower((ar_name)::text) < 'b'::text)) Filter: (lower((ar_name)::text) ~~ 'a%'::text) Total runtime: 2098.62 msec (7 rows) The "ORDER BY" clause is not using the index!. I don't know why. I have the locale configured to C, and the index works well with the = "like" operator.=20 =BFCould you help me? I am really lost.=20 =09 ______________________________________________ Renovamos el Correo Yahoo!: =A1100 MB GRATIS! Nuevos servicios, m=E1s seguridad http://correo.yahoo.es ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend