From pgsql-performance-owner@postgresql.org Mon Feb 2 05:48:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 60794D1D946 for ; Mon, 2 Feb 2004 09:48:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 18212-03 for ; Mon, 2 Feb 2004 05:48:26 -0400 (AST) 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 A8F3ED1D8F3 for ; Mon, 2 Feb 2004 05:48:23 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) id 1Anagq-000BMP-0Y; Mon, 02 Feb 2004 09:48:25 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 91826171D7; Mon, 2 Feb 2004 09:48:23 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id E7E6E17175; Mon, 2 Feb 2004 09:48:21 +0000 (GMT) From: Richard Huxton To: Neil Conway , "Loeke" Subject: Re: views? Date: Mon, 2 Feb 2004 09:48:21 +0000 User-Agent: KMail/1.5 Cc: pgsql-performance@postgresql.org References: <1075316194.466850@seven.kulnet.kuleuven.ac.be> <87k738ivl8.fsf@mailbox.samurai.com> In-Reply-To: <87k738ivl8.fsf@mailbox.samurai.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402020948.21370.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/1 X-Sequence-Number: 5525 On Saturday 31 January 2004 04:35, Neil Conway wrote: > > This is called a "materialized view". PostgreSQL doesn't support them > yet, but most people think it would be a Good Thing to have. There is a project on gborg (called "mview" iirc) though I don't know how far it's got - I think it's still pretty new. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Mon Feb 2 10:47:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2354AD1D286 for ; Mon, 2 Feb 2004 14:47:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 29892-01 for ; Mon, 2 Feb 2004 10:47:19 -0400 (AST) Received: from linux.finestmedia.tv (linux.finestmedia.tv [213.180.31.12]) by svr1.postgresql.org (Postfix) with ESMTP id 28E08D1D16D for ; Mon, 2 Feb 2004 10:47:14 -0400 (AST) Received: from rigmor (sms.finestmedia.tv [213.180.31.11]) by linux.finestmedia.tv (Postfix) with SMTP id 8AAD818E718 for ; Mon, 2 Feb 2004 16:44:22 +0200 (EET) From: "Rigmor Ukuhe" To: Subject: "Overlaping" indexes Date: Mon, 2 Feb 2004 16:46:22 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/2 X-Sequence-Number: 5526 Hi, I have many indexes somehow overlaping like: ... btree ("STATUS", "VISIBLE", "NP_ID"); ... btree ("STATUS", "VISIBLE"); is perfomance gained by "more exact" index worth overhead with managing indexes. Rigmor Ukuhe Finestmedia Ltd --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.564 / Virus Database: 356 - Release Date: 19.01.2004 From pgsql-performance-owner@postgresql.org Mon Feb 2 11:04:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1FB8DD1C512 for ; Mon, 2 Feb 2004 15:04:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 31284-10 for ; Mon, 2 Feb 2004 11:03:59 -0400 (AST) Received: from serwer.skawsoft.com.pl (skawina.eu.org [80.48.213.66]) by svr1.postgresql.org (Postfix) with ESMTP id 45DC4D1D2AC for ; Mon, 2 Feb 2004 11:03:51 -0400 (AST) Received: from klaster.net (backbone.zab.citynet.pl [212.244.6.69]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 7EC032B3CB; Mon, 2 Feb 2004 16:03:38 +0100 (CET) Message-ID: <401E6755.7050806@klaster.net> Date: Mon, 02 Feb 2004 16:05:57 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.6b) Gecko/20031208 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Rigmor Ukuhe Cc: pgsql-performance@postgresql.org Subject: Re: "Overlaping" indexes References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/3 X-Sequence-Number: 5527 Dnia 2004-02-02 15:46, U�ytkownik Rigmor Ukuhe napisa�: > Hi, > > I have many indexes somehow overlaping like: > ... btree ("STATUS", "VISIBLE", "NP_ID"); > ... btree ("STATUS", "VISIBLE"); > > is perfomance gained by "more exact" index worth overhead with managing > indexes. The second (2 columns) index is useless - it's function is well done by the first one (3 columns). Regards, Tomasz Myrta From pgsql-advocacy-owner@postgresql.org Mon Feb 2 13:23:33 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 36E68D1CACB; Mon, 2 Feb 2004 17:22:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 96476-03; Mon, 2 Feb 2004 13:22:10 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 87508D1B4C0; Mon, 2 Feb 2004 13:22:08 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4358269; Mon, 02 Feb 2004 09:23:07 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: , pgsql-advocacy@postgresql.org Subject: MySQL+InnoDB vs. PostgreSQL test? Date: Mon, 2 Feb 2004 09:21:12 -0800 User-Agent: KMail/1.5.4 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402020921.12076.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/1 X-Sequence-Number: 3572 Folks, I've had requests from a couple of businesses to see results of infomal MySQL +InnoDB vs. PostgreSQL tests. I know that we don't have the setup to do full formal benchmarking, but surely someone in our community has gone head-to-head on your own application? -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Feb 2 14:15:25 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E30A3D1D25F for ; Mon, 2 Feb 2004 18:07:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 16788-04 for ; Mon, 2 Feb 2004 14:07:16 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 8BD98D1CCA7 for ; Mon, 2 Feb 2004 14:07:15 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4358513 for pgsql-performance@postgresql.org; Mon, 02 Feb 2004 10:08:18 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Subject: Mainframe Linux + PostgreSQL Date: Mon, 2 Feb 2004 10:06:23 -0800 User-Agent: KMail/1.5.4 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402021006.23304.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/5 X-Sequence-Number: 5529 Folks, Is anyone on this list using PostgreSQL on a mini or mainframe platform? If so, drop me a line. Thanks! -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-advocacy-owner@postgresql.org Mon Feb 2 14:19:10 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9C5D4D1B8A3; Mon, 2 Feb 2004 18:06:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 12959-09; Mon, 2 Feb 2004 14:06:26 -0400 (AST) Received: from localhost.localdomain (unknown [166.70.154.50]) by svr1.postgresql.org (Postfix) with ESMTP id D3CCBD1D299; Mon, 2 Feb 2004 14:06:24 -0400 (AST) Received: from [127.0.0.1] (strongbad [127.0.0.1]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id i12I6Knm007865; Mon, 2 Feb 2004 11:06:20 -0700 In-Reply-To: <200402020921.12076.josh@agliodbs.com> References: <200402020921.12076.josh@agliodbs.com> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <83927B58-55AA-11D8-99C4-000A959D1424@intercation.com> Content-Transfer-Encoding: 7bit Cc: pgsql-advocacy@postgresql.org, From: Adam Ruth Subject: Re: MySQL+InnoDB vs. PostgreSQL test? Date: Mon, 2 Feb 2004 11:06:24 -0700 To: josh@agliodbs.com X-Mailer: Apple Mail (2.612) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/2 X-Sequence-Number: 3573 Josh, I evaluated MySQL + InnoDB briefly for a project, once. I didn't get very far because of some severe limitations in MySQL. I had to import all of the data from an existing database (MS SQL). One of the tables was about 8 million rows, 10 fields, and had 5 indexes. I found it quite impossible to import into MySQL. I would import the data into a table with no indexes, then perform a bunch of manipulation on it (I wasn't just converting from MS SQL, but also needed to alter quite a bit of the structure). After the manipulation, I would drop some columns and build the indexes. It took MySQL over 4 days to do this! What I found out was that any DDL changes to a table in MySQL actually does this: create a new table, copy all of the data over, then drop the old table and rename the new one. Whenever I added a new index, MySQL would go through the process of rebuilding each previous index. Same thing when adding or dropping columns. I could not find a way to import all of the data in a reasonable amount of time. For comparison, it took less that 45 minutes to import all of the data in to PostgreSQL (that's ALL of the data, not just that one table). Needless to say (but I'll say it anyway :-), I didn't get any farther in my evaluation, there was no point. One more thing that annoyed me. If you started a process, such as a large DDL operation, or heaven forbid, a cartesian join (what? I never do that!). There's no way to cancel it with InnoDB. You have to wait for it to finish. Hitting ctrl+c in their command line tool only kills the command line tool, the process continues. Even if you stop the database and restart it (including with a hard boot), it will pick right up where it left off and continue. That proved to be way too much of a pain for me. Disclaimer: I'm not a real MySQL expert, or anything. There could be ways of getting around this, but after two weeks of trying, I decided to give up. It only took me a few hours to build the requisite PostgreSQL scripts and I never looked back. Adam Ruth On Feb 2, 2004, at 10:21 AM, Josh Berkus wrote: > Folks, > > I've had requests from a couple of businesses to see results of > infomal MySQL > +InnoDB vs. PostgreSQL tests. I know that we don't have the setup > to do > full formal benchmarking, but surely someone in our community has gone > head-to-head on your own application? > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco > > > ---------------------------(end of > broadcast)--------------------------- > TIP 8: explain analyze is your friend > From pgsql-performance-owner@postgresql.org Mon Feb 2 14:38:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 44A62D1C9DA for ; Mon, 2 Feb 2004 18:35:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 29910-02 for ; Mon, 2 Feb 2004 14:35:47 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id CE32FD1B582 for ; Mon, 2 Feb 2004 14:35:45 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i12IYPRC010004; Mon, 2 Feb 2004 11:34:33 -0700 (MST) Date: Mon, 2 Feb 2004 11:30:36 -0700 (MST) From: "scott.marlowe" To: Tomasz Myrta Cc: Rigmor Ukuhe , Subject: Re: "Overlaping" indexes In-Reply-To: <401E6755.7050806@klaster.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/6 X-Sequence-Number: 5530 On Mon, 2 Feb 2004, Tomasz Myrta wrote: > Dnia 2004-02-02 15:46, U?ytkownik Rigmor Ukuhe napisa3: > > Hi, > > > > I have many indexes somehow overlaping like: > > ... btree ("STATUS", "VISIBLE", "NP_ID"); > > ... btree ("STATUS", "VISIBLE"); > > > > is perfomance gained by "more exact" index worth overhead with managing > > indexes. > > The second (2 columns) index is useless - it's function is well done by > the first one (3 columns). Not entirely, since it only has to sort two columns, it will be smaller, and will therefore be somewhat faster. On the other hand, I've seen a lot of folks create multi column indexes who didn't really understand how they work in Postgresql. From pgsql-performance-owner@postgresql.org Mon Feb 2 14:48:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 67102D1D2DB for ; Mon, 2 Feb 2004 18:40:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 28898-07 for ; Mon, 2 Feb 2004 14:40:47 -0400 (AST) Received: from serwer.skawsoft.com.pl (skawina.eu.org [80.48.213.66]) by svr1.postgresql.org (Postfix) with ESMTP id 27E04D1D299 for ; Mon, 2 Feb 2004 14:40:46 -0400 (AST) Received: from klaster.net (core-1.citynet.pl [80.48.135.14]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 50CFC2B3CB; Mon, 2 Feb 2004 19:40:43 +0100 (CET) Message-ID: <401E9A37.1070909@klaster.net> Date: Mon, 02 Feb 2004 19:43:03 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.6b) Gecko/20031208 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: "scott.marlowe" Cc: Rigmor Ukuhe , pgsql-performance@postgresql.org Subject: Re: "Overlaping" indexes References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/7 X-Sequence-Number: 5531 Dnia 2004-02-02 19:30, U�ytkownik scott.marlowe napisa�: > Not entirely, since it only has to sort two columns, it will be smaller, > and will therefore be somewhat faster. Can you say something more about it? Will it be enough faster to keep them both? Did anyone make such tests? Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Mon Feb 2 15:03:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0BBFDD1B45B for ; Mon, 2 Feb 2004 19:03:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 42442-02 for ; Mon, 2 Feb 2004 15:03:40 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id EC0B4D1D2F7 for ; Mon, 2 Feb 2004 15:03:35 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i12J2dRC012693; Mon, 2 Feb 2004 12:02:39 -0700 (MST) Date: Mon, 2 Feb 2004 11:58:49 -0700 (MST) From: "scott.marlowe" To: Tomasz Myrta Cc: Rigmor Ukuhe , Subject: Re: "Overlaping" indexes In-Reply-To: <401E9A37.1070909@klaster.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/8 X-Sequence-Number: 5532 On Mon, 2 Feb 2004, Tomasz Myrta wrote: > Dnia 2004-02-02 19:30, U�ytkownik scott.marlowe napisa�: > > Not entirely, since it only has to sort two columns, it will be smaller, > > and will therefore be somewhat faster. > > Can you say something more about it? Will it be enough faster to keep > them both? Did anyone make such tests? that really depends on the distribution of the third column. If there's only a couple of values in the third column, no big deal. If each entry is unique, and it's a large table, very big deal. It is only useful to have a three column index if you actually use it. If you have an index on (a,b,c) and select order by b, the index won't get used unless the a part is in the where clause. the other issue is updates. IT WILL cost more to update two indexes rather than one. Generally, you can drop / readd the index and use explain analyze on one of your own queries to see if that helps. From pgsql-performance-owner@postgresql.org Mon Feb 2 15:18:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 96F8AD1D283 for ; Mon, 2 Feb 2004 19:18:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 48132-05 for ; Mon, 2 Feb 2004 15:18:24 -0400 (AST) Received: from mail.ez3pl.com (66-136-75-131.ded.swbell.net [66.136.75.131]) by svr1.postgresql.org (Postfix) with ESMTP id 91966D1B4B7 for ; Mon, 2 Feb 2004 15:18:17 -0400 (AST) Received: from kbarnard ([172.25.96.149]) by mail.ez3pl.com (8.11.2/8.11.2) with ESMTP id i12JHEo06728 for ; Mon, 2 Feb 2004 13:17:14 -0600 From: "Kevin Barnard" To: pgsql-performance@postgresql.org Date: Mon, 02 Feb 2004 13:14:15 -0600 MIME-Version: 1.0 Subject: Increasing number of PG connections. Message-ID: <401E4D27.26927.3254D8C1@localhost> X-mailer: Pegasus Mail for Windows (v4.12a) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/10 X-Sequence-Number: 5534 I am running a Dual Xeon hyperthreaded server with 4GB RAM RAID-5. The only thing running on the server is Postgres running under Fedora. I have a 700 connection limit. The DB is setup as a backend for a very high volume website. Most of the queries are simple, such as logging accesses, user login verification etc. There are a few bigger things suchas reporting etc but for the most part each transaction lasts less then a second. The connections are not persistant (I'm using pg_connect in PHP) The system was at 2 GB with a 400 connection limit. We ran into problems because we hit the limit of connections during high volume. 1. Does 400 connections sound consistant with the 2GB of RAM? Does 700 sound good with 4 GB. I've read a little on optimizing postgres. Is there anything else I can do maybe OS wise to increase how many connections I get before I start swapping? 2. Are there any clustering technologies that will work with postgres? Specifically I'm looking at increasing the number of connections. The bottom line is since the website launched (middle of January) we have increased the number of http connections, and increased bandwidth allowances by over 10 times. The site continues to grow and we are looking at our options. Some of the ideas have been possible DB replication. Write to master and read from multiple slaves. Other ideas including increasing hardware. This is the biggest site I have ever worked with. Almost everything else fits in a T1 with a single DB server handling multiple sites. Does anybody with experence in this realm have any suggestions? Thank you in advance for whatever help you can provide. -- Kevin Barnard From pgsql-performance-owner@postgresql.org Mon Feb 2 15:17:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 003F4D1B4BE for ; Mon, 2 Feb 2004 19:17:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 47644-04 for ; Mon, 2 Feb 2004 15:17:39 -0400 (AST) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 79B2AD1D299 for ; Mon, 2 Feb 2004 15:17:38 -0400 (AST) Received: from [134.22.69.227] (dyn-69-227.tor.dsl.tht.net [134.22.69.227]) by tht.net (Postfix) with ESMTP id 4459D76B0B; Mon, 2 Feb 2004 14:17:42 -0500 (EST) Subject: Re: "Overlaping" indexes From: Rod Taylor To: Tomasz Myrta Cc: Scott Marlowe , Rigmor Ukuhe , Postgresql Performance In-Reply-To: <401E9A37.1070909@klaster.net> References: <401E9A37.1070909@klaster.net> Content-Type: text/plain; charset=iso-8859-2 Message-Id: <1075749471.308.105.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 02 Feb 2004 14:17:52 -0500 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/9 X-Sequence-Number: 5533 On Mon, 2004-02-02 at 13:43, Tomasz Myrta wrote: > Dnia 2004-02-02 19:30, U�ytkownik scott.marlowe napisa�: > > Not entirely, since it only has to sort two columns, it will be smaller, > > and will therefore be somewhat faster. > > Can you say something more about it? Will it be enough faster to keep > them both? Did anyone make such tests? You can actually come up with test cases where both indexes are useful. The three column index will have more data to sift through. That said, having both indexes used means there is less ram available for cache. The biggest mistake I see is people doing everything they can to optimize a single query, then they optimize the next query, etc. When you consider the entire set of queries, those two indexes are very likely to slow select throughput down due to increased memory requirements and the system hitting disk a little more often. It's similar to the mistake of benchmarking a set of 1000 row tables and optimizing memory settings for that, then using that configuration on the 10M row tables in production. From pgsql-performance-owner@postgresql.org Mon Feb 2 15:27:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 28D15D1CA83 for ; Mon, 2 Feb 2004 19:27:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 53427-02 for ; Mon, 2 Feb 2004 15:27:46 -0400 (AST) Received: from front3.mail.megapathdsl.net (front3.mail.megapathdsl.net [66.80.60.32]) by svr1.postgresql.org (Postfix) with ESMTP id 42597D1C9FB for ; Mon, 2 Feb 2004 15:27:44 -0400 (AST) Received: from [64.32.131.193] (HELO [192.168.1.11]) by front3.mail.megapathdsl.net (CommuniGate Pro SMTP 4.1.3) with ESMTP id 124270437 for pgsql-performance@postgresql.org; Mon, 02 Feb 2004 11:27:43 -0800 Subject: pg_stat_activity From: Orion Henry To: pgsql-performance@postgresql.org Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-rktVDCjj/B55ldAG8H8u" Organization: Message-Id: <1075750062.16672.87.camel@orthanc> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 02 Feb 2004 11:27:42 -0800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/11 X-Sequence-Number: 5535 --=-rktVDCjj/B55ldAG8H8u Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Quick Question, The full query listed in pg_stat_activity is getting truncated. Does anyone know how I can see the full query in progress? --=20 Orion Henry --=-rktVDCjj/B55ldAG8H8u Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQBAHqSu9IoQcq23xtARAjkgAJ9k/QY+1pwGwLnKRQ2azfBa4gzGKACgj1uM z3/RkkSy8VphALsADC/sz0I= =gKRr -----END PGP SIGNATURE----- --=-rktVDCjj/B55ldAG8H8u-- From pgsql-performance-owner@postgresql.org Mon Feb 2 15:40:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 40245D1CAE1 for ; Mon, 2 Feb 2004 19:39:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 56950-03 for ; Mon, 2 Feb 2004 15:39:31 -0400 (AST) Received: from leo.supplyfx.com (h-67-100-199-42.LSANCA54.covad.net [67.100.199.42]) by svr1.postgresql.org (Postfix) with ESMTP id 71364D1CA65 for ; Mon, 2 Feb 2004 15:39:29 -0400 (AST) Received: from [10.0.100.33] (unknown [10.0.100.33]) by leo.supplyfx.com (Postfix) with ESMTP id AF75044B58; Mon, 2 Feb 2004 11:39:24 -0800 (PST) In-Reply-To: <401E4D27.26927.3254D8C1@localhost> References: <401E4D27.26927.3254D8C1@localhost> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <8133E3F7-55B7-11D8-AEAC-000A95AB8896@quotefx.net> Content-Transfer-Encoding: 7bit Cc: pgsql-performance@postgresql.org From: Qing Zhao Subject: Re: Increasing number of PG connections. Date: Mon, 2 Feb 2004 11:39:24 -0800 To: Kevin Barnard X-Mailer: Apple Mail (2.612) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/12 X-Sequence-Number: 5536 I am new here. I have a question related to this in some way. Our web site needs to upload a large volume of data into Postgres at a time. The performance deterioates as number of rows becomes larger. When it reaches 2500 rows, it never come back to GUI. Since the tests were run through GUI, my suspision is that it might be caused by the way the application server talking to Postgres server, the connections, etc.. What might be the factors involved here? Does anyone know? Thanks a lot! Qing On Feb 2, 2004, at 11:14 AM, Kevin Barnard wrote: > I am running a Dual Xeon hyperthreaded server with 4GB RAM RAID-5. > The only > thing running on the server is Postgres running under Fedora. I have > a 700 > connection limit. > > The DB is setup as a backend for a very high volume website. Most of > the queries > are simple, such as logging accesses, user login verification etc. > There are a few > bigger things suchas reporting etc but for the most part each > transaction lasts less > then a second. The connections are not persistant (I'm using > pg_connect in PHP) > > The system was at 2 GB with a 400 connection limit. We ran into > problems because > we hit the limit of connections during high volume. > > 1. Does 400 connections sound consistant with the 2GB of RAM? Does > 700 sound > good with 4 GB. I've read a little on optimizing postgres. Is there > anything else I can > do maybe OS wise to increase how many connections I get before I start > swapping? > > 2. Are there any clustering technologies that will work with > postgres? Specifically I'm > looking at increasing the number of connections. > > The bottom line is since the website launched (middle of January) we > have increased > the number of http connections, and increased bandwidth allowances by > over 10 > times. The site continues to grow and we are looking at our options. > Some of the > ideas have been possible DB replication. Write to master and read > from multiple > slaves. Other ideas including increasing hardware. > > This is the biggest site I have ever worked with. Almost everything > else fits in a T1 > with a single DB server handling multiple sites. Does anybody with > experence in this > realm have any suggestions? > > Thank you in advance for whatever help you can provide. > -- > Kevin Barnard > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > From pgsql-advocacy-owner@postgresql.org Mon Feb 2 16:14:45 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BE309D1B8A3; Mon, 2 Feb 2004 20:14:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 69093-05; Mon, 2 Feb 2004 16:14:15 -0400 (AST) Received: from bramble.mmrd.com (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 0FCD5D1CAC7; Mon, 2 Feb 2004 16:14:13 -0400 (AST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id i12JcRcM017093; Mon, 2 Feb 2004 14:38:28 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id i12KE8l13320; Mon, 2 Feb 2004 15:14:08 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id XT88DS9H; Mon, 2 Feb 2004 15:14:06 -0500 Subject: Re: MySQL+InnoDB vs. PostgreSQL test? From: Robert Treat To: Josh Berkus Cc: pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org In-Reply-To: <200402020921.12076.josh@agliodbs.com> References: <200402020921.12076.josh@agliodbs.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 02 Feb 2004 15:14:08 -0500 Message-Id: <1075752848.23889.134.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/3 X-Sequence-Number: 3574 On Mon, 2004-02-02 at 12:21, Josh Berkus wrote: > Folks, > > I've had requests from a couple of businesses to see results of infomal MySQL > +InnoDB vs. PostgreSQL tests. I know that we don't have the setup to do > full formal benchmarking, but surely someone in our community has gone > head-to-head on your own application? > We have the setup to do informal benchmarking via OSDL, but afaik mysql doesn't conform to any of the dbt benchmarks... Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL From pgsql-performance-owner@postgresql.org Mon Feb 2 16:56:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7F447D1D52A for ; Mon, 2 Feb 2004 20:56:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 88369-04 for ; Mon, 2 Feb 2004 16:56:37 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 883A0D1D2E5 for ; Mon, 2 Feb 2004 16:56:34 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i12KrhRC024301; Mon, 2 Feb 2004 13:53:43 -0700 (MST) Date: Mon, 2 Feb 2004 13:49:53 -0700 (MST) From: "scott.marlowe" To: Qing Zhao Cc: Kevin Barnard , Subject: inserting large number of rows was: Re: Increasing number of PG connections. In-Reply-To: <8133E3F7-55B7-11D8-AEAC-000A95AB8896@quotefx.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/15 X-Sequence-Number: 5539 On Mon, 2 Feb 2004, Qing Zhao wrote: > I am new here. I have a question related to this in some way. > > Our web site needs to upload a large volume of data into Postgres at a > time. The performance deterioates as number of rows becomes larger. > When it reaches 2500 rows, it never come back to GUI. Since the tests > were run through GUI, my suspision is > that it might be caused by the way the application server talking to > Postgres server, the connections, etc.. What might be the factors > involved here? Does anyone know? Actually, I'm gonna go out on a limb here and assume two things: 1. you've got lotsa fk/pk relationships setup. 2. you're analyzing the table empty before loading it up. What happens in this instance is that the analyze on an empty, or nearly so, table, means that during the inserts, postgresql thinks you have only a few rows. At first, this is fine, as pgsql will seq scan the tables to make sure there is a proper key in both. As the number of rows increases, the planner needs to switch to index scans but doesn't, because it doesn't know that the number of rows is increasing. Fix: insert a few hundred rows, run analyze, check to see if the explain for inserts is showing index scans or not. If not, load a few more hundred rows, analyze, rinse, repeat. Also, look for fk/pk mismatches. I.e. an int4 field pointing to an int8 field. That's a performance killer, so if the pk/fk types don't match, see if you can change your field types to match and try again. From pgsql-performance-owner@postgresql.org Mon Feb 2 17:22:08 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D18CBD1B4DA for ; Mon, 2 Feb 2004 20:52:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 84473-07 for ; Mon, 2 Feb 2004 16:52:26 -0400 (AST) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by svr1.postgresql.org (Postfix) with ESMTP id F41ABD1B4BD for ; Mon, 2 Feb 2004 16:52:22 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) id 1Anl3P-000G5v-0Z; Mon, 02 Feb 2004 20:52:23 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id BC7B716401; Mon, 2 Feb 2004 20:52:22 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 2434B1593E; Mon, 2 Feb 2004 20:52:20 +0000 (GMT) From: Richard Huxton To: Qing Zhao , Kevin Barnard Subject: Bulk Record upload (was Re: Increasing number of PG connections) Date: Mon, 2 Feb 2004 20:52:19 +0000 User-Agent: KMail/1.5 Cc: pgsql-performance@postgresql.org References: <401E4D27.26927.3254D8C1@localhost> <8133E3F7-55B7-11D8-AEAC-000A95AB8896@quotefx.net> In-Reply-To: <8133E3F7-55B7-11D8-AEAC-000A95AB8896@quotefx.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402022052.19253.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/16 X-Sequence-Number: 5540 On Monday 02 February 2004 19:39, Qing Zhao wrote: > I am new here. I have a question related to this in some way. Hmm - no real connection I can see - might have been better to start a new thread rather than replying to this one. Also, it is usually considered best practice not to quote large amounts of the previous message if you're not replying to it, > Our web site needs to upload a large volume of data into Postgres at a > time. The performance deterioates as number of rows becomes larger. > When it reaches 2500 rows, it never come back to GUI. Since the tests > were run through GUI, my suspision is > that it might be caused by the way the application server talking to > Postgres server, the connections, etc.. What might be the factors > involved here? Does anyone know? You don't really give us enough information. What GUI are you talking about? How are you loading this data - as a series of INSERT statements, text-file with separators, from Access/MySQL etc? In general, the fastest way to add a large number of rows is via the COPY sql command. Next best is to batch your inserts together into larger transactions of say 100-1000 inserts. Two other things to be aware of are: use of VACUUM/ANALYZE and configuration tuning (see http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php). PG shouldn't have a problem with inserting a few thousand rows, so I suspect it's something to do with your application/GUI setup. Hope that helps, if not try turning on statement logging for PG and then we can see what commands your GUI is sending. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Mon Feb 2 18:32:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9B4C3D1D2E5 for ; Mon, 2 Feb 2004 21:06:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 94473-02 for ; Mon, 2 Feb 2004 17:06:39 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 153B7D1D168 for ; Mon, 2 Feb 2004 17:06:37 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i12L2PRC025088; Mon, 2 Feb 2004 14:02:55 -0700 (MST) Date: Mon, 2 Feb 2004 13:58:35 -0700 (MST) From: "scott.marlowe" To: Kevin Barnard Cc: Subject: Re: Increasing number of PG connections. In-Reply-To: <401E4D27.26927.3254D8C1@localhost> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/18 X-Sequence-Number: 5542 On Mon, 2 Feb 2004, Kevin Barnard wrote: > I am running a Dual Xeon hyperthreaded server with 4GB RAM RAID-5. The only > thing running on the server is Postgres running under Fedora. I have a 700 > connection limit. > > The DB is setup as a backend for a very high volume website. Most of the queries > are simple, such as logging accesses, user login verification etc. There are a few > bigger things suchas reporting etc but for the most part each transaction lasts less > then a second. The connections are not persistant (I'm using pg_connect in PHP) > > The system was at 2 GB with a 400 connection limit. We ran into problems because > we hit the limit of connections during high volume. what do you mean at 2 GB? Is that how much is in kernel cache plus buffer, plus used, plus etc??? Could you give us the top of top output to make sure? If most of that is kernel cache, then that's fine. My experience has been that individual postgresql backends only weigh in at a mega byte at most, and they share buffer, so 700 connections can be anywhere from 300meg to 1 gig. the rest would be buffer memory. It's not a good idea to give up too much to shared buffers, as the database isn't as good at caching as the kernel. What do you have in postgresql.conf? sort_mem, shared_buffers, etc??? sort_mem can be a real killer if it lets the processes chew up too much memory. Once sort_mem gets high enough to make the machine start swapping it is doing more harm than good being that high, and should usually be lowered a fair bit. How many disks in your RAID5? The more the better. Is it hardware with battery backed cache? If you write much to it it will help to have battery backed cache on board. If it's a megaraid / LSI board, get the megaraid2 driver, it's supposedly much faster. You may find it hard to get postgresql to use any more memory than you have, as 32 bit apps can only address 2 gigs anyway, but the extra can certainly be used by the kernel as cache, which will help. From pgsql-performance-owner@postgresql.org Tue Feb 3 14:57:17 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A0B72D1D7FA for ; Mon, 2 Feb 2004 21:51:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 08976-05 for ; Mon, 2 Feb 2004 17:51:16 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 663F1D1D59F for ; Mon, 2 Feb 2004 17:51:14 -0400 (AST) 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 i12LpEsv065200 for ; Mon, 2 Feb 2004 21:51:14 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i12LQP1d059911 for pgsql-performance@postgresql.org; Mon, 2 Feb 2004 21:26:25 GMT From: "Loeke" X-Newsgroups: comp.databases.postgresql.performance Subject: Re: views? Date: Mon, 2 Feb 2004 22:26:43 +0100 Organization: KULeuvenNet Lines: 16 Message-ID: <1075757185.980191@seven.kulnet.kuleuven.ac.be> References: <1075316194.466850@seven.kulnet.kuleuven.ac.be> <87k738ivl8.fsf@mailbox.samurai.com> <200402020948.21370.dev@archonet.com> X-Complaints-To: abuse@belnet.be X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Cache-Post-Path: seven.kulnet.kuleuven.ac.be!unknown@10-4-148-255.kotnet.org X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/) To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=BAYES_00, FORGED_HOTMAIL_RCVD2, NO_DNS_FOR_FROM, PRIORITY_NO_NAME X-Spam-Level: X-Archive-Number: 200402/51 X-Sequence-Number: 5575 > > This is called a "materialized view". PostgreSQL doesn't support them > > yet, but most people think it would be a Good Thing to have. > > There is a project on gborg (called "mview" iirc) though I don't know how far > it's got - I think it's still pretty new. tnx > > ---------------------------(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 Mon Feb 2 17:37:48 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 36FC9D1D2DB for ; Mon, 2 Feb 2004 21:37:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 04591-05 for ; Mon, 2 Feb 2004 17:37:11 -0400 (AST) Received: from internet.potentialtech.com (h-66-167-251-6.PHLAPAFG.covad.net [66.167.251.6]) by svr1.postgresql.org (Postfix) with ESMTP id 8D145D1BCA7 for ; Mon, 2 Feb 2004 17:37:08 -0400 (AST) Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP id C383F69A68; Mon, 2 Feb 2004 16:37:05 -0500 (EST) Message-ID: <401EC2FE.3000500@potentialtech.com> Date: Mon, 02 Feb 2004 16:37:02 -0500 From: Bill Moran User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 X-Accept-Language: en-us, en MIME-Version: 1.0 Cc: Qing Zhao , pgsql-performance@postgresql.org Subject: Re: inserting large number of rows was: Re: Increasing References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/17 X-Sequence-Number: 5541 I must have missed this post when it was made earlier. Pardon the noise if my suggestion has already been made. Unlike MySQL (and possibly other database servers) PostgreSQL is faster when inserting inside a transaction. Depending on the method in which you are actually adding the records. In my own experience (generating a list of INSERT statements from a perl script and using psql to execute them) the difference in performance was incredibly dramatic when I added a "BEGIN WORK" at the beginning and "COMMIT WORK" at the end. scott.marlowe wrote: > On Mon, 2 Feb 2004, Qing Zhao wrote: > > >>I am new here. I have a question related to this in some way. >> >>Our web site needs to upload a large volume of data into Postgres at a >>time. The performance deterioates as number of rows becomes larger. >>When it reaches 2500 rows, it never come back to GUI. Since the tests >>were run through GUI, my suspision is >>that it might be caused by the way the application server talking to >>Postgres server, the connections, etc.. What might be the factors >>involved here? Does anyone know? > > > Actually, I'm gonna go out on a limb here and assume two things: > > 1. you've got lotsa fk/pk relationships setup. > 2. you're analyzing the table empty before loading it up. > > What happens in this instance is that the analyze on an empty, or nearly > so, table, means that during the inserts, postgresql thinks you have only > a few rows. At first, this is fine, as pgsql will seq scan the > tables to make sure there is a proper key in both. As the number of > rows increases, the planner needs to switch to index scans but doesn't, > because it doesn't know that the number of rows is increasing. > > Fix: insert a few hundred rows, run analyze, check to see if the explain > for inserts is showing index scans or not. If not, load a few more > hundred rows, analyze, rinse, repeat. > > Also, look for fk/pk mismatches. I.e. an int4 field pointing to an int8 > field. That's a performance killer, so if the pk/fk types don't match, > see if you can change your field types to match and try again. > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Mon Feb 2 19:14:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id CD202D1C512 for ; Mon, 2 Feb 2004 23:14:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 43339-02 for ; Mon, 2 Feb 2004 19:14:51 -0400 (AST) Received: from mail.ez3pl.com (66-136-75-131.ded.swbell.net [66.136.75.131]) by svr1.postgresql.org (Postfix) with ESMTP id 4C088D1BB72 for ; Mon, 2 Feb 2004 19:14:43 -0400 (AST) Received: from kbarnard ([172.25.96.149]) by mail.ez3pl.com (8.11.2/8.11.2) with ESMTP id i12NDgo12241 for ; Mon, 2 Feb 2004 17:13:42 -0600 From: "Kevin Barnard" To: Date: Mon, 02 Feb 2004 17:10:43 -0600 MIME-Version: 1.0 Subject: Re: Increasing number of PG connections. Message-ID: <401E8493.30458.332D5CEF@localhost> In-reply-to: References: <401E4D27.26927.3254D8C1@localhost> X-mailer: Pegasus Mail for Windows (v4.12a) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/19 X-Sequence-Number: 5543 On 2 Feb 2004 at 13:58, scott.marlowe wrote: > what do you mean at 2 GB? Is that how much is in kernel cache plus > buffer, plus used, plus etc??? Could you give us the top of top output to > make sure? If most of that is kernel cache, then that's fine. 2GB was total system memory. We upgraded to 4GB to prior to increasing the number of connections. Here's the top of top 16:14:17 up 2 days, 16:15, 1 user, load average: 7.60, 6.56, 4.61 730 processes: 721 sleeping, 9 running, 0 zombie, 0 stopped CPU states: cpu user nice system irq softirq iowait idle total 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% cpu00 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% cpu01 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% cpu02 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% cpu03 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% Mem: 3747644k av, 3298344k used, 449300k free, 0k shrd, 147880k buff 2158532k active, 760040k inactive Swap: 1048088k av, 0k used, 1048088k free 2262156k cached The DB is pretty close to max connections at this point in time. I don't know why CPU shows 0% in every bucket. It looks like I can increase the number of connections a little from here. This is a fairly standard Fedora install. It's using version 2.4.22 of the Kernel. Postgres is a complied version using 7.4.1 > experience has been that individual postgresql backends only weigh in at a > mega byte at most, and they share buffer, so 700 connections can be > anywhere from 300meg to 1 gig. the rest would be buffer memory. It's not > a good idea to give up too much to shared buffers, as the database isn't > as good at caching as the kernel. OK I take this as I should keep shared buffers around 2x connections then correct? > > What do you have in postgresql.conf? sort_mem, shared_buffers, etc??? Here is what I have that is not set from the defaults. max_connections = 700 shared_buffers = 1500 sort_mem = 512 random_page_cost = 2 stats_start_collector = true stats_command_string = true stats_block_level = true stats_row_level = true > sort_mem can be a real killer if it lets the processes chew up too much > memory. Once sort_mem gets high enough to make the machine start swapping > it is doing more harm than good being that high, and should usually be > lowered a fair bit. I dropped it down to 512 as you can see. Should I be running with all of the stats on? I am no longer using pg_autovacuum. I seem to be getting better results with an hourly Vacuum anaylse. > How many disks in your RAID5? The more the better. Is it hardware with > battery backed cache? If you write much to it it will help to have > battery backed cache on board. If it's a megaraid / LSI board, get the > megaraid2 driver, it's supposedly much faster. 4 disk IBM ServeRAID 5i with battery backed cache. > You may find it hard to get postgresql to use any more memory than you > have, as 32 bit apps can only address 2 gigs anyway, but the extra can > certainly be used by the kernel as cache, which will help. Isn't that only true for each indivdual process space. Shouldn't each process have access at most 2GB. If each backend is in it's own process space is this really a limit since all of my queries are pretty small. I have been monitoring the system has it gets up to load. For most of the time the sytem sits around 100-300 connections. Once it ramps up it ramps up hard. Top starts cycling at 0 and 133% CPU for irq, softirq and iowait. The system stays at 700 connections until users give up. I can watch bandwidth utilization drop to almost nothing right before the DB catches up. -- Kevin Barnard Speed Fulfillment and Call Center kbarnard@speedfc.com 214-258-0120 From pgsql-performance-owner@postgresql.org Mon Feb 2 19:52:02 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1C0FBD1B45B for ; Mon, 2 Feb 2004 23:51:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 56037-01 for ; Mon, 2 Feb 2004 19:51:57 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id EA020D1D2F7 for ; Mon, 2 Feb 2004 19:51:49 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i12NnWRC010207; Mon, 2 Feb 2004 16:49:32 -0700 (MST) Date: Mon, 2 Feb 2004 16:45:42 -0700 (MST) From: "scott.marlowe" To: Kevin Barnard Cc: Subject: Re: Increasing number of PG connections. In-Reply-To: <401E8493.30458.332D5CEF@localhost> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/20 X-Sequence-Number: 5544 On Mon, 2 Feb 2004, Kevin Barnard wrote: > On 2 Feb 2004 at 13:58, scott.marlowe wrote: > > > what do you mean at 2 GB? Is that how much is in kernel cache plus > > buffer, plus used, plus etc??? Could you give us the top of top output to > > make sure? If most of that is kernel cache, then that's fine. > > 2GB was total system memory. We upgraded to 4GB to prior to increasing the > number of connections. Oh, ok. I thought you meant the system was using 2 gigs of RAM for postgresql > Here's the top of top > > 16:14:17 up 2 days, 16:15, 1 user, load average: 7.60, 6.56, 4.61 > 730 processes: 721 sleeping, 9 running, 0 zombie, 0 stopped > CPU states: cpu user nice system irq softirq iowait idle > total 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% > cpu00 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% > cpu01 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% > cpu02 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% > cpu03 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% > Mem: 3747644k av, 3298344k used, 449300k free, 0k shrd, 147880k buff > 2158532k active, 760040k inactive > Swap: 1048088k av, 0k used, 1048088k free 2262156k cached when you have a high load but load CPU usage, you are usually I/O bound. > The DB is pretty close to max connections at this point in time. I don't know why > CPU shows 0% in every bucket. It looks like I can increase the number of > connections a little from here. This is a fairly standard Fedora install. It's using > version 2.4.22 of the Kernel. Postgres is a complied version using 7.4.1 On this machine you could probably handle even more. What I want is to get your page return times down enough so you don't need to increase the number of connections. I.e. if you've got 2 second response times and you drop those to 0.2 seconds, then you won't need as many processes to handle the load (theoretically... :-) > > experience has been that individual postgresql backends only weigh in at a > > mega byte at most, and they share buffer, so 700 connections can be > > anywhere from 300meg to 1 gig. the rest would be buffer memory. It's not > > a good idea to give up too much to shared buffers, as the database isn't > > as good at caching as the kernel. > > OK I take this as I should keep shared buffers around 2x connections then correct? Not really. What happens is that if the shared buffers are so large that they are as large as or god forbid, larger than the kernel cache, then the kernel cache becomes less effective. The general rule of thumb is 25% of memory, or 256 Megs, whichever is less. The real test is that you want enough shared_buffers so that all the result sets currently being smooshed up against each other in joins, sorts, etc... can fit in postgresql's shared buffers, or at least the buffers can hold a fair chunk of it. So, the number of buffers can be anywhere from a few thousand, up to 40000 or 50000, sometimes even higher. But for most tuning you won't be needing to be above 32768, which is 256 Megs of ram. > > What do you have in postgresql.conf? sort_mem, shared_buffers, etc??? > > Here is what I have that is not set from the defaults. > > max_connections = 700 > shared_buffers = 1500 > sort_mem = 512 > random_page_cost = 2 > stats_start_collector = true > stats_command_string = true > stats_block_level = true > stats_row_level = true > > > > sort_mem can be a real killer if it lets the processes chew up too much > > memory. Once sort_mem gets high enough to make the machine start swapping > > it is doing more harm than good being that high, and should usually be > > lowered a fair bit. > > I dropped it down to 512 as you can see. Should I be running with all of the stats on? > I am no longer using pg_autovacuum. I seem to be getting better results with an > hourly Vacuum anaylse. Seeing as how top shows 2262156k kernel cache, you can afford to give up a fair bit more than 512k per sort. I generally run 8192 (8 meg) but I don't handle 700 simos. Try running it a little higher, 2048, 4096, etc... and see if that helps. Note you can change sort_mem and just do a pg_ctl reload to make the change, without interrupting service, unlike shared_buffers, which requires a restart. > > How many disks in your RAID5? The more the better. Is it hardware with > > battery backed cache? If you write much to it it will help to have > > battery backed cache on board. If it's a megaraid / LSI board, get the > > megaraid2 driver, it's supposedly much faster. > > 4 disk IBM ServeRAID 5i with battery backed cache. Do you have the cache set to write back or write through? Write through can be a performance killer. But I don't think your RAID is the problem, it looks to me like postgresql is doing a lot of I/O. When you run top, do the postgresql processes show a lot of D status? That's usually waiting on I/O > > You may find it hard to get postgresql to use any more memory than you > > have, as 32 bit apps can only address 2 gigs anyway, but the extra can > > certainly be used by the kernel as cache, which will help. > > Isn't that only true for each indivdual process space. Shouldn't each process have > access at most 2GB. If each backend is in it's own process space is this really a limit > since all of my queries are pretty small. Right, each process can use a big chunk, but shared_buffers will top out at ~2 gig. Most tests have shown a negative return on a shared_buffers setting that big though, so the nicest thing about the extra memory is that the kernel can use it to cache, AND you can increase your sort_mem to something larger. > I have been monitoring the system has it gets up to load. For most of the time the > sytem sits around 100-300 connections. Once it ramps up it ramps up hard. Top > starts cycling at 0 and 133% CPU for irq, softirq and iowait. The system stays at 700 > connections until users give up. I can watch bandwidth utilization drop to almost > nothing right before the DB catches up. Yeah, it sounds to me like it's grinding down to a halt because postgresql isn't being able to hold enough data in memory for what it's doing. Try increasing shared_buffers to 5000 to as high as 30000 or 50000, a but at a time, as well as increasing sort_mem to 4096 or 8192. Note that increasing shared_buffers will have a very positive effect on performance at first, then less effect, then slowly bring it back down as it goes too high, but isn't likely to starve the machine (64k buffers = 512 meg, you've got the memory to spare, so no great loss). however, sort_mem will have a huge effect right up until it's big enough for all your sorts to fit into memory. once that happens, increasing it won't help or hurt UNTIL the machine gets enough load to make the sorts use up all memory and send it into a swap storm, so be careful about overdoing sorts. I.e. shared_buffers = too big, no big deal, sort_mem too big = time bomb. what you want to do is get the machine to a point where the kernel cache is about twice the size or larger, than the shared_buffers. I'd start at 10000 shared buffers and 4096 sort mem and see what happens. If you've still got >2 gig kernel cache at that point, then increase both a bit (2x or so) and see how much kernel cache you've got. If your kernel cache stays above 1Gig, and the machine is running faster, you're doing pretty good. you may need to increase shmmax and friends to increase the shared_buffers that high, but sort_mem requires no new kernel configuration. From pgsql-advocacy-owner@postgresql.org Mon Feb 2 20:45:13 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 09086D1D8CF; Tue, 3 Feb 2004 00:44:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 67945-09; Mon, 2 Feb 2004 20:44:59 -0400 (AST) Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) by svr1.postgresql.org (Postfix) with ESMTP id 68B23D1D8BF; Mon, 2 Feb 2004 20:44:55 -0400 (AST) Received: from [203.221.246.225] (helo=familyhealth.com.au) by relay01.kbs.net.au with esmtp (Exim 3.36 #2) id 1Anog4-0002w6-00; Tue, 03 Feb 2004 11:44:32 +1100 Message-ID: <401EEEF0.8050001@familyhealth.com.au> Date: Tue, 03 Feb 2004 08:44:32 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Adam Ruth Cc: josh@agliodbs.com, pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org Subject: Re: MySQL+InnoDB vs. PostgreSQL test? References: <200402020921.12076.josh@agliodbs.com> <83927B58-55AA-11D8-99C4-000A959D1424@intercation.com> In-Reply-To: <83927B58-55AA-11D8-99C4-000A959D1424@intercation.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/4 X-Sequence-Number: 3575 > One more thing that annoyed me. If you started a process, such as a > large DDL operation, or heaven forbid, a cartesian join (what? I never > do that!). I believe InnoDB also has O(n) rollback time. eg. if you are rolling back 100 million row changes, it takes a long, long time. In PostgreSQL rolling back is O(1)... Chris From pgsql-hackers-owner@postgresql.org Mon Feb 2 23:37:34 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DE7A5D1B4D2 for ; Tue, 3 Feb 2004 03:37:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 22809-01 for ; Mon, 2 Feb 2004 23:37:28 -0400 (AST) Received: from ALPHA6.ITS.MONASH.EDU.AU (alpha6.its.monash.edu.au [130.194.1.25]) by svr1.postgresql.org (Postfix) with ESMTP id 9A595D1B80B for ; Mon, 2 Feb 2004 23:37:23 -0400 (AST) Received: from localhost ([130.194.13.83]) by vaxc.its.monash.edu.au (PMDF V6.1 #39306) with ESMTP id <01L65X972JYQ9358F0@vaxc.its.monash.edu.au> for pgsql-hackers@postgresql.org; Tue, 03 Feb 2004 11:55:32 +1100 Received: from splat.its.monash.edu.au (localhost.its.monash.edu.au [127.0.0.1]) by localhost (Postfix) with ESMTP id E930923C008 for ; Tue, 03 Feb 2004 11:55:31 +1100 (EST) Received: from bruce.csse.monash.edu.au (bruce.csse.monash.edu.au [130.194.64.3]) by splat.its.monash.edu.au (Postfix) with ESMTP id D6C73164006 for ; Tue, 03 Feb 2004 11:55:31 +1100 (EST) Received: from bruce.csse.monash.edu.au (localhost [127.0.0.1]) by bruce.csse.monash.edu.au (8.12.8+Sun/8.12.8) with ESMTP id i130tVNq021492 for ; Tue, 03 Feb 2004 11:55:31 +1100 (EST) Received: from localhost (sgaric@localhost) by bruce.csse.monash.edu.au (8.12.8+Sun/8.12.2/Submit) with ESMTP id i130tV3w021489 for ; Tue, 03 Feb 2004 11:55:31 +1100 (EST) Date: Tue, 03 Feb 2004 11:55:31 +1100 (EST) From: Slavisa Garic Subject: COPY from question In-reply-to: <1070584326.18838.235.camel@cletus.lyris.com> To: pgsql-hackers@postgresql.org Message-id: MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Content-transfer-encoding: 7BIT X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/78 X-Sequence-Number: 49667 Hi, I have a question about the COPY statement. I am using PGSQL(7.3.4) with python-2.3 on RedHat v8 machine. The problem I have is the following. Using pg module in python I am trying to run the COPY command to populate the large table. I am using this to replace the INSERT which takes about few hours to add 70000 entries where copy takes minute and a half. Now these stats come from the NetBSD machine I also use which doesn't have this problem but has same python and same pgsql installed. My understanding is that COPY workes FROM 'filename' or STDIN where the last characters are '.\\n'. I tried using the copy from 'filename' and as I said NetBSD is not complaining where I get the following error on Linux machine even if permissions on the data file are 777: _pg.error: ERROR: COPY command, running in backend with effective uid 26, could not open file '/home/slavisa/.nimrod/experiments/demo/ejdata' for reading. Errno = Permission denied (13). I can't figure out why would this be occuring so I wanted to switch to FROM STDIN option but I got stuck here due to lack of knowledge I have to admit. What I would like to ask anyone who knows anything about this. If you know what the problem is with FROM file option or you know how to get COPY FROM STDIN working from within the python (or any other) program, help would be greatly appreciated, Regards, Slavisa From pgsql-advocacy-owner@postgresql.org Mon Feb 2 21:24:16 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DACDFD1D597; Tue, 3 Feb 2004 01:24:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 81703-04; Mon, 2 Feb 2004 21:24:11 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 86A43D1C513; Mon, 2 Feb 2004 21:24:07 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i131MNRC017447; Mon, 2 Feb 2004 18:22:23 -0700 (MST) Date: Mon, 2 Feb 2004 18:18:32 -0700 (MST) From: "scott.marlowe" To: Christopher Kings-Lynne Cc: Adam Ruth , , , Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? In-Reply-To: <401EEEF0.8050001@familyhealth.com.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/5 X-Sequence-Number: 3576 On Tue, 3 Feb 2004, Christopher Kings-Lynne wrote: > > One more thing that annoyed me. If you started a process, such as a > > large DDL operation, or heaven forbid, a cartesian join (what? I never > > do that!). > > I believe InnoDB also has O(n) rollback time. eg. if you are rolling > back 100 million row changes, it takes a long, long time. In PostgreSQL > rolling back is O(1)... Actually, it takes signifigantly longer to rollback than to roll forward, so to speak, so that if you inserted for 10,000 rows and it took 5 minutes, it would take upwards of 30 times as long to roll back. This is from the docs: http://www.mysql.com/documentation/mysql/bychapter/manual_Table_types.html#InnoDB_tuning Point 8: # Beware of big rollbacks of mass inserts: InnoDB uses the insert buffer to save disk I/O in inserts, but in a corresponding rollback no such mechanism is used. A disk-bound rollback can take 30 times the time of the corresponding insert. Killing the database process will not help because the rollback will start again at the database startup. The only way to get rid of a runaway rollback is to increase the buffer pool so that the rollback becomes CPU-bound and runs fast, or delete the whole InnoDB database. From pgsql-advocacy-owner@postgresql.org Mon Feb 2 22:49:32 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 12286D1D841 for ; Tue, 3 Feb 2004 02:49:28 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 04144-08 for ; Mon, 2 Feb 2004 22:49:25 -0400 (AST) Received: from smtp018.mail.yahoo.com (smtp018.mail.yahoo.com [216.136.174.115]) by svr1.postgresql.org (Postfix) with SMTP id E660BD1D55E for ; Mon, 2 Feb 2004 22:49:20 -0400 (AST) Received: from unknown (HELO europa.janwieck.net) (janwieck@68.80.245.191 with login) by smtp018.mail.yahoo.com with SMTP; 3 Feb 2004 02:49:23 -0000 Received: from Yahoo.com (pcp01341166pcs.wilog301.pa.comcast.net [68.80.245.191]) (authenticated) by europa.janwieck.net (8.11.6/8.11.6) with ESMTP id i132nIr32426; Mon, 2 Feb 2004 21:49:18 -0500 Message-ID: <401EFD98.2020402@Yahoo.com> Date: Mon, 02 Feb 2004 20:47:04 -0500 From: Jan Wieck User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org Subject: Re: MySQL+InnoDB vs. PostgreSQL test? References: <200402020921.12076.josh@agliodbs.com> In-Reply-To: <200402020921.12076.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/6 X-Sequence-Number: 3577 Josh Berkus wrote: > Folks, > > I've had requests from a couple of businesses to see results of infomal MySQL > +InnoDB vs. PostgreSQL tests. I know that we don't have the setup to do > full formal benchmarking, but surely someone in our community has gone > head-to-head on your own application? > Josh, how does someone compare an Apache+PHP+MySQL "thing" against something implemented with half the stuff done in stored procedures and the entire business model guarded by referential integrity, custom triggers and whatnot? Seriously, I am tired of this kind of question. You gotta get bold enough to stand up in a "meeting" like that, say "guy's, you can ask me how this compares to Oracle ... but if you're seriously asking me how this compares to MySQL, call me again when you've done your homework". 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-advocacy-owner@postgresql.org Tue Feb 3 14:48:59 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A5651D1D2A0; Tue, 3 Feb 2004 02:20:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 95585-09; Mon, 2 Feb 2004 22:20:39 -0400 (AST) Received: from localhost.localdomain (unknown [166.70.154.50]) by svr1.postgresql.org (Postfix) with ESMTP id A863FD1C7F0; Mon, 2 Feb 2004 22:20:31 -0400 (AST) Received: from [127.0.0.1] (strongbad [127.0.0.1]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id i132KHnn004555; Mon, 2 Feb 2004 19:20:27 -0700 In-Reply-To: <401EEEF0.8050001@familyhealth.com.au> References: <200402020921.12076.josh@agliodbs.com> <83927B58-55AA-11D8-99C4-000A959D1424@intercation.com> <401EEEF0.8050001@familyhealth.com.au> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <8B730E67-55EF-11D8-B13C-000A959D1424@mac.com> Content-Transfer-Encoding: 7bit Cc: pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org, josh@agliodbs.com From: Adam Ruth Subject: Re: MySQL+InnoDB vs. PostgreSQL test? Date: Mon, 2 Feb 2004 19:20:33 -0700 To: Christopher Kings-Lynne X-Mailer: Apple Mail (2.612) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/21 X-Sequence-Number: 3592 Wow, I didn't know that (didn't get far enough to test any rollback). That's not a good thing. But then again, it's MySQL who needs rollback anyway? On Feb 2, 2004, at 5:44 PM, Christopher Kings-Lynne wrote: >> One more thing that annoyed me. If you started a process, such as a >> large DDL operation, or heaven forbid, a cartesian join (what? I >> never do that!). > > I believe InnoDB also has O(n) rollback time. eg. if you are rolling > back 100 million row changes, it takes a long, long time. In > PostgreSQL rolling back is O(1)... > > Chris > From pgsql-advocacy-owner@postgresql.org Mon Feb 2 23:01:32 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6BDAED1D52A; Tue, 3 Feb 2004 03:01:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 08448-04; Mon, 2 Feb 2004 23:01:10 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id EA7F8D1D528; Mon, 2 Feb 2004 23:01:05 -0400 (AST) Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i1330QVD004981; Tue, 3 Feb 2004 11:00:26 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <401F0FCD.70903@familyhealth.com.au> Date: Tue, 03 Feb 2004 11:04:45 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jan Wieck Cc: josh@agliodbs.com, pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org Subject: Re: MySQL+InnoDB vs. PostgreSQL test? References: <200402020921.12076.josh@agliodbs.com> <401EFD98.2020402@Yahoo.com> In-Reply-To: <401EFD98.2020402@Yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/7 X-Sequence-Number: 3578 > Seriously, I am tired of this kind of question. You gotta get bold > enough to stand up in a "meeting" like that, say "guy's, you can ask me > how this compares to Oracle ... but if you're seriously asking me how > this compares to MySQL, call me again when you've done your homework". Hey at least I noticed that InnoDB has one essential feature we don't: SELECT ... IN SHARE MODE; Which does a shared lock on a row as opposed to a write lock, hence avoiding nasty foreign key deadlocks... Chris From pgsql-advocacy-owner@postgresql.org Mon Feb 2 23:42:57 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9E457D1CA83; Tue, 3 Feb 2004 03:42:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 22226-08; Mon, 2 Feb 2004 23:42:52 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id E90F9D1C967; Mon, 2 Feb 2004 23:42:47 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4361252; Mon, 02 Feb 2004 19:43:54 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Christopher Kings-Lynne , Jan Wieck Subject: Re: MySQL+InnoDB vs. PostgreSQL test? Date: Mon, 2 Feb 2004 19:41:57 -0800 User-Agent: KMail/1.5.4 Cc: pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org References: <200402020921.12076.josh@agliodbs.com> <401EFD98.2020402@Yahoo.com> <401F0FCD.70903@familyhealth.com.au> In-Reply-To: <401F0FCD.70903@familyhealth.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402021941.57516.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/8 X-Sequence-Number: 3579 Chris, > Hey at least I noticed that InnoDB has one essential feature we don't: > > SELECT ... IN SHARE MODE; > > Which does a shared lock on a row as opposed to a write lock, hence > avoiding nasty foreign key deadlocks... Um, wrong. We don't lock rows for SELECT. -- -Josh Berkus ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco From pgsql-hackers-owner@postgresql.org Tue Feb 3 00:01:07 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 797A7D1B582 for ; Tue, 3 Feb 2004 04:00:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 29364-01 for ; Tue, 3 Feb 2004 00:00:46 -0400 (AST) Received: from mail63.csoft.net (leary.csoft.net [63.111.22.80]) by svr1.postgresql.org (Postfix) with SMTP id 4D949D1CCDB for ; Tue, 3 Feb 2004 00:00:46 -0400 (AST) Received: (qmail 9542 invoked by uid 1112); 3 Feb 2004 04:01:35 -0000 Date: Mon, 2 Feb 2004 23:01:35 -0500 (EST) From: Kris Jurka X-X-Sender: To: Slavisa Garic Cc: Subject: Re: COPY from question In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/80 X-Sequence-Number: 49669 On Tue, 3 Feb 2004, Slavisa Garic wrote: > My understanding is that COPY workes FROM 'filename' or STDIN where the > last characters are '.\\n'. I tried using the copy from 'filename' and as > I said NetBSD is not complaining where I get the following error on Linux > machine even if permissions on the data file are 777: > > _pg.error: ERROR: COPY command, running in backend with effective uid > 26, could not open file '/home/slavisa/.nimrod/experiments/demo/ejdata' > for reading. Errno = Permission denied (13). > This is probably a permissions problem at a higher level, check the permissions on the directories in the path. Kris Jurka From pgsql-hackers-owner@postgresql.org Tue Feb 3 00:07:19 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B8370D1D27C for ; Tue, 3 Feb 2004 04:07:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 27899-09 for ; Tue, 3 Feb 2004 00:07:08 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 20BF2D1D2A0 for ; Tue, 3 Feb 2004 00:07:09 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i13475fT011230; Mon, 2 Feb 2004 23:07:05 -0500 (EST) To: Slavisa Garic Cc: pgsql-hackers@postgresql.org Subject: Re: COPY from question In-reply-to: References: Comments: In-reply-to Slavisa Garic message dated "Tue, 03 Feb 2004 11:55:31 +1100" Date: Mon, 02 Feb 2004 23:07:05 -0500 Message-ID: <11229.1075781225@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/81 X-Sequence-Number: 49670 Slavisa Garic writes: > ... I get the following error on Linux > machine even if permissions on the data file are 777: > _pg.error: ERROR: COPY command, running in backend with effective uid > 26, could not open file '/home/slavisa/.nimrod/experiments/demo/ejdata' > for reading. Errno = Permission denied (13). Most likely the postgres user doesn't have read permission for one of the directories in that path. regards, tom lane PS: this didn't really belong on pghackers. From pgsql-advocacy-owner@postgresql.org Tue Feb 3 14:49:03 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A5245D1D8A9 for ; Tue, 3 Feb 2004 04:08:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 32152-01 for ; Tue, 3 Feb 2004 00:08:51 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 20C95D1D492 for ; Tue, 3 Feb 2004 00:08:52 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1348ggc011251; Mon, 2 Feb 2004 23:08:42 -0500 (EST) To: josh@agliodbs.com Cc: Christopher Kings-Lynne , Jan Wieck , pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? In-reply-to: <200402021941.57516.josh@agliodbs.com> References: <200402020921.12076.josh@agliodbs.com> <401EFD98.2020402@Yahoo.com> <401F0FCD.70903@familyhealth.com.au> <200402021941.57516.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Mon, 02 Feb 2004 19:41:57 -0800" Date: Mon, 02 Feb 2004 23:08:42 -0500 Message-ID: <11250.1075781322@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/22 X-Sequence-Number: 3593 Josh Berkus writes: >> Hey at least I noticed that InnoDB has one essential feature we don't: >> SELECT ... IN SHARE MODE; >> >> Which does a shared lock on a row as opposed to a write lock, hence >> avoiding nasty foreign key deadlocks... > Um, wrong. We don't lock rows for SELECT. No, but Chris is correct that we could do with having some kind of shared lock facility at the row level. regards, tom lane From pgsql-advocacy-owner@postgresql.org Tue Feb 3 00:27:42 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5C973D1CACB; Tue, 3 Feb 2004 04:27:28 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 33584-07; Tue, 3 Feb 2004 00:27:24 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 7D3A7D1D1D5; Tue, 3 Feb 2004 00:27:22 -0400 (AST) Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i134QMVD013986; Tue, 3 Feb 2004 12:26:22 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <401F23F3.8080009@familyhealth.com.au> Date: Tue, 03 Feb 2004 12:30:43 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: josh@agliodbs.com, Jan Wieck , pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? References: <200402020921.12076.josh@agliodbs.com> <401EFD98.2020402@Yahoo.com> <401F0FCD.70903@familyhealth.com.au> <200402021941.57516.josh@agliodbs.com> <11250.1075781322@sss.pgh.pa.us> In-Reply-To: <11250.1075781322@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/10 X-Sequence-Number: 3581 >>Um, wrong. We don't lock rows for SELECT. > > No, but Chris is correct that we could do with having some kind of > shared lock facility at the row level. Out of interest, what is it about this particular task that's so hard? (Not that I could code it myself). But surely you can use the same sort of thing as the FOR UPDATE code path? Chris From pgsql-advocacy-owner@postgresql.org Tue Feb 3 14:49:07 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6FE00D1D516 for ; Tue, 3 Feb 2004 04:44:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 39778-06 for ; Tue, 3 Feb 2004 00:44:04 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 28EF1D1D4D5 for ; Tue, 3 Feb 2004 00:44:05 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i134hvmY011554; Mon, 2 Feb 2004 23:43:57 -0500 (EST) To: Christopher Kings-Lynne Cc: josh@agliodbs.com, Jan Wieck , pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? In-reply-to: <401F23F3.8080009@familyhealth.com.au> References: <200402020921.12076.josh@agliodbs.com> <401EFD98.2020402@Yahoo.com> <401F0FCD.70903@familyhealth.com.au> <200402021941.57516.josh@agliodbs.com> <11250.1075781322@sss.pgh.pa.us> <401F23F3.8080009@familyhealth.com.au> Comments: In-reply-to Christopher Kings-Lynne message dated "Tue, 03 Feb 2004 12:30:43 +0800" Date: Mon, 02 Feb 2004 23:43:57 -0500 Message-ID: <11553.1075783437@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/23 X-Sequence-Number: 3594 Christopher Kings-Lynne writes: >> No, but Chris is correct that we could do with having some kind of >> shared lock facility at the row level. > Out of interest, what is it about this particular task that's so hard? Keeping track of multiple lockers in a fixed amount of disk space. regards, tom lane From pgsql-advocacy-owner@postgresql.org Tue Feb 3 01:21:26 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0C9D8D1D179 for ; Tue, 3 Feb 2004 05:21:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 49824-06 for ; Tue, 3 Feb 2004 01:21:20 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 002A9D1CCD7 for ; Tue, 3 Feb 2004 01:21:21 -0400 (AST) 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 i135LKsv060801 for ; Tue, 3 Feb 2004 05:21:20 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i1354guq057597 for pgsql-advocacy@postgresql.org; Tue, 3 Feb 2004 05:04:42 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.advocacy Subject: Re: MySQL+InnoDB vs. PostgreSQL test? Date: Mon, 02 Feb 2004 23:54:15 -0500 Organization: cbbrowne Computing Inc Lines: 58 Message-ID: References: <200402020921.12076.josh@agliodbs.com> <401EFD98.2020402@Yahoo.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 (Reasonable Discussion, linux) Cancel-Lock: sha1:FlHFE6j3aqeVcjDx1wGz/kE5/GA= To: pgsql-advocacy@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/13 X-Sequence-Number: 3584 In an attempt to throw the authorities off his trail, JanWieck@Yahoo.com (Jan Wieck) transmitted: > Josh Berkus wrote: >> I've had requests from a couple of businesses to see results of >> infomal MySQL >> +InnoDB vs. PostgreSQL tests. I know that we don't have the setup >> to do full formal benchmarking, but surely someone in our community >> has gone head-to-head on your own application? > > how does someone compare an Apache+PHP+MySQL "thing" against something > implemented with half the stuff done in stored procedures and the > entire business model guarded by referential integrity, custom > triggers and whatnot? > > Seriously, I am tired of this kind of question. You gotta get bold > enough to stand up in a "meeting" like that, say "guy's, you can ask > me how this compares to Oracle ... but if you're seriously asking me > how this compares to MySQL, call me again when you've done your > homework". Actually, before saying anything in public about their products, check out what they require for use of their protected trademarks. To wit, they indicate that: "The MySQL AB Marks may not be used in a manner or with respect to products that will decrease the value of the MySQL AB Marks or otherwise impair or damage MySQL AB's brand integrity, reputation or goodwill" It seems to me that presenting a benchmark that did not favor their product could be quite reasonably considered to be an "impairment" of their integrity, reputation, or goodwill, and therefore be something worthy of legal attack. That certainly wouldn't be new to the database industry; numerous (most?) database vendors forbid third parties from presenting benchmarks without their express consent. It is actually rather surprising that despite having the budget to put together a "benchmarketing" group, the only results that they are publishing are multiple years old, with a paucity of InnoDB(tm) results, and where they only seem to compare it with ancient versions of "competitors." And, of course, if "MaxDB(tm)" is their future, replacing the older storage schemes, the benchmarks should be based on that. And the benchmarks that exist there are all based on the R/3 (tm) SD module, which is spectacularly different from the usual web server work. (It looks like that involves throwing a load of BDC sessions at the server, but I'm guessing, and in any case, it's work SAP AG did...) -- let name="cbbrowne" and tld="acm.org" in name ^ "@" ^ tld;; http://www.ntlug.org/~cbbrowne/nonrdbms.html "Has anyone ever thought about the fact that in general, the only web sites that are consistently making money are the ones dealing in pornography? This brings new meaning to the term, "obscene profits". :)" -- Paul Robinson From pgsql-advocacy-owner@postgresql.org Tue Feb 3 00:51:59 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8767AD1D88B; Tue, 3 Feb 2004 04:51:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 43185-04; Tue, 3 Feb 2004 00:51:36 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 30CD6D1D52A; Tue, 3 Feb 2004 00:51:35 -0400 (AST) Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i134p5VD016899; Tue, 3 Feb 2004 12:51:05 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <401F29BF.7060705@familyhealth.com.au> Date: Tue, 03 Feb 2004 12:55:27 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: josh@agliodbs.com, Jan Wieck , pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? References: <200402020921.12076.josh@agliodbs.com> <401EFD98.2020402@Yahoo.com> <401F0FCD.70903@familyhealth.com.au> <200402021941.57516.josh@agliodbs.com> <11250.1075781322@sss.pgh.pa.us> <401F23F3.8080009@familyhealth.com.au> <11553.1075783437@sss.pgh.pa.us> In-Reply-To: <11553.1075783437@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/11 X-Sequence-Number: 3582 >>Out of interest, what is it about this particular task that's so hard? > > > Keeping track of multiple lockers in a fixed amount of disk space. Why not look at how InnoDB does it? Or is that not applicable? From pgsql-advocacy-owner@postgresql.org Tue Feb 3 01:18:19 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id CD1A8D1CCD6; Tue, 3 Feb 2004 05:18:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 45848-10; Tue, 3 Feb 2004 01:18:10 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id A58F7D1CAF6; Tue, 3 Feb 2004 01:18:10 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4361698; Mon, 02 Feb 2004 21:19:13 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Christopher Kings-Lynne Subject: Re: MySQL+InnoDB vs. PostgreSQL test? Date: Mon, 2 Feb 2004 21:17:15 -0800 User-Agent: KMail/1.5.4 Cc: pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org References: <200402020921.12076.josh@agliodbs.com> <401F0FCD.70903@familyhealth.com.au> <200402021941.57516.josh@agliodbs.com> In-Reply-To: <200402021941.57516.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402022117.15918.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/12 X-Sequence-Number: 3583 Chris, > > Which does a shared lock on a row as opposed to a write lock, hence > > avoiding nasty foreign key deadlocks... > > Um, wrong. We don't lock rows for SELECT. Unless you meant something else? Am I not following you? -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-advocacy-owner@postgresql.org Tue Feb 3 01:49:17 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 33B5DD1D18D; Tue, 3 Feb 2004 05:49:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 58246-02; Tue, 3 Feb 2004 01:49:10 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id C6897D1CCCF; Tue, 3 Feb 2004 01:49:09 -0400 (AST) Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i135mHVD023374; Tue, 3 Feb 2004 13:48:17 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <401F3729.9010202@familyhealth.com.au> Date: Tue, 03 Feb 2004 13:52:41 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org Subject: Re: MySQL+InnoDB vs. PostgreSQL test? References: <200402020921.12076.josh@agliodbs.com> <401F0FCD.70903@familyhealth.com.au> <200402021941.57516.josh@agliodbs.com> <200402022117.15918.josh@agliodbs.com> In-Reply-To: <200402022117.15918.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/14 X-Sequence-Number: 3585 >>Um, wrong. We don't lock rows for SELECT. > > Unless you meant something else? Am I not following you? I mean row level shared read lock. eg. a lock that says, you can read but you cannot delete. It's what postgres needs to alleviate its foreign key trigger deadlock problems. Chris From pgsql-performance-owner@postgresql.org Tue Feb 3 03:03:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D5387D1C9E1 for ; Tue, 3 Feb 2004 07:03:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 73713-08 for ; Tue, 3 Feb 2004 03:02:57 -0400 (AST) Received: from mx1.starman.ee (mx1.starman.ee [62.65.192.16]) by svr1.postgresql.org (Postfix) with ESMTP id 5F074D1B837 for ; Tue, 3 Feb 2004 03:02:56 -0400 (AST) Received: from webware.ee (pc234.host4.starman.ee [62.65.196.234]) by mx1.starman.ee (Postfix) with ESMTP id A17AF193381; Tue, 3 Feb 2004 09:02:29 +0200 (EET) Message-ID: <401F47A9.7070106@webware.ee> Date: Tue, 03 Feb 2004 09:03:05 +0200 From: =?ISO-8859-1?Q?Erki_Kaldj=E4rv?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.0.1) Gecko/20020823 Netscape/7.0 X-Accept-Language: en-gb, en MIME-Version: 1.0 To: Bill Moran Cc: Qing Zhao , pgsql-performance@postgresql.org Subject: Re: inserting large number of rows was: Re: Increasing References: <401EC2FE.3000500@potentialtech.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/31 X-Sequence-Number: 5555 You could do high speed inserts with COPY command: http://developer.postgresql.org/docs/postgres/sql-copy.html Check whenether your database adapter/client lib supports it (i guess it does). Note that it doesnt help very much if there are fk's/triggers's on the target table. Bill Moran wrote: > I must have missed this post when it was made earlier. Pardon the > noise if > my suggestion has already been made. > > Unlike MySQL (and possibly other database servers) PostgreSQL is > faster when > inserting inside a transaction. Depending on the method in which you are > actually adding the records. > > In my own experience (generating a list of INSERT statements from a perl > script and using psql to execute them) the difference in performance was > incredibly dramatic when I added a "BEGIN WORK" at the beginning and > "COMMIT WORK" at the end. > > scott.marlowe wrote: > >> On Mon, 2 Feb 2004, Qing Zhao wrote: >> >> >>> I am new here. I have a question related to this in some way. >>> >>> Our web site needs to upload a large volume of data into Postgres at >>> a time. The performance deterioates as number of rows becomes >>> larger. When it reaches 2500 rows, it never come back to GUI. Since >>> the tests were run through GUI, my suspision is >>> that it might be caused by the way the application server talking to >>> Postgres server, the connections, etc.. What might be the factors >>> involved here? Does anyone know? >> >> >> >> Actually, I'm gonna go out on a limb here and assume two things: >> >> 1. you've got lotsa fk/pk relationships setup. >> 2. you're analyzing the table empty before loading it up. >> >> What happens in this instance is that the analyze on an empty, or >> nearly so, table, means that during the inserts, postgresql thinks >> you have only a few rows. At first, this is fine, as pgsql will seq >> scan the tables to make sure there is a proper key in both. As the >> number of rows increases, the planner needs to switch to index scans >> but doesn't, because it doesn't know that the number of rows is >> increasing. >> >> Fix: insert a few hundred rows, run analyze, check to see if the >> explain for inserts is showing index scans or not. If not, load a >> few more hundred rows, analyze, rinse, repeat. >> >> Also, look for fk/pk mismatches. I.e. an int4 field pointing to an >> int8 field. That's a performance killer, so if the pk/fk types don't >> match, see if you can change your field types to match and try again. >> >> >> ---------------------------(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 Tue Feb 3 03:25:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BD9C7D1B57C for ; Tue, 3 Feb 2004 07:25:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 81015-09 for ; Tue, 3 Feb 2004 03:25:41 -0400 (AST) Received: from marvin.harmless.hu (marvin.harmless.hu [195.70.51.173]) by svr1.postgresql.org (Postfix) with ESMTP id 10024D1B53C for ; Tue, 3 Feb 2004 03:25:41 -0400 (AST) Received: from marvin.harmless.hu (marvin.harmless.hu [195.70.51.173]) by marvin.harmless.hu (Postfix) with ESMTP id DDFE31000118B for ; Tue, 3 Feb 2004 08:25:38 +0100 (CET) Date: Tue, 3 Feb 2004 08:25:38 +0100 (CET) From: Czuczy Gergely X-X-Sender: phoemix@localhost To: pgsql-performance@postgresql.org Subject: PQexecParams and types Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/32 X-Sequence-Number: 5556 Hello i've read in the docs to use the proper indexes both types must match in the where clause, to achive this the user can simply put a string into the side of the equation mark and pgsql will convert it automaticly. my question is, when I'm using PQexecParams, should I give all the values as a string, and it will be converted, or I have to figure out the type of the given field somehow? i'm writing an interface for my php extension(i'm not statisfied by the boundled), so i cannot figure out the type of the fields in most cases. what should be done for the best performance in this situation? Bye, Gergely Czuczy mailto: phoemix@harmless.hu PGP: http://phoemix.harmless.hu/phoemix.pgp The point is, that geeks are not necessarily the outcasts society often believes they are. The fact is that society isn't cool enough to be included in our activities. From pgsql-hackers-owner@postgresql.org Tue Feb 3 06:58:03 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 55C7ED1B4C0 for ; Tue, 3 Feb 2004 10:58:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 63059-02 for ; Tue, 3 Feb 2004 06:57:45 -0400 (AST) Received: from filer (c-24-6-183-218.client.comcast.net [24.6.183.218]) by svr1.postgresql.org (Postfix) with ESMTP id B64A3D1D342 for ; Tue, 3 Feb 2004 06:57:43 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Tue, 03 Feb 2004 02:57:46 -0800 Date: Tue, 3 Feb 2004 02:57:46 -0800 From: Kevin Brown To: pgsql-hackers@postgresql.org Subject: Re: COPY from question Message-ID: <20040203105746.GE2608@filer> Mail-Followup-To: Kevin Brown , pgsql-hackers@postgresql.org References: <1070584326.18838.235.camel@cletus.lyris.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: Organization: Frobozzco International User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/85 X-Sequence-Number: 49674 Slavisa Garic wrote: > Using pg module in python I am trying to run the COPY command to populate > the large table. I am using this to replace the INSERT which takes about > few hours to add 70000 entries where copy takes minute and a half. That difference in speed seems quite large. Too large. Are you batching your INSERTs into transactions (you should be in order to get good performance)? Do you have a ton of indexes on the table? Does it have triggers on it or some other thing (if so then COPY may well wind up doing the wrong thing since the triggers won't fire for the rows it inserts)? I don't know what kind of schema you're using, but it takes perhaps a couple of hours to insert 2.5 million rows on my system. But the rows in my schema may be much smaller than yours. -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Tue Feb 3 08:54:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 28D62D1B511 for ; Tue, 3 Feb 2004 12:54:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 06711-02 for ; Tue, 3 Feb 2004 08:54:33 -0400 (AST) Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) by svr1.postgresql.org (Postfix) with ESMTP id 82803D1D8A9 for ; Tue, 3 Feb 2004 08:54:31 -0400 (AST) Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) id 1Ao04K-0005L7-Oz for pgsql-performance@postgresql.org; Tue, 03 Feb 2004 13:54:20 +0100 Received: from [195.135.143.205] (helo=[195.135.143.205]) by emma.rox.net with asmtp (Exim 4.22) id 1Ao04K-0005Kh-3B for pgsql-performance@postgresql.org; Tue, 03 Feb 2004 13:54:20 +0100 Mime-Version: 1.0 (Apple Message framework v612) Content-Transfer-Encoding: 7bit Message-Id: <13E980A8-5648-11D8-BC99-000A95A6F0DC@cluster9.com> Content-Type: text/plain; charset=US-ASCII; format=flowed To: PgSQL Performance ML From: David Teran Subject: cache whole data in RAM Date: Tue, 3 Feb 2004 13:54:17 +0100 X-Mailer: Apple Mail (2.612) X-Scanned-By: rockenstein AG X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/33 X-Sequence-Number: 5557 Hi, we are trying to speed up a database which has about 3 GB of data. The server has 8 GB RAM and we wonder how we can ensure that the whole DB is read into RAM. We hope that this will speed up some queries. regards David From pgsql-performance-owner@postgresql.org Tue Feb 3 09:21:25 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0CB5ED1DA34 for ; Tue, 3 Feb 2004 13:21:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 15032-03 for ; Tue, 3 Feb 2004 09:21:21 -0400 (AST) Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) by svr1.postgresql.org (Postfix) with ESMTP id 9E7B3D1D9F2 for ; Tue, 3 Feb 2004 09:21:19 -0400 (AST) Received: from concord.pspl.co.in ([202.54.11.72]:62622 helo=frodo.hserus.net) by frodo.hserus.net with asmtp (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.30 #0) id 1Ao0UR-000NGw-8g by authid with plain; Tue, 03 Feb 2004 18:51:19 +0530 Message-ID: <401FA16E.4040202@frodo.hserus.net> Date: Tue, 03 Feb 2004 18:56:06 +0530 From: Shridhar Daithankar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Teran Cc: PgSQL Performance ML Subject: Re: cache whole data in RAM References: <13E980A8-5648-11D8-BC99-000A95A6F0DC@cluster9.com> In-Reply-To: <13E980A8-5648-11D8-BC99-000A95A6F0DC@cluster9.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/34 X-Sequence-Number: 5558 David Teran wrote: > we are trying to speed up a database which has about 3 GB of data. The > server has 8 GB RAM and we wonder how we can ensure that the whole DB is > read into RAM. We hope that this will speed up some queries. Neither the DBa or postgresql has to do anything about it. Usually OS caches the data in it's buffer cache. That is certainly true for linux and freeBSD does that. Most of the unices certainly do. To my knowledge linux is most aggresive one at that..(Rather over aggressive..) Make sure that you size effective cache size correctly. It helps postgresql planner at times.. HTH Shridhar From pgsql-performance-owner@postgresql.org Tue Feb 3 09:26:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 47C86D1D189 for ; Tue, 3 Feb 2004 13:26:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 14848-06 for ; Tue, 3 Feb 2004 09:26:11 -0400 (AST) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id D59ABD1D12E for ; Tue, 3 Feb 2004 09:26:08 -0400 (AST) Received: (qmail 21804 invoked by uid 500); 3 Feb 2004 13:27:39 -0000 Date: Tue, 3 Feb 2004 07:27:39 -0600 From: Bruno Wolff III To: David Teran Cc: PgSQL Performance ML Subject: Re: cache whole data in RAM Message-ID: <20040203132739.GA1468@wolff.to> Mail-Followup-To: David Teran , PgSQL Performance ML References: <13E980A8-5648-11D8-BC99-000A95A6F0DC@cluster9.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13E980A8-5648-11D8-BC99-000A95A6F0DC@cluster9.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/35 X-Sequence-Number: 5559 On Tue, Feb 03, 2004 at 13:54:17 +0100, David Teran wrote: > Hi, > > we are trying to speed up a database which has about 3 GB of data. The > server has 8 GB RAM and we wonder how we can ensure that the whole DB > is read into RAM. We hope that this will speed up some queries. The OS should do this on its own. What you don't want to do is set shared_buffers (in postgresql.conf) too high. From what I remember from past discussions it should be something between about 1000 and 10000. sort_mem is trickier since that memory is per sort and a single query can potentially generate multiple parallel sorts. You will have to make some guesses for this based on what you think the number of concurrent sorts will be when the system is stressed and not use too much memory. You might also find that after a point you don't get a lot of benefit from increasing sort_mem. You should set effective_cache_size pretty large. Probably you want to subtract the space used by shared_buffers and sort_mem (* times estimated parallel sorts) and what you think is reasonable overhead for other processes from the 8GB of memory. Since your DB's disk blocks will almost certainly all be in buffer cache, you are going to want to set random_page_cost to be pretty close to 1. From pgsql-performance-owner@postgresql.org Tue Feb 3 09:36:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3FF6BD1D2DF for ; Tue, 3 Feb 2004 13:36:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 18445-05 for ; Tue, 3 Feb 2004 09:36:02 -0400 (AST) Received: from ms-smtp-03.tampabay.rr.com (ms-smtp-03-smtplb.tampabay.rr.com [65.32.5.133]) by svr1.postgresql.org (Postfix) with ESMTP id 2A022D1D120 for ; Tue, 3 Feb 2004 09:35:58 -0400 (AST) Received: from unity.basin.cultured.net (24161231hfc249.tampabay.rr.com [24.161.231.249]) by ms-smtp-03.tampabay.rr.com (8.12.10/8.12.7) with ESMTP id i13DZv1c004905; Tue, 3 Feb 2004 08:35:57 -0500 (EST) Subject: Re: cache whole data in RAM From: Chris Trawick To: David Teran Cc: PgSQL Performance ML In-Reply-To: <13E980A8-5648-11D8-BC99-000A95A6F0DC@cluster9.com> References: <13E980A8-5648-11D8-BC99-000A95A6F0DC@cluster9.com> Content-Type: text/plain Message-Id: <1075815126.15880.0.camel@unity.basin.cultured.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Tue, 03 Feb 2004 08:32:07 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/36 X-Sequence-Number: 5560 Put it on a RAM disk. chris On Tue, 2004-02-03 at 07:54, David Teran wrote: > Hi, > > we are trying to speed up a database which has about 3 GB of data. The > server has 8 GB RAM and we wonder how we can ensure that the whole DB > is read into RAM. We hope that this will speed up some queries. > > regards David > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html > From pgsql-advocacy-owner@postgresql.org Tue Feb 3 09:49:27 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E5FB4D1D283 for ; Tue, 3 Feb 2004 13:49:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 25020-06 for ; Tue, 3 Feb 2004 09:49:17 -0400 (AST) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 45FF8D1B83D for ; Tue, 3 Feb 2004 09:49:14 -0400 (AST) Received: (qmail 32015 invoked from network); 3 Feb 2004 13:49:20 -0000 Received: from localhost (HELO squeegit) (threshar@127.0.0.1) by localhost with SMTP; 3 Feb 2004 13:49:20 -0000 Date: Tue, 3 Feb 2004 08:52:03 -0500 From: Jeff To: josh@agliodbs.com Cc: pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? Message-Id: <20040203085203.5c5f926c.threshar@torgo.978.org> In-Reply-To: <83927B58-55AA-11D8-99C4-000A959D1424@intercation.com> References: <200402020921.12076.josh@agliodbs.com> <83927B58-55AA-11D8-99C4-000A959D1424@intercation.com> X-Mailer: Sylpheed version 0.9.9 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/15 X-Sequence-Number: 3586 Well, when I prepared my PG presentation I did some testing of MySQL (So I could be justified in calling it lousy :). I used the latest release (4.0.something I think) I was first bitten by my table type being MyISAM when I thought I set the default ot InnoDB. But I decided since my test was going to be read-only MyISAM should be the best possible choice. I loaded up a couple million records and changed my stored procedure into a perl script [I also decided to use this perl script for testing PG to be fair]. For one client mysql simply screamed. Then I decided to see what happens with 20 clients. MySQL clocked in at 650 seconds. During this time the machine was VERY unresponsive. To be fair, that could be Linux, not MySQL. PG (7.3.4) clocked in at 220 seconds. The machine was perfectly fine during the test - nice and responsive. The hardware wasn't much - dual p2-450 running stock RH8. (2x15k 18g scsi drives for the data volume) Then I decided to try the "beloved" InnoDB. Well.. after it sat for a few hours at 100% cpu loading the data I killed it off and gave up on InnoDB.. I am interested in the numbers. Perhaps I'll fire it up again someday and let it finish loading. Remember - you cannot judge mysql by since connection performance - you can't beat it. But just add up the concurrency and watch the cookies tumble -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-advocacy-owner@postgresql.org Tue Feb 3 14:49:22 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6080CD1CAC7; Tue, 3 Feb 2004 14:02:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 28744-10; Tue, 3 Feb 2004 10:02:49 -0400 (AST) Received: from linux.finestmedia.tv (linux.finestmedia.tv [213.180.31.12]) by svr1.postgresql.org (Postfix) with ESMTP id CF7ACD1D189; Tue, 3 Feb 2004 10:02:46 -0400 (AST) Received: from rigmor (sms.finestmedia.tv [213.180.31.11]) by linux.finestmedia.tv (Postfix) with SMTP id 2A94418E718; Tue, 3 Feb 2004 15:59:53 +0200 (EET) From: "Rigmor Ukuhe" To: "Jeff" , Cc: , Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? Date: Tue, 3 Feb 2004 16:02:00 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: <20040203085203.5c5f926c.threshar@torgo.978.org> X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/26 X-Sequence-Number: 3597 > script [I also decided to use this perl script for testing PG to be > fair]. > > For one client mysql simply screamed. > If already have test case set up, you could inform us, from where Postgres starts to beat MySql. Because if with 5 clients it still "screams" then i would give it a try in case of that kind of requirements. Rigmor Ukuhe > Then I decided to see what happens with 20 clients. > > MySQL clocked in at 650 seconds. During this time the machine was VERY > unresponsive. To be fair, that could be Linux, not MySQL. > > PG (7.3.4) clocked in at 220 seconds. The machine was perfectly fine > during the test - nice and responsive. > > The hardware wasn't much - dual p2-450 running stock RH8. (2x15k 18g > scsi drives for the data volume) > > Then I decided to try the "beloved" InnoDB. > > Well.. after it sat for a few hours at 100% cpu loading the data I > killed it off and gave up on InnoDB.. I am interested in the numbers. > Perhaps I'll fire it up again someday and let it finish loading. > > Remember - you cannot judge mysql by since connection performance - you > can't beat it. But just add up the concurrency and watch the cookies > tumble > > -- > Jeff Trout > http://www.jefftrout.com/ > http://www.stuarthamm.net/ > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend > --- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.564 / Virus Database: 356 - Release Date: 19.01.2004 > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.564 / Virus Database: 356 - Release Date: 19.01.2004 From pgsql-performance-owner@postgresql.org Tue Feb 3 10:53:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 18CDAD1B911 for ; Tue, 3 Feb 2004 14:53:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 57543-01 for ; Tue, 3 Feb 2004 10:53:22 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 0749FD1B4B7 for ; Tue, 3 Feb 2004 10:53:19 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i13ErDXx017667; Tue, 3 Feb 2004 09:53:14 -0500 (EST) To: Czuczy Gergely Cc: pgsql-performance@postgresql.org Subject: Re: PQexecParams and types In-reply-to: References: Comments: In-reply-to Czuczy Gergely message dated "Tue, 03 Feb 2004 08:25:38 +0100" Date: Tue, 03 Feb 2004 09:53:13 -0500 Message-ID: <17666.1075819993@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/39 X-Sequence-Number: 5563 Czuczy Gergely writes: > i've read in the docs to use the proper indexes both types must match in > the where clause, to achive this the user can simply put a string into the > side of the equation mark and pgsql will convert it automaticly. my > question is, when I'm using PQexecParams, should I give all the values as > a string, and it will be converted, or I have to figure out the type of > the given field somehow? You should leave the parameter types unspecified. Their types will be resolved in much the same way that a quoted literal is handled. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Feb 3 10:56:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BCFD1D1D283 for ; Tue, 3 Feb 2004 14:56:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 56422-07 for ; Tue, 3 Feb 2004 10:56:09 -0400 (AST) Received: from marvin.harmless.hu (marvin.harmless.hu [195.70.51.173]) by svr1.postgresql.org (Postfix) with ESMTP id 687E1D1CCA8 for ; Tue, 3 Feb 2004 10:56:06 -0400 (AST) Received: from marvin.harmless.hu (marvin.harmless.hu [195.70.51.173]) by marvin.harmless.hu (Postfix) with ESMTP id B0FC71000122D; Tue, 3 Feb 2004 15:56:06 +0100 (CET) Date: Tue, 3 Feb 2004 15:56:06 +0100 (CET) From: Czuczy Gergely X-X-Sender: phoemix@localhost To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: PQexecParams and types In-Reply-To: <17666.1075819993@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/40 X-Sequence-Number: 5564 hello to leave it unspecified what value should I set to the paramTypes array? and could you insert this answer to to docs, it could be useful Bye, Gergely Czuczy mailto: phoemix@harmless.hu PGP: http://phoemix.harmless.hu/phoemix.pgp The point is, that geeks are not necessarily the outcasts society often believes they are. The fact is that society isn't cool enough to be included in our activities. On Tue, 3 Feb 2004, Tom Lane wrote: > Czuczy Gergely writes: > > i've read in the docs to use the proper indexes both types must match in > > the where clause, to achive this the user can simply put a string into the > > side of the equation mark and pgsql will convert it automaticly. my > > question is, when I'm using PQexecParams, should I give all the values as > > a string, and it will be converted, or I have to figure out the type of > > the given field somehow? > > You should leave the parameter types unspecified. Their types will be > resolved in much the same way that a quoted literal is handled. > > regards, tom lane > From pgsql-hackers-owner@postgresql.org Tue Feb 3 11:10:37 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A7CFBD1C9AB for ; Tue, 3 Feb 2004 15:10:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 64191-04 for ; Tue, 3 Feb 2004 11:10:27 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 051E1D1B83D for ; Tue, 3 Feb 2004 11:10:25 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i13FATtL017868; Tue, 3 Feb 2004 10:10:29 -0500 (EST) To: Kevin Brown Cc: pgsql-hackers@postgresql.org Subject: Re: COPY from question In-reply-to: <20040203105746.GE2608@filer> References: <1070584326.18838.235.camel@cletus.lyris.com> <20040203105746.GE2608@filer> Comments: In-reply-to Kevin Brown message dated "Tue, 03 Feb 2004 02:57:46 -0800" Date: Tue, 03 Feb 2004 10:10:29 -0500 Message-ID: <17867.1075821029@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/91 X-Sequence-Number: 49680 Kevin Brown writes: > Slavisa Garic wrote: >> Using pg module in python I am trying to run the COPY command to populate >> the large table. I am using this to replace the INSERT which takes about >> few hours to add 70000 entries where copy takes minute and a half. > That difference in speed seems quite large. Too large. Are you batching > your INSERTs into transactions (you should be in order to get good > performance)? Do you have a ton of indexes on the table? Does it have > triggers on it or some other thing (if so then COPY may well wind up doing > the wrong thing since the triggers won't fire for the rows it > inserts)? COPY *does* fire triggers, and has done so for quite a few releases. My bet is that the issue is failing to batch individual INSERTs into transactions. On a properly-set-up machine you can't get more than one transaction commit per client per disk revolution, so the penalty for trivial transactions like single inserts is pretty steep. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Feb 3 11:27:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D712AD1B80B for ; Tue, 3 Feb 2004 15:27:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 71240-08 for ; Tue, 3 Feb 2004 11:27:22 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 64098D1D841 for ; Tue, 3 Feb 2004 11:27:19 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i13FRM3A018107; Tue, 3 Feb 2004 10:27:23 -0500 (EST) To: Czuczy Gergely Cc: pgsql-performance@postgresql.org Subject: Re: PQexecParams and types In-reply-to: References: Comments: In-reply-to Czuczy Gergely message dated "Tue, 03 Feb 2004 15:56:06 +0100" Date: Tue, 03 Feb 2004 10:27:22 -0500 Message-ID: <18106.1075822042@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/41 X-Sequence-Number: 5565 Czuczy Gergely writes: > to leave it unspecified what value should I set to the paramTypes array? > and could you insert this answer to to docs, it could be useful It is in the docs: paramTypes[] specifies, by OID, the data types to be assigned to the parameter symbols. If paramTypes is NULL, or any particular element in the array is zero, the server assigns a data type to the parameter symbol in the same way it would do for an untyped literal string. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Feb 3 11:38:08 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 59361D1B917 for ; Tue, 3 Feb 2004 15:38:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 72249-09 for ; Tue, 3 Feb 2004 11:38:03 -0400 (AST) Received: from mail.ez3pl.com (66-136-75-131.ded.swbell.net [66.136.75.131]) by svr1.postgresql.org (Postfix) with ESMTP id 22F59D1B897 for ; Tue, 3 Feb 2004 11:38:00 -0400 (AST) Received: from kbarnard ([172.25.96.149]) by mail.ez3pl.com (8.11.2/8.11.2) with ESMTP id i13Fb2o22184 for ; Tue, 3 Feb 2004 09:37:02 -0600 From: "Kevin Barnard" To: Date: Tue, 03 Feb 2004 09:34:01 -0600 MIME-Version: 1.0 Subject: Re: Increasing number of PG connections. Message-ID: <401F6B09.32118.342102@localhost> In-reply-to: References: <401E8493.30458.332D5CEF@localhost> X-mailer: Pegasus Mail for Windows (v4.12a) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/42 X-Sequence-Number: 5566 On 2 Feb 2004 at 16:45, scott.marlowe wrote: > Do you have the cache set to write back or write through? Write through > can be a performance killer. But I don't think your RAID is the problem, > it looks to me like postgresql is doing a lot of I/O. When you run top, > do the postgresql processes show a lot of D status? That's usually waiting > on I/O > Actually I'm not sure. It's setup with the factory defaults from IBM. Actually when I start hitting the limit I was surprised to find only a few D status indicators. Most of the processes where sleeping. > what you want to do is get the machine to a point where the kernel cache > is about twice the size or larger, than the shared_buffers. I'd start at > 10000 shared buffers and 4096 sort mem and see what happens. If you've > still got >2 gig kernel cache at that point, then increase both a bit (2x > or so) and see how much kernel cache you've got. If your kernel cache > stays above 1Gig, and the machine is running faster, you're doing pretty > good. > I've set shared to 10000 and sort to 4096. I just have to wait until the afternoon before I see system load start to max out. Thanks for the tips I'm crossing my fingers. -- Kevin Barnard From pgsql-advocacy-owner@postgresql.org Tue Feb 3 11:51:08 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9AEBBD1CAE1 for ; Tue, 3 Feb 2004 15:51:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 81260-07 for ; Tue, 3 Feb 2004 11:51:02 -0400 (AST) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id D15B6D1C7F7 for ; Tue, 3 Feb 2004 11:50:58 -0400 (AST) Received: (qmail 33725 invoked from network); 3 Feb 2004 15:51:07 -0000 Received: from localhost (HELO squeegit) (threshar@127.0.0.1) by localhost with SMTP; 3 Feb 2004 15:51:07 -0000 Date: Tue, 3 Feb 2004 10:53:49 -0500 From: Jeff To: "Rigmor Ukuhe" Cc: josh@agliodbs.com, pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? Message-Id: <20040203105349.2f700477.threshar@torgo.978.org> In-Reply-To: References: <20040203085203.5c5f926c.threshar@torgo.978.org> X-Mailer: Sylpheed version 0.9.9 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/16 X-Sequence-Number: 3587 On Tue, 3 Feb 2004 16:02:00 +0200 "Rigmor Ukuhe" wrote: > > script [I also decided to use this perl script for testing PG to be > > fair]. > > > > For one client mysql simply screamed. > > > > If already have test case set up, you could inform us, from where > Postgres starts to beat MySql. Because if with 5 clients it still > "screams" then i would give it a try in case of that kind of > requirements. > I just checked (to see about restarting the innodb test) and it appears that it'll take a bit of work to get the machine up and running. I don't have time right now to do further testing. However, you could try it out. Not sure at what point it will topple, in my case it didn't matter if it ran good with 5 clients as I'll always have many more clients than 5. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-advocacy-owner@postgresql.org Tue Feb 3 12:18:23 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6E388D1D2E4 for ; Tue, 3 Feb 2004 16:18:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 95486-10 for ; Tue, 3 Feb 2004 12:18:14 -0400 (AST) Received: from hosting.commandprompt.com (215.commandprompt.com [207.173.200.215]) by svr1.postgresql.org (Postfix) with ESMTP id 32EA2D1C9FB for ; Tue, 3 Feb 2004 12:18:09 -0400 (AST) Received: from commandprompt.com (clbb-109.saw.net [64.146.135.109]) (authenticated) by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i13GI2m00401; Tue, 3 Feb 2004 08:18:03 -0800 Message-ID: <401FCA05.60408@commandprompt.com> Date: Tue, 03 Feb 2004 08:19:17 -0800 From: "Joshua D. Drake" Organization: Command Prompt, Inc. User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christopher Browne Cc: pgsql-advocacy@postgresql.org Subject: Re: MySQL+InnoDB vs. PostgreSQL test? References: <200402020921.12076.josh@agliodbs.com> <401EFD98.2020402@Yahoo.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------000107020305090009020802" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/17 X-Sequence-Number: 3588 This is a multi-part message in MIME format. --------------000107020305090009020802 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Christopher Browne wrote: >In an attempt to throw the authorities off his trail, JanWieck@Yahoo.com (Jan Wieck) transmitted: > > >>Josh Berkus wrote: >> >> >>>I've had requests from a couple of businesses to see results of >>>infomal MySQL >>>+InnoDB vs. PostgreSQL tests. I know that we don't have the setup >>>to do full formal benchmarking, but surely someone in our community >>>has gone head-to-head on your own application? >>> >>> >>how does someone compare an Apache+PHP+MySQL "thing" against something >>implemented with half the stuff done in stored procedures and the >>entire business model guarded by referential integrity, custom >>triggers and whatnot? >> >>Seriously, I am tired of this kind of question. You gotta get bold >>enough to stand up in a "meeting" like that, say "guy's, you can ask >>me how this compares to Oracle ... but if you're seriously asking me >>how this compares to MySQL, call me again when you've done your >>homework". >> >> > >Actually, before saying anything in public about their products, check >out what they require for use of their protected trademarks. > > >To wit, they indicate that: > > "The MySQL AB Marks may not be used in a manner or with respect to > products that will decrease the value of the MySQL AB Marks or > otherwise impair or damage MySQL AB's brand integrity, reputation or > goodwill" > >It seems to me that presenting a benchmark that did not favor their >product could be quite reasonably considered to be an "impairment" of >their integrity, reputation, or goodwill, and therefore be something >worthy of legal attack. > > It depends on how it is presented. Basically you just don't offer an opinion on the matter. For example... MySQL was 10x slower than PostgreSQL in this test.... Instead you could use something like. We performed the following test. MySQL scored this much PostgreSQL scored this much Notice no use of explaination..... 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 --------------000107020305090009020802 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Christopher Browne wrote:
In an attempt to throw the authorities off his trail, JanWieck@Yahoo.com (Jan Wieck) transmitted:
  
Josh Berkus wrote:
    
I've had requests from a couple of businesses to see results of
infomal MySQL
+InnoDB vs. PostgreSQL tests.    I know that we don't have the setup
to do full formal benchmarking, but surely someone in our community
has gone head-to-head on your own application?
      
how does someone compare an Apache+PHP+MySQL "thing" against something
implemented with half the stuff done in stored procedures and the
entire business model guarded by referential integrity, custom
triggers and whatnot?

Seriously, I am tired of this kind of question. You gotta get bold
enough to stand up in a "meeting" like that, say "guy's, you can ask
me how this compares to Oracle ... but if you're seriously asking me
how this compares to MySQL, call me again when you've done your
homework".
    

Actually, before saying anything in public about their products, check
out what they require for use of their protected trademarks.
<http://www.mysql.com/company/trademark.html>

To wit, they indicate that:

  "The MySQL AB Marks may not be used in a manner or with respect to
  products that will decrease the value of the MySQL AB Marks or
  otherwise impair or damage MySQL AB's brand integrity, reputation or
  goodwill"

It seems to me that presenting a benchmark that did not favor their
product could be quite reasonably considered to be an "impairment" of
their integrity, reputation, or goodwill, and therefore be something
worthy of legal attack.
  
It depends on how it is presented. Basically you just don't offer an opinion on the matter.
For example...

MySQL was 10x slower than PostgreSQL in this test....

Instead you could use something like.

We performed the following test.

MySQL scored this much
PostgreSQL scored this much

Notice no use of explaination.....

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
--------------000107020305090009020802-- From pgsql-performance-owner@postgresql.org Tue Feb 3 12:43:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2B90FD1B917 for ; Tue, 3 Feb 2004 16:43:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 07433-08 for ; Tue, 3 Feb 2004 12:43:11 -0400 (AST) Received: from alexandria15.alexsrv15.com (alexandria15.alexsrv15.com [216.74.85.97]) by svr1.postgresql.org (Postfix) with ESMTP id B5593D1B511 for ; Tue, 3 Feb 2004 12:43:10 -0400 (AST) Received: from valenfor by alexandria15.alexsrv15.com with local (Exim 4.24) id 1Ao3db-0002sp-EL for pgsql-performance@postgresql.org; Tue, 03 Feb 2004 11:42:59 -0500 From: "Kevin Carpenter" To: pgsql-performance@postgresql.org Reply-To: kevin@valenfor.com Subject: Database conversion woes... X-Mailer: NeoMail 1.26 X-IPAddress: 65.218.233.130 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Message-Id: Date: Tue, 03 Feb 2004 11:42:59 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - alexandria15.alexsrv15.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [32391 32391] / [47 12] X-AntiAbuse: Sender Address Domain - alexandria15.alexsrv15.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/44 X-Sequence-Number: 5568 Hello everyone, I am doing a massive database conversion from MySQL to Postgresql for a company I am working for. This has a few quirks to it that I haven't been able to nail down the answers I need from reading and searching through previous list info. For starters, I am moving roughly 50 seperate databases which each one represents one of our clients and is roughly 500 megs to 3 gigs in size. Currently we are using the MySQL replication, and so I am looking at Mammoths replicator for this one. However I have seen it only allows on DB to be replicated at a time. With the size of each single db, I don't know how I could put them all together under one roof, and if I was going to, what are the maximums that Postgres can handle for tables in one db? We track over 2 million new points of data (records) a day, and are moving to 5 million in the next year. Second what about the physical database size, what are the limits there? I have seen that it was 4 gig on Linux from a 2000 message, but what about now? Have we found way's past that? Thanks in advance, will give more detail - just looking for some open directions and maybe some kicks to fuel my thought in other areas. Thanks, -- kevin@valenfor.com From pgsql-advocacy-owner@postgresql.org Tue Feb 3 14:49:09 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id F33D5D1CA90 for ; Tue, 3 Feb 2004 16:46:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 07022-10 for ; Tue, 3 Feb 2004 12:46:21 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id D6739D1C513 for ; Tue, 3 Feb 2004 12:46:20 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i13Gk5IB019176; Tue, 3 Feb 2004 11:46:06 -0500 (EST) To: Jeff Cc: "Rigmor Ukuhe" , josh@agliodbs.com, pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? In-reply-to: <20040203105349.2f700477.threshar@torgo.978.org> References: <20040203085203.5c5f926c.threshar@torgo.978.org> <20040203105349.2f700477.threshar@torgo.978.org> Comments: In-reply-to Jeff message dated "Tue, 03 Feb 2004 10:53:49 -0500" Date: Tue, 03 Feb 2004 11:46:05 -0500 Message-ID: <19175.1075826765@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/24 X-Sequence-Number: 3595 Jeff writes: > Not sure at what point it will topple, in my case it didn't matter if it > ran good with 5 clients as I'll always have many more clients than 5. I did some idle, very unscientific tests the other day that indicated that MySQL insert performance starts to suck with just 2 concurrent inserters. Given a file containing 10000 INSERT commands, a single mysql client ran the file in about a second. So if I feed the file simultaneously to two mysqls in two shell windows, it should take about two seconds total to do the 20000 inserts, right? The observed times were 13 to 15 seconds. (I believe this is with a MyISAM table, since I just said CREATE TABLE without any options.) It does scream with only one client though ... regards, tom lane From pgsql-advocacy-owner@postgresql.org Tue Feb 3 13:29:08 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id F2243D1B4B5 for ; Tue, 3 Feb 2004 16:52:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 14883-03 for ; Tue, 3 Feb 2004 12:52:20 -0400 (AST) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 50FFCD1D2DB for ; Tue, 3 Feb 2004 12:52:17 -0400 (AST) Received: (qmail 34884 invoked from network); 3 Feb 2004 16:52:20 -0000 Received: from localhost (HELO squeegit) (threshar@127.0.0.1) by localhost with SMTP; 3 Feb 2004 16:52:20 -0000 Date: Tue, 3 Feb 2004 11:55:02 -0500 From: Jeff To: Tom Lane Cc: rigmor.ukuhe@finestmedia.com, josh@agliodbs.com, pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? Message-Id: <20040203115502.51820b31.threshar@torgo.978.org> In-Reply-To: <19175.1075826765@sss.pgh.pa.us> References: <20040203085203.5c5f926c.threshar@torgo.978.org> <20040203105349.2f700477.threshar@torgo.978.org> <19175.1075826765@sss.pgh.pa.us> X-Mailer: Sylpheed version 0.9.9 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/20 X-Sequence-Number: 3591 On Tue, 03 Feb 2004 11:46:05 -0500 Tom Lane wrote: > Jeff writes: > > Not sure at what point it will topple, in my case it didn't matter > > if it ran good with 5 clients as I'll always have many more clients > > than 5. > > I did some idle, very unscientific tests the other day that indicated > that MySQL insert performance starts to suck with just 2 concurrent > inserters. Given a file containing 10000 INSERT commands, a single > mysql client ran the file in about a second. So if I feed the file > simultaneously to two mysqls in two shell windows, it should take > about two seconds total to do the 20000 inserts, right? The observed > times were 13 to 15 seconds. (I believe this is with a MyISAM table, > since I just said CREATE TABLE without any options.) > MyISAM is well known to suck if you update/insert/delete because it simply aquires a full table lock when you perform those operations! InnoDB is supposed to be better at that. So your results are fairly in line with what you should see. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Tue Feb 3 13:18:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C2CB1D1D2DB for ; Tue, 3 Feb 2004 16:57:52 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 17839-03 for ; Tue, 3 Feb 2004 12:57:50 -0400 (AST) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 9BD13D1C9FB for ; Tue, 3 Feb 2004 12:57:47 -0400 (AST) Received: (qmail 34973 invoked from network); 3 Feb 2004 16:57:51 -0000 Received: from localhost (HELO squeegit) (threshar@127.0.0.1) by localhost with SMTP; 3 Feb 2004 16:57:51 -0000 Date: Tue, 3 Feb 2004 12:00:34 -0500 From: Jeff To: kevin@valenfor.com Cc: pgsql-performance@postgresql.org Subject: Re: Database conversion woes... Message-Id: <20040203120034.78adcc5c.threshar@torgo.978.org> In-Reply-To: References: X-Mailer: Sylpheed version 0.9.9 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/47 X-Sequence-Number: 5571 On Tue, 03 Feb 2004 11:42:59 -0500 "Kevin Carpenter" wrote: > For starters, I am moving roughly 50 seperate databases which each one > represents one of our clients and is roughly 500 megs to 3 gigs in > size. > Currently we are using the MySQL replication, and so I am looking at > Mammoths replicator for this one. However I have seen it only allows > on DB to be replicated at a time. With the size of each single db, I Not knowing too much about mammoths, but how the others work, you should be able to run a replicator for each db. (Or hack a shell script up to make it run the replicator for each db.. either way each db will be replicated independant of the others) > don't know how I could put them all together under one roof, and if I > was going to, what are the maximums that Postgres can handle for > tables in one db? We track over 2 million new points of data > (records) a day, and are moving to 5 million in the next year. > From the docs: Maximum size for a database unlimited (4 TB databases exist) Maximum size for a table 16 TB on all operating systems Maximum size for a row 1.6 TB Maximum size for a field 1 GB Maximum number of rows in a table unlimited Maximum number of columns in a table 250 - 1600 depending on column types Maximum number of indexes on a table unlimited ... My largest PG db is 50GB. My busiest PG db runs about 50 update|delete|insert's / second (sustained throughout the day. It bursts up to 150 now and then). And we're doing about 40 selects / second. And the machine it is running on is typically 95% idle. (Quad 2ghz xeon) -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-advocacy-owner@postgresql.org Tue Feb 3 14:49:15 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9DA9FD1D7BE for ; Tue, 3 Feb 2004 17:03:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 16757-07 for ; Tue, 3 Feb 2004 13:03:32 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 3BB0DD1D342 for ; Tue, 3 Feb 2004 13:03:30 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i13H3BfA019419; Tue, 3 Feb 2004 12:03:12 -0500 (EST) To: Jeff Cc: rigmor.ukuhe@finestmedia.com, josh@agliodbs.com, pgsql-advocacy@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? In-reply-to: <20040203115502.51820b31.threshar@torgo.978.org> References: <20040203085203.5c5f926c.threshar@torgo.978.org> <20040203105349.2f700477.threshar@torgo.978.org> <19175.1075826765@sss.pgh.pa.us> <20040203115502.51820b31.threshar@torgo.978.org> Comments: In-reply-to Jeff message dated "Tue, 03 Feb 2004 11:55:02 -0500" Date: Tue, 03 Feb 2004 12:03:11 -0500 Message-ID: <19418.1075827791@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/25 X-Sequence-Number: 3596 Jeff writes: > On Tue, 03 Feb 2004 11:46:05 -0500 > Tom Lane wrote: >> I did some idle, very unscientific tests the other day that indicated >> that MySQL insert performance starts to suck with just 2 concurrent >> inserters. Given a file containing 10000 INSERT commands, a single >> mysql client ran the file in about a second. So if I feed the file >> simultaneously to two mysqls in two shell windows, it should take >> about two seconds total to do the 20000 inserts, right? The observed >> times were 13 to 15 seconds. (I believe this is with a MyISAM table, >> since I just said CREATE TABLE without any options.) > MyISAM is well known to suck if you update/insert/delete because it > simply aquires a full table lock when you perform those operations! Sure, I wasn't expecting it to actually overlap any operations. (If you try the same test with Postgres, the scaling factor is a little better than linear because we do get some overlap.) But that shouldn't result in a factor-of-seven slowdown. There's something badly wrong with their low-level locking algorithms I think. regards, tom lane From pgsql-advocacy-owner@postgresql.org Tue Feb 3 13:28:52 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 22555D1D263 for ; Tue, 3 Feb 2004 17:23:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 30823-02 for ; Tue, 3 Feb 2004 13:23:29 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 1E499D1D189 for ; Tue, 3 Feb 2004 13:23:28 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i13HKgd1029083; Tue, 3 Feb 2004 10:20:42 -0700 (MST) Date: Tue, 3 Feb 2004 10:16:46 -0700 (MST) From: "scott.marlowe" To: "Joshua D. Drake" Cc: Christopher Browne , Subject: Re: MySQL+InnoDB vs. PostgreSQL test? In-Reply-To: <401FCA05.60408@commandprompt.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/19 X-Sequence-Number: 3590 On Tue, 3 Feb 2004, Joshua D. Drake wrote: > Christopher Browne wrote: > > >In an attempt to throw the authorities off his trail, JanWieck@Yahoo.com (Jan Wieck) transmitted: > > > > > >>Josh Berkus wrote: > >> > >> > >>>I've had requests from a couple of businesses to see results of > >>>infomal MySQL > >>>+InnoDB vs. PostgreSQL tests. I know that we don't have the setup > >>>to do full formal benchmarking, but surely someone in our community > >>>has gone head-to-head on your own application? > >>> > >>> > >>how does someone compare an Apache+PHP+MySQL "thing" against something > >>implemented with half the stuff done in stored procedures and the > >>entire business model guarded by referential integrity, custom > >>triggers and whatnot? > >> > >>Seriously, I am tired of this kind of question. You gotta get bold > >>enough to stand up in a "meeting" like that, say "guy's, you can ask > >>me how this compares to Oracle ... but if you're seriously asking me > >>how this compares to MySQL, call me again when you've done your > >>homework". > >> > >> > > > >Actually, before saying anything in public about their products, check > >out what they require for use of their protected trademarks. > > > > > >To wit, they indicate that: > > > > "The MySQL AB Marks may not be used in a manner or with respect to > > products that will decrease the value of the MySQL AB Marks or > > otherwise impair or damage MySQL AB's brand integrity, reputation or > > goodwill" > > > >It seems to me that presenting a benchmark that did not favor their > >product could be quite reasonably considered to be an "impairment" of > >their integrity, reputation, or goodwill, and therefore be something > >worthy of legal attack. > > > > > It depends on how it is presented. Basically you just don't offer an > opinion on the matter. > For example... > > MySQL was 10x slower than PostgreSQL in this test.... > > Instead you could use something like. > > We performed the following test. > > MySQL scored this much > PostgreSQL scored this much My guess is that what they are saying is that you can't make a program like: mysqlhelper without their permission. Using their mark in a review is fair use, and the only way they could get you is if you either failed to attribute it, or had signed a license with them saying you wouldn't do benchmarks, like how Oracle licenses their software. From pgsql-performance-owner@postgresql.org Tue Feb 3 13:37:48 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B662DD1C513 for ; Tue, 3 Feb 2004 17:37:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 36601-10 for ; Tue, 3 Feb 2004 13:37:28 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 3B8C2D1B917 for ; Tue, 3 Feb 2004 13:37:27 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i13HYYd1000805; Tue, 3 Feb 2004 10:34:34 -0700 (MST) Date: Tue, 3 Feb 2004 10:30:38 -0700 (MST) From: "scott.marlowe" To: Kevin Carpenter Cc: Subject: Re: Database conversion woes... In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/49 X-Sequence-Number: 5573 On Tue, 3 Feb 2004, Kevin Carpenter wrote: > Hello everyone, > > I am doing a massive database conversion from MySQL to Postgresql for a > company I am working for. This has a few quirks to it that I haven't > been able to nail down the answers I need from reading and searching > through previous list info. > > For starters, I am moving roughly 50 seperate databases which each one > represents one of our clients and is roughly 500 megs to 3 gigs in size. > Currently we are using the MySQL replication, and so I am looking at > Mammoths replicator for this one. However I have seen it only allows on > DB to be replicated at a time. Look into importing all those seperate databases into seperate schemas in one postgresql database. > With the size of each single db, I don't > know how I could put them all together under one roof, There's no functional difference to postgresql if you have 1 huge database or 50 smaller ones that add up to the same size. > and if I was > going to, what are the maximums that Postgres can handle for tables in > one db? None. also see: http://www.postgresql.org/docs/faqs/FAQ.html#4.5 > We track over 2 million new points of data (records) a day, and > are moving to 5 million in the next year. That's quite a bit. Postgresql can handle it. > Second what about the physical database size, what are the limits there? none. > I have seen that it was 4 gig on Linux from a 2000 message, but what > about now? Have we found way's past that? It has never been 4 gig. It was once, a long time ago, 2 gig for a table I believe. That was fixed years ago. > Thanks in advance, will give more detail - just looking for some open > directions and maybe some kicks to fuel my thought in other areas. Import in bulk, either using copy or wrap a few thousand inserts inside begin;end; pairs. From pgsql-performance-owner@postgresql.org Tue Feb 3 15:04:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B0F08D1C9DA for ; Tue, 3 Feb 2004 19:02:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 78347-03 for ; Tue, 3 Feb 2004 15:02:19 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 1F7DDD1D55E for ; Tue, 3 Feb 2004 15:02:18 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4364845; Tue, 03 Feb 2004 11:03:15 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: kevin@valenfor.com, pgsql-performance@postgresql.org Subject: Re: Database conversion woes... Date: Tue, 3 Feb 2004 11:01:57 -0800 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200402031101.57458.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/52 X-Sequence-Number: 5576 Kevin, > With the size of each single db, I don't > know how I could put them all together under one roof, and if I was > going to, what are the maximums that Postgres can handle for tables in > one db? We track over 2 million new points of data (records) a day, and > are moving to 5 million in the next year. Use schemas per Scott's suggestion. This will also ease the sharing of data between "databases". > Second what about the physical database size, what are the limits there? > I have seen that it was 4 gig on Linux from a 2000 message, but what > about now? Have we found way's past that? The biggest database I've ever worked with was 175G, but I've seen reports of 2TB databases out there. We don't know what the limit is; so far it's always been hardware. > Thanks in advance, will give more detail - just looking for some open > directions and maybe some kicks to fuel my thought in other areas. Come back to this list for help tuning your system! You'll need it, you've got an unusual set-up. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Feb 3 15:42:01 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B920AD1CACB for ; Tue, 3 Feb 2004 19:30:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 90336-07 for ; Tue, 3 Feb 2004 15:30:02 -0400 (AST) Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net [194.217.242.86]) by svr1.postgresql.org (Postfix) with ESMTP id 2AD20D1D2DB for ; Tue, 3 Feb 2004 15:29:56 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 1Ao6FA-0002C9-0b; Tue, 03 Feb 2004 19:29:56 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 1481A166A1; Tue, 3 Feb 2004 19:29:55 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id CFB6C16587; Tue, 3 Feb 2004 19:29:52 +0000 (GMT) From: Richard Huxton To: kevin@valenfor.com, pgsql-performance@postgresql.org Subject: Re: Database conversion woes... Date: Tue, 3 Feb 2004 19:29:52 +0000 User-Agent: KMail/1.5 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402031929.52383.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/54 X-Sequence-Number: 5578 On Tuesday 03 February 2004 16:42, Kevin Carpenter wrote: > > Thanks in advance, will give more detail - just looking for some open > directions and maybe some kicks to fuel my thought in other areas. I've taken to doing a lot of my data manipulation (version conversions etc) in PG even if the final resting place is MySQL. It's generally not too difficult to transfer data but you will have problems with MySQL's more "relaxed attitude" to data types (things like all-zero timestamps). I tend to write a script to tidy the data before export, and repeatedly restore from backup until the script corrects all problems.Not sure how convenient that'll be with dozens of gigs of data. Might be practical to start with the smaller databases, let your script grow in capabilities before importing the larger ones. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Tue Feb 3 16:21:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 675DBD1D2DF for ; Tue, 3 Feb 2004 20:21:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 19954-02 for ; Tue, 3 Feb 2004 16:21:29 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 0ABDBD1B4DC for ; Tue, 3 Feb 2004 16:21:28 -0400 (AST) 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 i13KLRsv038088 for ; Tue, 3 Feb 2004 20:21:27 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i13KAT02035494 for pgsql-performance@postgresql.org; Tue, 3 Feb 2004 20:10:29 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Database conversion woes... Date: Tue, 03 Feb 2004 14:59:04 -0500 Organization: Hub.Org Networking Services Lines: 60 Message-ID: <60y8rkkk8n.fsf@dev6.int.libertyrms.info> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.110002 (No Gnus v0.2) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:SziVhVZbd8JavXhL98d0O+FEhow= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/55 X-Sequence-Number: 5579 kevin@valenfor.com ("Kevin Carpenter") writes: > I am doing a massive database conversion from MySQL to Postgresql for a > company I am working for. This has a few quirks to it that I haven't > been able to nail down the answers I need from reading and searching > through previous list info. > > For starters, I am moving roughly 50 seperate databases which each > one represents one of our clients and is roughly 500 megs to 3 gigs > in size. Currently we are using the MySQL replication, and so I am > looking at Mammoths replicator for this one. However I have seen it > only allows on DB to be replicated at a time. With the size of each > single db, I don't know how I could put them all together under one > roof, and if I was going to, what are the maximums that Postgres can > handle for tables in one db? We track over 2 million new points of > data (records) a day, and are moving to 5 million in the next year. I'll be evasive about replication, because the answers are pretty painful :-(, but as for the rest of it, nothing about this sounds challenging. There is room for debate here as to whether you should have: a) One postmaster and many database instances, 2) One postmaster, one (or a few) database instances, and do the client 'split' via schemas, or iii) Several postmasters, many database instances. Replication will tend to work best with scenario 2), which minimizes the number of connections that are needed to manage replication; that's definitely a factor worth considering. It is also possible for it to be worthwhile to spread vastly differing kinds of activity across different backends so that they can have separate buffer caches. If all the activity is shared across one postmaster, that means it is all shared across one buffer cache, and there are pathological situations that are occasionally observed in practice where one process will be "trashing" the shared cache, thereby injuring performance for all other processes using that back end. In such a case, it may be best to give the "ill-behaved" process its own database instance with a small cache that it can thrash on without inconveniencing others. Jan Wieck is working on some improvements for buffer management in 7.5 that may improve the situation vis-a-vis buffering, but that is certainly not something ready to deploy in production just yet. > Second what about the physical database size, what are the limits > there? I have seen that it was 4 gig on Linux from a 2000 message, > but what about now? Have we found way's past that? There's NO problem with having enormous databases now; each table is represented as one or more files (if you break a size barrier, oft configured as 1GB, it creates an "extent" and extends into another file), and for there to be problems with this, the problems would be _really crippling_ OS problems. -- (format nil "~S@~S" "cbbrowne" "cbbrowne.com") http://www3.sympatico.ca/cbbrowne/linuxxian.html "We come to bury DOS, not to praise it." -- Paul Vojta , paraphrasing a quote of Shakespeare From pgsql-performance-owner@postgresql.org Tue Feb 3 18:21:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6D59CD1B44D for ; Tue, 3 Feb 2004 22:21:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 74964-02 for ; Tue, 3 Feb 2004 18:21:02 -0400 (AST) Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) by svr1.postgresql.org (Postfix) with ESMTP id 4B49BD1CCA8 for ; Tue, 3 Feb 2004 18:20:59 -0400 (AST) 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_01C3EA98.755BD566" Subject: Compile Vs RPMs Date: Tue, 3 Feb 2004 15:58:22 -0500 Message-ID: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785097FB2@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Compile Vs RPMs Thread-Index: AcPqmHVV9aX2CME9RGWWPmgoyuponQ== From: "Anjan Dave" To: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/56 X-Sequence-Number: 5580 This is a multi-part message in MIME format. ------_=_NextPart_001_01C3EA98.755BD566 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, =20 I would like to know whether there are any significant performance advantages of compiling (say, 7.4) on your platform (being RH7.3, 8, and 9.0, and Fedora especially) versus getting the relevant binaries (rpm) from the postgresql site? Hardware is Intel XEON (various speeds, upto 2.8GHz, single/dual/quad configuration). =20 Thankyou, Anjan =20 =20 =20 =20 ************************************************************************ **=20 This e-mail and any files transmitted with it are intended for the use of the addressee(s) only and may be confidential and covered by the attorney/client and other privileges. If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system. Any other use of this e-mail is prohibited. =20 ------_=_NextPart_001_01C3EA98.755BD566 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Message
Hello,
 
I would l= ike to know=20 whether there are any significant performance advantages of compiling (say,= 7.4)=20 on your platform (being RH7.3, 8, and 9.0, and Fedora especially) versus ge= tting=20 the relevant binaries (rpm) from the postgresql site? Hardware is Intel XEO= N=20 (various speeds, upto 2.8GHz, single/dual/quad=20 configuration).
 
Thankyou,
Anjan
 
 
 
 

************************************************************************= **=20

This e-mail and any files transmitted with it are intended for the use o= f the=20 addressee(s) only and may be confidential and covered by the attorney/clien= t and=20 other privileges. If you received this e-mail in error, please notify the= =20 sender; do not disclose, copy, distribute, or take any action in reliance o= n the=20 contents of this information; and delete it from your system. Any other use= of=20 this e-mail is prohibited.

 
=00 ------_=_NextPart_001_01C3EA98.755BD566-- From pgsql-performance-owner@postgresql.org Fri Feb 6 16:52:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6AE1BD1D16E for ; Tue, 3 Feb 2004 22:26:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 75869-02 for ; Tue, 3 Feb 2004 18:26:47 -0400 (AST) Received: from alexandria15.alexsrv15.com (alexandria15.alexsrv15.com [216.74.85.97]) by svr1.postgresql.org (Postfix) with ESMTP id 98CC1D1C9AB for ; Tue, 3 Feb 2004 18:26:44 -0400 (AST) Received: from [65.218.233.130] (helo=icrossing.com) by alexandria15.alexsrv15.com with asmtp (Exim 4.24) id 1Ao90F-0000jT-KT for pgsql-performance@postgresql.org; Tue, 03 Feb 2004 17:26:43 -0500 Message-ID: <40202034.5060407@icrossing.com> Date: Tue, 03 Feb 2004 15:27:00 -0700 From: Kevin Carpenter User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Database conversion woes... References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - alexandria15.alexsrv15.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - icrossing.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/99 X-Sequence-Number: 5623 First just wanted to say thank you all for the quick and helpful answers. With all the input I know I am on the right track. With that in mind I created a perl script to do my migrations and to do it based on moving from a db name to a schema name. I had done alot of the reading on converting based on the miss match of data types that MySQL likes to use. I must say it is VERY nice having a intelligent system that say won't let a date of '0000-00-00' be entered. Luckily I didn't have to deal with any enumerations. So the conversion goes on. I will definitely be back and forth in here as I get the new queries written and start migrating all I can back into the pg backend using plpgsql or c for the stored procedures where required. The mammoth replicator has been working well. I had tried the pgsql-r and had limited success with it, and dbmirror was just taking to long having to do 4 db transactions just to mirror one command. I have eserv but was never really a java kind of guy. Alright then - back to my code. Again thanks for the help and info. Kevin From pgsql-performance-owner@postgresql.org Tue Feb 3 18:29:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 29426D1C511 for ; Tue, 3 Feb 2004 22:29:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 75141-05 for ; Tue, 3 Feb 2004 18:29:27 -0400 (AST) Received: from alexandria15.alexsrv15.com (alexandria15.alexsrv15.com [216.74.85.97]) by svr1.postgresql.org (Postfix) with ESMTP id 13D19D1D2C5 for ; Tue, 3 Feb 2004 18:29:25 -0400 (AST) Received: from [65.218.233.130] (helo=valenfor.com) by alexandria15.alexsrv15.com with asmtp (Exim 4.24) id 1Ao92q-0000wW-Ih for pgsql-performance@postgresql.org; Tue, 03 Feb 2004 17:29:24 -0500 Message-ID: <402020D5.2050902@valenfor.com> Date: Tue, 03 Feb 2004 15:29:41 -0700 From: Kevin User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Database conversion woes... Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - alexandria15.alexsrv15.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - valenfor.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/57 X-Sequence-Number: 5581 First just wanted to say thank you all for the quick and helpful answers. With all the input I know I am on the right track. With that in mind I created a perl script to do my migrations and to do it based on moving from a db name to a schema name. I had done alot of the reading on converting based on the miss match of data types that MySQL likes to use. I must say it is VERY nice having a intelligent system that say won't let a date of '0000-00-00' be entered. Luckily I didn't have to deal with any enumerations. So the conversion goes on. I will definitely be back and forth in here as I get the new queries written and start migrating all I can back into the pg backend using plpgsql or c for the stored procedures where required. The mammoth replicator has been working well. I had tried the pgsql-r and had limited success with it, and dbmirror was just taking to long having to do 4 db transactions just to mirror one command. I have eserv but was never really a java kind of guy. Alright then - back to my code. Again thanks for the help and info. Kevin From pgsql-performance-owner@postgresql.org Tue Feb 3 18:43:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EF336D1D17E for ; Tue, 3 Feb 2004 22:43:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 83784-02 for ; Tue, 3 Feb 2004 18:43:12 -0400 (AST) Received: from internet.potentialtech.com (h-66-167-251-6.PHLAPAFG.covad.net [66.167.251.6]) by svr1.postgresql.org (Postfix) with ESMTP id 2FF43D1C7F7 for ; Tue, 3 Feb 2004 18:43:09 -0400 (AST) Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP id D7A2769A4B; Tue, 3 Feb 2004 17:43:10 -0500 (EST) Message-ID: <402023FC.7000007@potentialtech.com> Date: Tue, 03 Feb 2004 17:43:08 -0500 From: Bill Moran User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Anjan Dave Cc: pgsql-performance@postgresql.org Subject: Re: Compile Vs RPMs References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785097FB2@vt-pe2550-001.vantage.vantage.com> In-Reply-To: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785097FB2@vt-pe2550-001.vantage.vantage.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/58 X-Sequence-Number: 5582 Anjan Dave wrote: > Hello, > > I would like to know whether there are any significant performance > advantages of compiling (say, 7.4) on your platform (being RH7.3, 8, and > 9.0, and Fedora especially) versus getting the relevant binaries (rpm) > from the postgresql site? Hardware is Intel XEON (various speeds, upto > 2.8GHz, single/dual/quad configuration). "significant" is a relative term. 1% can be significant under the proper circumstances ... http://www.potentialtech.com/wmoran/source.php The information isn't specific to Postgres, and the results aren't really conclusive, but hopefully it helps. I really think that if someone would actually test this with Postgres and post the results, it would be very beneficial to the community. I have it on my list of things to do, but it's unlikely to get done in the first quarter the way things are going. -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Tue Feb 3 19:01:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9CF4AD1CCBE for ; Tue, 3 Feb 2004 23:01:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 89888-02 for ; Tue, 3 Feb 2004 19:01:51 -0400 (AST) 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 8627CD1CCA8 for ; Tue, 3 Feb 2004 19:01:48 -0400 (AST) Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] helo=bacon.tmsl.demon.co.uk) by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) id 1Ao9YE-0007Gu-0V for pgsql-performance@postgresql.org; Tue, 03 Feb 2004 23:01:50 +0000 Date: Tue, 3 Feb 2004 23:01:47 +0000 From: Paul Thomas To: "pgsql-performance @ postgresql . org" Subject: Re: Compile Vs RPMs Message-ID: <20040203230147.A23912@bacon> References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785097FB2@vt-pe2550-001.vantage.vantage.com> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=ISO-8859-1 In-Reply-To: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785097FB2@vt-pe2550-001.vantage.vantage.com>; from adave@vantage.com on Tue, Feb 03, 2004 at 20:58:22 +0000 X-Mailer: Balsa 1.2.3 Lines: 24 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/59 X-Sequence-Number: 5583 On 03/02/2004 20:58 Anjan Dave wrote: > Hello, > > I would like to know whether there are any significant performance > advantages of compiling (say, 7.4) on your platform (being RH7.3, 8, and > 9.0, and Fedora especially) versus getting the relevant binaries (rpm) > from the postgresql site? Hardware is Intel XEON (various speeds, upto > 2.8GHz, single/dual/quad configuration). Very unlikely I would have thought. Databases tend to speed-limited by I-O performance and the amount of RAM available for caching etc. Having said that, I've only got one machine (the laptop on which I'm writing this email) which has still got its rpm binaries. My other machines have all been upgraded from source. -- Paul Thomas +------------------------------+---------------------------------------------+ | Thomas Micro Systems Limited | Software Solutions for the Smaller Business | | Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk | +------------------------------+---------------------------------------------+ From pgsql-performance-owner@postgresql.org Tue Feb 3 19:34:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5A8F9D1D283 for ; Tue, 3 Feb 2004 23:34:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 99977-04 for ; Tue, 3 Feb 2004 19:34:07 -0400 (AST) 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 6FAAED1C98E for ; Tue, 3 Feb 2004 19:34:04 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) id 1AoA3S-0001vf-0W; Tue, 03 Feb 2004 23:34:06 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 87401166A1; Tue, 3 Feb 2004 23:34:05 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id A00DC16560; Tue, 3 Feb 2004 23:34:03 +0000 (GMT) From: Richard Huxton To: Kevin , pgsql-performance@postgresql.org Subject: Re: Database conversion woes... Date: Tue, 3 Feb 2004 23:34:03 +0000 User-Agent: KMail/1.5 References: <402020D5.2050902@valenfor.com> In-Reply-To: <402020D5.2050902@valenfor.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402032334.03190.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/60 X-Sequence-Number: 5584 On Tuesday 03 February 2004 22:29, Kevin wrote: > The mammoth replicator has been working well. I had tried > the pgsql-r and had limited success with it, and dbmirror was just > taking to long having to do 4 db transactions just to mirror one > command. I have eserv but was never really a java kind of guy. When this is over and you've got the time, I don't suppose you could put together a few hundred words describing your experiences with the Mammoth replicator - there are a couple of places they could be posted. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Tue Feb 3 20:21:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2914FD1C512 for ; Wed, 4 Feb 2004 00:21:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 12756-09 for ; Tue, 3 Feb 2004 20:21:31 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 409EED1B44D for ; Tue, 3 Feb 2004 20:21:28 -0400 (AST) 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 i140LRsv084968 for ; Wed, 4 Feb 2004 00:21:27 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i140AQjj082895 for pgsql-performance@postgresql.org; Wed, 4 Feb 2004 00:10:26 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Compile Vs RPMs Date: Tue, 03 Feb 2004 18:43:08 -0500 Organization: Hub.Org Networking Services Lines: 30 Message-ID: <60smhrk9v7.fsf@dev6.int.libertyrms.info> References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF785097FB2@vt-pe2550-001.vantage.vantage.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.110002 (No Gnus v0.2) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:CFNZzrflupejaiUcT0p9nHRBfOE= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/61 X-Sequence-Number: 5585 adave@vantage.com ("Anjan Dave") writes: > I would like to know whether there are any significant performance > advantages of compiling (say, 7.4) on your platform (being RH7.3, 8, > and 9.0, and Fedora especially) versus getting the relevant binaries > (rpm) from the postgresql site? Hardware is Intel XEON (various > speeds, upto 2.8GHz, single/dual/quad configuration). Some Linux distribution makers make grand claims of such advantages, but it is not evident that this is much better than superstition. You are certainly NOT going to see GCC generating MMX code automagically that would lead to PostgreSQL becoming 8 times faster. Indeed, in database work, it is quite likely that you will find things to be largely I/O bound, with CPU usage being a very much secondary factor. I did some relative benchmarking between compiling PostgreSQL on GCC versus IBM's PPC compilers a while back; did not see differences that could be _clearly_ discerned as separate from "observational noise." You should expect find that adding RAM, or adding a better disk controller would provide discernable differences in performance. It is much less clear that custom compiling will have any substantial effect on I/O-bound processing. -- output = reverse("ofni.smrytrebil" "@" "enworbbc") Christopher Browne (416) 646 3304 x124 (land) From pgsql-advocacy-owner@postgresql.org Thu Feb 5 12:29:27 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 461BED1D3BC; Wed, 4 Feb 2004 13:36:52 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 73900-01; Wed, 4 Feb 2004 09:36:49 -0400 (AST) Received: from gw.tssi.com (gw.tssi.com [198.147.197.1]) by svr1.postgresql.org (Postfix) with ESMTP id AF5BAD1D283; Wed, 4 Feb 2004 09:36:44 -0400 (AST) Received: from gw.tssi.com (nolan@gw.tssi.com [127.0.0.1] (may be forged)) by gw.tssi.com (8.12.6/8.12.6) with ESMTP id i14Dai8S009495; Wed, 4 Feb 2004 07:36:45 -0600 Received: (from nolan@localhost) by gw.tssi.com (8.12.6/8.12.6/Submit) id i14DahHM009493; Wed, 4 Feb 2004 07:36:43 -0600 From: Mike Nolan Message-Id: <200402041336.i14DahHM009493@gw.tssi.com> Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? To: JanWieck@Yahoo.com (Jan Wieck) Date: Wed, 4 Feb 2004 07:36:43 -0600 (CST) Cc: josh@agliodbs.com, pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org In-Reply-To: <401EFD98.2020402@Yahoo.com> from "Jan Wieck" at Feb 02, 2004 08:47:04 PM X-Mailer: ELM [version 2.5 PL3] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/38 X-Sequence-Number: 3609 > Seriously, I am tired of this kind of question. You gotta get bold > enough to stand up in a "meeting" like that, say "guy's, you can ask me > how this compares to Oracle ... but if you're seriously asking me how > this compares to MySQL, call me again when you've done your homework". Can they call you at the unemployment office? -- Mike Nolan From pgsql-performance-owner@postgresql.org Wed Feb 4 12:30:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0F2B7D1D25F for ; Wed, 4 Feb 2004 16:30:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 44208-04 for ; Wed, 4 Feb 2004 12:30:09 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 5E550D1CAE1 for ; Wed, 4 Feb 2004 12:30:03 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i14GT03F002354; Wed, 4 Feb 2004 09:29:00 -0700 (MST) Date: Wed, 4 Feb 2004 09:24:57 -0700 (MST) From: "scott.marlowe" To: Christopher Browne Cc: Subject: Re: Compile Vs RPMs In-Reply-To: <60smhrk9v7.fsf@dev6.int.libertyrms.info> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/63 X-Sequence-Number: 5587 On Tue, 3 Feb 2004, Christopher Browne wrote: > adave@vantage.com ("Anjan Dave") writes: > > I would like to know whether there are any significant performance > > advantages of compiling (say, 7.4) on your platform (being RH7.3, 8, > > and 9.0, and Fedora especially) versus getting the relevant binaries > > (rpm) from the postgresql site? Hardware is Intel XEON (various > > speeds, upto 2.8GHz, single/dual/quad configuration). > > Some Linux distribution makers make grand claims of such advantages, > but it is not evident that this is much better than superstition. > > You are certainly NOT going to see GCC generating MMX code > automagically that would lead to PostgreSQL becoming 8 times faster. > > Indeed, in database work, it is quite likely that you will find things > to be largely I/O bound, with CPU usage being a very much secondary > factor. > > I did some relative benchmarking between compiling PostgreSQL on GCC > versus IBM's PPC compilers a while back; did not see differences that > could be _clearly_ discerned as separate from "observational noise." > > You should expect find that adding RAM, or adding a better disk > controller would provide discernable differences in performance. It > is much less clear that custom compiling will have any substantial > effect on I/O-bound processing. I would add that the primary reason for compiling versus using RPMs is to take advantage of some compile time option having to do with block size, or using a patch to try and test a system that has found a new corner case where postgresql is having issues performing well, like the vacuum page delay patch for fixing the issue with disk bandwidth saturation. If you've got a machine grinding to its knees under certain loads, and have a test box to test it on, and the test box shows better performance, it might be better to patch the live server on the off hours if it will keep the thing up and running during the day. In that way, performance differences are very real, but because you are doing something you can't do with factory rpms. Of course, building custom rpms isn't that hard to do, so if you had a lot of boxes that needed a patched flavor of postgresql, you could still run from rpms and have the custom patch. From pgsql-advocacy-owner@postgresql.org Wed Feb 4 18:55:30 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A215BD1B55C for ; Wed, 4 Feb 2004 22:55:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 90258-10 for ; Wed, 4 Feb 2004 18:55:24 -0400 (AST) Received: from smtp015.mail.yahoo.com (smtp015.mail.yahoo.com [216.136.173.59]) by svr1.postgresql.org (Postfix) with SMTP id B7E08D1D2C5 for ; Wed, 4 Feb 2004 18:55:21 -0400 (AST) Received: from unknown (HELO europa.janwieck.net) (janwieck@68.80.245.191 with login) by smtp015.mail.yahoo.com with SMTP; 4 Feb 2004 22:55:23 -0000 Received: from Yahoo.com (pcp01341166pcs.wilog301.pa.comcast.net [68.80.245.191]) (authenticated) by europa.janwieck.net (8.11.6/8.11.6) with ESMTP id i14MtOr07584; Wed, 4 Feb 2004 17:55:25 -0500 Message-ID: <402169FE.8010802@Yahoo.com> Date: Wed, 04 Feb 2004 16:54:06 -0500 From: Jan Wieck User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mike Nolan Cc: josh@agliodbs.com, pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? References: <200402041336.i14DahHM009493@gw.tssi.com> In-Reply-To: <200402041336.i14DahHM009493@gw.tssi.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/33 X-Sequence-Number: 3604 Mike Nolan wrote: >> Seriously, I am tired of this kind of question. You gotta get bold >> enough to stand up in a "meeting" like that, say "guy's, you can ask me >> how this compares to Oracle ... but if you're seriously asking me how >> this compares to MySQL, call me again when you've done your homework". > > Can they call you at the unemployment office? It might not work with the words I used above, but the point I tried to make is that the hardest thing you can "sell" is a "no". I mean, not just saying "no", but selling it in a way that the customer will not go with the next idiot who claims "we can do that". If the customer has a stupid idea, like envisioning an enterprise solution based on ImSOL, there is no way you will be able to deliver it. Paying customer or not, you will fail if you bow to their "strategic" decisions and ignore knowing that the stuff they want to use just doesn't fit. That is absolutely not ImSOL specific. If someone comes to me and asks for a HA scenario with zero transaction loss during failover, we can discuss a little if this is really what he needs or not, but if he needs that, the solution will be Oracle or DB2, for sure I will not claim that PostgreSQL can do that, because it cannot. 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 Wed Feb 4 18:44:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BDD53D1B55C for ; Wed, 4 Feb 2004 22:44:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 91487-03 for ; Wed, 4 Feb 2004 18:44:47 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id BE370D1B4DA for ; Wed, 4 Feb 2004 18:44:46 -0400 (AST) 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 i14Mik1Y029970 for ; Wed, 4 Feb 2004 22:44:46 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i14Mid0T029938 for pgsql-performance@postgresql.org; Wed, 4 Feb 2004 22:44:39 GMT From: William Yu X-Newsgroups: comp.databases.postgresql.performance Subject: Re: cache whole data in RAM Date: Wed, 04 Feb 2004 14:44:42 -0800 Organization: Hub.Org Networking Services Lines: 19 Message-ID: References: <13E980A8-5648-11D8-BC99-000A95A6F0DC@cluster9.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.5) Gecko/20031007 X-Accept-Language: en-us, en In-Reply-To: <13E980A8-5648-11D8-BC99-000A95A6F0DC@cluster9.com> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/64 X-Sequence-Number: 5588 David Teran wrote: > Hi, > > we are trying to speed up a database which has about 3 GB of data. The > server has 8 GB RAM and we wonder how we can ensure that the whole DB is > read into RAM. We hope that this will speed up some queries. > > regards David > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html > Upon bootup, automatically run "SELECT * FROM xyz" on every table in your database. From pgsql-performance-owner@postgresql.org Wed Feb 4 18:55:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B0F94D1C98E for ; Wed, 4 Feb 2004 22:55:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 98117-01 for ; Wed, 4 Feb 2004 18:55:38 -0400 (AST) Received: from busybox.pixar.com (busybox.pixar.com [138.72.18.213]) by svr1.postgresql.org (Postfix) with ESMTP id 8059ED1B837 for ; Wed, 4 Feb 2004 18:55:31 -0400 (AST) Received: from pixar.com (dreadnok.pixar.com [138.72.16.110]) by busybox.pixar.com (8.12.8/8.12.8) with ESMTP id i14MtFHw030245 for ; Wed, 4 Feb 2004 14:55:15 -0800 Message-ID: <40217853.20309@pixar.com> Date: Wed, 04 Feb 2004 14:55:15 -0800 From: Mark Harrison User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: select is not using index? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/65 X-Sequence-Number: 5589 We are suddenly getting slow queries on a particular table. Explain shows a sequential scan. We have "vacuum analyze" ed the table. Any hints? Many TIA! Mark testdb=# \d bigtable Table "public.bigtable" Column | Type | Modifiers ---------+---------+----------- id | bigint | not null typeid | integer | not null reposid | integer | not null Indexes: bigtable_id_key unique btree (id) Foreign Key constraints: type FOREIGN KEY (typeid) REFERENCES types(typeid) ON UPDATE NO ACTION ON DELETE NO ACTION, repository FOREIGN KEY (reposid) REFERENCES repositories(reposid) ON UPDATE NO ACTION ON DELETE NO ACTION testdb=# select count(1) from bigtable; count --------- 3056831 (1 row) testdb=# explain select * from bigtable where id = 123; QUERY PLAN ----------------------------------------------------------- Seq Scan on bigtable (cost=0.00..60000.00 rows=1 width=16) Filter: (id = 123) (2 rows) testdb=# vacuum verbose analyze bigtable; INFO: --Relation public.bigtable-- INFO: Pages 19200: Changed 0, Empty 0; Tup 3056831: Vac 0, Keep 0, UnUsed 207009. Total CPU 1.03s/0.24u sec elapsed 9.32 sec. INFO: Analyzing public.bigtable VACUUM testdb=# explain select * from bigtable where id = 123; QUERY PLAN ----------------------------------------------------------- Seq Scan on bigtable (cost=0.00..57410.39 rows=1 width=16) Filter: (id = 123) (2 rows) -- Mark Harrison Pixar Animation Studios From pgsql-performance-owner@postgresql.org Wed Feb 4 19:22:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 65FFBD1B837 for ; Wed, 4 Feb 2004 23:22:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 07338-01 for ; Wed, 4 Feb 2004 19:22:26 -0400 (AST) Received: from mail3.worldispnetwork.com (linux403.worldispnetwork.com [66.132.146.16]) by svr1.postgresql.org (Postfix) with SMTP id 82336D1B52F for ; Wed, 4 Feb 2004 19:22:24 -0400 (AST) Received: (qmail 15355 invoked by uid 399); 4 Feb 2004 23:20:45 -0000 Received: from unknown (HELO px.nrglinx.local) (postmaster@linxtechnologies.com@65.124.40.63) by linux403.worldispnetwork.com with SMTP; 4 Feb 2004 23:20:45 -0000 Received: from [192.168.0.65] (helo=nrglinxmain.nrglinx.local) by px.nrglinx.local with esmtp (Exim 3.35 #1 (Debian)) id 1AoWLf-00005n-00 for ; Wed, 04 Feb 2004 15:22:23 -0800 Received: from harvey.nrglinx.local ([192.168.0.133]) by nrglinxmain.nrglinx.local with Microsoft SMTPSVC(5.0.2195.6713); Wed, 4 Feb 2004 15:22:23 -0800 Subject: Re: select is not using index? From: Corey Edwards To: Mark Harrison Cc: pgsql-performance@postgresql.org In-Reply-To: <40217853.20309@pixar.com> References: <40217853.20309@pixar.com> Content-Type: text/plain Organization: Linx Technologies Message-Id: <1075936942.12400.18.camel@harvey> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 04 Feb 2004 15:22:23 -0800 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 04 Feb 2004 23:22:23.0531 (UTC) FILETIME=[BE7167B0:01C3EB75] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/66 X-Sequence-Number: 5590 On Wed, 2004-02-04 at 14:55, Mark Harrison wrote: > testdb=# \d bigtable > Table "public.bigtable" > Column | Type | Modifiers > ---------+---------+----------- > id | bigint | not null > typeid | integer | not null > reposid | integer | not null > Indexes: bigtable_id_key unique btree (id) > testdb=# explain select * from bigtable where id = 123; Your column is a bigint but 123 defaults to type int. Indexes aren't used when there's a type mismatch. Use an explicit cast or quote it: select * from bigtable where id = 123::bigint; Or select * from bigtable where id = '123'; Corey From pgsql-hackers-owner@postgresql.org Wed Feb 4 21:10:51 2004 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BE780D1BB64 for ; Thu, 5 Feb 2004 01:10:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 39801-05 for ; Wed, 4 Feb 2004 21:10:47 -0400 (AST) Received: from ALPHA9.ITS.MONASH.EDU.AU (alpha9.its.monash.edu.au [130.194.1.9]) by svr1.postgresql.org (Postfix) with ESMTP id 16294D1D8AC for ; Wed, 4 Feb 2004 21:10:45 -0400 (AST) Received: from localhost ([130.194.13.83]) by vaxh.its.monash.edu.au (PMDF V5.2-31 #39306) with ESMTP id <01L68PDT34OO8X2X49@vaxh.its.monash.edu.au> for pgsql-hackers@postgresql.org; Thu, 5 Feb 2004 11:42:35 +1100 Received: from splat.its.monash.edu.au (localhost.its.monash.edu.au [127.0.0.1]) by localhost (Postfix) with ESMTP id 5237B23C00C; Thu, 05 Feb 2004 11:42:34 +1100 (EST) Received: from bruce.csse.monash.edu.au (bruce.csse.monash.edu.au [130.194.64.3]) by splat.its.monash.edu.au (Postfix) with ESMTP id 44CE5164007; Thu, 05 Feb 2004 11:42:34 +1100 (EST) Received: from bruce.csse.monash.edu.au (localhost [127.0.0.1]) by bruce.csse.monash.edu.au (8.12.8+Sun/8.12.8) with ESMTP id i150gYNq010022; Thu, 05 Feb 2004 11:42:34 +1100 (EST) Received: from localhost (sgaric@localhost) by bruce.csse.monash.edu.au (8.12.8+Sun/8.12.2/Submit) with ESMTP id i150gXob010019; Thu, 05 Feb 2004 11:42:33 +1100 (EST) Date: Thu, 05 Feb 2004 11:42:32 +1100 (EST) From: Slavisa Garic Subject: Re: COPY from question In-reply-to: <20040203105746.GE2608@filer> To: Kevin Brown Cc: pgsql-hackers@postgresql.org Message-id: MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Content-transfer-encoding: 7BIT X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/170 X-Sequence-Number: 49759 Hi Kevin, On Tue, 3 Feb 2004, Kevin Brown wrote: > Slavisa Garic wrote: > > Using pg module in python I am trying to run the COPY command to populate > > the large table. I am using this to replace the INSERT which takes about > > few hours to add 70000 entries where copy takes minute and a half. > > That difference in speed seems quite large. Too large. Are you batching > your INSERTs into transactions (you should be in order to get good > performance)? Do you have a ton of indexes on the table? Does it have > triggers on it or some other thing (if so then COPY may well wind up doing > the wrong thing since the triggers won't fire for the rows it inserts)? > > I don't know what kind of schema you're using, but it takes perhaps a > couple of hours to insert 2.5 million rows on my system. But the rows > in my schema may be much smaller than yours. You are right about the indexes. There is quite a few of them (5-6 without looking at the schema). The problem is that I do need those indexes as I have a lot of SELECTs on that table and inserts are only happening once. You are also right about the rows (i think) as I have about 15-20 columns. This could be split into few other table and it used to be but I have merged them because of the requirement for the faster SELECTs. With the current schema there most of my modules that access the database are not required to do expensive JOINs as they used to. Because faster SELECTs are more important to me then faster INSERTs I had to do this. THis wasn't a problem for me until I have started creating experiments which had more than 20 thousand jobs which translates to 20 thousand rows in this big table. I do batch INSERTs into one big transaction (1000 rows at a time). While i did get some improvement compared to the single transaction per insert it was still not fast enough (well not for me :) ). Could you please elaborate on the triggers? I have no idea what kind of triggers there are in PGSQL or relational databases. With regards to my problem, I did solve it by piping the data into the COPY stdin. Now I have about 75000 rows inserted in 40 seconds which is extremely good for me. Thank you for your help, Regards, Slavisa > -- > Kevin Brown kevin@sysexperts.com > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > From pgsql-performance-owner@postgresql.org Thu Feb 5 01:16:38 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0317FD1C9E1 for ; Thu, 5 Feb 2004 05:16:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 11194-06 for ; Thu, 5 Feb 2004 01:16:39 -0400 (AST) Received: from front3.mail.megapathdsl.net (front3.mail.megapathdsl.net [66.80.60.32]) by svr1.postgresql.org (Postfix) with ESMTP id 14C6ED1C512 for ; Thu, 5 Feb 2004 01:16:33 -0400 (AST) Received: from [64.32.131.193] (HELO [192.168.1.11]) by front3.mail.megapathdsl.net (CommuniGate Pro SMTP 4.1.3) with ESMTP id 125079862 for pgsql-performance@postgresql.org; Wed, 04 Feb 2004 21:16:38 -0800 Subject: 7.3 vs 7.4 performance From: Orion Henry To: pgsql-performance@postgresql.org Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-YvIuE5J7VWwVd0qsLRg0" Organization: Message-Id: <1075958197.2438.330.camel@orthanc> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 04 Feb 2004 21:16:37 -0800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/67 X-Sequence-Number: 5591 --=-YvIuE5J7VWwVd0qsLRg0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable I've done some testing of 7.3.4 vs 7.4.1 and found 7.4.1 to be 20%-30% slower than 7.3.4. Is this common knowledge or am I just unlucky with my query/data selection? Things of note that might matter: the machine is a dual Opteron 1.4GHz running Fedora Core 1 Test 1 for X86_64. The 7.3.4 was from the Fedora distro and the 7.4.1 was the PGDG package. The database is 3.5 Gigs with 10 millions rows and the machine had 1 Gig or ram. Oh... as a side note I'm happy to announce that the 2.6 Linux kernel has more than DOUBLED the speed of all my Postgres queries over the 2.4. =3D) --=20 Orion Henry --=-YvIuE5J7VWwVd0qsLRg0 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQBAIdG19IoQcq23xtARAjvRAJ9Jho1WaVakSp3/cEINrBvEyM0+VwCeKSFf TDIT1jHr+z8XCXO7CC0crvQ= =glIm -----END PGP SIGNATURE----- --=-YvIuE5J7VWwVd0qsLRg0-- From pgsql-performance-owner@postgresql.org Thu Feb 5 01:28:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A4435D1D885 for ; Thu, 5 Feb 2004 05:28:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 14656-06 for ; Thu, 5 Feb 2004 01:28:52 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 129FBD1C9E1 for ; Thu, 5 Feb 2004 01:28:46 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4374202; Wed, 04 Feb 2004 21:29:54 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Orion Henry , pgsql-performance@postgresql.org Subject: Re: 7.3 vs 7.4 performance Date: Wed, 4 Feb 2004 21:27:59 -0800 User-Agent: KMail/1.5.4 References: <1075958197.2438.330.camel@orthanc> In-Reply-To: <1075958197.2438.330.camel@orthanc> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402042127.59134.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/68 X-Sequence-Number: 5592 Orion, > I've done some testing of 7.3.4 vs 7.4.1 and found 7.4.1 to be 20%-30% > slower than 7.3.4. Is this common knowledge or am I just unlucky with > my query/data selection? No, it's not common knowledge. It should be the other way around. Perhaps it's the queries you picked? Even so ..... feel free to post individual EXPLAIN ANALYZEs to the list. > Things of note that might matter: the machine is a dual Opteron 1.4GHz > running Fedora Core 1 Test 1 for X86_64. The 7.3.4 was from the Fedora > distro and the 7.4.1 was the PGDG package. The database is 3.5 Gigs > with 10 millions rows and the machine had 1 Gig or ram. I'm wondering if we need specific compile-time switches for Opteron. I know we got Opteron code tweaks in the last version, but am not sure if a --with is required to activate them. > Oh... as a side note I'm happy to announce that the 2.6 Linux kernel has > more than DOUBLED the speed of all my Postgres queries over the 2.4. =) Keen. Waiting for upgrades .... -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Feb 5 01:44:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 63D6ED1D92F for ; Thu, 5 Feb 2004 05:44:56 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 20511-04 for ; Thu, 5 Feb 2004 01:44:58 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 71BEDD1D883 for ; Thu, 5 Feb 2004 01:44:46 -0400 (AST) 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 i155ip1Y092218 for ; Thu, 5 Feb 2004 05:44:51 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i155aYMV090180 for pgsql-performance@postgresql.org; Thu, 5 Feb 2004 05:36:34 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: 7.3 vs 7.4 performance Date: Thu, 05 Feb 2004 00:32:08 -0500 Organization: cbbrowne Computing Inc Lines: 30 Message-ID: References: <1075958197.2438.330.camel@orthanc> 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 (Reasonable Discussion, linux) Cancel-Lock: sha1:vIn0Wcnfqo4WlqskMn1pV7xC5mY= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/69 X-Sequence-Number: 5593 Oops! orion@trustcommerce.com (Orion Henry) was seen spray-painting on a wall: > I've done some testing of 7.3.4 vs 7.4.1 and found 7.4.1 to be 20%-30% > slower than 7.3.4. Is this common knowledge or am I just unlucky with > my query/data selection? That seems unusual; the opposite seems more typical in view of there being some substantial improvements to the query optimizer. Have you tried doing EXPLAIN ANALYZE on the queries on both sides? There would doubtless be interest in figuring out what is breaking down... > Things of note that might matter: the machine is a dual Opteron > 1.4GHz running Fedora Core 1 Test 1 for X86_64. The 7.3.4 was from > the Fedora distro and the 7.4.1 was the PGDG package. The database > is 3.5 Gigs with 10 millions rows and the machine had 1 Gig or ram. > > Oh... as a side note I'm happy to announce that the 2.6 Linux kernel > has more than DOUBLED the speed of all my Postgres queries over the > 2.4. =) I did some heavy-transaction-oriented tests recently on somewhat heftier quad-Xeon hardware, and found little difference between 2.4 and 2.6, and a small-but-quite-repeatable advantage with FreeBSD 4.9. Now, I'm quite sure my load was rather different from yours, but I find the claim of doubling of speed rather surprising. -- (format nil "~S@~S" "aa454" "freenet.carleton.ca") http://www.ntlug.org/~cbbrowne/spiritual.html Failure is not an option. It comes bundled with your Microsoft product. From pgsql-performance-owner@postgresql.org Thu Feb 5 02:57:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2FCFCD1B80B for ; Thu, 5 Feb 2004 06:57:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 35290-10 for ; Thu, 5 Feb 2004 02:57:13 -0400 (AST) Received: from unity.basin.cultured.net (24161231hfc249.tampabay.rr.com [24.161.231.249]) by svr1.postgresql.org (Postfix) with ESMTP id 14659D1C9AB for ; Thu, 5 Feb 2004 02:54:19 -0400 (AST) Received: by unity.basin.cultured.net (Postfix, from userid 1000) id 3F7E357BE2; Thu, 5 Feb 2004 01:50:32 -0500 (EST) Subject: Re: 7.3 vs 7.4 performance From: Chris Trawick To: Christopher Browne Cc: pgsql-performance@postgresql.org In-Reply-To: References: <1075958197.2438.330.camel@orthanc> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1075963608.12947.8.camel@unity.basin.cultured.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Thu, 05 Feb 2004 01:50:31 -0500 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/70 X-Sequence-Number: 5594 On Thu, 2004-02-05 at 00:32, Christopher Browne wrote: > > Things of note that might matter: the machine is a dual Opteron > > 1.4GHz running Fedora Core 1 Test 1 for X86_64. The 7.3.4 was from > > the Fedora distro and the 7.4.1 was the PGDG package. The database > > is 3.5 Gigs with 10 millions rows and the machine had 1 Gig or ram. > > > > Oh... as a side note I'm happy to announce that the 2.6 Linux kernel > > has more than DOUBLED the speed of all my Postgres queries over the > > 2.4. =) > > I did some heavy-transaction-oriented tests recently on somewhat > heftier quad-Xeon hardware, and found little difference between 2.4 > and 2.6, and a small-but-quite-repeatable advantage with FreeBSD 4.9. > Now, I'm quite sure my load was rather different from yours, but I > find the claim of doubling of speed rather surprising. I don't. I got a similar boost out of 2.6 when dealing with extreme concurrency. Then again, I also got a similar boost out of 7.4. The two together tickled my bank account. ;) One question though... It sounds like your 7.3 binaries are 64-bit and your 7.4 binaries are 32-bit. Have you tried grabbing the SRPM for 7.4 and recompiling it for X86_64? chris From pgsql-performance-owner@postgresql.org Thu Feb 5 07:15:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E5E93D1B8A3 for ; Thu, 5 Feb 2004 11:15:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 24882-08 for ; Thu, 5 Feb 2004 07:15:26 -0400 (AST) Received: from smtp.uol.com.br (smtpout5.uol.com.br [200.221.11.58]) by svr1.postgresql.org (Postfix) with ESMTP id A2B73D1B481 for ; Thu, 5 Feb 2004 07:15:17 -0400 (AST) Received: from smanote (200-158-225-44.dsl.telesp.net.br [200.158.225.44]) by scorpion5.uol.com.br (Postfix) with SMTP id 52A1D85D8; Thu, 5 Feb 2004 09:15:21 -0200 (BRST) Message-ID: <003c01c3ebd9$35c724e0$cf00a8c0@smanote> From: "Carlos Eduardo Smanioto" To: "Christopher Browne" , References: <1075958197.2438.330.camel@orthanc> Subject: Re: 7.3 vs 7.4 performance Date: Thu, 5 Feb 2004 09:14:17 -0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 1 X-MSMail-Priority: High X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/71 X-Sequence-Number: 5595 > I did some heavy-transaction-oriented tests recently on somewhat > heftier quad-Xeon hardware, and found little difference between 2.4 > and 2.6, and a small-but-quite-repeatable advantage with FreeBSD 4.9. > Now, I'm quite sure my load was rather different from yours, but I > find the claim of doubling of speed rather surprising. > -- What's the type of File System you used in the Linux? I am wanting to know which is the operational system better for PostgreSQL: FreeBSD versus Linux 2.6. Thanks. []'s Carlos Eduardo Smanioto (Brazil) ----- Original Message ----- From: "Christopher Browne" To: Sent: Thursday, February 05, 2004 3:32 AM Subject: Re: [PERFORM] 7.3 vs 7.4 performance > Oops! orion@trustcommerce.com (Orion Henry) was seen spray-painting on a wall: > > I've done some testing of 7.3.4 vs 7.4.1 and found 7.4.1 to be 20%-30% > > slower than 7.3.4. Is this common knowledge or am I just unlucky with > > my query/data selection? > > That seems unusual; the opposite seems more typical in view of there > being some substantial improvements to the query optimizer. > > Have you tried doing EXPLAIN ANALYZE on the queries on both sides? > There would doubtless be interest in figuring out what is breaking > down... > > > Things of note that might matter: the machine is a dual Opteron > > 1.4GHz running Fedora Core 1 Test 1 for X86_64. The 7.3.4 was from > > the Fedora distro and the 7.4.1 was the PGDG package. The database > > is 3.5 Gigs with 10 millions rows and the machine had 1 Gig or ram. > > > > Oh... as a side note I'm happy to announce that the 2.6 Linux kernel > > has more than DOUBLED the speed of all my Postgres queries over the > > 2.4. =) > > I did some heavy-transaction-oriented tests recently on somewhat > heftier quad-Xeon hardware, and found little difference between 2.4 > and 2.6, and a small-but-quite-repeatable advantage with FreeBSD 4.9. > Now, I'm quite sure my load was rather different from yours, but I > find the claim of doubling of speed rather surprising. > -- > (format nil "~S@~S" "aa454" "freenet.carleton.ca") > http://www.ntlug.org/~cbbrowne/spiritual.html > Failure is not an option. It comes bundled with your Microsoft product. > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html From pgsql-performance-owner@postgresql.org Thu Feb 5 08:15:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EB906D1CAD9 for ; Thu, 5 Feb 2004 12:15:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 48809-07 for ; Thu, 5 Feb 2004 08:15:09 -0400 (AST) Received: from mailserv.mobilecohesion.com (picard.mobilecohesion.com [80.4.157.11]) by svr1.postgresql.org (Postfix) with ESMTP id 54A7FD1BCA7 for ; Thu, 5 Feb 2004 08:15:00 -0400 (AST) Received: from cpc4-blfs2-3-0-cust48.blfs.cable.ntl.com ([81.110.249.48] helo=pestilence) by mailserv.mobilecohesion.com with asmtp (Exim 4.10) id 1AoiPL-0004MK-00 for pgsql-performance@postgresql.org; Thu, 05 Feb 2004 12:14:59 +0000 From: "Damien Dougan" To: Subject: Index Performance Help Date: Thu, 5 Feb 2004 12:13:40 -0000 Organization: MobileCohesion Message-ID: <004b01c3ebe1$7e0c9a70$7701a8c0@pestilence> 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.2627 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/72 X-Sequence-Number: 5596 Hi All, I've been seeing very slow read performance on a database of 1 million indexed subscribers, which I believe is nothing to do with the data itself, but delays on processing the index. If I make a random jump into the index (say X), it can take about 50ms to read the subscriber. If I then make a "close by" lookup (say X+10), it takes only about 0.5ms to read the subscriber. Making another lookup to a "far away" (say X+1000), it again takes about 50ms to read. From the analyze output, it looks like most of the work is being done in the index scan of the subscriber table - reading the actual data from the PublicView is quite fast. Am I correct in my analysis? Is there anything I can do to improve the performance of the index lookups? (The indexes in question are all created as B-TREE.) I've tried increasing the index memory and making a number of queries around the index range, but a stray of several hundred indexes from a cached entry always results in a major lookup delay. I've also increased the shared memory available to Postgres to 80MB incase this is a paging of the index, but it hasn't seemed to have any effect. Sample analyze output for an initial query: hydradb=# explain analyze select * from pvsubscriber where actorid = 'b3432-asdas-232-Subscriber793500'; QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ ---------------------------------------- Nested Loop Left Join (cost=0.00..13.19 rows=1 width=100) (actual time=49.688..49.699 rows=1 loops=1) -> Nested Loop Left Join (cost=0.00..10.16 rows=1 width=69) (actual time=49.679..49.689 rows=1 loops=1) Join Filter: ("inner".mc_childactor_id = "outer".id) -> Nested Loop (cost=0.00..10.15 rows=1 width=69) (actual time=49.669..49.677 rows=1 loops=1) -> Nested Loop (cost=0.00..7.12 rows=1 width=73) (actual time=43.969..43.974 rows=1 loops=1) -> Index Scan using mc_actor_key on mc_actor (cost=0.00..4.08 rows=1 width=69) (actual time=39.497..39.499 rows=1 loops=1) Index Cond: ((actorid)::text = 'b3432-asdas-232-Subscriber793500'::text) -> Index Scan using rel_actor_has_subscriber_idx1 on rel_actor_has_subscriber rel_sub (cost=0.00..3.02 rows=1 width=8) (actual time=4.458..4.460 rows=1 loops=1) Index Cond: ("outer".id = rel_sub.mc_actor_id) -> Index Scan using mc_subscriber_id_idx on mc_subscriber sub (cost=0.00..3.02 rows=1 width=4) (actual time=5.689..5.691 rows=1 loops=1) Index Cond: (sub.id = "outer".mc_subscriber_id) -> Seq Scan on rel_actor_has_actor rel_parent (cost=0.00..0.00 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=1) -> Index Scan using mc_actor_id_idx on mc_actor (cost=0.00..3.02 rows=1 width=39) (actual time=0.002..0.002 rows=0 loops=1) Index Cond: ("outer".mc_parentactor_id = mc_actor.id) Total runtime: 49.845 ms (15 rows) And the analyze output for a "nearby" subscriber (10 indexes away): hydradb=# explain analyze select * from pvsubscriber where actorid = 'b3432-asdas-232-Subscriber793510'; QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ ---------------------------------------- Nested Loop Left Join (cost=0.00..13.19 rows=1 width=100) (actual time=0.278..0.288 rows=1 loops=1) -> Nested Loop Left Join (cost=0.00..10.16 rows=1 width=69) (actual time=0.271..0.280 rows=1 loops=1) Join Filter: ("inner".mc_childactor_id = "outer".id) -> Nested Loop (cost=0.00..10.15 rows=1 width=69) (actual time=0.264..0.272 rows=1 loops=1) -> Nested Loop (cost=0.00..7.12 rows=1 width=73) (actual time=0.246..0.251 rows=1 loops=1) -> Index Scan using mc_actor_key on mc_actor (cost=0.00..4.08 rows=1 width=69) (actual time=0.220..0.221 rows=1 loops=1) Index Cond: ((actorid)::text = 'b3432-asdas-232-Subscriber793510'::text) -> Index Scan using rel_actor_has_subscriber_idx1 on rel_actor_has_subscriber rel_sub (cost=0.00..3.02 rows=1 width=8) (actual time=0.017..0.018 rows=1 loops=1) Index Cond: ("outer".id = rel_sub.mc_actor_id) -> Index Scan using mc_subscriber_id_idx on mc_subscriber sub (cost=0.00..3.02 rows=1 width=4) (actual time=0.012..0.013 rows=1 loops=1) Index Cond: (sub.id = "outer".mc_subscriber_id) -> Seq Scan on rel_actor_has_actor rel_parent (cost=0.00..0.00 rows=1 width=8) (actual time=0.002..0.002 rows=0 loops=1) -> Index Scan using mc_actor_id_idx on mc_actor (cost=0.00..3.02 rows=1 width=39) (actual time=0.001..0.001 rows=0 loops=1) Index Cond: ("outer".mc_parentactor_id = mc_actor.id) Total runtime: 0.428 ms (15 rows) Many thanks, Damien ---------------------------------------------------------------------- Damien Dougan, Software Architect Mobile Cohesion - http://www.mobilecohesion.com Email: damien.dougan@mobilecohesion.com Mobile: +44 7766477997 ---------------------------------------------------------------------- From pgsql-performance-owner@postgresql.org Thu Feb 5 09:45:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4EDFAD1D283 for ; Thu, 5 Feb 2004 13:44:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 80600-10 for ; Thu, 5 Feb 2004 09:44:56 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 2D64CD1D201 for ; Thu, 5 Feb 2004 09:44:47 -0400 (AST) 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 i15Diq1a034328 for ; Thu, 5 Feb 2004 13:44:52 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i15DaW8Z032104 for pgsql-performance@postgresql.org; Thu, 5 Feb 2004 13:36:32 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: 7.3 vs 7.4 performance Date: Thu, 05 Feb 2004 08:30:55 -0500 Organization: cbbrowne Computing Inc Lines: 37 Message-ID: References: <1075958197.2438.330.camel@orthanc> <003c01c3ebd9$35c724e0$cf00a8c0@smanote> 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 (Reasonable Discussion, linux) Cancel-Lock: sha1:DmueHpMbboqT5lm4gvpPjO+lq/c= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/73 X-Sequence-Number: 5597 In an attempt to throw the authorities off his trail, csmanioto@uol.com.br ("Carlos Eduardo Smanioto") transmitted: >> I did some heavy-transaction-oriented tests recently on somewhat >> heftier quad-Xeon hardware, and found little difference between 2.4 >> and 2.6, and a small-but-quite-repeatable advantage with FreeBSD >> 4.9. Now, I'm quite sure my load was rather different from yours, >> but I find the claim of doubling of speed rather surprising. > > What's the type of File System you used in the Linux? I am wanting > to know which is the operational system better for PostgreSQL: > FreeBSD versus Linux 2.6. On the Linux box in question, I was using JFS, which has had the mixed reviews, lately, that on the one hand, it _appears_ to be a tad faster than all the others, but that has been, on the other hand, associated with systems hanging up and crashing, under load. The latter bit is a _really_ big caveat. On that particular machine, I have a nicely repeatable "test case" where I can do a particular set of "system load" that consistently takes the system down, to the point of having to hit the "big red button." If I could point to a clear reason why it happens, I'd be a much happier camper. As it stands, it is a bit nebulous whether the problem is: a) Hardware drivers, b) Flakey hardware (which Linux 2.6.1 copes with a lot better than 2.4!), c) Flakey 2.4 kernel, d) Problem with JFS, e) Something else not yet identified as a plausible cause. If I could say, "Oh, it's an identified bug in the Frobozz RAID controller drivers, and was fixed in 2.6.0-pre-17", that would help allay the suspicion that the problem could be any of the above. -- let name="aa454" and tld="freenet.carleton.ca" in name ^ "@" ^ tld;; http://www.ntlug.org/~cbbrowne/ "Another result of the tyranny of Pascal is that beginners don't use function pointers." --Rob Pike From pgsql-performance-owner@postgresql.org Thu Feb 5 11:16:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DCDC9D1D17E for ; Thu, 5 Feb 2004 15:07:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 22729-02 for ; Thu, 5 Feb 2004 11:07:28 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id C73E4D1D52E for ; Thu, 5 Feb 2004 11:07:18 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i15F7PGA002551; Thu, 5 Feb 2004 10:07:25 -0500 (EST) To: josh@agliodbs.com Cc: Orion Henry , pgsql-performance@postgresql.org Subject: Re: 7.3 vs 7.4 performance In-reply-to: <200402042127.59134.josh@agliodbs.com> References: <1075958197.2438.330.camel@orthanc> <200402042127.59134.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Wed, 04 Feb 2004 21:27:59 -0800" Date: Thu, 05 Feb 2004 10:07:25 -0500 Message-ID: <2550.1075993645@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/74 X-Sequence-Number: 5598 Josh Berkus writes: > I'm wondering if we need specific compile-time switches for Opteron. I know > we got Opteron code tweaks in the last version, Not in 7.4. There is some marginal hacking in the spinlock code in CVS tip for multi-CPU i386 and x86_64 (viz, add a PAUSE instruction inside the wait loop) but I'm not sure that will have any significance in real life. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Feb 5 11:58:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C3466D1C7F0 for ; Thu, 5 Feb 2004 15:54:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 44390-08 for ; Thu, 5 Feb 2004 11:54:45 -0400 (AST) Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net [194.217.242.86]) by svr1.postgresql.org (Postfix) with ESMTP id A6A92D1B917 for ; Thu, 5 Feb 2004 11:54:35 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 1Aolpp-0003HB-0b; Thu, 05 Feb 2004 15:54:33 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 0622016C47; Thu, 5 Feb 2004 15:54:31 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 6287E16AB3; Thu, 5 Feb 2004 15:54:28 +0000 (GMT) From: Richard Huxton To: "Damien Dougan" , Subject: Re: Index Performance Help Date: Thu, 5 Feb 2004 15:54:27 +0000 User-Agent: KMail/1.5 References: <004b01c3ebe1$7e0c9a70$7701a8c0@pestilence> In-Reply-To: <004b01c3ebe1$7e0c9a70$7701a8c0@pestilence> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402051554.27672.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/75 X-Sequence-Number: 5599 On Thursday 05 February 2004 12:13, Damien Dougan wrote: > Hi All, > > I've been seeing very slow read performance on a database of 1 million > indexed subscribers, which I believe is nothing to do with the data > itself, but delays on processing the index. > > If I make a random jump into the index (say X), it can take about 50ms > to read the subscriber. If I then make a "close by" lookup (say X+10), > it takes only about 0.5ms to read the subscriber. Making another lookup > to a "far away" (say X+1000), it again takes about 50ms to read. The first time, it has to fetch a block from disk. The second time that disk block is already in RAM so it's much faster. The third time it needs a different disk block. > Am I correct in my analysis? Is there anything I can do to improve the > performance of the index lookups? Make sure you have enough RAM to buffer your disks. Buy faster disks. > I've tried increasing the index memory and making a number of queries > around the index range, but a stray of several hundred indexes from a > cached entry always results in a major lookup delay. Yep, that'll be your disks. > I've also increased the shared memory available to Postgres to 80MB > incase this is a paging of the index, but it hasn't seemed to have any > effect. Probably the wrong thing to do (although you don't mention what hardware you've got). Read the tuning document at: http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php > Sample analyze output for an initial query: > > hydradb=# explain analyze select * from pvsubscriber where actorid = > 'b3432-asdas-232-Subscriber793500'; ... > -> Index Scan using mc_actor_key on mc_actor > (cost=0.00..4.08 rows=1 width=69) (actual time=39.497..39.499 rows=1 > loops=1) ... > Total runtime: 49.845 ms > And the analyze output for a "nearby" subscriber (10 indexes away): > > hydradb=# explain analyze select * from pvsubscriber where actorid = > 'b3432-asdas-232-Subscriber793510'; > ... > -> Index Scan using mc_actor_key on mc_actor > (cost=0.00..4.08 rows=1 width=69) (actual time=0.220..0.221 rows=1 > loops=1) > Total runtime: 0.428 ms > (15 rows) That certainly seems to be the big change - the only way to consistently get 1ms timings is going to be to make sure all your data is cached. Try the tuning guide above and see what difference that makes. If that's no good, post again with details of your config settings, hardware, number of clients etc... -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Thu Feb 5 12:43:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 89803D1D528 for ; Thu, 5 Feb 2004 16:41:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 72949-01 for ; Thu, 5 Feb 2004 12:41:55 -0400 (AST) Received: from mailserv.mobilecohesion.com (picard.mobilecohesion.com [80.4.157.11]) by svr1.postgresql.org (Postfix) with ESMTP id 43812D1D2BC for ; Thu, 5 Feb 2004 12:41:54 -0400 (AST) Received: from cpc4-blfs2-3-0-cust48.blfs.cable.ntl.com ([81.110.249.48] helo=pestilence) by mailserv.mobilecohesion.com with asmtp (Exim 4.10) id 1AomZG-00056S-00; Thu, 05 Feb 2004 16:41:30 +0000 From: "Damien Dougan" To: "'Richard Huxton'" , Subject: Re: Index Performance Help Date: Thu, 5 Feb 2004 16:40:10 -0000 Organization: MobileCohesion Message-ID: <005601c3ec06$b8b22f30$7701a8c0@pestilence> 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.2627 In-Reply-To: <200402051554.27672.dev@archonet.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/76 X-Sequence-Number: 5600 Thanks Richard. It certainly does appear to be memory related (on a smaller data set of 250K subscribers, all accesses are < 1ms). We're going to play with increasing RAM on the machine, and applying the optimisation levels on the page you recommended. (We're also running on a hardware RAID controlled SCSI set - mirrored disks so reading should be very fast). Cheers, Damien From pgsql-performance-owner@postgresql.org Thu Feb 5 13:31:38 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E1DFCD1B45B for ; Thu, 5 Feb 2004 17:31:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 95231-04 for ; Thu, 5 Feb 2004 13:31:27 -0400 (AST) Received: from busybox.pixar.com (busybox.pixar.com [138.72.18.213]) by svr1.postgresql.org (Postfix) with ESMTP id 67B38D1D201 for ; Thu, 5 Feb 2004 13:31:26 -0400 (AST) Received: from pixar.com (dreadnok.pixar.com [138.72.16.110]) by busybox.pixar.com (8.12.8/8.12.8) with ESMTP id i15HVOHw025958; Thu, 5 Feb 2004 09:31:24 -0800 Message-ID: <40227DEC.5010007@pixar.com> Date: Thu, 05 Feb 2004 09:31:24 -0800 From: Mark Harrison User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Corey Edwards Cc: pgsql-performance@postgresql.org Subject: Re: select is not using index? References: <40217853.20309@pixar.com> <1075936942.12400.18.camel@harvey> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/77 X-Sequence-Number: 5601 Corey Edwards wrote: > Your column is a bigint but 123 defaults to type int. Indexes aren't > used when there's a type mismatch. Use an explicit cast or quote it: > > select * from bigtable where id = 123::bigint; > > Or > > select * from bigtable where id = '123'; Thanks Corey, both of these do exactly what I need... Cheers, Mark -- Mark Harrison Pixar Animation Studios From pgsql-performance-owner@postgresql.org Thu Feb 5 14:09:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 02D79D1D141 for ; Thu, 5 Feb 2004 18:04:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 10569-01 for ; Thu, 5 Feb 2004 14:04:47 -0400 (AST) Received: from front1.mail.megapathdsl.net (front1.mail.megapathdsl.net [66.80.60.31]) by svr1.postgresql.org (Postfix) with ESMTP id 1852FD1CCA8 for ; Thu, 5 Feb 2004 14:04:45 -0400 (AST) Received: from [64.32.131.193] (HELO [192.168.1.11]) by front1.mail.megapathdsl.net (CommuniGate Pro SMTP 4.1.3) with ESMTP id 144211911; Thu, 05 Feb 2004 10:04:44 -0800 Subject: Re: 7.3 vs 7.4 performance From: Orion Henry To: Chris Trawick Cc: pgsql-performance@postgresql.org In-Reply-To: <1075963608.12947.8.camel@unity.basin.cultured.net> References: <1075958197.2438.330.camel@orthanc> <1075963608.12947.8.camel@unity.basin.cultured.net> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-3YGp1MwjqXtp7tsfpj5d" Organization: Message-Id: <1076004284.8748.5.camel@orthanc> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 05 Feb 2004 10:04:44 -0800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/78 X-Sequence-Number: 5602 --=-3YGp1MwjqXtp7tsfpj5d Content-Type: text/plain Content-Transfer-Encoding: quoted-printable >=20 > One question though... It sounds like your 7.3 binaries are 64-bit and > your 7.4 binaries are 32-bit. Have you tried grabbing the SRPM for 7.4 > and recompiling it for X86_64? No, they were all 64 bit. I'm going to run explains on all my queries and see if I can find=20 anything of interest... --=-3YGp1MwjqXtp7tsfpj5d Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQBAIoW89IoQcq23xtARAgQtAJ0Z0ot4JdgMk04Vcd1/n7VmiTeMJQCgvpvU 8129n/s0yeToIKnnhD8y5/4= =ehKT -----END PGP SIGNATURE----- --=-3YGp1MwjqXtp7tsfpj5d-- From pgsql-performance-owner@postgresql.org Thu Feb 5 14:29:38 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 72F01D1B49E for ; Thu, 5 Feb 2004 18:29:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 21710-03 for ; Thu, 5 Feb 2004 14:29:31 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 89F13D1D52A for ; Thu, 5 Feb 2004 14:29:30 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4377106; Thu, 05 Feb 2004 10:30:33 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Damien Dougan" , "'Richard Huxton'" , Subject: Re: Index Performance Help Date: Thu, 5 Feb 2004 10:28:35 -0800 User-Agent: KMail/1.5.4 References: <005601c3ec06$b8b22f30$7701a8c0@pestilence> In-Reply-To: <005601c3ec06$b8b22f30$7701a8c0@pestilence> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402051028.35116.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/79 X-Sequence-Number: 5603 Damian, Also, if there have been a lot of updates to the table, you may need to run a REINDEX on it. An attenuated index would be slow to load because of the nummber of empty disk blocks. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-advocacy-owner@postgresql.org Thu Feb 5 19:10:04 2004 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 44E0AD1B4B7; Thu, 5 Feb 2004 23:09:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 37500-04; Thu, 5 Feb 2004 19:09:45 -0400 (AST) Received: from busybox.pixar.com (busybox.pixar.com [138.72.18.213]) by svr1.postgresql.org (Postfix) with ESMTP id D71EBD1B49E; Thu, 5 Feb 2004 19:09:42 -0400 (AST) Received: from pixar.com (dreadnok.pixar.com [138.72.16.110]) by busybox.pixar.com (8.12.8/8.12.8) with ESMTP id i15N9aHw027368; Thu, 5 Feb 2004 15:09:36 -0800 Message-ID: <4022CD30.2070500@pixar.com> Date: Thu, 05 Feb 2004 15:09:36 -0800 From: Mark Harrison User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jan Wieck Cc: Mike Nolan , josh@agliodbs.com, pgsql-performance@postgresql.org, pgsql-advocacy@postgresql.org Subject: Re: [PERFORM] MySQL+InnoDB vs. PostgreSQL test? References: <200402041336.i14DahHM009493@gw.tssi.com> <402169FE.8010802@Yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/40 X-Sequence-Number: 3611 Jan Wieck wrote: > It might not work with the words I used above, but the point I tried to > make is that the hardest thing you can "sell" is a "no". I mean, not > just saying "no", but selling it in a way that the customer will not go > with the next idiot who claims "we can do that". But you will need some kind of data or reasoning to back up your response, especially if it is deviating from the conventional wisdom, or from some familiar system. Especially in this case, it's not a "no" answer that's being sold... it's "solution a is better than solution b, even though you might be more familiar with solution b." Cheers, Mark From pgsql-performance-owner@postgresql.org Thu Feb 5 22:32:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C8300D1D141 for ; Fri, 6 Feb 2004 02:31:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 91431-10 for ; Thu, 5 Feb 2004 22:31:56 -0400 (AST) Received: from ALPHA6.ITS.MONASH.EDU.AU (alpha6.its.monash.edu.au [130.194.1.25]) by svr1.postgresql.org (Postfix) with ESMTP id BC184D1CA65 for ; Thu, 5 Feb 2004 22:31:51 -0400 (AST) Received: from localhost ([130.194.13.84]) by vaxc.its.monash.edu.au (PMDF V6.1 #39306) with ESMTP id <01L6A3TM2OMU935CT1@vaxc.its.monash.edu.au> for pgsql-performance@postgresql.org; Fri, 06 Feb 2004 11:46:59 +1100 Received: from blammo.its.monash.edu.au (localhost.its.monash.edu.au [127.0.0.1]) by localhost (Postfix) with ESMTP id 2A99E39C004 for ; Fri, 06 Feb 2004 11:46:58 +1100 (EST) Received: from bruce.csse.monash.edu.au (bruce.csse.monash.edu.au [130.194.64.3]) by blammo.its.monash.edu.au (Postfix) with ESMTP id 14A992DC010 for ; Fri, 06 Feb 2004 11:46:58 +1100 (EST) Received: from bruce.csse.monash.edu.au (localhost [127.0.0.1]) by bruce.csse.monash.edu.au (8.12.8+Sun/8.12.8) with ESMTP id i160kvNq000371 for ; Fri, 06 Feb 2004 11:46:58 +1100 (EST) Received: from localhost (sgaric@localhost) by bruce.csse.monash.edu.au (8.12.8+Sun/8.12.2/Submit) with ESMTP id i160kvVI000368 for ; Fri, 06 Feb 2004 11:46:57 +1100 (EST) Date: Fri, 06 Feb 2004 11:46:57 +1100 (EST) From: Slavisa Garic Subject: COPY with INDEXES question In-reply-to: To: pgsql-performance@postgresql.org Message-id: MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Content-transfer-encoding: 7BIT X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/81 X-Sequence-Number: 5605 Hi, I have a quick question. In order to speed up insertion of large number of rows (100s of thousands) I replaced the INSERT with the COPY. This works fine but one question popped into my mind. Does copy updates indexes on that table if there are some defined? Thanks, Slavisa From pgsql-performance-owner@postgresql.org Thu Feb 5 23:21:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B6E95D1C516 for ; Fri, 6 Feb 2004 03:21:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 09699-05 for ; Thu, 5 Feb 2004 23:21:23 -0400 (AST) Received: from ALPHA8.ITS.MONASH.EDU.AU (alpha8.its.monash.edu.au [130.194.1.8]) by svr1.postgresql.org (Postfix) with ESMTP id 4CB4AD1B4AA for ; Thu, 5 Feb 2004 23:21:19 -0400 (AST) Received: from localhost ([130.194.13.81]) by vaxh.its.monash.edu.au (PMDF V5.2-31 #39306) with ESMTP id <01L6A8875AUA8X2YLM@vaxh.its.monash.edu.au> for pgsql-performance@postgresql.org; Fri, 6 Feb 2004 13:52:29 +1100 Received: from kapow.its.monash.edu.au (localhost.its.monash.edu.au [127.0.0.1]) by localhost (Postfix) with ESMTP id D446E1B000E; Fri, 06 Feb 2004 13:52:28 +1100 (EST) Received: from bruce.csse.monash.edu.au (bruce.csse.monash.edu.au [130.194.64.3]) by kapow.its.monash.edu.au (Postfix) with ESMTP id BB93912400F; Fri, 06 Feb 2004 13:52:28 +1100 (EST) Received: from bruce.csse.monash.edu.au (localhost [127.0.0.1]) by bruce.csse.monash.edu.au (8.12.8+Sun/8.12.8) with ESMTP id i162qSNq025280; Fri, 06 Feb 2004 13:52:28 +1100 (EST) Received: from localhost (sgaric@localhost) by bruce.csse.monash.edu.au (8.12.8+Sun/8.12.2/Submit) with ESMTP id i162qS03025277; Fri, 06 Feb 2004 13:52:28 +1100 (EST) Date: Fri, 06 Feb 2004 13:52:28 +1100 (EST) From: Slavisa Garic Subject: Re: COPY with INDEXES question In-reply-to: <402301D4.8030604@familyhealth.com.au> To: Christopher Kings-Lynne Cc: Slavisa Garic , pgsql-performance@postgresql.org Message-id: MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Content-transfer-encoding: 7BIT X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/83 X-Sequence-Number: 5607 Thanks for the reply and thanks even more for the good one :). Cheers, Slavisa On Fri, 6 Feb 2004, Christopher Kings-Lynne wrote: > > I have a quick question. In order to speed up insertion of large number of > > rows (100s of thousands) I replaced the INSERT with the COPY. This works > > fine but one question popped into my mind. Does copy updates indexes on > > that table if there are some defined? > > Yes, of course. Runs triggers and stuff as well. > > Chris > > From pgsql-performance-owner@postgresql.org Thu Feb 5 22:47:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E0EC9D1CAE1 for ; Fri, 6 Feb 2004 02:47:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 00264-01 for ; Thu, 5 Feb 2004 22:47:51 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id E1867D1B917 for ; Thu, 5 Feb 2004 22:47:46 -0400 (AST) Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i162lm2m016778; Fri, 6 Feb 2004 10:47:48 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <402301D4.8030604@familyhealth.com.au> Date: Fri, 06 Feb 2004 10:54:12 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Slavisa Garic Cc: pgsql-performance@postgresql.org Subject: Re: COPY with INDEXES question References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/82 X-Sequence-Number: 5606 > I have a quick question. In order to speed up insertion of large number of > rows (100s of thousands) I replaced the INSERT with the COPY. This works > fine but one question popped into my mind. Does copy updates indexes on > that table if there are some defined? Yes, of course. Runs triggers and stuff as well. Chris From pgsql-performance-owner@postgresql.org Fri Feb 6 16:43:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A4A8CD1CB0F for ; Fri, 6 Feb 2004 02:55:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 00159-05 for ; Thu, 5 Feb 2004 22:55:18 -0400 (AST) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2DFBDD1CA67 for ; Thu, 5 Feb 2004 22:55:14 -0400 (AST) Received: from [134.22.70.253] (dyn-70-253.tor.dsl.tht.net [134.22.70.253]) by tht.net (Postfix) with ESMTP id C78F676A2A; Thu, 5 Feb 2004 21:55:21 -0500 (EST) Subject: Re: COPY with INDEXES question From: Rod Taylor To: Slavisa Garic Cc: Postgresql Performance In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-XjcbCDOxoJ/XCmYGop3A" Message-Id: <1076036127.308.586.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Thu, 05 Feb 2004 21:55:28 -0500 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/97 X-Sequence-Number: 5621 --=-XjcbCDOxoJ/XCmYGop3A Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, 2004-02-05 at 19:46, Slavisa Garic wrote: > Hi, >=20 > I have a quick question. In order to speed up insertion of large number of > rows (100s of thousands) I replaced the INSERT with the COPY. This works > fine but one question popped into my mind. Does copy updates indexes on > that table if there are some defined? Copy does nearly everything that standard inserts to. RULES are the only thing that come to mind. Triggers, indexes, constraints, etc. are all applied. --=20 Rod Taylor Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL PGP Key: http://www.rbt.ca/rbtpub.asc --=-XjcbCDOxoJ/XCmYGop3A 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 (FreeBSD) iD8DBQBAIwIf6DETLow6vwwRAvKwAJ9TIi35EL0mwMbQZXwRoRhSxkF+vQCaAkKL nRWDxCgBjiY/FGA3I80VOOo= =W+US -----END PGP SIGNATURE----- --=-XjcbCDOxoJ/XCmYGop3A-- From pgsql-performance-owner@postgresql.org Fri Feb 6 03:18:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 96280D1CA67 for ; Fri, 6 Feb 2004 07:18:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 67557-09 for ; Fri, 6 Feb 2004 03:18:46 -0400 (AST) Received: from alvarezp.ods.org (unknown [200.77.201.28]) by svr1.postgresql.org (Postfix) with ESMTP id B9D9AD1D36C for ; Fri, 6 Feb 2004 03:18:44 -0400 (AST) Received: (from apache@localhost) by alvarezp.ods.org (8.11.6/8.11.6) id i167J5B11836; Thu, 5 Feb 2004 23:19:05 -0800 X-Authentication-Warning: alvarezp.ods.org: apache set sender to alvarezp@alvarezp.ods.org using -f Received: from 192.168.0.64 (SquirrelMail authenticated user alvarezp) by alvarezp.ods.org with HTTP; Thu, 5 Feb 2004 23:19:04 -0800 (PST) Message-ID: <4207.192.168.0.64.1076051944.squirrel@alvarezp.ods.org> Date: Thu, 5 Feb 2004 23:19:04 -0800 (PST) Subject: Seq scan on zero-parameters function From: "Octavio Alvarez" To: pgsql-performance@postgresql.org Reply-To: alvarezp@alvarezp.ods.org User-Agent: SquirrelMail/1.4.0-1.7.x MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/84 X-Sequence-Number: 5608 Hi! I'd like to know if this is expected behavior. These are two couples of queries. In each couple, the first one has a WHERE field = function() condition, just like the second one, but in the form WHERE field = (SELECT function()). In my opinion, both should have the same execution plan, as the function has no parameters and, therefore, is constant. I'm concerned about this, because the second form looks like a workaround. *** TESTED IN: PostgreSQL 7.4.1 on i686-pc-cygwin *** pgdb=# explain analyze select count(*) from t_students where period = (select current_period_id()); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=127.84..127.84 rows=1 width=0) (actual time=1.000..1.000 rows=1 loops=1) InitPlan -> Result (cost=0.00..0.01 rows=1 width=0) (actual time=1.000..1.000 rows=1 loops=1) -> Index Scan using i_t_students__period on t_students (cost=0.00..127.71 rows=44 width=0) (actual time=1.000..1.000 rows=21 loop=1) Index Cond: (period = $0) Total runtime: 1.000 ms (6 rows) pgdb=# explain analyze select count(*) from t_students where period = (select current_period_id()); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=127.84..127.84 rows=1 width=0) (actual time=1.000..1.000 rows=1 loops=1) InitPlan -> Result (cost=0.00..0.01 rows=1 width=0) (actual time=1.000..1.000 rows=1 loops=1) -> Index Scan using i_t_students__period on t_students (cost=0.00..127.71 rows=44 width=0) (actual time=1.000..1.000 rows=21 loop=1) Index Cond: (period = $0) Total runtime: 1.000 ms (6 rows) pgdb=# select version(); version --------------------------------------------------------------------------------------- PostgreSQL 7.4.1 on i686-pc-cygwin, compiled by GCC gcc (GCC) 3.3.1 (cygming special) (1 row) pgdb=# *** TESTED IN: PostgreSQL 7.3.4 on i386-redhat-linux-gnu *** pgdb=# explain analyze select count(*) from t_students where period = current_period_id(); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=182.32..182.32 rows=1 width=0) (actual time=49077.38..49077.38 rows=1 loops=1) -> Seq Scan on t_students (cost=0.00..182.22 rows=43 width=0) (actual time=17993.89..49077.13 rows=21 loops=1) Filter: (period = current_period_id()) Total runtime: 49077.61 msec (4 rows) pgdb=# explain analyze select count(*) from t_students where period = (select current_period_id()); QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=125.19..125.19 rows=1 width=0) (actual time=131.59..131.60 rows=1 loops=1) InitPlan -> Result (cost=0.00..0.01 rows=1 width=0) (actual time=41.05..41.06 rows=1 loops=1) -> Index Scan using i_t_students__period on t_students (cost=0.00..125.08 rows=43 width=0) (actual time=131.28..131.48 rows=21 loops=1) Index Cond: (period = $0) Total runtime: 131.95 msec (6 rows) pgdb=# select version(); version ----------------------------------------------------------------- PostgreSQL 7.3.4 on i386-redhat-linux-gnu, compiled by GCC 2.96 (1 row) -- Octavio Alvarez. E-mail: alvarezp@alvarezp.ods.org. Agradezco que sus correos sean enviados siempre a esta direcci�n. From pgsql-performance-owner@postgresql.org Fri Feb 6 04:43:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 39D7CD1B897 for ; Fri, 6 Feb 2004 08:43:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 95995-02 for ; Fri, 6 Feb 2004 04:43:01 -0400 (AST) Received: from alvarezp.ods.org (unknown [200.77.201.28]) by svr1.postgresql.org (Postfix) with ESMTP id 5EC24D1D31D for ; Fri, 6 Feb 2004 04:42:58 -0400 (AST) Received: (from apache@localhost) by alvarezp.ods.org (8.11.6/8.11.6) id i168hDl12193; Fri, 6 Feb 2004 00:43:13 -0800 X-Authentication-Warning: alvarezp.ods.org: apache set sender to alvarezp@alvarezp.ods.org using -f Received: from 192.168.0.64 (SquirrelMail authenticated user alvarezp) by alvarezp.ods.org with HTTP; Fri, 6 Feb 2004 00:43:12 -0800 (PST) Message-ID: <4795.192.168.0.64.1076056992.squirrel@alvarezp.ods.org> In-Reply-To: <40234207.6040207@klaster.net> References: <4207.192.168.0.64.1076051944.squirrel@alvarezp.ods.org> <40234207.6040207@klaster.net> Date: Fri, 6 Feb 2004 00:43:12 -0800 (PST) Subject: Re: Seq scan on zero-parameters function From: "Octavio Alvarez" To: "Tomasz Myrta" Cc: pgsql-performance@postgresql.org Reply-To: alvarezp@alvarezp.ods.org User-Agent: SquirrelMail/1.4.0-1.7.x MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/85 X-Sequence-Number: 5609 Tomasz Myrta said: > Dnia 2004-02-06 08:19, U�ytkownik Octavio Alvarez napisa�: >> In each couple, the first one has a WHERE field = function() >> condition, just like the second one, but in the form WHERE field = >> (SELECT function()). In my opinion, both should have the same execution >> plan, as the function has no parameters and, therefore, is constant. > > Nope. > > What would you say about function without params returning timeofday()? > Is it constant? No... :-P ;-) > If you are sure, that your function returns constant value - declare it > as IMMUTABLE. (look at CREATE FUNCTION documentation) Thanks for the hint. In fact, my current_period_id() is based on time, but it should be constant along the query execution. I mean, I don't want some records filtered with some values and other with other values... I'll have an uncongruent recordset. Say SELECT [field-list] FROM [complex-join] WHERE sec = datepart('second', now()); Now suppose the query takes always more than 1 second because of the complex-join or whatever reason: I will naver have a congruent recordset. IMMUTABLE wouldn't help here, only wrapping the function in a subquery. Is this expected behavior? Is this standards compliant (if it can be qualified as such)? Octavio. -- Octavio Alvarez. E-mail: alvarezp@alvarezp.ods.org. Agradezco que sus correos sean enviados siempre a esta direcci�n. From pgsql-performance-owner@postgresql.org Fri Feb 6 04:50:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5A205D1D31F for ; Fri, 6 Feb 2004 08:50:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 96866-03 for ; Fri, 6 Feb 2004 04:50:55 -0400 (AST) Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net [194.217.242.86]) by svr1.postgresql.org (Postfix) with ESMTP id 36411D1D362 for ; Fri, 6 Feb 2004 04:50:53 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 1Ap1hN-0007LI-0b; Fri, 06 Feb 2004 08:50:53 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 2BB0416350; Fri, 6 Feb 2004 08:50:53 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 3EFDF15A6C; Fri, 6 Feb 2004 08:50:51 +0000 (GMT) From: Richard Huxton To: alvarezp@alvarezp.ods.org, pgsql-performance@postgresql.org Subject: Re: Seq scan on zero-parameters function Date: Fri, 6 Feb 2004 08:50:50 +0000 User-Agent: KMail/1.5 References: <4207.192.168.0.64.1076051944.squirrel@alvarezp.ods.org> In-Reply-To: <4207.192.168.0.64.1076051944.squirrel@alvarezp.ods.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402060850.50818.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/86 X-Sequence-Number: 5610 On Friday 06 February 2004 07:19, Octavio Alvarez wrote: > Hi! > > I'd like to know if this is expected behavior. These are two couples of > queries. In each couple, the first one has a WHERE field = function() > condition, just like the second one, but in the form WHERE field = > (SELECT function()). In my opinion, both should have the same execution > plan, as the function has no parameters and, therefore, is constant. Not necessarily constant - think about random() or timeofday(). Have you set the attributes on your function? http://www.postgresql.org/docs/7.4/static/sql-createfunction.html > pgdb=# explain analyze select count(*) from t_students where period = > (select current_period_id()); It's not entirely clear to me why this form is different from the other form though. -- Richard Huxton Archonet Ltd From pgsql-sql-owner@postgresql.org Fri Feb 6 04:53:26 2004 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 708E5D1B911 for ; Fri, 6 Feb 2004 08:52:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 93361-10 for ; Fri, 6 Feb 2004 04:52:55 -0400 (AST) Received: from serwer.skawsoft.com.pl (skawina.eu.org [80.48.213.66]) by svr1.postgresql.org (Postfix) with ESMTP id 91BA3D1D854 for ; Fri, 6 Feb 2004 04:52:53 -0400 (AST) Received: from klaster.net (backbone.zab.citynet.pl [212.244.6.69]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 10E292B3CB; Fri, 6 Feb 2004 09:52:53 +0100 (CET) Message-ID: <4023567E.1020406@klaster.net> Date: Fri, 06 Feb 2004 09:55:26 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.6b) Gecko/20031208 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: alvarezp@alvarezp.ods.org, Lista dyskusyjna pgsql-sql Subject: Re: [PERFORM] Seq scan on zero-parameters function References: <4207.192.168.0.64.1076051944.squirrel@alvarezp.ods.org> <40234207.6040207@klaster.net> <4795.192.168.0.64.1076056992.squirrel@alvarezp.ods.org> In-Reply-To: <4795.192.168.0.64.1076056992.squirrel@alvarezp.ods.org> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/63 X-Sequence-Number: 16754 Dnia 2004-02-06 09:43, U�ytkownik Octavio Alvarez napisa�: > Thanks for the hint. > > In fact, my current_period_id() is based on time, but it should be > constant along the query execution. I mean, I don't want some records > filtered with some values and other with other values... I'll have an > uncongruent recordset. Well - you didn't read the chapter I noticed you, did you? Look at function now(). It returns always the same value inside transaction. If your current_period_id() works the same way as now() then declare it as STABLE. Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Fri Feb 6 04:58:01 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id AB072D1B47D for ; Fri, 6 Feb 2004 08:57:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 99659-04 for ; Fri, 6 Feb 2004 04:57:37 -0400 (AST) Received: from victoria1.openweb.be (victoria1.openweb.be [212.3.244.180]) by svr1.postgresql.org (Postfix) with SMTP id B5287D1B911 for ; Fri, 6 Feb 2004 04:57:33 -0400 (AST) Received: (qmail 9227 invoked from network); 6 Feb 2004 08:57:15 -0000 Received: from unknown (HELO Morpheus) (217.145.35.101) by radius2.openweb.be with SMTP; 6 Feb 2004 08:57:15 -0000 From: "Bruno BAGUETTE" To: Subject: Increase performance of a UNION query that thakes 655.07 msec to be runned ? Date: Fri, 6 Feb 2004 09:58:44 +0100 Message-ID: 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.4024 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/87 X-Sequence-Number: 5611 Hello, Do you see a way to get better performances with this query which takes currently 655.07 msec to be done. levure=> explain analyze SELECT distinct lower(substr(l_name, 1, 1)) AS initiale FROM people levure-> UNION levure-> SELECT distinct lower(substr(org_name, 1, 1)) AS initiale FROM organizations levure-> ORDER BY initiale; QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ ----------- Sort (cost=158.73..158.78 rows=20 width=43) (actual time=650.82..650.89 rows=39 loops=1) Sort Key: initiale -> Unique (cost=157.30..158.30 rows=20 width=43) (actual time=649.55..650.17 rows=39 loops=1) -> Sort (cost=157.30..157.80 rows=200 width=43) (actual time=649.55..649.67 rows=69 loops=1) Sort Key: initiale -> Append (cost=69.83..149.66 rows=200 width=43) (actual time=198.48..648.51 rows=69 loops=1) -> Subquery Scan "*SELECT* 1" (cost=69.83..74.83 rows=100 width=38) (actual time=198.48..230.62 rows=37 loops=1) -> Unique (cost=69.83..74.83 rows=100 width=38) (actual time=198.46..230.31 rows=37 loops=1) -> Sort (cost=69.83..72.33 rows=1000 width=38) (actual time=198.45..205.99 rows=4093 loops=1) Sort Key: lower(substr((l_name)::text, 1, 1)) -> Seq Scan on people (cost=0.00..20.00 rows=1000 width=38) (actual time=0.19..52.33 rows=4093 loops=1) -> Subquery Scan "*SELECT* 2" (cost=69.83..74.83 rows=100 width=43) (actual time=361.82..417.62 rows=32 loops=1) -> Unique (cost=69.83..74.83 rows=100 width=43) (actual time=361.79..417.33 rows=32 loops=1) -> Sort (cost=69.83..72.33 rows=1000 width=43) (actual time=361.79..374.81 rows=7074 loops=1) Sort Key: lower(substr((org_name)::text, 1, 1)) -> Seq Scan on organizations (cost=0.00..20.00 rows=1000 width=43) (actual time=0.23..95.47 rows=7074 loops=1) Total runtime: 655.07 msec (17 rows) I was thinking that a index on lower(substr(l_name, 1, 1)) and another index on lower(substr(org_name, 1, 1)) should gives better performances. When I've to create theses two indexes, it seems like this is not allowed : levure=> CREATE INDEX firstchar_lastname_idx ON people(lower(substr(l_name, 1, 1))); ERROR: parser: parse error at or near "(" at character 59 Do you have another idea to get better performances ? Thanks in advance :-) PS : Note that this database is VACUUMed twice per day (and sometimes more). ------------------------------------- Bruno BAGUETTE - pgsql-ml@baguette.net From pgsql-performance-owner@postgresql.org Fri Feb 6 06:44:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DCD84D1D528 for ; Fri, 6 Feb 2004 10:43:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 33378-10 for ; Fri, 6 Feb 2004 06:43:27 -0400 (AST) Received: from fuji.krosing.net (silmet.estpak.ee [194.126.97.78]) by svr1.postgresql.org (Postfix) with ESMTP id 80F8FD1D18D for ; Fri, 6 Feb 2004 06:43:18 -0400 (AST) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id i16AhGDJ002814; Fri, 6 Feb 2004 12:43:16 +0200 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id i16AhEOu002812; Fri, 6 Feb 2004 12:43:14 +0200 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: 7.3 vs 7.4 performance From: Hannu Krosing To: Orion Henry Cc: pgsql-performance@postgresql.org In-Reply-To: <1075958197.2438.330.camel@orthanc> References: <1075958197.2438.330.camel@orthanc> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1076064194.2546.6.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 06 Feb 2004 12:43:14 +0200 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/88 X-Sequence-Number: 5612 Orion Henry kirjutas N, 05.02.2004 kell 07:16: > I've done some testing of 7.3.4 vs 7.4.1 and found 7.4.1 to be 20%-30% > slower than 7.3.4. Is this common knowledge or am I just unlucky with > my query/data selection? > > Things of note that might matter: the machine is a dual Opteron 1.4GHz > running Fedora Core 1 Test 1 for X86_64. The 7.3.4 was from the Fedora > distro and the 7.4.1 was the PGDG package. Are you sure that it is not the case that it is not tha case that 7.3.4 is 64 bit and the PGDG package is 32 ? > The database is 3.5 Gigs with 10 millions rows and the machine had 1 Gig or ram. > > Oh... as a side note I'm happy to announce that the 2.6 Linux kernel has > more than DOUBLED the speed of all my Postgres queries over the 2.4. =) Is this on this same hardware ? ------------- Hannu From pgsql-performance-owner@postgresql.org Fri Feb 6 06:45:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B65DED1CACC for ; Fri, 6 Feb 2004 10:45:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 35093-07 for ; Fri, 6 Feb 2004 06:45:03 -0400 (AST) Received: from fuji.krosing.net (silmet.estpak.ee [194.126.97.78]) by svr1.postgresql.org (Postfix) with ESMTP id 2480BD1D269 for ; Fri, 6 Feb 2004 06:45:00 -0400 (AST) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id i16Aj0DJ002820; Fri, 6 Feb 2004 12:45:00 +0200 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id i16AixuG002818; Fri, 6 Feb 2004 12:44:59 +0200 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: 7.3 vs 7.4 performance From: Hannu Krosing To: Christopher Browne Cc: pgsql-performance@postgresql.org In-Reply-To: References: <1075958197.2438.330.camel@orthanc> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1076064299.2546.9.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 06 Feb 2004 12:44:59 +0200 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/89 X-Sequence-Number: 5613 Christopher Browne kirjutas N, 05.02.2004 kell 07:32: > Oops! orion@trustcommerce.com (Orion Henry) was seen spray-painting on a wall: > > Oh... as a side note I'm happy to announce that the 2.6 Linux kernel > > has more than DOUBLED the speed of all my Postgres queries over the > > 2.4. =) > > I did some heavy-transaction-oriented tests recently on somewhat > heftier quad-Xeon hardware, and found little difference between 2.4 > and 2.6, and a small-but-quite-repeatable advantage with FreeBSD 4.9. > Now, I'm quite sure my load was rather different from yours, but I > find the claim of doubling of speed rather surprising. perhaps you were just IO-bound while he was not ? or starving on some locks ? ------------- Hannu From pgsql-performance-owner@postgresql.org Fri Feb 6 10:55:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5786ED1CA90 for ; Fri, 6 Feb 2004 14:55:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 30542-06 for ; Fri, 6 Feb 2004 10:55:34 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 1AB15D1C7F7 for ; Fri, 6 Feb 2004 10:55:30 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i16EtSel029561; Fri, 6 Feb 2004 09:55:28 -0500 (EST) To: Richard Huxton Cc: alvarezp@alvarezp.ods.org, pgsql-performance@postgresql.org Subject: Re: Seq scan on zero-parameters function In-reply-to: <200402060850.50818.dev@archonet.com> References: <4207.192.168.0.64.1076051944.squirrel@alvarezp.ods.org> <200402060850.50818.dev@archonet.com> Comments: In-reply-to Richard Huxton message dated "Fri, 06 Feb 2004 08:50:50 +0000" Date: Fri, 06 Feb 2004 09:55:28 -0500 Message-ID: <29560.1076079328@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/90 X-Sequence-Number: 5614 Richard Huxton writes: > It's not entirely clear to me why this form is different from the other form > though. The code that checks for expressions containing unstable functions doesn't look inside sub-selects. Arguably this is a bug, but people were relying on that behavior way back before we had these nice STABLE/IMMUTABLE tags for functions. I'm hesitant to change it for fear of breaking people's apps. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Feb 6 11:29:47 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A929BD1D3A4 for ; Fri, 6 Feb 2004 15:28:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 38691-10 for ; Fri, 6 Feb 2004 11:28:26 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 37F30D1CA65 for ; Fri, 6 Feb 2004 11:28:22 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i16FSOJv029925; Fri, 6 Feb 2004 10:28:24 -0500 (EST) To: "Bruno BAGUETTE" Cc: pgsql-performance@postgresql.org Subject: Re: Increase performance of a UNION query that thakes 655.07 msec to be runned ? In-reply-to: References: Comments: In-reply-to "Bruno BAGUETTE" message dated "Fri, 06 Feb 2004 09:58:44 +0100" Date: Fri, 06 Feb 2004 10:28:24 -0500 Message-ID: <29924.1076081304@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/91 X-Sequence-Number: 5615 "Bruno BAGUETTE" writes: > Do you see a way to get better performances with this query which takes > currently 655.07 msec to be done. > levure=> explain analyze SELECT distinct lower(substr(l_name, 1, 1)) AS > initiale FROM people > levure-> UNION > levure-> SELECT distinct lower(substr(org_name, 1, 1)) AS initiale FROM > organizations > levure-> ORDER BY initiale; This is inherently a bit inefficient since the UNION implies a DISTINCT step, thus partially repeating the DISTINCT work done inside each SELECT. It would likely be a tad faster to drop the DISTINCTs from the subselects and rely on UNION to do the filtering. However, you're still gonna have a big SORT/UNIQUE step. As of PG 7.4 you could probably get a performance win by converting the thing to use GROUP BY instead of DISTINCT or UNION: select initiale from ( select lower(substr(l_name,1,1)) as initiale from people union all select lower(substr(org_name,1,1)) as initiale from organizations ) ss group by initiale order by initiale; This should use a HashAggregate to do the unique-ification. I think that will be faster than Sort/Unique. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Feb 6 11:52:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 17AA0D1D412 for ; Fri, 6 Feb 2004 15:52:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 53218-07 for ; Fri, 6 Feb 2004 11:52:40 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id EC437D1C7F7 for ; Fri, 6 Feb 2004 11:52:35 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id C93FD358A5; Fri, 6 Feb 2004 07:52:24 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id C7CC5352E6; Fri, 6 Feb 2004 07:52:24 -0800 (PST) Date: Fri, 6 Feb 2004 07:52:24 -0800 (PST) From: Stephan Szabo To: Bruno BAGUETTE Cc: pgsql-performance@postgresql.org Subject: Re: Increase performance of a UNION query that thakes In-Reply-To: Message-ID: <20040206074755.M86604@megazone.bigpanda.com> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/92 X-Sequence-Number: 5616 On Fri, 6 Feb 2004, Bruno BAGUETTE wrote: > I was thinking that a index on lower(substr(l_name, 1, 1)) and another > index on lower(substr(org_name, 1, 1)) should gives better performances. > When I've to create theses two indexes, it seems like this is not > allowed : > > levure=> CREATE INDEX firstchar_lastname_idx ON > people(lower(substr(l_name, 1, 1))); > ERROR: parser: parse error at or near "(" at character 59 In 7.4, I believe you would say on people((lower(substr(l_name,1,1)))) but I'm not sure that index would really help in practice. > Do you have another idea to get better performances ? In addition to what Tom said, the row estimates look suspiciously default. You mention vacuuming, but do you ever analyze the tables? Also, what do you have sort_mem set to? From pgsql-performance-owner@postgresql.org Fri Feb 6 12:35:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 69C90D1D342 for ; Fri, 6 Feb 2004 16:34:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 72284-07 for ; Fri, 6 Feb 2004 12:33:39 -0400 (AST) Received: from victoria1.openweb.be (victoria1.openweb.be [212.3.244.180]) by svr1.postgresql.org (Postfix) with SMTP id 62C23D1D26C for ; Fri, 6 Feb 2004 12:33:37 -0400 (AST) Received: (qmail 25557 invoked from network); 6 Feb 2004 16:33:18 -0000 Received: from unknown (HELO Morpheus) (217.145.35.101) by radius2.openweb.be with SMTP; 6 Feb 2004 16:33:18 -0000 From: "Bruno BAGUETTE" To: "'Tom Lane'" , "'Bruno BAGUETTE'" Cc: Subject: RE : Increase performance of a UNION query that thakes 655.07 msec to be runned ? Date: Fri, 6 Feb 2004 17:34:48 +0100 Message-ID: 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.4024 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <29924.1076081304@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/93 X-Sequence-Number: 5617 re-Hello, As suggested by Tom, I've removed the distinct and tried it's query : levure=> explain analyze select initiale from ( levure(> select lower(substr(l_name,1,1)) as initiale from people levure(> union all levure(> select lower(substr(org_name,1,1)) as initiale from organizations levure(> ) ss levure-> group by initiale order by initiale; QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ - Group (cost=1018.48..1074.32 rows=1117 width=17) (actual time=783.47..867.61 rows=39 loops=1) -> Sort (cost=1018.48..1046.40 rows=11167 width=17) (actual time=782.18..801.68 rows=11167 loops=1) Sort Key: initiale -> Subquery Scan ss (cost=0.00..267.67 rows=11167 width=17) (actual time=0.23..330.31 rows=11167 loops=1) -> Append (cost=0.00..267.67 rows=11167 width=17) (actual time=0.22..263.69 rows=11167 loops=1) -> Subquery Scan "*SELECT* 1" (cost=0.00..87.93 rows=4093 width=15) (actual time=0.22..79.51 rows=4093 loops=1) -> Seq Scan on people (cost=0.00..87.93 rows=4093 width=15) (actual time=0.20..53.82 rows=4093 loops=1) -> Subquery Scan "*SELECT* 2" (cost=0.00..179.74 rows=7074 width=17) (actual time=0.24..146.12 rows=7074 loops=1) -> Seq Scan on organizations (cost=0.00..179.74 rows=7074 width=17) (actual time=0.23..100.70 rows=7074 loops=1) Total runtime: 874.79 msec (10 rows) That seems to be 200 msec longer that my first query... Indeed, I've noticed something strange : now, if I rerun my initial query, I get worse runtime than this morning : levure=> EXPLAIN ANALYZE SELECT lower(substr(l_name, 1, 1)) AS initiale FROM people levure-> UNION levure-> SELECT lower(substr(org_name, 1, 1)) AS initiale FROM organizations levure-> ORDER BY initiale; QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ Sort (cost=1130.85..1133.64 rows=1117 width=17) (actual time=802.52..802.58 rows=39 loops=1) Sort Key: initiale -> Unique (cost=1018.48..1074.32 rows=1117 width=17) (actual time=712.04..801.83 rows=39 loops=1) -> Sort (cost=1018.48..1046.40 rows=11167 width=17) (actual time=712.03..732.63 rows=11167 loops=1) Sort Key: initiale -> Append (cost=0.00..267.67 rows=11167 width=17) (actual time=0.21..263.54 rows=11167 loops=1) -> Subquery Scan "*SELECT* 1" (cost=0.00..87.93 rows=4093 width=15) (actual time=0.20..80.47 rows=4093 loops=1) -> Seq Scan on people (cost=0.00..87.93 rows=4093 width=15) (actual time=0.19..54.14 rows=4093 loops=1) -> Subquery Scan "*SELECT* 2" (cost=0.00..179.74 rows=7074 width=17) (actual time=0.28..144.82 rows=7074 loops=1) -> Seq Scan on organizations (cost=0.00..179.74 rows=7074 width=17) (actual time=0.27..99.06 rows=7074 loops=1) Total runtime: 806.47 msec (11 rows) I don't understand why this runtime has changed because no data has been added/updated/deleted since several weeks (I'm working on a copy of the production database. And this copy is not accessible for the users). My PostgreSQL version is PostgreSQL 7.3.2, I have to ask to the administrator if it can be upgraded to 7.4 in the production server. Thanks in advance for your help. --------------------------------------- Bruno BAGUETTE - pgsql-ml@baguette.net From pgsql-performance-owner@postgresql.org Fri Feb 6 12:40:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 06608D1D31D for ; Fri, 6 Feb 2004 16:39:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 77685-04 for ; Fri, 6 Feb 2004 12:39:54 -0400 (AST) Received: from victoria1.openweb.be (victoria1.openweb.be [212.3.244.180]) by svr1.postgresql.org (Postfix) with SMTP id BCA63D1D26A for ; Fri, 6 Feb 2004 12:39:52 -0400 (AST) Received: (qmail 25729 invoked from network); 6 Feb 2004 16:39:51 -0000 Received: from unknown (HELO Morpheus) (217.145.35.101) by radius2.openweb.be with SMTP; 6 Feb 2004 16:39:51 -0000 From: "Bruno BAGUETTE" To: "'Stephan Szabo'" , "'Bruno BAGUETTE'" Cc: Subject: RE : Increase performance of a UNION query that thakes 655.07 msec to be runned ? Date: Fri, 6 Feb 2004 17:41:20 +0100 Message-ID: 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.4024 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <20040206074755.M86604@megazone.bigpanda.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/94 X-Sequence-Number: 5618 > In addition to what Tom said, the row estimates look > suspiciously default. You mention vacuuming, but do you ever > analyze the tables? I run VACUUM FULL ANALYZE with the postgres user on all the PostgreSQL databases on the server, twice a day, sometimes more. > Also, what do you have sort_mem set to? [root@levure data]# cat postgresql.conf | grep sort_mem sort_mem = 6144 # min 64, size in KB Do you think I should increase that value ? It's not so easy to do a good setup of that postgresql.conf file, is there any tool that suggests some values for that ? Thanks in advance for your tips :-) --------------------------------------- Bruno BAGUETTE - pgsql-ml@baguette.net From pgsql-performance-owner@postgresql.org Fri Feb 6 13:39:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 15F8FD1CCCC for ; Fri, 6 Feb 2004 17:06:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 88300-02 for ; Fri, 6 Feb 2004 13:06:47 -0400 (AST) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by svr1.postgresql.org (Postfix) with ESMTP id 3B275D1CAF6 for ; Fri, 6 Feb 2004 13:06:44 -0400 (AST) Received: from osdl.org (markw@ibm-b.pdx.osdl.net [172.20.1.51]) by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i16H5LN16010; Fri, 6 Feb 2004 09:05:22 -0800 Message-Id: <200402061705.i16H5LN16010@mail.osdl.org> Date: Fri, 6 Feb 2004 09:05:04 -0800 (PST) From: markw@osdl.org Subject: Re: 7.3 vs 7.4 performance To: csmanioto@uol.com.br Cc: cbbrowne@acm.org, pgsql-performance@postgresql.org In-Reply-To: <003c01c3ebd9$35c724e0$cf00a8c0@smanote> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/96 X-Sequence-Number: 5620 I have some results with our DBT-2 (OLTP) workload on various linux-2.6 filesystems, if you'll find that interesting: http://developer.osdl.org/markw/fs/dbt2_project_results.html I've found JFS to perform similarly to ext2. Reiserfs isn't far behind. XFS and ext3 fall off a bit. These results are also on a 4-way Xeon, with about 70 drives and a ~ 30GB database. Mark On 5 Feb, Carlos Eduardo Smanioto wrote: >> I did some heavy-transaction-oriented tests recently on somewhat >> heftier quad-Xeon hardware, and found little difference between 2.4 >> and 2.6, and a small-but-quite-repeatable advantage with FreeBSD 4.9. >> Now, I'm quite sure my load was rather different from yours, but I >> find the claim of doubling of speed rather surprising. >> -- > > What's the type of File System you used in the Linux? I am wanting to know > which is the operational system better for PostgreSQL: FreeBSD versus Linux > 2.6. > > Thanks. > > []'s > Carlos Eduardo Smanioto (Brazil) > > ----- Original Message ----- > From: "Christopher Browne" > To: > Sent: Thursday, February 05, 2004 3:32 AM > Subject: Re: [PERFORM] 7.3 vs 7.4 performance > > >> Oops! orion@trustcommerce.com (Orion Henry) was seen spray-painting on a > wall: >> > I've done some testing of 7.3.4 vs 7.4.1 and found 7.4.1 to be 20%-30% >> > slower than 7.3.4. Is this common knowledge or am I just unlucky with >> > my query/data selection? >> >> That seems unusual; the opposite seems more typical in view of there >> being some substantial improvements to the query optimizer. >> >> Have you tried doing EXPLAIN ANALYZE on the queries on both sides? >> There would doubtless be interest in figuring out what is breaking >> down... >> >> > Things of note that might matter: the machine is a dual Opteron >> > 1.4GHz running Fedora Core 1 Test 1 for X86_64. The 7.3.4 was from >> > the Fedora distro and the 7.4.1 was the PGDG package. The database >> > is 3.5 Gigs with 10 millions rows and the machine had 1 Gig or ram. >> > >> > Oh... as a side note I'm happy to announce that the 2.6 Linux kernel >> > has more than DOUBLED the speed of all my Postgres queries over the >> > 2.4. =) >> >> I did some heavy-transaction-oriented tests recently on somewhat >> heftier quad-Xeon hardware, and found little difference between 2.4 >> and 2.6, and a small-but-quite-repeatable advantage with FreeBSD 4.9. >> Now, I'm quite sure my load was rather different from yours, but I >> find the claim of doubling of speed rather surprising. >> -- >> (format nil "~S@~S" "aa454" "freenet.carleton.ca") >> http://www.ntlug.org/~cbbrowne/spiritual.html >> Failure is not an option. It comes bundled with your Microsoft product. >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 5: Have you checked our extensive FAQ? >> >> http://www.postgresql.org/docs/faqs/FAQ.html > > > ---------------------------(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 From pgsql-performance-owner@postgresql.org Fri Feb 6 13:16:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DB22FD1C98E for ; Fri, 6 Feb 2004 17:15:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 88406-09 for ; Fri, 6 Feb 2004 13:15:17 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id AEE77D1B51F for ; Fri, 6 Feb 2004 13:15:16 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 40128359B5; Fri, 6 Feb 2004 09:13:42 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 3E846359B4; Fri, 6 Feb 2004 09:13:42 -0800 (PST) Date: Fri, 6 Feb 2004 09:13:42 -0800 (PST) From: Stephan Szabo To: Bruno BAGUETTE Cc: pgsql-performance@postgresql.org Subject: Re: RE : Increase performance of a UNION query that thakes In-Reply-To: Message-ID: <20040206085014.N88075@megazone.bigpanda.com> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/95 X-Sequence-Number: 5619 On Fri, 6 Feb 2004, Bruno BAGUETTE wrote: > > In addition to what Tom said, the row estimates look > > suspiciously default. You mention vacuuming, but do you ever > > analyze the tables? > > I run VACUUM FULL ANALYZE with the postgres user on all the PostgreSQL > databases on the server, twice a day, sometimes more. Wierd, because you're getting 1000 estimated on both people and organizations. What does pg_class have to say about those two tables? > > Also, what do you have sort_mem set to? > > [root@levure data]# cat postgresql.conf | grep sort_mem > sort_mem = 6144 # min 64, size in KB > > Do you think I should increase that value ? Hmm, I'd expect that the sort would fit in that space in general. If you want to try different values, you can set sort_mem from psql rather than changing the configuration file. ---- On my machine the index does actually help, although I needed to lower random_page_cost a little from its default of 4 to get it to use it preferentially, but I'm also getting times about 1/3 of yours (and my machine is pretty poor) so I think I may not have data that matches yours very well. From pgsql-sql-owner@postgresql.org Fri Feb 6 14:06:27 2004 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C47D9D1C9DB for ; Fri, 6 Feb 2004 17:24:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 93710-09 for ; Fri, 6 Feb 2004 13:24:43 -0400 (AST) Received: from alvarezp.ods.org (unknown [200.77.201.28]) by svr1.postgresql.org (Postfix) with ESMTP id 0045BD1CACB for ; Fri, 6 Feb 2004 13:24:40 -0400 (AST) Received: (from apache@localhost) by alvarezp.ods.org (8.11.6/8.11.6) id i16HOrR14772; Fri, 6 Feb 2004 09:24:53 -0800 X-Authentication-Warning: alvarezp.ods.org: apache set sender to alvarezp@alvarezp.ods.org using -f Received: from 192.168.0.64 (SquirrelMail authenticated user alvarezp) by alvarezp.ods.org with HTTP; Fri, 6 Feb 2004 09:24:52 -0800 (PST) Message-ID: <3080.192.168.0.64.1076088292.squirrel@alvarezp.ods.org> In-Reply-To: <4023567E.1020406@klaster.net> References: <4207.192.168.0.64.1076051944.squirrel@alvarezp.ods.org> <40234207.6040207@klaster.net> <4795.192.168.0.64.1076056992.squirrel@alvarezp.ods.org> <4023567E.1020406@klaster.net> Date: Fri, 6 Feb 2004 09:24:52 -0800 (PST) Subject: Re: [PERFORM] Seq scan on zero-parameters function From: "Octavio Alvarez" To: "Tomasz Myrta" Cc: "Lista dyskusyjna pgsql-sql" Reply-To: alvarezp@alvarezp.ods.org User-Agent: SquirrelMail/1.4.0-1.7.x MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/68 X-Sequence-Number: 16759 Tomasz Myrta said: > Dnia 2004-02-06 09:43, U�ytkownik Octavio Alvarez napisa�: >> Thanks for the hint. >> >> In fact, my current_period_id() is based on time, but it should be >> constant along the query execution. I mean, I don't want some records >> filtered with some values and other with other values... I'll have an >> uncongruent recordset. > > Well - you didn't read the chapter I noticed you, did you? Huummm.. No... :-$ But now I did. Although the chapter makes it look as "how will the optimizer think the function behaves", not "how the function actually behaves". But thanks. It's a lot clearer now. I assume that if I want to make "timeofday" have a stable-behavior, I must enclose it in a sub-query. Am I right? -- Octavio Alvarez. E-mail: alvarezp@alvarezp.ods.org. Agradezco que sus correos sean enviados siempre a esta direcci�n. From pgsql-performance-owner@postgresql.org Fri Feb 6 17:36:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 58E94D1DB20 for ; Fri, 6 Feb 2004 21:36:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 14242-08 for ; Fri, 6 Feb 2004 17:36:04 -0400 (AST) Received: from iceberg.ics911.net (h-66-167-103-228.CHCGILGM.covad.net [66.167.103.228]) by svr1.postgresql.org (Postfix) with ESMTP id 4D639D1DAD1 for ; Fri, 6 Feb 2004 17:36:01 -0400 (AST) Received: from FS.Denninger.Net (ip68-1-64-244.pn.at.cox.net [68.1.64.244]) by iceberg.ics911.net (8.12.2/8.11.6) with ESMTP id i16La27b055769 for ; Fri, 6 Feb 2004 15:36:03 -0600 (CST) (envelope-from karl@FS.Denninger.Net) Received: from FS.Denninger.Net (localhost [127.0.0.1]) by FS.Denninger.Net (8.12.10/8.12.8) with ESMTP id i16La2D6004966; Fri, 6 Feb 2004 15:36:02 -0600 (CST) (envelope-from karl@FS.Denninger.Net) Received: (from karl@localhost) by FS.Denninger.Net (8.12.10/8.12.8/Submit) id i16La2nB004965; Fri, 6 Feb 2004 15:36:02 -0600 (CST) Message-ID: <20040206153602.B4910@Denninger.Net> Date: Fri, 6 Feb 2004 15:36:02 -0600 From: Karl Denninger To: pgsql-performance@postgresql.org Subject: Why is query selecting sequential? Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.93.2i Organization: Karl's Sushi and Packet Smashers X-Die-Spammers: Spammers cheerfully broiled for supper and served with ketchup! X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/100 X-Sequence-Number: 5624 I have two tables which have related selection data; they get updated separately. One contains messages, the second an "index key" for each user's viewing history. When I attempt to use a select that merges the two to produce a "true or false" output in one of the reply rows, I get a sequential scan of the second table - which is NOT what I want! Here are the table definitions and query explain results... akcs=> \d post Table "public.post" Column | Type | Modifiers -----------+-----------------------------+----------------------------------------------------------- forum | text | number | integer | toppost | integer | views | integer | default 0 login | text | subject | text | message | text | inserted | timestamp without time zone | modified | timestamp without time zone | who | text | reason | text | ordinal | integer | not null default nextval('public.post_ordinal_seq'::text) replies | integer | default 0 ip | text | invisible | integer | sticky | integer | lock | integer | pinned | integer | default 0 replied | timestamp without time zone | Indexes: "post_forum" btree (forum) "post_lookup" btree (forum, number) "post_order" btree (number, inserted) "post_toppost" btree (forum, toppost, inserted) akcs=> \d forumlog; Table "public.forumlog" Column | Type | Modifiers ----------+-----------------------------+----------- login | text | forum | text | lastview | timestamp without time zone | number | integer | Indexes: "forumlog_composite" btree (login, forum, number) "forumlog_login" btree (login) "forumlog_number" btree (number) akcs=> explain select forum, (replied > (select lastview from forumlog where forumlog.login='%s' and forumlog.forum='%s' and number=post.number)) as newflag, * from post where forum = '%s' and toppost = 1 order by pinned desc, replied desc; QUERY PLAN ------------------------------------------------------------------------------------------- Sort (cost=3.20..3.21 rows=1 width=218) Sort Key: pinned, replied -> Index Scan using post_forum on post (cost=0.00..3.19 rows=1 width=218) Index Cond: (forum = '%s'::text) Filter: (toppost = 1) SubPlan -> Seq Scan on forumlog (cost=0.00..1.18 rows=1 width=8) Filter: ((login = '%s'::text) AND (forum = '%s'::text) AND (number = $0)) (8 rows) Why is the subplan using a sequential scan? At minimum the index on the post number ("forumlog_number") should be used, no? What would be even better would be a set of indices that allow at least two (or even all three) of the keys in the inside SELECT to be used. What am I missing here? -- -- Karl Denninger (karl@denninger.net) Internet Consultant & Kids Rights Activist http://www.denninger.net Tired of spam at your company? LOOK HERE! http://childrens-justice.org Working for family and children's rights http://diversunion.org LOG IN AND GET YOUR TANK STICKERS TODAY! From pgsql-performance-owner@postgresql.org Fri Feb 6 17:52:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 44E40D1C9DB for ; Fri, 6 Feb 2004 21:52:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 19487-06 for ; Fri, 6 Feb 2004 17:52:34 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 81033D1C517 for ; Fri, 6 Feb 2004 17:52:32 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4383716; Fri, 06 Feb 2004 13:53:35 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Karl Denninger , pgsql-performance@postgresql.org Subject: Re: Why is query selecting sequential? Date: Fri, 6 Feb 2004 13:51:39 -0800 User-Agent: KMail/1.5.4 References: <20040206153602.B4910@Denninger.Net> In-Reply-To: <20040206153602.B4910@Denninger.Net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402061351.39084.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/101 X-Sequence-Number: 5625 Karl, > SubPlan > -> Seq Scan on forumlog (cost=0.00..1.18 rows=1 width=8) > Filter: ((login = '%s'::text) AND (forum = '%s'::text) AND (number = $0)) > Why is the subplan using a sequential scan? At minimum the index on the > post number ("forumlog_number") should be used, no? What would be even > better would be a set of indices that allow at least two (or even all three) > of the keys in the inside SELECT to be used. It's using a seq scan because you have only 1 row in the table. Don't bother testing performance before your database is populated. PostgreSQL doesn't just use an index because it's there; it uses and index because it's faster than not using one. If there is more than one row in the table, then: 1) run ANALYZE forumlog; 2) Send us the EXPLAIN ANALYZE, not just the explain for the query. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Feb 6 18:22:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4DB28D1B456 for ; Fri, 6 Feb 2004 22:22:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 30481-04 for ; Fri, 6 Feb 2004 18:22:37 -0400 (AST) Received: from iceberg.ics911.net (h-66-167-103-228.CHCGILGM.covad.net [66.167.103.228]) by svr1.postgresql.org (Postfix) with ESMTP id 17224D1DAA9 for ; Fri, 6 Feb 2004 18:22:34 -0400 (AST) Received: from FS.Denninger.Net (ip68-1-64-244.pn.at.cox.net [68.1.64.244]) by iceberg.ics911.net (8.12.2/8.11.6) with ESMTP id i16MMX7b055881; Fri, 6 Feb 2004 16:22:33 -0600 (CST) (envelope-from karl@FS.Denninger.Net) Received: from FS.Denninger.Net (localhost [127.0.0.1]) by FS.Denninger.Net (8.12.10/8.12.8) with ESMTP id i16MMWD6005288; Fri, 6 Feb 2004 16:22:32 -0600 (CST) (envelope-from karl@FS.Denninger.Net) Received: (from karl@localhost) by FS.Denninger.Net (8.12.10/8.12.8/Submit) id i16MMW0h005287; Fri, 6 Feb 2004 16:22:32 -0600 (CST) Message-ID: <20040206162232.D4910@Denninger.Net> Date: Fri, 6 Feb 2004 16:22:32 -0600 From: Karl Denninger To: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: Why is query selecting sequential? References: <20040206153602.B4910@Denninger.Net> <200402061351.39084.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.93.2i In-Reply-To: <200402061351.39084.josh@agliodbs.com>; from Josh Berkus on Fri, Feb 06, 2004 at 01:51:39PM -0800 Organization: Karl's Sushi and Packet Smashers X-Die-Spammers: Spammers cheerfully broiled for supper and served with ketchup! X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/102 X-Sequence-Number: 5626 On Fri, Feb 06, 2004 at 01:51:39PM -0800, Josh Berkus wrote: > Karl, > > > SubPlan > > -> Seq Scan on forumlog (cost=0.00..1.18 rows=1 width=8) > > Filter: ((login = '%s'::text) AND (forum = '%s'::text) AND > (number = $0)) > > > Why is the subplan using a sequential scan? At minimum the index on the > > post number ("forumlog_number") should be used, no? What would be even > > better would be a set of indices that allow at least two (or even all three) > > of the keys in the inside SELECT to be used. > > It's using a seq scan because you have only 1 row in the table. Don't > bother testing performance before your database is populated. > > PostgreSQL doesn't just use an index because it's there; it uses and index > because it's faster than not using one. > > If there is more than one row in the table, then: > 1) run ANALYZE forumlog; > 2) Send us the EXPLAIN ANALYZE, not just the explain for the query. Hmmm... there is more than one row in the table. :-) There aren't a huge number, but there are a few. I know about the optimizer not using indices if there are no (or only one) row in the table - not making that mistake here. Ran analyze forumlog; Same results. Here's an explain analyze with actual values (that DO match real values in the table) filled in. akcs=> explain analyze select forum, (replied > (select lastview from forumlog where forumlog.login='genesis' and forumlog.forum='General' and number=post.number)) as newflag, * from post where forum = 'General' and toppost = 1 order by pinned desc, replied desc; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------- Sort (cost=28.41..28.42 rows=6 width=218) (actual time=0.677..0.698 rows=5 loops=1) Sort Key: pinned, replied -> Index Scan using post_toppost on post (cost=0.00..28.33 rows=6 width=218) (actual time=0.403..0.606 rows=5 loops=1) Index Cond: ((forum = 'General'::text) AND (toppost = 1)) SubPlan -> Seq Scan on forumlog (cost=0.00..1.18 rows=1 width=8) (actual time=0.015..0.027 rows=1 loops=5) Filter: ((login = 'genesis'::text) AND (forum = 'General'::text) AND (number = $0)) Total runtime: 0.915 ms (8 rows) -- -- Karl Denninger (karl@denninger.net) Internet Consultant & Kids Rights Activist http://www.denninger.net Tired of spam at your company? LOOK HERE! http://childrens-justice.org Working for family and children's rights http://diversunion.org LOG IN AND GET YOUR TANK STICKERS TODAY! From pgsql-performance-owner@postgresql.org Fri Feb 6 18:37:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9F3F5D1CACC for ; Fri, 6 Feb 2004 22:37:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 33912-06 for ; Fri, 6 Feb 2004 18:37:51 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 11381D1B45B for ; Fri, 6 Feb 2004 18:37:49 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4383941; Fri, 06 Feb 2004 14:38:54 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Karl Denninger , pgsql-performance@postgresql.org Subject: Re: Why is query selecting sequential? Date: Fri, 6 Feb 2004 14:36:57 -0800 User-Agent: KMail/1.5.4 References: <20040206153602.B4910@Denninger.Net> <200402061351.39084.josh@agliodbs.com> <20040206162232.D4910@Denninger.Net> In-Reply-To: <20040206162232.D4910@Denninger.Net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402061436.57903.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/103 X-Sequence-Number: 5627 Karl, Well, still with only 5 rows in the forumlog table you're not going get realistic results compared to a loaded database. However, you are making things difficult for the parser with awkward query syntax; what you currently have encourages a sequential loop. If there are potentially several rows in forumlog for each row in post, then your query won't work either. > akcs=> explain analyze select forum, (replied > (select lastview from forumlog where forumlog.login='genesis' and forumlog.forum='General' and number=post.number)) as newflag, * from post where forum = 'General' and toppost = 1 order by pinned desc, replied desc; Instead: if only one row in forumlog per row in post: SELECT (replied > lastview) AS newflag, post.* FROM post, forumlog WHERE post.forum = 'General' and toppost = 1 and forumlog.login = 'genesis' and forumlog.forum='General' and forumlog.number=post.number; -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Feb 6 21:02:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B585BD1CCCC for ; Sat, 7 Feb 2004 01:02:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 75451-03 for ; Fri, 6 Feb 2004 21:02:19 -0400 (AST) Received: from front3.mail.megapathdsl.net (front3.mail.megapathdsl.net [66.80.60.32]) by svr1.postgresql.org (Postfix) with ESMTP id CCBECD1CA67 for ; Fri, 6 Feb 2004 21:02:14 -0400 (AST) Received: from [64.32.131.193] (HELO [192.168.1.11]) by front3.mail.megapathdsl.net (CommuniGate Pro SMTP 4.1.3) with ESMTP id 125601182; Fri, 06 Feb 2004 17:02:16 -0800 Subject: Re: 7.3 vs 7.4 performance From: Orion Henry To: Hannu Krosing Cc: pgsql-performance@postgresql.org In-Reply-To: <1076064194.2546.6.camel@fuji.krosing.net> References: <1075958197.2438.330.camel@orthanc> <1076064194.2546.6.camel@fuji.krosing.net> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-509eXqC/54em5njBok9b" Organization: Message-Id: <1076115730.3377.119.camel@orthanc> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 06 Feb 2004 17:02:10 -0800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/104 X-Sequence-Number: 5628 --=-509eXqC/54em5njBok9b Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, 2004-02-06 at 02:43, Hannu Krosing wrote: > Orion Henry kirjutas N, 05.02.2004 kell 07:16: > > I've done some testing of 7.3.4 vs 7.4.1 and found 7.4.1 to be 20%-30% > > slower than 7.3.4. Is this common knowledge or am I just unlucky with > > my query/data selection? > >=20 > > Things of note that might matter: the machine is a dual Opteron 1.4GHz > > running Fedora Core 1 Test 1 for X86_64. The 7.3.4 was from the Fedora > > distro and the 7.4.1 was the PGDG package. >=20 > Are you sure that it is not the case that it is not tha case that 7.3.4 > is 64 bit and the PGDG package is 32 ? Yes sure... I don't know if they were compiled with differing optimizations or compilers though... > > The database is 3.5 Gigs with 10 millions rows and the machine had 1 Gi= g or ram. > >=20 > > Oh... as a side note I'm happy to announce that the 2.6 Linux kernel has > > more than DOUBLED the speed of all my Postgres queries over the 2.4. = =3D) >=20 > Is this on this same hardware ? No. I havent gotten the 2.6 kernel working on the Opteron yet. The 2x spe= edup=20 was on a dual Athlon 2GHz. --=-509eXqC/54em5njBok9b Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQBAJDkS9IoQcq23xtARAqBJAJ9EQYm1SVy+FC96vq+B2MdRa0UswwCeKjT+ 2wIphftBjTCOr5JDXe/1JrA= =2Rq4 -----END PGP SIGNATURE----- --=-509eXqC/54em5njBok9b-- From pgsql-performance-owner@postgresql.org Fri Feb 6 21:03:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E004CD1D9E6 for ; Sat, 7 Feb 2004 01:03:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 71900-07 for ; Fri, 6 Feb 2004 21:03:34 -0400 (AST) Received: from front3.mail.megapathdsl.net (front3.mail.megapathdsl.net [66.80.60.32]) by svr1.postgresql.org (Postfix) with ESMTP id D1B4BD1D8AE for ; Fri, 6 Feb 2004 21:03:30 -0400 (AST) Received: from [64.32.131.193] (HELO [192.168.1.11]) by front3.mail.megapathdsl.net (CommuniGate Pro SMTP 4.1.3) with ESMTP id 125601327; Fri, 06 Feb 2004 17:03:33 -0800 Subject: Re: 7.3 vs 7.4 performance From: Orion Henry To: Hannu Krosing Cc: Christopher Browne , pgsql-performance@postgresql.org In-Reply-To: <1076064299.2546.9.camel@fuji.krosing.net> References: <1075958197.2438.330.camel@orthanc> <1076064299.2546.9.camel@fuji.krosing.net> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-FsiOBq/99i5gIC1gts9e" Organization: Message-Id: <1076115806.3377.122.camel@orthanc> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 06 Feb 2004 17:03:26 -0800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/105 X-Sequence-Number: 5629 --=-FsiOBq/99i5gIC1gts9e Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, 2004-02-06 at 02:44, Hannu Krosing wrote: > Christopher Browne kirjutas N, 05.02.2004 kell 07:32: > > Oops! orion@trustcommerce.com (Orion Henry) was seen spray-painting on = a wall: > > > Oh... as a side note I'm happy to announce that the 2.6 Linux kernel > > > has more than DOUBLED the speed of all my Postgres queries over the > > > 2.4. =3D) > >=20 > > I did some heavy-transaction-oriented tests recently on somewhat > > heftier quad-Xeon hardware, and found little difference between 2.4 > > and 2.6, and a small-but-quite-repeatable advantage with FreeBSD 4.9. > > Now, I'm quite sure my load was rather different from yours, but I > > find the claim of doubling of speed rather surprising. >=20 > perhaps you were just IO-bound while he was not ? >=20 > or starving on some locks ? The queries were across almost 4 gigs of data on a machine with 512 MB of r= am. I personally was assuming it was the anticipatory disk scheduler... but ala= s I=20 don't know why it affected me so much. --=-FsiOBq/99i5gIC1gts9e Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQBAJDle9IoQcq23xtARAtXAAJ9WQPOyJYDd+jVYeOzpAjewiRYtPACfZW7M IfuGj1u0dWda1MWGfhMyRwM= =dRe5 -----END PGP SIGNATURE----- --=-FsiOBq/99i5gIC1gts9e-- From pgsql-performance-owner@postgresql.org Fri Feb 6 21:49:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 81699D1D30E for ; Sat, 7 Feb 2004 01:49:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 84229-09 for ; Fri, 6 Feb 2004 21:49:19 -0400 (AST) Received: from front1.mail.megapathdsl.net (front1.mail.megapathdsl.net [66.80.60.31]) by svr1.postgresql.org (Postfix) with ESMTP id 33C7BD1D2AD for ; Fri, 6 Feb 2004 21:49:15 -0400 (AST) Received: from [64.32.131.193] (HELO [192.168.1.11]) by front1.mail.megapathdsl.net (CommuniGate Pro SMTP 4.1.3) with ESMTP id 144553296; Fri, 06 Feb 2004 17:49:09 -0800 Subject: Re: 7.3 vs 7.4 performance From: Orion Henry To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org In-Reply-To: <200402042127.59134.josh@agliodbs.com> References: <1075958197.2438.330.camel@orthanc> <200402042127.59134.josh@agliodbs.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-atji1b62IFzCT1nJfa2W" Organization: Message-Id: <1076118545.3377.164.camel@orthanc> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 06 Feb 2004 17:49:05 -0800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/106 X-Sequence-Number: 5630 --=-atji1b62IFzCT1nJfa2W Content-Type: multipart/alternative; boundary="=-aPwhXs4ml9ImxRnprlHw" --=-aPwhXs4ml9ImxRnprlHw Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2004-02-04 at 21:27, Josh Berkus wrote: > Orion, >=20 > > I've done some testing of 7.3.4 vs 7.4.1 and found 7.4.1 to be 20%-30% > > slower than 7.3.4. Is this common knowledge or am I just unlucky with > > my query/data selection? >=20 > No, it's not common knowledge. It should be the other way around. Perh= aps=20 > it's the queries you picked? Even so ..... feel free to post individua= l=20 > EXPLAIN ANALYZEs to the list. Thank you... Here's one good example of 7.3 beating 7.4 soundly: Again this could me some compile option since I built the 7.4 RPM=20 from source and I got the 7.3 from Fedora or something to do with the Opteron architecture. (Yes the compiled postgres is 64 bit) SELECT cid,media_name,media_type,count(*) as count,sum(a_amount)=20 as a,sum(case when b_amount > 0 then b_amount else 0 end) as b, sum(case when b_amount < 0 then b_amount else 0 end) as c=20 FROM transdata JOIN media_info ON (media =3D media_type)=20 WHERE cid =3D 140100 AND demo is not null=20 AND trans_date between date '2004-01-01'=20 AND date_trunc('month',date '2004-01-01' + interval '32 days')=20 GROUP BY cid,media_name,media_type; Here's 7.3's time and explain real 0m34.260s user 0m0.010s sys 0m0.000s --------------------------------------------------------------- Aggregate (cost=3D7411.88..7415.32 rows=3D17 width=3D25) -> Group (cost=3D7411.88..7413.60 rows=3D172 width=3D25) -> Sort (cost=3D7411.88..7412.31 rows=3D172 width=3D25) Sort Key: transdata.cid, media_info.media_name, transdata.me= dia_type -> Hash Join (cost=3D1.22..7405.50 rows=3D172 width=3D25) Hash Cond: ("outer".media_type =3D "inner".media) -> Index Scan using transdata_date_index on transdata= (cost=3D0.00..7401.27 rows=3D172 width=3D14) Index Cond: ((trans_date >=3D ('2004-01-01'::dat= e)::timestamp with time zone) AND (trans_date <=3D ('2004-02-01 00:00:00'::= timestamp without time zone)::timestamp with time zone)) Filter: ((cid =3D 140100) AND (demo IS NOT NULL)) -> Hash (cost=3D1.18..1.18 rows=3D18 width=3D11) -> Seq Scan on media_info (cost=3D0.00..1.18 r= ows=3D18 width=3D11) Here's 7.4's time and explain real 0m43.052s user 0m0.000s sys 0m0.020s = QUERY PLAN ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ----------------------------------------- HashAggregate (cost=3D8098.26..8098.29 rows=3D2 width=3D23) -> Hash Join (cost=3D1.22..8095.48 rows=3D159 width=3D23) Hash Cond: ("outer".media_type =3D "inner".media) -> Index Scan using transdata_date_index on transdata (cost=3D0.= 00..8091.87 rows=3D159 width=3D14) Index Cond: ((trans_date >=3D ('2004-01-01'::date)::timestam= p with time zone) AND (trans_date <=3D ('2004-02-01 00:00:00'::timestamp wi= thout time zone)::timestamp with time zone)) Filter: ((cid =3D 140100) AND (demo IS NOT NULL)) -> Hash (cost=3D1.18..1.18 rows=3D18 width=3D11) -> Seq Scan on media_info (cost=3D0.00..1.18 rows=3D18 wid= th=3D11) --=-aPwhXs4ml9ImxRnprlHw Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, 2004-02-04 at 21:27, Josh Berkus wrote:
Orion,

> I've done some testing of 7.3.4 vs 7.4.1 and found 7.4.1 to be 20%-30%
> slower than 7.3.4.  Is this common knowledge or am I just unlucky with
> my query/data selection?

No, it's not common knowledge.  It should be the other way around.   Perhap=
s=20
it's the queries you picked?   Even so .....  feel free to post individual=
=20
EXPLAIN ANALYZEs to the list.

Thank you...

Here's one good example of 7.3 beating 7.4 soundly:
Again this could me some compile option since I built the 7.4 RPM=20
from source and I got the 7.3 from Fedora or something to
do with the Opteron architecture.  (Yes the compiled postgres
is 64 bit)

SELECT cid,media_name,media_type,count(*) as count,sum(a_amount)=20
as a,sum(case when b_amount > 0 then b_amount else 0 end) as b,
sum(case when b_amount < 0 then b_amount else 0 end) as c=20
FROM transdata JOIN media_info ON (media =3D media_type)=20
WHERE cid =3D 140100 AND demo is not null=20
AND trans_date between date '2004-01-01'=20
AND date_trunc('month',date '2004-01-01' + interval '32 days')=20
GROUP BY cid,media_name,media_type;

Here's 7.3's time and explain

real    0m34.260s
user    0m0.010s
sys     0m0.000s

---------------------------------------------------------------
 Aggregate  (cost=3D7411.88..7415.32 rows=3D17 width=3D25)
   ->  Group  (cost=3D7411.88..7413.60 rows=3D172 wi=
dth=3D25)
         ->  Sort  (co=
st=3D7411.88..7412.31 rows=3D172 width=3D25)
            &nb=
sp;  Sort Key: transdata.cid, media_info.media_name, transdata.media_t=
ype
            &nb=
sp;  ->  Hash Join  (cost=3D1.22..7405.50 rows=3D172 widt=
h=3D25)
            &nb=
sp;        Hash Cond: ("outer"=
.media_type =3D "inner".media)
            &nb=
sp;        ->  Index Scan using =
transdata_date_index on transdata  (cost=3D0.00..7401.27 rows=3D172 wi=
dth=3D14)
            &nb=
sp;            =
  Index Cond: ((trans_date >=3D ('2004-01-01'::date)::timestamp wit=
h time zone) AND (trans_date <=3D ('2004-02-01 00:00:00'::timestamp with=
out time zone)::timestamp with time zone))
            &nb=
sp;            =
  Filter: ((cid =3D 140100) AND (demo IS NOT NULL))
            &nb=
sp;        ->  Hash  (cost=
=3D1.18..1.18 rows=3D18 width=3D11)
            &nb=
sp;            =
  ->  Seq Scan on media_info  (cost=3D0.00..1.18 rows=3D1=
8 width=3D11)


Here's 7.4's time and explain

real    0m43.052s
user    0m0.000s
sys     0m0.020s

            &nb=
sp;            =
            &nb=
sp;            =
            &nb=
sp;            =
            &nb=
sp;  QUERY PLAN
---------------------------------------------------------------------------=
---------------------------------------------------------------------------=
-----------------------------------------
 HashAggregate  (cost=3D8098.26..8098.29 rows=3D2 width=3D23)
   ->  Hash Join  (cost=3D1.22..8095.48 rows=3D159 w=
idth=3D23)
         Hash Cond: ("outer&qu=
ot;.media_type =3D "inner".media)
         ->  Index Scan usi=
ng transdata_date_index on transdata  (cost=3D0.00..8091.87 rows=3D159=
 width=3D14)
            &nb=
sp;  Index Cond: ((trans_date >=3D ('2004-01-01'::date)::timestamp =
with time zone) AND (trans_date <=3D ('2004-02-01 00:00:00'::timestamp w=
ithout time zone)::timestamp with time zone))
            &nb=
sp;  Filter: ((cid =3D 140100) AND (demo IS NOT NULL))
         ->  Hash  (co=
st=3D1.18..1.18 rows=3D18 width=3D11)
            &nb=
sp;  ->  Seq Scan on media_info  (cost=3D0.00..1.18 rows=
=3D18 width=3D11)



--=-aPwhXs4ml9ImxRnprlHw-- --=-atji1b62IFzCT1nJfa2W Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQBAJEQR9IoQcq23xtARAuPiAKChkleDgV159Tw7weSKZTXOSWp8BgCfbtqb M59Z9FiGJIoDCdAZsYUYC+k= =/Pn/ -----END PGP SIGNATURE----- --=-atji1b62IFzCT1nJfa2W-- From pgsql-performance-owner@postgresql.org Fri Feb 6 21:53:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EC0DED1D29D for ; Sat, 7 Feb 2004 01:53:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 84069-10 for ; Fri, 6 Feb 2004 21:53:53 -0400 (AST) Received: from iceberg.ics911.net (h-66-167-103-228.CHCGILGM.covad.net [66.167.103.228]) by svr1.postgresql.org (Postfix) with ESMTP id 9ED0ED1D287 for ; Fri, 6 Feb 2004 21:53:48 -0400 (AST) Received: from FS.Denninger.Net (ip68-1-64-244.pn.at.cox.net [68.1.64.244]) by iceberg.ics911.net (8.12.2/8.11.6) with ESMTP id i171rn7b056320; Fri, 6 Feb 2004 19:53:49 -0600 (CST) (envelope-from karl@FS.Denninger.Net) Received: from FS.Denninger.Net (localhost [127.0.0.1]) by FS.Denninger.Net (8.12.10/8.12.8) with ESMTP id i171rmD6006528; Fri, 6 Feb 2004 19:53:48 -0600 (CST) (envelope-from karl@FS.Denninger.Net) Received: (from karl@localhost) by FS.Denninger.Net (8.12.10/8.12.8/Submit) id i171rmKg006527; Fri, 6 Feb 2004 19:53:48 -0600 (CST) Message-ID: <20040206195348.B6406@Denninger.Net> Date: Fri, 6 Feb 2004 19:53:48 -0600 From: Karl Denninger To: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: Why is query selecting sequential? References: <20040206153602.B4910@Denninger.Net> <200402061351.39084.josh@agliodbs.com> <20040206162232.D4910@Denninger.Net> <200402061436.57903.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.93.2i In-Reply-To: <200402061436.57903.josh@agliodbs.com>; from Josh Berkus on Fri, Feb 06, 2004 at 02:36:57PM -0800 Organization: Karl's Sushi and Packet Smashers X-Die-Spammers: Spammers cheerfully broiled for supper and served with ketchup! X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/107 X-Sequence-Number: 5631 On Fri, Feb 06, 2004 at 02:36:57PM -0800, Josh Berkus wrote: > Karl, > > Well, still with only 5 rows in the forumlog table you're not going get > realistic results compared to a loaded database. However, you are making > things difficult for the parser with awkward query syntax; what you currently > have encourages a sequential loop. > > If there are potentially several rows in forumlog for each row in post, then > your query won't work either. It better not. Indeed, I WANT it to blow up if there is, as that's a serious error, and am counting on that to happen (and yes, I know it will - and it should!) > > akcs=> explain analyze select forum, (replied > (select lastview from > forumlog where forumlog.login='genesis' and forumlog.forum='General' and > number=post.number)) as newflag, * from post where forum = 'General' and > toppost = 1 order by pinned desc, replied desc; > > Instead: > > if only one row in forumlog per row in post: > > SELECT (replied > lastview) AS newflag, post.* > FROM post, forumlog > WHERE post.forum = 'General' and toppost = 1 and forumlog.login = 'genesis' > and forumlog.forum='General' and forumlog.number=post.number; It still thinks its going to sequentially scan it... I'll see what happens when I get some more rows in the table and if it decides to start using the indices then.... akcs=> explain analyze select (replied > lastview) as newflag, post.* from post, forumlog where post.forum ='General' and toppost = 1 and forumlog.login='genesis' and forumlog.forum='General' order by post.pinned desc, post.replied desc; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------- Sort (cost=23.83..23.90 rows=30 width=226) (actual time=1.228..1.331 rows=25 loops=1) Sort Key: post.pinned, post.replied -> Nested Loop (cost=1.15..23.09 rows=30 width=226) (actual time=0.157..0.797 rows=25 loops=1) -> Index Scan using post_toppost on post (cost=0.00..21.27 rows=6 width=218) (actual time=0.059..0.089 rows=5 loops=1) Index Cond: ((forum = 'General'::text) AND (toppost = 1)) -> Materialize (cost=1.15..1.20 rows=5 width=8) (actual time=0.013..0.046 rows=5 loops=5) -> Seq Scan on forumlog (cost=0.00..1.15 rows=5 width=8) (actual time=0.027..0.065 rows=5 loops=1) Filter: ((login = 'genesis'::text) AND (forum = 'General'::text)) Total runtime: 1.754 ms (9 rows) -- -- Karl Denninger (karl@denninger.net) Internet Consultant & Kids Rights Activist http://www.denninger.net Tired of spam at your company? LOOK HERE! http://childrens-justice.org Working for family and children's rights http://diversunion.org LOG IN AND GET YOUR TANK STICKERS TODAY! From pgsql-performance-owner@postgresql.org Fri Feb 6 22:33:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 45B75D1B80B for ; Sat, 7 Feb 2004 02:33:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 95590-03 for ; Fri, 6 Feb 2004 22:33:46 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 7B221D1B4DE for ; Fri, 6 Feb 2004 22:33:42 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4386958; Fri, 06 Feb 2004 18:34:51 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Orion Henry Subject: Re: 7.3 vs 7.4 performance Date: Fri, 6 Feb 2004 18:32:53 -0800 User-Agent: KMail/1.5.4 Cc: pgsql-performance@postgresql.org References: <1075958197.2438.330.camel@orthanc> <200402042127.59134.josh@agliodbs.com> <1076118545.3377.164.camel@orthanc> In-Reply-To: <1076118545.3377.164.camel@orthanc> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402061832.53009.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/108 X-Sequence-Number: 5632 Orion, > Here's one good example of 7.3 beating 7.4 soundly: > Again this could me some compile option since I built the 7.4 RPM > from source and I got the 7.3 from Fedora or something to > do with the Opteron architecture. (Yes the compiled postgres > is 64 bit) Need an EXPLAIN ANALYZE, not just an EXPLAIN. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sat Feb 7 02:52:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 68C9BD1C98E for ; Sat, 7 Feb 2004 06:52:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 64268-09 for ; Sat, 7 Feb 2004 02:52:30 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 3F37FD1B911 for ; Sat, 7 Feb 2004 02:52:29 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i176psXI017426; Sat, 7 Feb 2004 01:51:55 -0500 (EST) To: Karl Denninger Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: Why is query selecting sequential? In-reply-to: <20040206162232.D4910@Denninger.Net> References: <20040206153602.B4910@Denninger.Net> <200402061351.39084.josh@agliodbs.com> <20040206162232.D4910@Denninger.Net> Comments: In-reply-to Karl Denninger message dated "Fri, 06 Feb 2004 16:22:32 -0600" Date: Sat, 07 Feb 2004 01:51:54 -0500 Message-ID: <17425.1076136714@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/109 X-Sequence-Number: 5633 Karl Denninger writes: > akcs=> explain analyze select forum, (replied > (select lastview from forumlog where forumlog.login='genesis' and forumlog.forum='General' and number=post.number)) as newflag, * from post where forum = 'General' and toppost = 1 order by pinned desc, replied desc; > QUERY PLAN > ---------------------------------------------------------------------------------------------------------------------------- > Sort (cost=28.41..28.42 rows=6 width=218) (actual time=0.677..0.698 rows=5 loops=1) > Sort Key: pinned, replied > -> Index Scan using post_toppost on post (cost=0.00..28.33 rows=6 width=218) (actual time=0.403..0.606 rows=5 loops=1) > Index Cond: ((forum = 'General'::text) AND (toppost = 1)) > SubPlan > -> Seq Scan on forumlog (cost=0.00..1.18 rows=1 width=8) (actual time=0.015..0.027 rows=1 loops=5) > Filter: ((login = 'genesis'::text) AND (forum = 'General'::text) AND (number = $0)) > Total runtime: 0.915 ms > (8 rows) As noted elsewhere, the inner subplan will not switch over to an indexscan until you get some more data in that table. Note however that the subplan is only accounting for about 0.13 msec (0.027*5) so it's not the major cost here anyway. The slow part seems to be the indexed fetch from "post", which is taking nearly 0.5 msec to fetch five rows. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Feb 7 03:28:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9B44ED1B49E for ; Sat, 7 Feb 2004 07:28:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 73370-04 for ; Sat, 7 Feb 2004 03:28:21 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id DC621D1D26A for ; Sat, 7 Feb 2004 03:28:19 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i177SHtc017838; Sat, 7 Feb 2004 02:28:17 -0500 (EST) To: josh@agliodbs.com Cc: Orion Henry , pgsql-performance@postgresql.org Subject: Re: 7.3 vs 7.4 performance In-reply-to: <200402061832.53009.josh@agliodbs.com> References: <1075958197.2438.330.camel@orthanc> <200402042127.59134.josh@agliodbs.com> <1076118545.3377.164.camel@orthanc> <200402061832.53009.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Fri, 06 Feb 2004 18:32:53 -0800" Date: Sat, 07 Feb 2004 02:28:17 -0500 Message-ID: <17837.1076138897@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/110 X-Sequence-Number: 5634 Josh Berkus writes: > Orion, >> Here's one good example of 7.3 beating 7.4 soundly: > Need an EXPLAIN ANALYZE, not just an EXPLAIN. Indeed. Also, please try 7.4 with enable_hashagg turned off to see what it does with a 7.3-style plan. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Feb 7 12:11:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9B7AAD1B49E for ; Sat, 7 Feb 2004 16:11:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 77207-10 for ; Sat, 7 Feb 2004 12:11:08 -0400 (AST) Received: from iceberg.ics911.net (h-66-167-103-228.CHCGILGM.covad.net [66.167.103.228]) by svr1.postgresql.org (Postfix) with ESMTP id A51EFD1B4DA for ; Sat, 7 Feb 2004 12:11:07 -0400 (AST) Received: from FS.Denninger.Net (ip68-1-64-244.pn.at.cox.net [68.1.64.244]) by iceberg.ics911.net (8.12.2/8.11.6) with ESMTP id i17GAr7b060400; Sat, 7 Feb 2004 10:10:59 -0600 (CST) (envelope-from karl@FS.Denninger.Net) Received: from FS.Denninger.Net (localhost [127.0.0.1]) by FS.Denninger.Net (8.12.10/8.12.8) with ESMTP id i17GArD6015068; Sat, 7 Feb 2004 10:10:53 -0600 (CST) (envelope-from karl@FS.Denninger.Net) Received: (from karl@localhost) by FS.Denninger.Net (8.12.10/8.12.8/Submit) id i17GAqxK015067; Sat, 7 Feb 2004 10:10:52 -0600 (CST) Message-ID: <20040207101052.A15045@Denninger.Net> Date: Sat, 7 Feb 2004 10:10:52 -0600 From: Karl Denninger To: Tom Lane Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: Why is query selecting sequential? References: <20040206153602.B4910@Denninger.Net> <200402061351.39084.josh@agliodbs.com> <20040206162232.D4910@Denninger.Net> <17425.1076136714@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.93.2i In-Reply-To: <17425.1076136714@sss.pgh.pa.us>; from Tom Lane on Sat, Feb 07, 2004 at 01:51:54AM -0500 Organization: Karl's Sushi and Packet Smashers X-Die-Spammers: Spammers cheerfully broiled for supper and served with ketchup! X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/111 X-Sequence-Number: 5635 On Sat, Feb 07, 2004 at 01:51:54AM -0500, Tom Lane wrote: > Karl Denninger writes: > > akcs=> explain analyze select forum, (replied > (select lastview from forumlog where forumlog.login='genesis' and forumlog.forum='General' and number=post.number)) as newflag, * from post where forum = 'General' and toppost = 1 order by pinned desc, replied desc; > > QUERY PLAN > > ---------------------------------------------------------------------------------------------------------------------------- > > Sort (cost=28.41..28.42 rows=6 width=218) (actual time=0.677..0.698 rows=5 loops=1) > > Sort Key: pinned, replied > > -> Index Scan using post_toppost on post (cost=0.00..28.33 rows=6 width=218) (actual time=0.403..0.606 rows=5 loops=1) > > Index Cond: ((forum = 'General'::text) AND (toppost = 1)) > > SubPlan > > -> Seq Scan on forumlog (cost=0.00..1.18 rows=1 width=8) (actual time=0.015..0.027 rows=1 loops=5) > > Filter: ((login = 'genesis'::text) AND (forum = 'General'::text) AND (number = $0)) > > Total runtime: 0.915 ms > > (8 rows) > > As noted elsewhere, the inner subplan will not switch over to an > indexscan until you get some more data in that table. Note however that > the subplan is only accounting for about 0.13 msec (0.027*5) so it's not > the major cost here anyway. The slow part seems to be the indexed fetch > from "post", which is taking nearly 0.5 msec to fetch five rows. > > regards, tom lane Ok... BTW, the other posted "cleaner" model doesn't work for me. If there is NO row in the subtable that matches, the other version returns nothing (which makes sense since the initial select fails to match any rows as one of the things its trying to match is missing.) I do need a return even if the log row is missing (and it WILL be, for a first visit to that particular item in the table by a particular user) -- -- Karl Denninger (karl@denninger.net) Internet Consultant & Kids Rights Activist http://www.denninger.net Tired of spam at your company? LOOK HERE! http://childrens-justice.org Working for family and children's rights http://diversunion.org LOG IN AND GET YOUR TANK STICKERS TODAY! From pgsql-performance-owner@postgresql.org Sat Feb 7 20:25:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id F31CCD1B4B7 for ; Sun, 8 Feb 2004 00:25:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 95525-01 for ; Sat, 7 Feb 2004 20:25:31 -0400 (AST) Received: from victoria1.openweb.be (victoria1.openweb.be [212.3.244.180]) by svr1.postgresql.org (Postfix) with SMTP id C3D09D1D642 for ; Sat, 7 Feb 2004 20:25:25 -0400 (AST) Received: (qmail 12517 invoked from network); 8 Feb 2004 00:25:12 -0000 Received: from unknown (HELO Morpheus) (217.145.35.101) by radius2.openweb.be with SMTP; 8 Feb 2004 00:25:12 -0000 From: "Bruno BAGUETTE" To: "'Stephan Szabo'" , "'Bruno BAGUETTE'" Cc: Subject: RE : RE : Increase performance of a UNION query that thakes 655.07 msec to be runned ? Date: Sun, 8 Feb 2004 01:26:40 +0100 Message-ID: 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.4024 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal In-Reply-To: <20040206085014.N88075@megazone.bigpanda.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/112 X-Sequence-Number: 5636 > On Fri, 6 Feb 2004, Bruno BAGUETTE wrote: > > > > In addition to what Tom said, the row estimates look suspiciously > > > default. You mention vacuuming, but do you ever analyze > > > the tables? > > > > I run VACUUM FULL ANALYZE with the postgres user on all the > > PostgreSQL > > databases on the server, twice a day, sometimes more. > > Wierd, because you're getting 1000 estimated on both people > and organizations. What does pg_class have to say about > those two tables? I'm sorry but I think that I misunderstand you. Are you telling me that running VACUUM FULL ANALYZE is weird ? Or do you mean another thing ? Finally, I've found another way : I've build a MATERIALIZED VIEW that stores the initial (CHAR(1) of both people and organizations, with an index on that column. I get excellent results : Unique (cost=0.00..290.34 rows=1117 width=5) (actual time=0.52..267.38 rows=39 loops=1) -> Index Scan using idx_mview_initials on mview_contacts (cost=0.00..262.42 rows=11167 width=5) (actual time=0.51..172.15 rows=11167 loops=1) Total runtime: 267.81 msec (3 rows) So, that's a better runtime :-) Thanks for your help :-) ------------------------------------- Bruno BAGUETTE - pgsql-ml@baguette.net From pgsql-performance-owner@postgresql.org Sun Feb 8 01:36:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 579BDD1CB1D for ; Sun, 8 Feb 2004 05:36:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 52065-04 for ; Sun, 8 Feb 2004 01:36:22 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 68808D1C98E for ; Sun, 8 Feb 2004 01:36:21 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id EC81035554; Sat, 7 Feb 2004 21:36:20 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id EB0E835337; Sat, 7 Feb 2004 21:36:20 -0800 (PST) Date: Sat, 7 Feb 2004 21:36:20 -0800 (PST) From: Stephan Szabo To: Bruno BAGUETTE Cc: pgsql-performance@postgresql.org Subject: Re: RE : RE : Increase performance of a UNION query that In-Reply-To: Message-ID: <20040207213513.A41594@megazone.bigpanda.com> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/113 X-Sequence-Number: 5637 On Sun, 8 Feb 2004, Bruno BAGUETTE wrote: > > On Fri, 6 Feb 2004, Bruno BAGUETTE wrote: > > > > > > In addition to what Tom said, the row estimates look suspiciously > > > > default. You mention vacuuming, but do you ever analyze > > > > the tables? > > > > > > I run VACUUM FULL ANALYZE with the postgres user on all the > > > PostgreSQL > > > databases on the server, twice a day, sometimes more. > > > > Wierd, because you're getting 1000 estimated on both people > > and organizations. What does pg_class have to say about > > those two tables? > > I'm sorry but I think that I misunderstand you. Are you telling me that > running VACUUM FULL ANALYZE is weird ? Or do you mean another thing ? No, I was saying it's wierd that it'd be misestimating to the default values after a vacuum full analyze. From pgsql-performance-owner@postgresql.org Mon Feb 9 01:35:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 38C34D1D55A for ; Mon, 9 Feb 2004 05:34:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 70687-07 for ; Mon, 9 Feb 2004 01:34:45 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 859EDD1D1C4 for ; Mon, 9 Feb 2004 01:34:38 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4396408; Sun, 08 Feb 2004 21:35:49 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Karl Denninger , Tom Lane Subject: Re: Why is query selecting sequential? Date: Sun, 8 Feb 2004 21:34:18 -0800 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org References: <20040206153602.B4910@Denninger.Net> <17425.1076136714@sss.pgh.pa.us> <20040207101052.A15045@Denninger.Net> In-Reply-To: <20040207101052.A15045@Denninger.Net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200402082134.18156.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/114 X-Sequence-Number: 5638 Karl, > BTW, the other posted "cleaner" model doesn't work for me. If there is NO > row in the subtable that matches, the other version returns nothing (which > makes sense since the initial select fails to match any rows as one of the > things its trying to match is missing.) Ah, wasn't thinking of that case. Problem with not really knowing what the database is about. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Feb 11 09:03:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4C2DFD1D643 for ; Wed, 11 Feb 2004 13:03:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 87947-10 for ; Wed, 11 Feb 2004 09:03:34 -0400 (AST) Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8161ED1DD71 for ; Wed, 11 Feb 2004 09:03:30 -0400 (AST) Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) id 1Aqu1P-0004FE-Cc for pgsql-performance@postgresql.org; Wed, 11 Feb 2004 14:03:19 +0100 Received: from [195.135.143.205] (helo=[195.135.143.205]) by emma.rox.net with asmtp (Exim 4.22) id 1Aqu1O-0004EF-D7 for pgsql-performance@postgresql.org; Wed, 11 Feb 2004 14:03:18 +0100 Mime-Version: 1.0 (Apple Message framework v612) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; format=flowed To: PgSQL Performance ML From: David Teran Subject: select count(*) from anIntColumn where int_value = 0; is very slow Date: Wed, 11 Feb 2004 14:03:15 +0100 X-Mailer: Apple Mail (2.612) X-Scanned-By: rockenstein AG X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/115 X-Sequence-Number: 5639 Hi we have a table with about 4 million rows. One column has an int value, there is a btree index on it. We tried to execute the following statement and it is very slow on a dual G5 2GHZ with 4 GB of RAM. explain analyze select count(*) from job_property where int_value = 0; Aggregate (cost=144348.80..144348.80 rows=1 width=0) (actual time=13536.852..13536.852 rows=1 loops=1) -> Seq Scan on job_property (cost=0.00..144255.15 rows=37459 width=0) (actual time=19.422..13511.653 rows=42115 loops=1) Filter: (int_value = 0) Total runtime: 13560.862 ms Is this more or less normal or can we optimize this a little bit? FrontBase (which we compare currently) takes 2 seconds first time and about 0.2 seconds on second+ queries. regards David From pgsql-performance-owner@postgresql.org Wed Feb 11 09:11:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id ABC49D1D643 for ; Wed, 11 Feb 2004 13:11:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 02307-01 for ; Wed, 11 Feb 2004 09:11:16 -0400 (AST) Received: from kix.fsv.cvut.cz (Kix.FSV.CVUT.CZ [147.32.129.84]) by svr1.postgresql.org (Postfix) with ESMTP id 03174D1DDA5 for ; Wed, 11 Feb 2004 09:11:12 -0400 (AST) Received: from localhost (stehule@localhost) by kix.fsv.cvut.cz (8.11.6/8.11.6) with ESMTP id i1BDBDN27168; Wed, 11 Feb 2004 14:11:13 +0100 Date: Wed, 11 Feb 2004 14:11:13 +0100 (CET) From: Pavel Stehule To: David Teran Cc: PgSQL Performance ML Subject: Re: select count(*) from anIntColumn where int_value = 0; In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/116 X-Sequence-Number: 5640 Hello, If you has index on id, then you can use SELECT id FROM tabulka ORDER BY id DESC LIMIT 1; See 4.8. FAQ Regards Pavel Stehule On Wed, 11 Feb 2004, David Teran wrote: > Hi > > we have a table with about 4 million rows. One column has an int value, > there is a btree index on it. We tried to execute the following > statement and it is very slow on a dual G5 2GHZ with 4 GB of RAM. > > explain analyze select count(*) from job_property where int_value = 0; > > Aggregate (cost=144348.80..144348.80 rows=1 width=0) (actual > time=13536.852..13536.852 rows=1 loops=1) > -> Seq Scan on job_property (cost=0.00..144255.15 rows=37459 > width=0) (actual time=19.422..13511.653 rows=42115 loops=1) > Filter: (int_value = 0) > Total runtime: 13560.862 ms > > > > Is this more or less normal or can we optimize this a little bit? > FrontBase (which we compare currently) takes 2 seconds first time and > about 0.2 seconds on second+ queries. > > regards David > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > From pgsql-performance-owner@postgresql.org Wed Feb 11 09:12:38 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C8D5AD1D1CD for ; Wed, 11 Feb 2004 13:12:28 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 02433-01 for ; Wed, 11 Feb 2004 09:12:14 -0400 (AST) Received: from linux.finestmedia.tv (linux.finestmedia.tv [213.180.31.12]) by svr1.postgresql.org (Postfix) with ESMTP id A4D42D1DD60 for ; Wed, 11 Feb 2004 09:12:10 -0400 (AST) Received: from rigmor (sms.finestmedia.tv [213.180.31.11]) by linux.finestmedia.tv (Postfix) with SMTP id EA17818E718; Wed, 11 Feb 2004 15:08:55 +0200 (EET) From: "Rigmor Ukuhe" To: "David Teran" , "PgSQL Performance ML" Subject: Re: select count(*) from anIntColumn where int_value = 0; is very slow Date: Wed, 11 Feb 2004 15:12:00 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/117 X-Sequence-Number: 5641 > > Hi > > we have a table with about 4 million rows. One column has an int value, > there is a btree index on it. We tried to execute the following > statement and it is very slow on a dual G5 2GHZ with 4 GB of RAM. > > explain analyze select count(*) from job_property where int_value = 0; > > Aggregate (cost=144348.80..144348.80 rows=1 width=0) (actual > time=13536.852..13536.852 rows=1 loops=1) > -> Seq Scan on job_property (cost=0.00..144255.15 rows=37459 > width=0) (actual time=19.422..13511.653 rows=42115 loops=1) > Filter: (int_value = 0) > Total runtime: 13560.862 ms Is your int_value data type int4? If not then use "... from job_property where int_value = '0'" Indexes are used only if datatypes matches. Rigmor Ukuhe > > > > Is this more or less normal or can we optimize this a little bit? > FrontBase (which we compare currently) takes 2 seconds first time and > about 0.2 seconds on second+ queries. > > regards David > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.564 / Virus Database: 356 - Release Date: 19.01.2004 From pgsql-performance-owner@postgresql.org Wed Feb 11 09:32:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0080BD1CE3E for ; Wed, 11 Feb 2004 13:32:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 05276-08 for ; Wed, 11 Feb 2004 09:32:09 -0400 (AST) Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7D84CD1DC77 for ; Wed, 11 Feb 2004 09:32:05 -0400 (AST) Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) id 1AquTJ-0007Xa-TO; Wed, 11 Feb 2004 14:32:09 +0100 Received: from [195.135.143.205] (helo=[195.135.143.205]) by emma.rox.net with asmtp (Exim 4.22) id 1AquTD-0007NP-GC; Wed, 11 Feb 2004 14:32:03 +0100 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: "PgSQL Performance ML" From: David Teran Subject: Re: select count(*) from anIntColumn where int_value = 0; is very slow Date: Wed, 11 Feb 2004 14:32:00 +0100 To: "Rigmor Ukuhe" X-Mailer: Apple Mail (2.612) X-Scanned-By: rockenstein AG X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/118 X-Sequence-Number: 5642 Hi, > Is your int_value data type int4? If not then use "... from > job_property > where int_value = '0'" > Indexes are used only if datatypes matches. > tried those variations already. Strange enough, after dropping and recreating the index everything worked fine. regards David From pgsql-performance-owner@postgresql.org Wed Feb 11 09:42:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4AD19D1DCEB for ; Wed, 11 Feb 2004 13:42:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 12962-05 for ; Wed, 11 Feb 2004 09:42:40 -0400 (AST) Received: from OMEGA.denver.ibsncentral.com (mail.ibsncentral.com [69.44.125.178]) by svr1.postgresql.org (Postfix) with ESMTP id 1F769D1DAA0 for ; Wed, 11 Feb 2004 09:42:36 -0400 (AST) Received: from [192.168.0.175] ([192.168.0.175]) by OMEGA.denver.ibsncentral.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 11 Feb 2004 06:42:20 -0700 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <1CC1B9FA-5C98-11D8-8191-000A95EA00C0@ibsncentral.com> Content-Transfer-Encoding: 7bit Cc: PgSQL Performance ML From: PC Drew Subject: Re: select count(*) from anIntColumn where int_value = 0; is very slow Date: Wed, 11 Feb 2004 06:42:19 -0700 To: David Teran X-Mailer: Apple Mail (2.612) X-OriginalArrivalTime: 11 Feb 2004 13:42:20.0830 (UTC) FILETIME=[DF4EEBE0:01C3F0A4] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/119 X-Sequence-Number: 5643 Had you done a VACUUM ANALYZE at all? There has been much discussion lately about the planner needing to be updated to know that the index is a better choice. On Feb 11, 2004, at 6:32 AM, David Teran wrote: > Hi, > >> Is your int_value data type int4? If not then use "... from >> job_property >> where int_value = '0'" >> Indexes are used only if datatypes matches. >> > tried those variations already. Strange enough, after dropping and > recreating the index everything worked fine. > > regards David > > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to > majordomo@postgresql.org > -- PC Drew Manager, Dominet IBSN 1600 Broadway, Suite 400 Denver, CO 80202 Phone: 303-984-4727 x107 Cell: 720-841-4543 Fax: 303-984-4730 Email: drewpc@ibsncentral.com From pgsql-performance-owner@postgresql.org Wed Feb 11 10:01:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2E5BFD1CACB for ; Wed, 11 Feb 2004 14:01:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 17517-07 for ; Wed, 11 Feb 2004 10:01:43 -0400 (AST) Received: from gate.rsb.ro (unknown [194.102.189.2]) by svr1.postgresql.org (Postfix) with ESMTP id 905AED1D8B7 for ; Wed, 11 Feb 2004 10:01:34 -0400 (AST) Received: from cec.ro (mail.cec.ro [194.102.189.5]) by gate.rsb.ro (STRONG Version/8.11.2) with ESMTP id i1BIQie32030 for ; Wed, 11 Feb 2004 19:26:44 +0100 Received: from [10.43.1.20] (account sbogdan HELO rsb.ro) by cec.ro (CommuniGate Pro SMTP 3.5.9) with ESMTP id 13294523 for pgsql-performance@postgresql.org; Wed, 11 Feb 2004 15:46:17 +0200 Message-ID: <402A3747.8000906@rsb.ro> Date: Wed, 11 Feb 2004 16:08:07 +0200 From: stefan bogdan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: update performance Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/120 X-Sequence-Number: 5644 hello i have postgres 7.3.2.,linux redhat 9.0 a database,and 20 tables a lot of fields are char(x) when i have to make update for all the fields except index postgres works verry hard what should i've changed in configuration to make it work faster thanks bogdan From pgsql-performance-owner@postgresql.org Wed Feb 11 10:46:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 58208D1CCBE for ; Wed, 11 Feb 2004 14:46:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 37662-05 for ; Wed, 11 Feb 2004 10:46:15 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 4191AD1B917 for ; Wed, 11 Feb 2004 10:46:11 -0400 (AST) 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 i1BEkA1a013723 for ; Wed, 11 Feb 2004 14:46:10 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i1BEKavf008798 for pgsql-performance@postgresql.org; Wed, 11 Feb 2004 14:20:36 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: select count(*) from anIntColumn where int_value = 0; Date: Wed, 11 Feb 2004 09:14:39 -0500 Organization: cbbrowne Computing Inc Lines: 61 Message-ID: References: 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 (Reasonable Discussion, linux) Cancel-Lock: sha1:DvWSndJxeakzIpJ+c4zUCBTUM2s= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/125 X-Sequence-Number: 5649 Oops! stehule@kix.fsv.cvut.cz (Pavel Stehule) was seen spray-painting on a wall: > > Regards > Pavel Stehule > > On Wed, 11 Feb 2004, David Teran wrote: > >> Hi >> >> we have a table with about 4 million rows. One column has an int value, >> there is a btree index on it. We tried to execute the following >> statement and it is very slow on a dual G5 2GHZ with 4 GB of RAM. >> >> explain analyze select count(*) from job_property where int_value = 0; >> >> Aggregate (cost=144348.80..144348.80 rows=1 width=0) (actual >> time=13536.852..13536.852 rows=1 loops=1) >> -> Seq Scan on job_property (cost=0.00..144255.15 rows=37459 >> width=0) (actual time=19.422..13511.653 rows=42115 loops=1) >> Filter: (int_value = 0) >> Total runtime: 13560.862 ms >> > If you has index on id, then you can use > SELECT id FROM tabulka ORDER BY id DESC LIMIT 1; > > See 4.8. FAQ I'm afraid that's not the answer. That would be the faster alternative to "select max(id) from tabulka;" I guess the question is, is there a faster way of coping with the "int_value = 0" part? It seems a little odd that the index was not selected; it appears that the count was 42115, right? The estimated number of rows was 37459, and if the table size is ~4M, then I would have expected the query optimizer to use the index. Could you try doing "ANALYZE JOB_PROPERTY;" and then try again? One thought that comes to mind is that perhaps the statistics are outdated. Another thought is that perhaps there are several really common values, and the statistics are crummy. You might relieve that by: alter table job_property alter column int_value set statistics 20; analyze job_property; (Or perhaps some higher value...) If there are a few very common discrete values in a particular field, then the default statistics may get skewed because the histogram hasn't enough bins... -- let name="cbbrowne" and tld="acm.org" in name ^ "@" ^ tld;; http://cbbrowne.com/info/wp.html Rules of the Evil Overlord #102. "I will not waste time making my enemy's death look like an accident -- I'm not accountable to anyone and my other enemies wouldn't believe it. From pgsql-performance-owner@postgresql.org Wed Feb 11 10:23:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BAFD2D1CCA8 for ; Wed, 11 Feb 2004 14:23:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 29499-04 for ; Wed, 11 Feb 2004 10:23:36 -0400 (AST) Received: from servidor5.servidorbr.net (unknown [69.57.128.78]) by svr1.postgresql.org (Postfix) with ESMTP id 66520D1CACD for ; Wed, 11 Feb 2004 10:23:27 -0400 (AST) Received: from cpanel by servidor5.servidorbr.net with local (Exim 4.24) id 1AqvH1-0004zh-KF for pgsql-performance@postgresql.org; Wed, 11 Feb 2004 12:23:31 -0200 Received: from 200.207.205.140 ([200.207.205.140]) by tiago.hazor.com.br (IMP) with HTTP for ; Wed, 11 Feb 2004 12:23:31 -0200 Message-ID: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> Date: Wed, 11 Feb 2004 12:23:31 -0200 From: alemon@tiago.hazor.com.br To: pgsql-performance@postgresql.org Subject: slow database MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 X-Originating-IP: 200.207.205.140 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - servidor5.servidorbr.net X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [32001 502] / [47 12] X-AntiAbuse: Sender Address Domain - tiago.hazor.com.br X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/121 X-Sequence-Number: 5645 my data base is very slow. The machine is a processor Xeon 2GB with 256 MB of RAM DDR. My archive of configuration is this: ================================================================ # # 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". #======================================================================== # # Connection Parameters # #tcpip_socket = false #ssl = false max_connections = 50 superuser_reserved_connections = 2 #port = 5432 #hostname_lookup = false #show_source_port = false #unix_socket_directory = '' #unix_socket_group = '' #unix_socket_permissions = 0777 # octal #virtual_host = '' #krb_server_keyfile = '' # # Shared Memory Size # shared_buffers = 5000 # min max_connections*2 or 16, 8KB each max_fsm_relations = 400 # min 10, fsm is free space map, ~40 bytes max_fsm_pages = 80000 # min 1000, fsm is free space map, ~6 bytes max_locks_per_transaction = 128 # min 10 wal_buffers = 4 # min 4, typically 8KB each # # Non-shared Memory Sizes # sort_mem = 131072 # min 64, size in KB #vacuum_mem = 8192 # min 1024, size in KB # # Write-ahead log (WAL) # checkpoint_segments = 3 # in logfile segments, min 1, 16MB each checkpoint_timeout = 300 # range 30-3600, in seconds # commit_delay = 0 # range 0-100000, in microseconds commit_siblings = 5 # range 1-1000 # fsync = false wal_sync_method = fdatasync # the default varies across platforms: # # fsync, fdatasync, open_sync, or open_datasync wal_debug = 0 # range 0-16 # # Optimizer Parameters # enable_seqscan = false enable_indexscan = false enable_tidscan = false enable_sort = false enable_nestloop = false enable_mergejoin = false enable_hashjoin = false effective_cache_size = 170000 # typically 8KB each random_page_cost = 1000000000 # units are one sequential page fetch cost cpu_tuple_cost = 0.3 # (same) cpu_index_tuple_cost = 0.6 # (same) cpu_operator_cost = 0.7 # (same) default_statistics_target = 1 # range 1-1000 # # GEQO Optimizer Parameters # geqo = true geqo_selection_bias = 2.0 # range 1.5-2.0 geqo_threshold = 2000 geqo_pool_size = 1024 # default based on tables in statement, # range 128-1024 geqo_effort = 1 geqo_generations = 0 geqo_random_seed = -1 # auto-compute seed # # Message display # server_min_messages = fatal # Values, in order of decreasing detail: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, log, fatal, # panic client_min_messages = fatal # Values, in order of decreasing detail: # debug5, debug4, debug3, debug2, debug1, # log, info, notice, warning, error silent_mode = false log_connections = false log_pid = false log_statement = false log_duration = false log_timestamp = false #log_min_error_statement = error # Values in order of increasing severity: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, panic(off) #debug_print_parse = false #debug_print_rewritten = false #debug_print_plan = false #debug_pretty_print = false #explain_pretty_print = true # requires USE_ASSERT_CHECKING #debug_assertions = true # # Syslog # #syslog = 0 # range 0-2 #syslog_facility = 'LOCAL0' #syslog_ident = 'postgres' # # Statistics # #show_parser_stats = false #show_planner_stats = false #show_executor_stats = false #show_statement_stats = false # requires BTREE_BUILD_STATS #show_btree_build_stats = false # # Access statistics collection # #stats_start_collector = true #stats_reset_on_server_start = true #stats_command_string = false #stats_row_level = false #stats_block_level = false # # Lock Tracing # #trace_notify = false # requires LOCK_DEBUG #trace_locks = false #trace_userlocks = false #trace_lwlocks = false #debug_deadlocks = false #trace_lock_oidmin = 16384 #trace_lock_table = 0 # # Misc # #autocommit = true #dynamic_library_path = '$libdir' #search_path = '$user,public' datestyle = 'iso, us' #timezone = unknown # actually, defaults to TZ environment setting #australian_timezones = false client_encoding = sql_ascii # actually, defaults to database encoding authentication_timeout = 1 # 1-600, in seconds deadlock_timeout = 100 # in milliseconds #default_transaction_isolation = 'read committed' #max_expr_depth = 1000 # min 10 #max_files_per_process = 1000 # min 25 #password_encryption = true #sql_inheritance = true #transform_null_equals = false #statement_timeout = 0 # 0 is disabled, in milliseconds db_user_namespace = false # # Locale settings # # (initialized by initdb -- may be changed) LC_MESSAGES = 'en_US' LC_MONETARY = 'en_US' LC_NUMERIC = 'en_US' LC_TIME = 'en_US' ================================================================ somebody please knows to give tips to me to increase the performance From pgsql-performance-owner@postgresql.org Wed Feb 11 10:27:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 25650D1CCA8 for ; Wed, 11 Feb 2004 14:27:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 33246-04 for ; Wed, 11 Feb 2004 10:27:15 -0400 (AST) Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) by svr1.postgresql.org (Postfix) with ESMTP id B3955D1B4D2 for ; Wed, 11 Feb 2004 10:27:10 -0400 (AST) Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) by zigo.dhs.org (Postfix) with ESMTP id B8F378E3A; Wed, 11 Feb 2004 15:27:09 +0100 (CET) Date: Wed, 11 Feb 2004 15:27:09 +0100 (CET) From: Dennis Bjorklund To: alemon@tiago.hazor.com.br Cc: pgsql-performance@postgresql.org Subject: Re: slow database In-Reply-To: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/122 X-Sequence-Number: 5646 On Wed, 11 Feb 2004 alemon@tiago.hazor.com.br wrote: > somebody please knows to give tips to me to increase the > performance Run VACUUM ANALYZE. Find one query that is slow. Run EXPLAIN ANALYZE on that query. Read the plan and figure out why it is slow. Fix it. -- /Dennis Bj�rklund From pgsql-performance-owner@postgresql.org Wed Feb 11 10:28:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C3327D1B917 for ; Wed, 11 Feb 2004 14:28:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 33710-05 for ; Wed, 11 Feb 2004 10:28:20 -0400 (AST) Received: from OMEGA.denver.ibsncentral.com (mail.ibsncentral.com [69.44.125.178]) by svr1.postgresql.org (Postfix) with ESMTP id D8AD1D1B4D2 for ; Wed, 11 Feb 2004 10:28:15 -0400 (AST) Received: from [192.168.0.175] ([192.168.0.175]) by OMEGA.denver.ibsncentral.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 11 Feb 2004 07:28:16 -0700 In-Reply-To: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> References: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <874D01B5-5C9E-11D8-8191-000A95EA00C0@ibsncentral.com> Content-Transfer-Encoding: 7bit Cc: pgsql-performance@postgresql.org From: PC Drew Subject: Re: slow database Date: Wed, 11 Feb 2004 07:28:15 -0700 To: alemon@tiago.hazor.com.br X-Mailer: Apple Mail (2.612) X-OriginalArrivalTime: 11 Feb 2004 14:28:16.0426 (UTC) FILETIME=[49C580A0:01C3F0AB] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/123 X-Sequence-Number: 5647 On Feb 11, 2004, at 7:23 AM, alemon@tiago.hazor.com.br wrote: > # > # Optimizer Parameters > # > enable_seqscan = false > enable_indexscan = false > enable_tidscan = false > enable_sort = false > enable_nestloop = false > enable_mergejoin = false > enable_hashjoin = false > Why did you disable *every* type of query method? Try commenting all of these out or changing them to "true" instead of "false". -- PC Drew Manager, Dominet IBSN 1600 Broadway, Suite 400 Denver, CO 80202 Phone: 303-984-4727 x107 Cell: 720-841-4543 Fax: 303-984-4730 Email: drewpc@ibsncentral.com From pgsql-performance-owner@postgresql.org Wed Feb 11 10:44:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 83EF8D1CACB for ; Wed, 11 Feb 2004 14:44:52 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 32096-08 for ; Wed, 11 Feb 2004 10:44:47 -0400 (AST) Received: from OMEGA.denver.ibsncentral.com (mail.ibsncentral.com [69.44.125.178]) by svr1.postgresql.org (Postfix) with ESMTP id D8078D1B4DE for ; Wed, 11 Feb 2004 10:44:39 -0400 (AST) Received: from [192.168.0.175] ([192.168.0.175]) by OMEGA.denver.ibsncentral.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 11 Feb 2004 07:44:44 -0700 In-Reply-To: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> References: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: pgsql-performance@postgresql.org From: PC Drew Subject: Re: slow database Date: Wed, 11 Feb 2004 07:44:42 -0700 To: alemon@tiago.hazor.com.br X-Mailer: Apple Mail (2.612) X-OriginalArrivalTime: 11 Feb 2004 14:44:44.0057 (UTC) FILETIME=[96720890:01C3F0AD] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/124 X-Sequence-Number: 5648 On Feb 11, 2004, at 7:23 AM, alemon@tiago.hazor.com.br wrote: > > > my data base is very slow. The machine is a processor Xeon 2GB with > 256 MB of RAM DDR. My archive of configuration is this: > After looking through the configuration some more, I would definitely recommend getting rid of your current postgresql.conf file and replacing it with the default. You have some very very odd settings, namely: This is dangerous, but maybe you need it: fsync = false You've essentially disabled the optimizer: enable_seqscan = false enable_indexscan = false enable_tidscan = false enable_sort = false enable_nestloop = false enable_mergejoin = false enable_hashjoin = false WOAH, this is huge: random_page_cost = 1000000000 Take a look at this page which goes through each option in the configuration file: http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html -- PC Drew Manager, Dominet IBSN 1600 Broadway, Suite 400 Denver, CO 80202 Phone: 303-984-4727 x107 Cell: 720-841-4543 Fax: 303-984-4730 Email: drewpc@ibsncentral.com From pgsql-performance-owner@postgresql.org Wed Feb 11 10:49:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9AD99D1B4D2 for ; Wed, 11 Feb 2004 14:49:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 39828-06 for ; Wed, 11 Feb 2004 10:49:04 -0400 (AST) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 97178D1B4DE for ; Wed, 11 Feb 2004 10:49:00 -0400 (AST) Received: from [134.22.71.39] (dyn-71-39.tor.dsl.tht.net [134.22.71.39]) by tht.net (Postfix) with ESMTP id CFDB776AAE; Wed, 11 Feb 2004 09:49:05 -0500 (EST) Subject: Re: slow database From: Rod Taylor To: alemon@tiago.hazor.com.br Cc: Postgresql Performance In-Reply-To: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> References: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> Content-Type: text/plain Message-Id: <1076510965.761.17.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 11 Feb 2004 09:49:26 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/126 X-Sequence-Number: 5650 On Wed, 2004-02-11 at 09:23, alemon@tiago.hazor.com.br wrote: > my data base is very slow. The machine is a processor Xeon 2GB with > 256 MB of RAM DDR. My archive of configuration is this: I'm not surprised. New values below old. > sort_mem = 131072 # min 64, size in KB sort_mem = 8192. > fsync = false Are you aware of the potential for data corruption during a hardware, power or software failure? > enable_seqscan = false > enable_indexscan = false > enable_tidscan = false > enable_sort = false > enable_nestloop = false > enable_mergejoin = false > enable_hashjoin = false You want all of these set to true, not false. > effective_cache_size = 170000 # typically 8KB each effective_cache_size = 16384. > random_page_cost = 1000000000 # units are one sequential page fetch cost random_page_cost = 3 > cpu_tuple_cost = 0.3 # (same) cpu_tuple_cost = 0.01 > cpu_index_tuple_cost = 0.6 # (same) cpu_index_tuple_cost = 0.001 > cpu_operator_cost = 0.7 # (same) cpu_operator_cost = 0.0025 > default_statistics_target = 1 # range 1-1000 default_statistics_target = 10 From pgsql-performance-owner@postgresql.org Wed Feb 11 11:36:38 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E17C2D1D1B2 for ; Wed, 11 Feb 2004 15:36:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 57510-08 for ; Wed, 11 Feb 2004 11:36:28 -0400 (AST) Received: from yorktown.nielsenmedia.com (yorktown.nielsenmedia.com [206.113.192.17]) by svr1.postgresql.org (Postfix) with ESMTP id BCE6ED1B4D2 for ; Wed, 11 Feb 2004 11:36:22 -0400 (AST) Received: from nmrusdunsxg1.nmrlan.net (nmrusdunsxg1.nmrlan.net [10.38.67.38]) by yorktown.nielsenmedia.com (8.12.10/8.12.8) with ESMTP id i1BFa5Dm016468 for ; Wed, 11 Feb 2004 10:36:05 -0500 (EST) Received: from cultured.net (unverified) by nmrusdunsxg1.nmrlan.net (Content Technologies SMTPRS 4.3.10) with ESMTP id for ; Wed, 11 Feb 2004 10:36:00 -0500 Message-ID: <402A4BE0.4040103@cultured.net> Date: Wed, 11 Feb 2004 10:36:00 -0500 From: Chris Trawick User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: slow database References: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> In-Reply-To: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/127 X-Sequence-Number: 5651 alemon@tiago.hazor.com.br wrote: >my data base is very slow. The machine is a processor Xeon 2GB with >256 MB of RAM DDR. My archive of configuration is this: > > This is a joke, right? chris From pgsql-performance-owner@postgresql.org Wed Feb 11 12:18:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3F005D1CCBE for ; Wed, 11 Feb 2004 16:16:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 78785-07 for ; Wed, 11 Feb 2004 12:16:15 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 6F0E7D1C9E1 for ; Wed, 11 Feb 2004 12:16:16 -0400 (AST) 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 i1BGGF1Y033566 for ; Wed, 11 Feb 2004 16:16:15 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i1BGAW5H032290 for pgsql-performance@postgresql.org; Wed, 11 Feb 2004 16:10:32 GMT From: Chris Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: slow database Date: Wed, 11 Feb 2004 10:39:19 -0500 Organization: cbbrowne Computing Inc Lines: 63 Message-ID: <603c9hiq1k.fsf@dev6.int.libertyrms.info> References: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.110002 (No Gnus v0.2) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:02lj7CptZQZ8T3Gc9H1jq69rJqo= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/131 X-Sequence-Number: 5655 alemon@tiago.hazor.com.br writes: > my data base is very slow. The machine is a processor Xeon 2GB with > 256 MB of RAM DDR. My archive of configuration is this: > sort_mem = 131072 # min 64, size in KB > #vacuum_mem = 8192 # min 1024, size in KB Change it back to 8192, or perhaps even less. This large value is probably causing swapping, because it leads to every sort trying to use 1073741824 bytes of memory, which is considerably more than you have. > fsync = false > wal_sync_method = fdatasync # the default varies across platforms: I presume that you are aware that you have chosen the value that leaves your data vulnerable to corruption? I wouldn't set this to false... > enable_seqscan = false > enable_indexscan = false > enable_tidscan = false > enable_sort = false > enable_nestloop = false > enable_mergejoin = false > enable_hashjoin = false Was there some reason why you wanted to disable every query optimization strategy that can be disabled? If you're looking to get slow queries, this would accomplish that nicely. > effective_cache_size = 170000 # typically 8KB each > random_page_cost = 1000000000 # units are one sequential page fetch cost > cpu_tuple_cost = 0.3 # (same) > cpu_index_tuple_cost = 0.6 # (same) > cpu_operator_cost = 0.7 # (same) Where did you get those numbers? The random_page_cost alone will probably force every query to do seq scans, ignoring indexes, and is _really_ nonsensical. The other values seem way off. > default_statistics_target = 1 # range 1-1000 ... Apparently it didn't suffice to try to disable query optimization, and modify the cost parameters into nonsense; it was also "needful" to tell the statistics analyzer to virtually eliminate statistics collection. If you want a value other than 10, then pick a value slightly LARGER than 10. > somebody please knows to give tips to me to increase the performance Delete the postgresql.conf file, create a new database using initdb, and take the file produced by _that_, and replace with that one. The default values, while not necessarily perfect, are likely to be 100x better than what you have got. Was this the result of someone trying to tune the database for some sort of anti-benchmark? -- let name="cbbrowne" and tld="cbbrowne.com" in name ^ "@" ^ tld;; http://www.ntlug.org/~cbbrowne/rdbms.html Rules of the Evil Overlord #179. "I will not outsource core functions." From pgsql-performance-owner@postgresql.org Wed Feb 11 11:54:15 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C5BE5D1D313 for ; Wed, 11 Feb 2004 15:54:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 69185-05 for ; Wed, 11 Feb 2004 11:54:01 -0400 (AST) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by svr1.postgresql.org (Postfix) with ESMTP id 92449D1CCBE for ; Wed, 11 Feb 2004 11:53:56 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) id 1Aqwga-0004yD-0Z; Wed, 11 Feb 2004 15:54:01 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 20E8A17AD5; Wed, 11 Feb 2004 15:54:00 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 1BCC116729; Wed, 11 Feb 2004 15:53:58 +0000 (GMT) From: Richard Huxton To: stefan bogdan , pgsql-performance@postgresql.org Subject: Re: update performance Date: Wed, 11 Feb 2004 15:53:57 +0000 User-Agent: KMail/1.5 References: <402A3747.8000906@rsb.ro> In-Reply-To: <402A3747.8000906@rsb.ro> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402111553.57724.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/128 X-Sequence-Number: 5652 On Wednesday 11 February 2004 14:08, stefan bogdan wrote: > hello > i have postgres 7.3.2.,linux redhat 9.0 > a database,and 20 tables > a lot of fields are char(x) > when i have to make update for all the fields except index > postgres works verry hard > what should i've changed in configuration to make it work faster Stefan - we need more information to help you. We'll want to know: 1. The query being run 2. EXPLAIN ANALYSE ... results for that query 3. The size of the tables involved. 4. That the tables have been VACCUM ANALYSE'd PS - you should upgrade to 7.3.4 (or is it 7.3.5 now?) -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Wed Feb 11 12:09:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 335A4D1CACD for ; Wed, 11 Feb 2004 16:09:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 79418-01 for ; Wed, 11 Feb 2004 12:09:15 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 4549BD1C513 for ; Wed, 11 Feb 2004 12:09:10 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1BG7Ec5000775; Wed, 11 Feb 2004 09:07:14 -0700 (MST) Date: Wed, 11 Feb 2004 09:02:18 -0700 (MST) From: "scott.marlowe" To: David Teran Cc: Rigmor Ukuhe , PgSQL Performance ML Subject: Re: select count(*) from anIntColumn where int_value = 0; In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/129 X-Sequence-Number: 5653 On Wed, 11 Feb 2004, David Teran wrote: > Hi, > > > Is your int_value data type int4? If not then use "... from > > job_property > > where int_value = '0'" > > Indexes are used only if datatypes matches. > > > tried those variations already. Strange enough, after dropping and > recreating the index everything worked fine. Has that table been updated a lot in its life? If so, it may have had a problem with index bloat... From pgsql-performance-owner@postgresql.org Wed Feb 11 12:33:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A127CD1D120 for ; Wed, 11 Feb 2004 16:18:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 81981-02 for ; Wed, 11 Feb 2004 12:18:38 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id D9285D1B4D2 for ; Wed, 11 Feb 2004 12:18:37 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1BGFmc5001650; Wed, 11 Feb 2004 09:15:48 -0700 (MST) Date: Wed, 11 Feb 2004 09:10:53 -0700 (MST) From: "scott.marlowe" To: stefan bogdan Cc: Subject: Re: update performance In-Reply-To: <402A3747.8000906@rsb.ro> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/132 X-Sequence-Number: 5656 On Wed, 11 Feb 2004, stefan bogdan wrote: > hello > i have postgres 7.3.2.,linux redhat 9.0 > a database,and 20 tables > a lot of fields are char(x) > when i have to make update for all the fields except index > postgres works verry hard > what should i've changed in configuration to make it work faster 1: Upgrate to 7.3.5, (or 7.4.1 if you're feeling adventurous) 2: Read this: http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html From pgsql-performance-owner@postgresql.org Wed Feb 11 12:17:52 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D2D53D1DA66 for ; Wed, 11 Feb 2004 16:16:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 76268-09 for ; Wed, 11 Feb 2004 12:16:42 -0400 (AST) Received: from servidor5.servidorbr.net (unknown [69.57.128.78]) by svr1.postgresql.org (Postfix) with ESMTP id 2AAACD1CE3E for ; Wed, 11 Feb 2004 12:16:43 -0400 (AST) Received: from cpanel by servidor5.servidorbr.net with local (Exim 4.24) id 1Aqx2Y-0001oj-7z for pgsql-performance@postgresql.org; Wed, 11 Feb 2004 14:16:42 -0200 Received: from 200.207.205.140 ([200.207.205.140]) by tiago.hazor.com.br (IMP) with HTTP for ; Wed, 11 Feb 2004 14:16:41 -0200 Message-ID: <1076516201.402a556a176d1@tiago.hazor.com.br> Date: Wed, 11 Feb 2004 14:16:42 -0200 From: alemon@tiago.hazor.com.br To: Postgresql Performance Subject: Re: slow database References: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> <1076510965.761.17.camel@jester> In-Reply-To: <1076510965.761.17.camel@jester> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 X-Originating-IP: 200.207.205.140 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - servidor5.servidorbr.net X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [32001 502] / [47 12] X-AntiAbuse: Sender Address Domain - tiago.hazor.com.br X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/130 X-Sequence-Number: 5654 the normal queries do not present problems, but all the ones that join has are very slow. OBS: I am using way ODBC. He will be that they exist some configuration specifies inside of the same bank or in the ODBC? Quoting Rod Taylor : > On Wed, 2004-02-11 at 09:23, alemon@tiago.hazor.com.br wrote: > > my data base is very slow. The machine is a processor Xeon 2GB with > > 256 MB of RAM DDR. My archive of configuration is this: > > I'm not surprised. New values below old. > > > > sort_mem = 131072 # min 64, size in KB > > sort_mem = 8192. > > > fsync = false > > Are you aware of the potential for data corruption during a hardware, > power or software failure? > > > enable_seqscan = false > > enable_indexscan = false > > enable_tidscan = false > > enable_sort = false > > enable_nestloop = false > > enable_mergejoin = false > > enable_hashjoin = false > > You want all of these set to true, not false. > > > effective_cache_size = 170000 # typically 8KB each > > effective_cache_size = 16384. > > > random_page_cost = 1000000000 # units are one sequential page fetch cost > > random_page_cost = 3 > > > cpu_tuple_cost = 0.3 # (same) > > cpu_tuple_cost = 0.01 > > > cpu_index_tuple_cost = 0.6 # (same) > > cpu_index_tuple_cost = 0.001 > > > cpu_operator_cost = 0.7 # (same) > > cpu_operator_cost = 0.0025 > > > default_statistics_target = 1 # range 1-1000 > > default_statistics_target = 10 > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > From pgsql-performance-owner@postgresql.org Wed Feb 11 13:05:56 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E008FD1DA5F for ; Wed, 11 Feb 2004 16:26:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 83818-07 for ; Wed, 11 Feb 2004 12:25:50 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id D9094D1D643 for ; Wed, 11 Feb 2004 12:25:50 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1BGNuc5002572; Wed, 11 Feb 2004 09:23:56 -0700 (MST) Date: Wed, 11 Feb 2004 09:19:01 -0700 (MST) From: "scott.marlowe" To: Cc: Subject: Re: slow database In-Reply-To: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/134 X-Sequence-Number: 5658 If my boss came to me and asked me to make my database server run as slowly as possible, I might come up with the exact same postgresql.conf file as what you posted. Just installing the default postgresql.conf that came with postgresql should make this machine run faster. Read this: http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html From pgsql-performance-owner@postgresql.org Wed Feb 11 13:57:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2FF78D1D9E6 for ; Wed, 11 Feb 2004 16:44:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 93013-08 for ; Wed, 11 Feb 2004 12:44:08 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id E951DD1DF22 for ; Wed, 11 Feb 2004 12:44:08 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1BGfNc5004363; Wed, 11 Feb 2004 09:41:23 -0700 (MST) Date: Wed, 11 Feb 2004 09:36:28 -0700 (MST) From: "scott.marlowe" To: stefan bogdan Cc: Subject: Re: update performance In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/136 X-Sequence-Number: 5660 On Wed, 11 Feb 2004, scott.marlowe wrote: > On Wed, 11 Feb 2004, stefan bogdan wrote: > > > hello > > i have postgres 7.3.2.,linux redhat 9.0 > > a database,and 20 tables > > a lot of fields are char(x) > > when i have to make update for all the fields except index > > postgres works verry hard > > what should i've changed in configuration to make it work faster > > 1: Upgrate to 7.3.5, (or 7.4.1 if you're feeling adventurous) > 2: Read this: > http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html As a followup, do you have mismatched foreign keys or big ugly constraints? Sometimes those can slow things down too. From pgsql-performance-owner@postgresql.org Wed Feb 11 13:03:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6DCB2D1D643 for ; Wed, 11 Feb 2004 17:00:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 02654-01 for ; Wed, 11 Feb 2004 13:00:28 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id EB0A4D1DA57 for ; Wed, 11 Feb 2004 13:00:28 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1BH0S8Y022127; Wed, 11 Feb 2004 12:00:28 -0500 (EST) To: alemon@tiago.hazor.com.br Cc: Postgresql Performance Subject: Re: slow database In-reply-to: <1076516201.402a556a176d1@tiago.hazor.com.br> References: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> <1076510965.761.17.camel@jester> <1076516201.402a556a176d1@tiago.hazor.com.br> Comments: In-reply-to alemon@tiago.hazor.com.br message dated "Wed, 11 Feb 2004 14:16:42 -0200" Date: Wed, 11 Feb 2004 12:00:28 -0500 Message-ID: <22126.1076518828@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/133 X-Sequence-Number: 5657 alemon@tiago.hazor.com.br writes: > the normal queries do not present problems, but all the ones > that join has are very slow. No surprise, as you've disabled all but the stupidest join algorithm... As others already pointed out, you'd be a lot better off with the default configuration settings than with this set. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Feb 11 13:26:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 447FED1D69B for ; Wed, 11 Feb 2004 17:15:28 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 04547-09 for ; Wed, 11 Feb 2004 13:15:13 -0400 (AST) Received: from servidor5.servidorbr.net (unknown [69.57.128.78]) by svr1.postgresql.org (Postfix) with ESMTP id 3D971D1DA5F for ; Wed, 11 Feb 2004 13:15:14 -0400 (AST) Received: from cpanel by servidor5.servidorbr.net with local (Exim 4.24) id 1AqxxB-0003Vx-SZ; Wed, 11 Feb 2004 15:15:13 -0200 Received: from 200.207.205.140 ([200.207.205.140]) by tiago.hazor.com.br (IMP) with HTTP for ; Wed, 11 Feb 2004 15:15:13 -0200 Message-ID: <1076519713.402a6321be75d@tiago.hazor.com.br> Date: Wed, 11 Feb 2004 15:15:13 -0200 From: alemon@tiago.hazor.com.br To: Tom Lane Cc: Postgresql Performance Subject: Re: slow database References: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> <1076510965.761.17.camel@jester> <1076516201.402a556a176d1@tiago.hazor.com.br> <22126.1076518828@sss.pgh.pa.us> In-Reply-To: <22126.1076518828@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 X-Originating-IP: 200.207.205.140 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - servidor5.servidorbr.net X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [32001 502] / [47 12] X-AntiAbuse: Sender Address Domain - tiago.hazor.com.br X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/135 X-Sequence-Number: 5659 I already came back the old conditions and I continue slow in the same way! Quoting Tom Lane : > alemon@tiago.hazor.com.br writes: > > the normal queries do not present problems, but all the ones > > that join has are very slow. > > No surprise, as you've disabled all but the stupidest join algorithm... > > As others already pointed out, you'd be a lot better off with the > default configuration settings than with this set. > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend > > From pgsql-performance-owner@postgresql.org Wed Feb 11 14:45:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C8628D1D8BF for ; Wed, 11 Feb 2004 17:56:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 25118-03 for ; Wed, 11 Feb 2004 13:56:08 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id B9CEDD1D8AE for ; Wed, 11 Feb 2004 13:56:08 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1BHrGc5011530; Wed, 11 Feb 2004 10:53:16 -0700 (MST) Date: Wed, 11 Feb 2004 10:48:20 -0700 (MST) From: "scott.marlowe" To: Cc: Tom Lane , Postgresql Performance Subject: Re: slow database In-Reply-To: <1076519713.402a6321be75d@tiago.hazor.com.br> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/138 X-Sequence-Number: 5662 On Wed, 11 Feb 2004 alemon@tiago.hazor.com.br wrote: > I already came back the old conditions and I continue slow in the same > way! OK, we need some things from you to help troubleshoot this problem. Postgresql version schema of your tables output of "explain analyze your query here" a chicken foot (haha, just kidding. :-) From pgsql-performance-owner@postgresql.org Wed Feb 11 14:52:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1E44DD1D5B0 for ; Wed, 11 Feb 2004 17:55:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 20981-08 for ; Wed, 11 Feb 2004 13:55:00 -0400 (AST) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 78390D1DB8B for ; Wed, 11 Feb 2004 13:55:00 -0400 (AST) Received: from [134.22.71.39] (dyn-71-39.tor.dsl.tht.net [134.22.71.39]) by tht.net (Postfix) with ESMTP id C9D3F76B22; Wed, 11 Feb 2004 12:55:02 -0500 (EST) Subject: Re: slow database From: Rod Taylor To: alemon@tiago.hazor.com.br Cc: Postgresql Performance In-Reply-To: <1076519713.402a6321be75d@tiago.hazor.com.br> References: <1076509411.402a3ae38d9b8@tiago.hazor.com.br> <1076510965.761.17.camel@jester> <1076516201.402a556a176d1@tiago.hazor.com.br> <22126.1076518828@sss.pgh.pa.us> <1076519713.402a6321be75d@tiago.hazor.com.br> Content-Type: text/plain Message-Id: <1076522121.761.51.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 11 Feb 2004 12:55:21 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/139 X-Sequence-Number: 5663 On Wed, 2004-02-11 at 12:15, alemon@tiago.hazor.com.br wrote: > I already came back the old conditions and I continue slow in the same > way! Dumb question, but did you restart the database after changing the config file? From pgsql-performance-owner@postgresql.org Wed Feb 11 14:23:18 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5F7C7D1E0D4 for ; Wed, 11 Feb 2004 18:19:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 36729-03 for ; Wed, 11 Feb 2004 14:18:54 -0400 (AST) Received: from servidor5.servidorbr.net (unknown [69.57.128.78]) by svr1.postgresql.org (Postfix) with ESMTP id 2C772D1DF75 for ; Wed, 11 Feb 2004 14:18:36 -0400 (AST) Received: from cpanel by servidor5.servidorbr.net with local (Exim 4.24) id 1AqywV-00058I-L2; Wed, 11 Feb 2004 16:18:35 -0200 Received: from 200.207.205.140 ([200.207.205.140]) by tiago.hazor.com.br (IMP) with HTTP for ; Wed, 11 Feb 2004 16:18:35 -0200 Message-ID: <1076523515.402a71fb8b30e@tiago.hazor.com.br> Date: Wed, 11 Feb 2004 16:18:35 -0200 From: alemon@tiago.hazor.com.br To: "scott.marlowe" Cc: Tom Lane , Postgresql Performance Subject: Re: slow database References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 X-Originating-IP: 200.207.205.140 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - servidor5.servidorbr.net X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [32001 502] / [47 12] X-AntiAbuse: Sender Address Domain - tiago.hazor.com.br X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/137 X-Sequence-Number: 5661 the version is 7.3.2 in a connective 9. the hen foot is without nails at the moment: =) | /|\ this is a principal table of system: CREATE TABLE public.compra_prod_forn ( nu_seq_prod_forn numeric(12) NOT NULL, cd_fabricante numeric(6), cd_moeda numeric(4) NOT NULL, cd_compra numeric(12) NOT NULL, cd_produto numeric(9), cd_fornecedor numeric(6), cd_incotermes numeric(3) NOT NULL, qtde_compra numeric(12,3), perc_comissao_holding numeric(5,2), vl_cotacao_unit_negociacao numeric(20,3), dt_retorno date, cd_status_cv numeric(3) NOT NULL, cd_usuario numeric(6) NOT NULL, tp_comissao varchar(25), vl_pif numeric(9,2), cd_fornecedor_contato numeric(6), cd_contato numeric(6), cd_un_peso varchar(20), vl_currier numeric(9,2), cd_iqf numeric(3), cd_un_peso_vl_unit varchar(10), dt_def_fornecedor date, vl_cotacao_unit_forn numeric(20,3), vl_cotacao_unit_local numeric(20,3), tp_vl_cotacao_unit numeric(1), cd_moeda_forn numeric(4), cd_moeda_local numeric(4), vl_cotacao_unit numeric(20,3), peso_bruto_emb varchar(20), id_fax numeric(1), id_email numeric(1), fob varchar(40), origem varchar(40), tipo_comissao varchar(40), descr_fabricante_select varchar(200), farmacopeia varchar(100), vl_frete numeric(10,3), descr_abandono_representada varchar(2000), descr_abandono_interno varchar(2000), vl_frete_unit numeric(10,3), CONSTRAINT compra_prod_forn_pkey PRIMARY KEY (cd_compra, nu_seq_prod_forn), CONSTRAINT "$1" FOREIGN KEY (cd_moeda_local) REFERENCES public.moeda (cd_moeda) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "$10" FOREIGN KEY (cd_usuario) REFERENCES public.usuario_sistema (cd_usuario) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "$11" FOREIGN KEY (cd_status_cv) REFERENCES public.status_compra_venda (cd_status_cv) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "$12" FOREIGN KEY (cd_moeda) REFERENCES public.moeda (cd_moeda) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "$2" FOREIGN KEY (cd_moeda_forn) REFERENCES public.moeda (cd_moeda) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "$3" FOREIGN KEY (cd_un_peso_vl_unit) REFERENCES public.unidades_peso (cd_un_peso) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "$4" FOREIGN KEY (cd_un_peso) REFERENCES public.unidades_peso (cd_un_peso) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "$5" FOREIGN KEY (cd_fornecedor_contato, cd_contato) REFERENCES public.fornecedor_contato (cd_fornecedor, cd_contato) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "$6" FOREIGN KEY (cd_fabricante) REFERENCES public.fabricante (cd_fabricante) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "$7" FOREIGN KEY (cd_produto, cd_fornecedor) REFERENCES public.fornecedor_produto (cd_produto, cd_fornecedor) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "$8" FOREIGN KEY (cd_incotermes) REFERENCES public.incotermes (cd_incotermes) ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT "$9" FOREIGN KEY (cd_compra) REFERENCES public.compra (cd_compra) ON UPDATE NO ACTION ON DELETE CASCADE ) WITH OIDS; Quoting "scott.marlowe" : > On Wed, 11 Feb 2004 alemon@tiago.hazor.com.br wrote: > > > I already came back the old conditions and I continue slow in the same > > way! > > OK, we need some things from you to help troubleshoot this problem. > > Postgresql version > schema of your tables > output of "explain analyze your query here" > a chicken foot (haha, just kidding. :-) > > From pgsql-performance-owner@postgresql.org Wed Feb 11 15:11:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 54001D1DD00 for ; Wed, 11 Feb 2004 18:51:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 46091-08 for ; Wed, 11 Feb 2004 14:51:17 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 92A0BD1DAB0 for ; Wed, 11 Feb 2004 14:51:17 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1BIkEc5016760; Wed, 11 Feb 2004 11:46:14 -0700 (MST) Date: Wed, 11 Feb 2004 11:41:18 -0700 (MST) From: "scott.marlowe" To: Cc: Tom Lane , Postgresql Performance Subject: Re: slow database In-Reply-To: <1076523515.402a71fb8b30e@tiago.hazor.com.br> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/140 X-Sequence-Number: 5664 First thing I would check is to make sure all those foreign keys are the same type. Second, make sure you've got indexes to go with them. I.e. on a multi-key fk, have a multi-key index. On Wed, 11 Feb 2004 alemon@tiago.hazor.com.br wrote: > the version is 7.3.2 in a connective 9. > the hen foot is without nails at the moment: =) > | > /|\ > > this is a principal table of system: > > CREATE TABLE public.compra_prod_forn > ( > nu_seq_prod_forn numeric(12) NOT NULL, > cd_fabricante numeric(6), > cd_moeda numeric(4) NOT NULL, > cd_compra numeric(12) NOT NULL, > cd_produto numeric(9), > cd_fornecedor numeric(6), > cd_incotermes numeric(3) NOT NULL, > qtde_compra numeric(12,3), > perc_comissao_holding numeric(5,2), > vl_cotacao_unit_negociacao numeric(20,3), > dt_retorno date, > cd_status_cv numeric(3) NOT NULL, > cd_usuario numeric(6) NOT NULL, > tp_comissao varchar(25), > vl_pif numeric(9,2), > cd_fornecedor_contato numeric(6), > cd_contato numeric(6), > cd_un_peso varchar(20), > vl_currier numeric(9,2), > cd_iqf numeric(3), > cd_un_peso_vl_unit varchar(10), > dt_def_fornecedor date, > vl_cotacao_unit_forn numeric(20,3), > vl_cotacao_unit_local numeric(20,3), > tp_vl_cotacao_unit numeric(1), > cd_moeda_forn numeric(4), > cd_moeda_local numeric(4), > vl_cotacao_unit numeric(20,3), > peso_bruto_emb varchar(20), > id_fax numeric(1), > id_email numeric(1), > fob varchar(40), > origem varchar(40), > tipo_comissao varchar(40), > descr_fabricante_select varchar(200), > farmacopeia varchar(100), > vl_frete numeric(10,3), > descr_abandono_representada varchar(2000), > descr_abandono_interno varchar(2000), > vl_frete_unit numeric(10,3), > CONSTRAINT compra_prod_forn_pkey PRIMARY KEY (cd_compra, nu_seq_prod_forn), > CONSTRAINT "$1" FOREIGN KEY (cd_moeda_local) REFERENCES public.moeda > (cd_moeda) ON UPDATE NO ACTION ON DELETE NO ACTION, > CONSTRAINT "$10" FOREIGN KEY (cd_usuario) REFERENCES public.usuario_sistema > (cd_usuario) ON UPDATE NO ACTION ON DELETE NO ACTION, > CONSTRAINT "$11" FOREIGN KEY (cd_status_cv) REFERENCES > public.status_compra_venda (cd_status_cv) ON UPDATE NO ACTION ON DELETE NO > ACTION, > CONSTRAINT "$12" FOREIGN KEY (cd_moeda) REFERENCES public.moeda (cd_moeda) ON > UPDATE NO ACTION ON DELETE NO ACTION, > CONSTRAINT "$2" FOREIGN KEY (cd_moeda_forn) REFERENCES public.moeda > (cd_moeda) ON UPDATE NO ACTION ON DELETE NO ACTION, > CONSTRAINT "$3" FOREIGN KEY (cd_un_peso_vl_unit) REFERENCES > public.unidades_peso (cd_un_peso) ON UPDATE NO ACTION ON DELETE NO ACTION, > CONSTRAINT "$4" FOREIGN KEY (cd_un_peso) REFERENCES public.unidades_peso > (cd_un_peso) ON UPDATE NO ACTION ON DELETE NO ACTION, > CONSTRAINT "$5" FOREIGN KEY (cd_fornecedor_contato, cd_contato) REFERENCES > public.fornecedor_contato (cd_fornecedor, cd_contato) ON UPDATE NO ACTION ON > DELETE NO ACTION, > CONSTRAINT "$6" FOREIGN KEY (cd_fabricante) REFERENCES public.fabricante > (cd_fabricante) ON UPDATE NO ACTION ON DELETE NO ACTION, > CONSTRAINT "$7" FOREIGN KEY (cd_produto, cd_fornecedor) REFERENCES > public.fornecedor_produto (cd_produto, cd_fornecedor) ON UPDATE NO ACTION ON > DELETE NO ACTION, > CONSTRAINT "$8" FOREIGN KEY (cd_incotermes) REFERENCES public.incotermes > (cd_incotermes) ON UPDATE NO ACTION ON DELETE NO ACTION, > CONSTRAINT "$9" FOREIGN KEY (cd_compra) REFERENCES public.compra (cd_compra) > ON UPDATE NO ACTION ON DELETE CASCADE > ) WITH OIDS; > > > > Quoting "scott.marlowe" : > > > On Wed, 11 Feb 2004 alemon@tiago.hazor.com.br wrote: > > > > > I already came back the old conditions and I continue slow in the same > > > way! > > > > OK, we need some things from you to help troubleshoot this problem. > > > > Postgresql version > > schema of your tables > > output of "explain analyze your query here" > > a chicken foot (haha, just kidding. :-) > > > > > > > > From pgsql-performance-owner@postgresql.org Wed Feb 11 18:41:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 235E2D1B53C for ; Wed, 11 Feb 2004 22:38:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 40871-07 for ; Wed, 11 Feb 2004 18:38:44 -0400 (AST) Received: from busybox.pixar.com (busybox.pixar.com [138.72.18.213]) by svr1.postgresql.org (Postfix) with ESMTP id 98F67D1B4D2 for ; Wed, 11 Feb 2004 18:38:43 -0400 (AST) Received: from pixar.com (dreadnok.pixar.com [138.72.16.110]) by busybox.pixar.com (8.12.8/8.12.8) with ESMTP id i1BMcfHw002912 for ; Wed, 11 Feb 2004 14:38:41 -0800 Message-ID: <402AAEF1.2050703@pixar.com> Date: Wed, 11 Feb 2004 14:38:41 -0800 From: Mark Harrison User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: coercing int to bigint for indexing purposes Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/141 X-Sequence-Number: 5665 Is there a way to automatically coerce an int into a bigint for indexing purposes? We have a table with a bigint column that is an index. For mi, there's no problem, since I now know to say select * from foo where id = 123::bigint but our casual users still say select * from foo where id = 123 causing a sequential scan because the type of 123 is not a bigint. As you can see, there's nearly 4 orders of magnitude difference in time, and we anticipate this will only get worse as our tables increase in size: LOG: duration: 0.861 ms statement: select * from big where id = 123123123123123; LOG: duration: 6376.917 ms statement: select * from big where id = 123; One thing I have considered is starting our id sequence at 5000000000 so that "real" queries will always be bigint-sized, but this seems to me a bit of a hack. Many TIA, Mark -- Mark Harrison Pixar Animation Studios From pgsql-performance-owner@postgresql.org Wed Feb 11 19:24:48 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8FD0CD1D1CD for ; Wed, 11 Feb 2004 23:24:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 58539-02 for ; Wed, 11 Feb 2004 19:24:41 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id D208BD1D1C3 for ; Wed, 11 Feb 2004 19:24:39 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1BNOfGp024097; Wed, 11 Feb 2004 18:24:41 -0500 (EST) To: Mark Harrison Cc: pgsql-performance@postgresql.org Subject: Re: coercing int to bigint for indexing purposes In-reply-to: <402AAEF1.2050703@pixar.com> References: <402AAEF1.2050703@pixar.com> Comments: In-reply-to Mark Harrison message dated "Wed, 11 Feb 2004 14:38:41 -0800" Date: Wed, 11 Feb 2004 18:24:41 -0500 Message-ID: <24096.1076541881@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/142 X-Sequence-Number: 5666 Mark Harrison writes: > Is there a way to automatically coerce an int into a bigint for > indexing purposes? This problem is fixed in CVS tip. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Feb 11 21:27:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 50FB3D1D643 for ; Thu, 12 Feb 2004 01:27:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 92675-02 for ; Wed, 11 Feb 2004 21:27:36 -0400 (AST) Received: from linda-3.paradise.net.nz (bm-3a.paradise.net.nz [202.0.58.22]) by svr1.postgresql.org (Postfix) with ESMTP id B5054D1D63E for ; Wed, 11 Feb 2004 21:27:33 -0400 (AST) Received: from smtp-3.paradise.net.nz (smtp-3b.paradise.net.nz [202.0.32.212]) by linda-3.paradise.net.nz (Paradise.net.nz) with ESMTP id <0HSY00LFK6OHJI@linda-3.paradise.net.nz> for pgsql-performance@postgresql.org; Thu, 12 Feb 2004 14:27:36 +1300 (NZDT) Received: from paradise.net.nz (218-101-45-46.paradise.net.nz [218.101.45.46]) by smtp-3.paradise.net.nz (Postfix) with ESMTP id 061F9AE115; Thu, 12 Feb 2004 14:26:41 +1300 (NZDT) Date: Thu, 12 Feb 2004 14:27:44 +1300 From: Mark Kirkwood Subject: Re: slow database In-reply-to: To: alemon@tiago.hazor.com.br Cc: "scott.marlowe" , Tom Lane , Postgresql Performance Message-id: <402AD690.9020106@paradise.net.nz> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=us-ascii Content-transfer-encoding: 7bit X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.5) Gecko/20031213 References: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/143 X-Sequence-Number: 5667 If things are still slow after you have checked your keys as indicated, then pick one query and post the output from EXPLAIN ANALYZE for the list to examine. oh - and ensure you are *not* still using your original postgresql.conf :-) best wishes Mark scott.marlowe wrote: >First thing I would check is to make sure all those foreign keys are the >same type. > >Second, make sure you've got indexes to go with them. I.e. on a multi-key >fk, have a multi-key index. > > > > > From pgsql-performance-owner@postgresql.org Wed Feb 11 21:54:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id AF11FD1C9BD for ; Thu, 12 Feb 2004 01:54:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 99696-03 for ; Wed, 11 Feb 2004 21:54:37 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 9FB8FD1C9B4 for ; Wed, 11 Feb 2004 21:54:34 -0400 (AST) Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i1C1s34v011350; Thu, 12 Feb 2004 09:54:03 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <402ADE8D.1090802@familyhealth.com.au> Date: Thu, 12 Feb 2004 10:01:49 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "scott.marlowe" Cc: David Teran , Rigmor Ukuhe , PgSQL Performance ML Subject: Re: select count(*) from anIntColumn where int_value = References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/144 X-Sequence-Number: 5668 >>>Is your int_value data type int4? If not then use "... from >>>job_property >>>where int_value = '0'" >>>Indexes are used only if datatypes matches. >>> >> >>tried those variations already. Strange enough, after dropping and >>recreating the index everything worked fine. > > > Has that table been updated a lot in its life? If so, it may have had a > problem with index bloat... Try creating a partial index: create index blah on tablw where int_value=0; Chris From pgsql-performance-owner@postgresql.org Thu Feb 12 14:31:17 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B3B1ED1BB95 for ; Thu, 12 Feb 2004 18:30:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 33263-08 for ; Thu, 12 Feb 2004 14:30:10 -0400 (AST) Received: from arkanoid.comvision.com (arkanoid.comvision.com [63.108.120.12]) by svr1.postgresql.org (Postfix) with ESMTP id 8D734D1CACD for ; Thu, 12 Feb 2004 14:30:09 -0400 (AST) Received: by arkanoid.comvision.com (Postfix, from userid 98) id EBA77179E0; Thu, 12 Feb 2004 13:51:45 -0500 (EST) Received: from [63.108.121.47] (calendar.comvision.com [63.108.121.47]) by arkanoid.comvision.com (Postfix) with ESMTP id 928E717931 for ; Thu, 12 Feb 2004 13:51:44 -0500 (EST) Mime-Version: 1.0 (Apple Message framework v612) Content-Transfer-Encoding: 7bit Message-Id: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> Content-Type: text/plain; charset=US-ASCII; format=flowed To: pgsql-performance@postgresql.org From: Leon Out Subject: Disappointing performance in db migrated from MS SQL Server Date: Thu, 12 Feb 2004 13:29:49 -0500 X-Mailer: Apple Mail (2.612) X-Sanitizer: Comvision mail filter X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/145 X-Sequence-Number: 5669 Hello all. I am in the midst of porting a large web application from a MS SQL Server backend to PostgreSQL. The migration work is basically complete, and we're at the testing and optimization phase of the project. The results so far have been disappointing, with Postgres performing queries in about the same time as SQL Server even though Postgres is running on a dedicated box with about 4 times the clock speed of the SQL Server box. For a chart of my results, please see http://leonout.com/pggraph.pdf for a graph of some test results. Here are the specs of the systems: SQL Server Dell PowerEdge 2400 Windows 2000 Advanced Server Dual Pentium III 667 2 GB Registered PC133 SDRAM MS SQL Server 2000 SP2 - shared database (although to be fair, this app is by far the heaviest) RAID 1 for system / RAID 5 for data (10k RPM Ultra160 SCSI drives) PostgreSQL Dell PowerEdge 2650 RedHat Enterprise Linux 3.1 Dual Xeon 3.06 GHz (Hyperthreading currently disabled) 4 GB DDR SDRAM PostgreSQL 7.4 - dedicated to this app, with no other apps running on system RAID 5 (15k RPM Ultra160 SCSI drives) The database is about 4.3 GB in size. My postgresql.conf is as follows: max_connections = 50 shared_buffers = 10000 # min 16, at least max_connections*2, 8KB each - default is 1000 sort_mem = 2000 # min 64, size in KB - default is 1024 (commented out) effective_cache_size = 250000 # typically 8KB each - default is 1000 (commented out) geqo = true 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 I hope that someone can help with this. Thanks in advance for your help! Leon From pgsql-performance-owner@postgresql.org Thu Feb 12 18:08:17 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D754DD1C9CF for ; Thu, 12 Feb 2004 18:44:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 41436-09 for ; Thu, 12 Feb 2004 14:44:18 -0400 (AST) Received: from OMEGA.denver.ibsncentral.com (mail.ibsncentral.com [69.44.125.178]) by svr1.postgresql.org (Postfix) with ESMTP id 5EF93D1BB9E for ; Thu, 12 Feb 2004 14:44:16 -0400 (AST) Received: from [192.168.0.175] ([192.168.0.175]) by OMEGA.denver.ibsncentral.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 12 Feb 2004 11:43:58 -0700 In-Reply-To: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> References: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <6A6E0DC6-5D8B-11D8-8356-000A95EA00C0@ibsncentral.com> Content-Transfer-Encoding: 7bit Cc: pgsql-performance@postgresql.org From: PC Drew Subject: Re: Disappointing performance in db migrated from MS SQL Server Date: Thu, 12 Feb 2004 11:43:57 -0700 To: Leon Out X-Mailer: Apple Mail (2.612) X-OriginalArrivalTime: 12 Feb 2004 18:43:58.0385 (UTC) FILETIME=[2CB46A10:01C3F198] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/149 X-Sequence-Number: 5673 Please run your largest (worst) queries using EXPLAIN ANALYZE and send in the results so we can see how the queries are being executed & optimized. On Feb 12, 2004, at 11:29 AM, Leon Out wrote: > Hello all. I am in the midst of porting a large web application from a > MS SQL Server backend to PostgreSQL. The migration work is basically > complete, and we're at the testing and optimization phase of the > project. The results so far have been disappointing, with Postgres > performing queries in about the same time as SQL Server even though > Postgres is running on a dedicated box with about 4 times the clock > speed of the SQL Server box. For a chart of my results, please see > http://leonout.com/pggraph.pdf for a graph of some test results. > -- PC Drew Manager, Dominet IBSN 1600 Broadway, Suite 400 Denver, CO 80202 Phone: 303-984-4727 x107 Cell: 720-841-4543 Fax: 303-984-4730 Email: drewpc@ibsncentral.com From pgsql-performance-owner@postgresql.org Thu Feb 12 17:21:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2CA43D1D1B2 for ; Thu, 12 Feb 2004 19:02:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 49975-05 for ; Thu, 12 Feb 2004 15:02:30 -0400 (AST) Received: from gomez.justsportsusa.com (unknown [208.29.195.72]) by svr1.postgresql.org (Postfix) with ESMTP id CD8DED1CAF3 for ; Thu, 12 Feb 2004 15:02:28 -0400 (AST) Received: from ehpg.net (gavin.justsportsusa.com [192.168.254.20] (may be forged)) by gomez.justsportsusa.com (8.12.9/8.12.4) with ESMTP id i1CJ16WD019209; Thu, 12 Feb 2004 11:01:09 -0800 Message-ID: <402BCDEA.2040207@ehpg.net> Date: Thu, 12 Feb 2004 11:03:06 -0800 From: "Gavin M. Roy" User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Leon Out Cc: pgsql-performance@postgresql.org Subject: Re: Disappointing performance in db migrated from MS SQL References: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> In-Reply-To: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/148 X-Sequence-Number: 5672 It might be helpful to include a sample query that is running slower than you expect, with the table structure, and the output of explain {query}. Gavin Leon Out wrote: > Hello all. I am in the midst of porting a large web application from a > MS SQL Server backend to PostgreSQL. The migration work is basically > complete, and we're at the testing and optimization phase of the > project. The results so far have been disappointing, with Postgres > performing queries in about the same time as SQL Server even though > Postgres is running on a dedicated box with about 4 times the clock > speed of the SQL Server box. For a chart of my results, please see > http://leonout.com/pggraph.pdf for a graph of some test results. > > Here are the specs of the systems: > > SQL Server > Dell PowerEdge 2400 > Windows 2000 Advanced Server > Dual Pentium III 667 > 2 GB Registered PC133 SDRAM > MS SQL Server 2000 SP2 - shared database (although to be fair, this > app is by far the heaviest) > RAID 1 for system / RAID 5 for data (10k RPM Ultra160 SCSI drives) > > PostgreSQL > Dell PowerEdge 2650 > RedHat Enterprise Linux 3.1 > Dual Xeon 3.06 GHz (Hyperthreading currently disabled) > 4 GB DDR SDRAM > PostgreSQL 7.4 - dedicated to this app, with no other apps running on > system > RAID 5 (15k RPM Ultra160 SCSI drives) > > The database is about 4.3 GB in size. > > My postgresql.conf is as follows: > > max_connections = 50 > shared_buffers = 10000 # min 16, at least max_connections*2, > 8KB each - default is 1000 > sort_mem = 2000 # min 64, size in KB - default is 1024 > (commented out) > effective_cache_size = 250000 # typically 8KB each - default is 1000 > (commented out) > geqo = true > > 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 > > > I hope that someone can help with this. Thanks in advance for your help! > > Leon > > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend From pgsql-performance-owner@postgresql.org Thu Feb 12 17:08:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 20272D1C9CF for ; Thu, 12 Feb 2004 19:05:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 51927-03 for ; Thu, 12 Feb 2004 15:05:35 -0400 (AST) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 62538D1BB9E for ; Thu, 12 Feb 2004 15:05:33 -0400 (AST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id i1CJ5XW13096; Thu, 12 Feb 2004 14:05:33 -0500 (EST) From: Bruce Momjian Message-Id: <200402121905.i1CJ5XW13096@candle.pha.pa.us> Subject: Re: Disappointing performance in db migrated from MS SQL Server In-Reply-To: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> To: Leon Out Date: Thu, 12 Feb 2004 14:05:33 -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 postgresql.org X-Archive-Number: 200402/147 X-Sequence-Number: 5671 Leon Out wrote: > Hello all. I am in the midst of porting a large web application from a > MS SQL Server backend to PostgreSQL. The migration work is basically > complete, and we're at the testing and optimization phase of the > project. The results so far have been disappointing, with Postgres > performing queries in about the same time as SQL Server even though > Postgres is running on a dedicated box with about 4 times the clock > speed of the SQL Server box. For a chart of my results, please see > http://leonout.com/pggraph.pdf for a graph of some test results. My only guess is that the tests are I/O bound and therefore the faster CPU's aren't helping PostgreSQL. -- 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 Thu Feb 12 16:22:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 36716D1B897 for ; Thu, 12 Feb 2004 19:23:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 61377-10 for ; Thu, 12 Feb 2004 15:23:09 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 5A778D1B4D2 for ; Thu, 12 Feb 2004 15:23:04 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1CJLDc5004248; Thu, 12 Feb 2004 12:21:13 -0700 (MST) Date: Thu, 12 Feb 2004 12:15:16 -0700 (MST) From: "scott.marlowe" To: Leon Out Cc: Subject: Re: Disappointing performance in db migrated from MS SQL In-Reply-To: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/146 X-Sequence-Number: 5670 On Thu, 12 Feb 2004, Leon Out wrote: > Hello all. I am in the midst of porting a large web application from a > MS SQL Server backend to PostgreSQL. The migration work is basically > complete, and we're at the testing and optimization phase of the > project. The results so far have been disappointing, with Postgres > performing queries in about the same time as SQL Server even though > Postgres is running on a dedicated box with about 4 times the clock > speed of the SQL Server box. For a chart of my results, please see > http://leonout.com/pggraph.pdf for a graph of some test results. A couple of things. One, CPU speed is about number 5 in the list of things that make a database fast. Drive subsystem (number of drivers, controller, RAID cache), memory speed, memory size, and proper database tuning are all significantly more important thatn the CPU speed. Our old server was a dual PIII-750 with 1.5 gig ram (PC133) and it ran about 85% as fast as our brand spanking new Dell 2650 dual 2800MHz box with 2 gig ram. They both had the same basic drive subsystem, by the way. Using a battery backed RAID controller (the lsi megaraid one, not the adaptect, as it's not very fast) made the biggest difference. With that thrown in we got about double the speed on the new box as the old one. Have you read the tuning docs on varlena? http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html It's a must read. > Here are the specs of the systems: > > SQL Server > Dell PowerEdge 2400 > Windows 2000 Advanced Server > Dual Pentium III 667 > 2 GB Registered PC133 SDRAM > MS SQL Server 2000 SP2 - shared database (although to be fair, this app > is by far the heaviest) > RAID 1 for system / RAID 5 for data (10k RPM Ultra160 SCSI drives) > > PostgreSQL > Dell PowerEdge 2650 > RedHat Enterprise Linux 3.1 > Dual Xeon 3.06 GHz (Hyperthreading currently disabled) > 4 GB DDR SDRAM > PostgreSQL 7.4 - dedicated to this app, with no other apps running on > system > RAID 5 (15k RPM Ultra160 SCSI drives) > > The database is about 4.3 GB in size. > > My postgresql.conf is as follows: > > max_connections = 50 > shared_buffers = 10000 # min 16, at least max_connections*2, > 8KB each - default is 1000 > sort_mem = 2000 # min 64, size in KB - default is 1024 > (commented out) > effective_cache_size = 250000 # typically 8KB each - default is 1000 > (commented out) I'm gonna guess that you could use a larger sort_mem (at least 8 meg, no more than 32 meg is usually a good range. With 4 gigs of ram, you can probably go to 64 or 128 meg if you only handle a hand full of clients at at time, but sort_mem is per sort, so be careful cranking it up too fast, as you'll throwh the server into a swap storm. I.e. setting sort_mem high is a foot gun. Your effective cache size should likely be at LEAST a setting that represents 2 gigs, maybe more. It's measured in blocks, so unless you've changed your block size from 8k, that would be: 250000 What are your query settings for random_page_cost, and cpu*cost settings? It's likely a good idea to drop your random page cost to close to 1, as with this much memory, most of your data will find itself in memory. 10000 is probably plenty for shared_buffers. You might try setting it higher to see if it helps, but I'm doubting it will. But more important, WHAT are you doing that's slow? Matching text, foreign keys, triggers, stored procedures? Use explain analyze on the the slow / mediocre queries and we can help a bit. From pgsql-performance-owner@postgresql.org Thu Feb 12 19:57:01 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8E7AED1D362 for ; Thu, 12 Feb 2004 20:27:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 91251-02 for ; Thu, 12 Feb 2004 16:27:25 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id D69FFD1BB9E for ; Thu, 12 Feb 2004 16:27:23 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4417083; Thu, 12 Feb 2004 12:28:27 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Leon Out , pgsql-performance@postgresql.org Subject: Re: Disappointing performance in db migrated from MS SQL Server Date: Thu, 12 Feb 2004 12:26:33 -0800 User-Agent: KMail/1.5.4 References: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> In-Reply-To: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402121226.33823.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/151 X-Sequence-Number: 5675 Leon, > Hello all. I am in the midst of porting a large web application from a > MS SQL Server backend to PostgreSQL. The migration work is basically > complete, and we're at the testing and optimization phase of the > project. The results so far have been disappointing, with Postgres > performing queries in about the same time as SQL Server even though > Postgres is running on a dedicated box with about 4 times the clock > speed of the SQL Server box. For a chart of my results, please see > http://leonout.com/pggraph.pdf for a graph of some test results. Your settings look ok to start, but we'll probably want to tune them further. Can you post some details of the tests? Include: 1) the query 2) the EXPLAIN ANALYZE results of the query 3) Whether you ran the test as the only connection, or whether you tested multi-user load. The last is fairly important for a SQL Server vs. PostgreSQL test; SQL Server is basically a single-user-database, so like MySQL it appears very fast until you get a bunch o' users on it. Finally, for most queries the disk I/O and the RAM are more important than the CPU clock speed. From the looks of it, you upgraded the CPU + RAM, but did downgraded the disk array as far as database writes are concered; not a terrible effective way to gain performance on your hardware. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Feb 12 18:55:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4215BD1D26D for ; Thu, 12 Feb 2004 22:20:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 25566-09 for ; Thu, 12 Feb 2004 18:20:31 -0400 (AST) Received: from bramble.mmrd.com (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 6C2A7D1BB95 for ; Thu, 12 Feb 2004 18:20:28 -0400 (AST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id i1CLl9cM026922 for ; Thu, 12 Feb 2004 16:47:09 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id i1CMKQl15686 for ; Thu, 12 Feb 2004 17:20:26 -0500 Received: from intergylinux (intergylinux.mmrd.com [172.25.4.92]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id XT88FRHZ; Thu, 12 Feb 2004 17:20:23 -0500 From: Chris Ruprecht Organization: CDRBill To: pgsql-performance@postgresql.org Subject: Re: Disappointing performance in db migrated from MS SQL Server Date: Thu, 12 Feb 2004 17:19:27 -0500 User-Agent: KMail/1.5.1 References: <200402121905.i1CJ5XW13096@candle.pha.pa.us> In-Reply-To: <200402121905.i1CJ5XW13096@candle.pha.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402121719.27666.chris@ruprecht.org> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/150 X-Sequence-Number: 5674 Bruce, my bet is on the limited amount of shared memory. The setup as posted by Leon only shows 80 MB. On a 4 GB database, that's not all that much. Depending on what he's doing, this might be a bottleneck. I don't like the virtual memory strategy of Linux too much and would rather increase this to 1 - 2 GB for the Postgres DB - Specially since he's not running anything else on the machine and he has 4 GB to play with. On Thursday 12 February 2004 14:05, Bruce Momjian wrote: > Leon Out wrote: [snip] > > My only guess is that the tests are I/O bound and therefore the faster > CPU's aren't helping PostgreSQL. From pgsql-performance-owner@postgresql.org Thu Feb 12 21:54:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E59A3D1B4DA for ; Fri, 13 Feb 2004 01:01:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 84355-03 for ; Thu, 12 Feb 2004 21:01:33 -0400 (AST) Received: from morework.geizhals.at (home.geizhals.at [213.229.14.34]) by svr1.postgresql.org (Postfix) with ESMTP id 291B5D1B4D2 for ; Thu, 12 Feb 2004 21:01:29 -0400 (AST) Received: from localhost (morework [127.0.0.1]) by morework.geizhals.at (Postfix) with ESMTP id C5B8052413B for ; Fri, 13 Feb 2004 02:01:29 +0100 (CET) Received: from morework.geizhals.at ([127.0.0.1]) by localhost (morework [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 16427-09 for ; Fri, 13 Feb 2004 02:01:29 +0100 (CET) Received: from geizhals.at (unknown [10.0.0.33]) by morework.geizhals.at (Postfix) with ESMTP id 81FF7524138 for ; Fri, 13 Feb 2004 02:01:29 +0100 (CET) Message-ID: <402C213A.4030105@geizhals.at> Date: Fri, 13 Feb 2004 01:58:34 +0100 From: "Marinos J. Yannikos" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031204 Thunderbird/0.4RC2 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: optimization ideas for frequent, large(ish) updates in frequently accessed DB? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p5 at geizhals.at X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/152 X-Sequence-Number: 5676 Hi, one of our tables has to be updated frequently, but concurrently running SELECT-queries must also have low latency times (it's being accessed through a web interface). I'm looking for ideas that might improve the interactive performance of the system, without slowing down the updates too much. Here are the characteristics of the table and its use: - approx. 2 million rows - approx. 4-5 million rows per day are replaced in short bursts of 1-200k rows (average ~3000 rows per update) - the table needs 6 indexes (not all indexes are used all the time, but keeping them all the time slows the system down less than re-creating some of them just before they're needed and dropping them afterwards) - an "update" means that 1-200k rows with a common value in a particular field are replaced with an arbitrary number of new rows (with the same value in that field), i.e.: begin transaction; delete from t where id=5; insert into t (id,...) values (5,...); ... [1-200k rows] end; The problem is, that a large update of this kind can delay SELECT queries running in parallel for several seconds, so the web interface used by several people will be unusable for a short while. Currently, I'm using temporary tables: create table xyz as select * from t limit 0; insert into xyz ... ... begin transaction; delete from t where id=5; insert into t select * from xyz; end; drop table xyz; This is slightly faster than inserting directly into t (and probably faster than using COPY, even though using that might reduce the overall load on the database). What other possibilities are there, other than splitting up the 15 columns of that table into several smaller tables, which is something I'd like to avoid? Would replication help? (I doubt it, but haven't tried it yet...) Writing to one table (without indexes) and creating indexes and renaming it to the "read table" periodically in a double buffering-like fashion wouldn't work either(?), since the views and triggers would have to be re-created every time as well and other problems might arise. The postgresql.conf options are already reasonably tweaked for performance(IMHO), but perhaps some settings are particularly critical: shared_buffers=100000 (I tried many values, this seems to work well for us - 12GB RAM) wal_buffers=500 sort_mem=800000 checkpoint_segments=16 effective_cache_size=1000000 etc. Any help/suggestions would be greatly appreciated... Even if it's something like "you need a faster db box, there's no other way" ;-) Regards, Marinos From pgsql-performance-owner@postgresql.org Fri Feb 13 02:29:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 02739D1D5B0 for ; Fri, 13 Feb 2004 06:29:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 55725-07 for ; Fri, 13 Feb 2004 02:29:34 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 3660BD1D597 for ; Fri, 13 Feb 2004 02:29:33 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4419577; Thu, 12 Feb 2004 22:30:37 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Marinos J. Yannikos" , pgsql-performance@postgresql.org Subject: Re: optimization ideas for frequent, large(ish) updates in frequently accessed DB? Date: Thu, 12 Feb 2004 22:28:41 -0800 User-Agent: KMail/1.5.4 References: <402C213A.4030105@geizhals.at> In-Reply-To: <402C213A.4030105@geizhals.at> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402122228.41680.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/153 X-Sequence-Number: 5677 Marinos, > shared_buffers=100000 > (I tried many values, this seems to work well for us - 12GB RAM) > wal_buffers=500 > sort_mem=800000 > checkpoint_segments=16 > effective_cache_size=1000000 > etc. 800MB for sort mem? Are you sure you typed that correctly? You must be counting on not having a lot of concurrent queries. It sure will speed up index updating, though! I think you might do well to experiment with using the checkpoint_delay and checkpoint_sibilings settings in order to get more efficient batch processing of updates while selects are going on. I would also suggest increasing checkpoint segments as much as your disk space will allow; I know one reporting database I run that does batch loads is using 128 (which is about a gig of disk, I think). What have you set max_fsm_relations and max_fsm_pages to? The latter should be very high for you, like 10,000,000 For that matter, what *version* of PostgreSQL are you running? Also, make sure that your tables get vaccuumed regularly. > Any help/suggestions would be greatly appreciated... Even if it's > something like "you need a faster db box, there's no other way" ;-) Well, a battery-backed RAID controller with a fast cache would certainly help. You'll also be glad to know that a *lot* of the improvements in the upcoming PostgreSQL 7.5 are aimed at giving better peformance on large, high-activity databases like yours. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Feb 13 05:25:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 97C0CD1CACB for ; Fri, 13 Feb 2004 09:25:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 98480-09 for ; Fri, 13 Feb 2004 05:25:35 -0400 (AST) Received: from email05.aon.at (WARSL402PIP4.highway.telekom.at [195.3.96.79]) by svr1.postgresql.org (Postfix) with SMTP id 2441DD1B8CE for ; Fri, 13 Feb 2004 05:25:33 -0400 (AST) Received: (qmail 575400 invoked from network); 13 Feb 2004 09:25:33 -0000 Received: from m160p026.dipool.highway.telekom.at (HELO PASCAL) ([62.46.9.250]) (envelope-sender ) by qmail5rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 13 Feb 2004 09:25:33 -0000 From: Manfred Koizar To: "Marinos J. Yannikos" Cc: pgsql-performance@postgresql.org Subject: Re: optimization ideas for frequent, large(ish) updates in frequently accessed DB? Date: Fri, 13 Feb 2004 10:26:16 +0100 Message-ID: References: <402C213A.4030105@geizhals.at> In-Reply-To: <402C213A.4030105@geizhals.at> X-Mailer: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/154 X-Sequence-Number: 5678 On Fri, 13 Feb 2004 01:58:34 +0100, "Marinos J. Yannikos" wrote: >I'm looking for ideas that might improve the interactive performance of >the system, without slowing down the updates too much. IOW, you could accept slower updates. Did you actually try and throttle down the insert rate? > Here are the >characteristics of the table and its use: > >- approx. 2 million rows Doesn't sound worrying. What's the min/max/average size of these rows? How large is this table? SELECT relpages FROM pg_class WHERE relname='...'; What else is in this database, how many tables, how large is the database (du $PGDATA)? >- approx. 4-5 million rows per day are replaced in short bursts of >1-200k rows (average ~3000 rows per update) How often do you VACUUM [ANALYSE]? >- the table needs 6 indexes (not all indexes are used all the time, but >keeping them all the time slows the system down less than re-creating >some of them just before they're needed and dropping them afterwards) I agree. >- an "update" means that 1-200k rows with a common value in a particular >field are replaced with an arbitrary number of new rows (with the same >value in that field), i.e.: > >begin transaction; > delete from t where id=5; > insert into t (id,...) values (5,...); > ... [1-200k rows] >end; This is a wide variation in the number of rows. You told us the average batch size is 3000. Is this also a *typical* batch size? And what is the number of rows where you start to get the feeling that it slows down other sessions? Where do the new values come from? I don't think they are typed in :-) Do they come from external sources or from the same database? If the latter, INSERT INTO ... SELECT ... might help. >The problem is, that a large update of this kind can delay SELECT >queries running in parallel for several seconds, so the web interface >used by several people will be unusable for a short while. Silly question: By SELECT you mean pure SELECT transactions and not some transaction that *mostly* reads from the database? I mean, you are sure your SELECT queries are slowed down and not blocked by the "updates". Show us the EXPLAIN ANALYSE output for the same SELECT, once when it is fast and once when it is slow. BTW, what is fast and what is slow? >Currently, I'm using temporary tables: > [...] >This is slightly faster than inserting directly into t (and probably >faster than using COPY, even though using that might reduce the overall >load on the database). You might try using a prepared INSERT statement or COPY. >shared_buffers=100000 >(I tried many values, this seems to work well for us - 12GB RAM) >wal_buffers=500 >sort_mem=800000 >checkpoint_segments=16 >effective_cache_size=1000000 See Josh's comments. >Any help/suggestions would be greatly appreciated... Even if it's >something like "you need a faster db box, there's no other way" ;-) We have to find out, what is the bottleneck. Tell us about your environment (hardware, OS, ...). Run top and/or vmstat and look for significant differences between times of normal processing and slow phases. Post top/vmstat output here if you need help. Servus Manfred From pgsql-performance-owner@postgresql.org Fri Feb 13 08:39:00 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DF99DD1D66C for ; Fri, 13 Feb 2004 12:38:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 64605-02 for ; Fri, 13 Feb 2004 08:38:59 -0400 (AST) Received: from fep03-mail.bloor.is.net.cable.rogers.com (fep03-mail.bloor.is.net.cable.rogers.com [66.185.86.73]) by svr1.postgresql.org (Postfix) with ESMTP id 8B243D1D642 for ; Fri, 13 Feb 2004 08:38:55 -0400 (AST) Received: from phlogiston.dydns.org ([65.49.121.67]) by fep03-mail.bloor.is.net.cable.rogers.com (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id <20040213123858.OLSU189272.fep03-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> for ; Fri, 13 Feb 2004 07:38:58 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id E85173F3A; Fri, 13 Feb 2004 07:38:57 -0500 (EST) Date: Fri, 13 Feb 2004 07:38:57 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Disappointing performance in db migrated from MS SQL Server Message-ID: <20040213123857.GF2222@phlogiston.dyndns.org> Mail-Followup-To: pgsql-performance@postgresql.org References: <200402121905.i1CJ5XW13096@candle.pha.pa.us> <200402121719.27666.chris@ruprecht.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200402121719.27666.chris@ruprecht.org> User-Agent: Mutt/1.5.4i X-Authentication-Info: Submitted using SMTP AUTH LOGIN at fep03-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] using ID at Fri, 13 Feb 2004 07:38:58 -0500 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/155 X-Sequence-Number: 5679 On Thu, Feb 12, 2004 at 05:19:27PM -0500, Chris Ruprecht wrote: > what he's doing, this might be a bottleneck. I don't like the virtual memory > strategy of Linux too much and would rather increase this to 1 - 2 GB for the > Postgres DB - Specially since he's not running anything else on the machine > and he has 4 GB to play with. Have you ever had luck with 2G of shared memory? When I have tried that, the system is very fast initially, and gradually slows to molasses-like speed. My hypothesis is that the cache-lookup logic isn't that smart, and so is inefficient either when using the cache or when doing cache maintenance. A -- Andrew Sullivan From pgsql-performance-owner@postgresql.org Fri Feb 13 11:20:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5AB58D1D298 for ; Fri, 13 Feb 2004 15:20:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 18706-08 for ; Fri, 13 Feb 2004 11:20:47 -0400 (AST) Received: from email01.aon.at (WARSL402PIP8.highway.telekom.at [195.3.96.97]) by svr1.postgresql.org (Postfix) with SMTP id D4390D1D2F7 for ; Fri, 13 Feb 2004 11:20:42 -0400 (AST) Received: (qmail 91558 invoked from network); 13 Feb 2004 15:20:45 -0000 Received: from m149p030.dipool.highway.telekom.at (HELO PASCAL) ([62.46.8.158]) (envelope-sender ) by qmail1rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 13 Feb 2004 15:20:45 -0000 From: Manfred Koizar To: "Marinos J. Yannikos" Cc: pgsql-performance@postgresql.org Subject: Re: optimization ideas for frequent, large(ish) updates in frequently accessed DB? Date: Fri, 13 Feb 2004 16:21:29 +0100 Message-ID: <2aop205msqcfhpgr1su0fvkm99nolq7t77@email.aon.at> References: <402C213A.4030105@geizhals.at> In-Reply-To: <402C213A.4030105@geizhals.at> X-Mailer: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/156 X-Sequence-Number: 5680 Marinos, while you are busy answering my first set of questions :-), here is an idea that might help even out resource consumption. On Fri, 13 Feb 2004 01:58:34 +0100, "Marinos J. Yannikos" wrote: >begin transaction; > delete from t where id=5; > insert into t (id,...) values (5,...); > ... [1-200k rows] >end; > >The problem is, that a large update of this kind can delay SELECT >queries running in parallel for several seconds, so the web interface >used by several people will be unusable for a short while. CREATE TABLE idmap ( internalid int NOT NULL PRIMARY KEY, visibleid int NOT NULL, active bool NOT NULL ); CREATE INDEX ipmap_visible ON idmap(visibleid); Populate this table with INSERT INTO idmap SELECT id, id, true FROM t; Change SELECT ... FROM t WHERE t.id = 5; to SELECT ... FROM t INNER JOIN idmap ON (idmap.internalid = t.id AND idmap.active) WHERE idmap.visibleid = 5; When you have to replace the rows in t for id=5, start by INSERT INTO idmap VALUES (12345, 5, false); Then repeatedly INSERT INTO t (id, ...) VALUES (12345, ...); at a rate as slow as you can accept. You don't have to wrap all INSERTs into a single transaction, but batching together a few hundred to a few thousand INSERTs will improve performance. When all the new values are in the database, you switch to the new id in one short transaction: BEGIN; UPDATE idmap SET active = false WHERE visibleid = 5 AND active; UPDATE idmap SET active = true WHERE internalid = 12345; COMMIT; Do the cleanup in off-peak hours (pseudocode): FOR delid IN (SELECT internalid FROM idmap WHERE NOT active) BEGIN DELETE FROM t WHERE id = delid; DELETE FROM idmap WHERE internalid = delid; END; VACUUM ANALYSE t; VACUUM ANALYSE idmap; To prevent this cleanup from interfering with INSERTs in progress, you might want to add a "beinginserted" flag to idmap. HTH. Servus Manfred From pgsql-performance-owner@postgresql.org Fri Feb 13 12:46:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1EE21D1D489 for ; Fri, 13 Feb 2004 16:46:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 47829-07 for ; Fri, 13 Feb 2004 12:46:28 -0400 (AST) Received: from email02.aon.at (WARSL402PIP7.highway.telekom.at [195.3.96.94]) by svr1.postgresql.org (Postfix) with SMTP id DB109D1C7F7 for ; Fri, 13 Feb 2004 12:46:19 -0400 (AST) Received: (qmail 581582 invoked from network); 13 Feb 2004 16:46:23 -0000 Received: from m149p030.dipool.highway.telekom.at (HELO PASCAL) ([62.46.8.158]) (envelope-sender ) by qmail2rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 13 Feb 2004 16:46:23 -0000 From: Manfred Koizar To: "Marinos J. Yannikos" , pgsql-performance@postgresql.org Subject: Re: optimization ideas for frequent, large(ish) updates in frequently accessed DB? Date: Fri, 13 Feb 2004 17:47:07 +0100 Message-ID: References: <402C213A.4030105@geizhals.at> <2aop205msqcfhpgr1su0fvkm99nolq7t77@email.aon.at> In-Reply-To: <2aop205msqcfhpgr1su0fvkm99nolq7t77@email.aon.at> X-Mailer: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/157 X-Sequence-Number: 5681 On Fri, 13 Feb 2004 16:21:29 +0100, I wrote: >Populate this table with > INSERT INTO idmap > SELECT id, id, true > FROM t; This should be INSERT INTO idmap SELECT DISTINCT id, id, true FROM t; Servus Manfred From pgsql-performance-owner@postgresql.org Fri Feb 13 16:57:00 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8DBAFD1D362 for ; Fri, 13 Feb 2004 20:56:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 34971-09 for ; Fri, 13 Feb 2004 16:56:57 -0400 (AST) Received: from arkanoid.comvision.com (arkanoid.comvision.com [63.108.120.12]) by svr1.postgresql.org (Postfix) with ESMTP id 27289D1D2F7 for ; Fri, 13 Feb 2004 16:56:49 -0400 (AST) Received: by arkanoid.comvision.com (Postfix, from userid 98) id 78419179EB; Fri, 13 Feb 2004 16:18:57 -0500 (EST) Received: from [63.108.121.47] (calendar.comvision.com [63.108.121.47]) by arkanoid.comvision.com (Postfix) with ESMTP id 4EAA9179FC for ; Fri, 13 Feb 2004 16:18:55 -0500 (EST) Mime-Version: 1.0 (Apple Message framework v612) In-Reply-To: <200402121226.33823.josh@agliodbs.com> References: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> <200402121226.33823.josh@agliodbs.com> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <268071B6-5E67-11D8-AB22-0030658FB514@comvision.com> Content-Transfer-Encoding: 7bit From: Leon Out Subject: Re: Disappointing performance in db migrated from MS SQL Server Date: Fri, 13 Feb 2004 15:56:52 -0500 To: pgsql-performance@postgresql.org X-Mailer: Apple Mail (2.612) X-Sanitizer: Comvision mail filter X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/158 X-Sequence-Number: 5682 All, thanks for your suggestions. I've tweaked my configuration, and I think I've squeezed a little more performance out of the setup. I also tried running several tests simultaneously against postgres and SQL Server, and postgres did much better with the heavy load. My new settings are: max_connections = 50 shared_buffers = 120000 # min 16, at least max_connections*2, 8KB each - default is 1000 sort_mem = 8000 # min 64, size in KB - default is 1024 (commented out) effective_cache_size = 375000 # typically 8KB each - default is 1000 (commented out) random_page_cost = 1 # units are one sequential page fetch cost - default is 4 (commented out) geqo = true Josh, the disks in the new system should be substantially faster than the old. Both are Ultra160 SCSI RAID 5 arrays, but the new system has 15k RPM disks, as opposed to the 10k RPM disks in the old system. On Feb 12, 2004, at 3:26 PM, Josh Berkus wrote: > Leon, > >> Hello all. I am in the midst of porting a large web application from a >> MS SQL Server backend to PostgreSQL. The migration work is basically >> complete, and we're at the testing and optimization phase of the >> project. The results so far have been disappointing, with Postgres >> performing queries in about the same time as SQL Server even though >> Postgres is running on a dedicated box with about 4 times the clock >> speed of the SQL Server box. For a chart of my results, please see >> http://leonout.com/pggraph.pdf for a graph of some test results. > > Your settings look ok to start, but we'll probably want to tune them > further. > Can you post some details of the tests? Include: > > 1) the query > 2) the EXPLAIN ANALYZE results of the query > 3) Whether you ran the test as the only connection, or whether you > tested > multi-user load. > > The last is fairly important for a SQL Server vs. PostgreSQL test; SQL > Server > is basically a single-user-database, so like MySQL it appears very > fast until > you get a bunch o' users on it. > > Finally, for most queries the disk I/O and the RAM are more important > than the > CPU clock speed. From the looks of it, you upgraded the CPU + RAM, > but did > downgraded the disk array as far as database writes are concered; not a > terrible effective way to gain performance on your hardware. > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco > From pgsql-performance-owner@postgresql.org Fri Feb 13 17:03:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A5C98D1C515 for ; Fri, 13 Feb 2004 21:03:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 46658-01 for ; Fri, 13 Feb 2004 17:03:27 -0400 (AST) Received: from arkanoid.comvision.com (arkanoid.comvision.com [63.108.120.12]) by svr1.postgresql.org (Postfix) with ESMTP id A5B0FD1B57C for ; Fri, 13 Feb 2004 17:03:19 -0400 (AST) Received: by arkanoid.comvision.com (Postfix, from userid 98) id DD1BF179FE; Fri, 13 Feb 2004 16:25:28 -0500 (EST) Received: from [63.108.121.47] (calendar.comvision.com [63.108.121.47]) by arkanoid.comvision.com (Postfix) with ESMTP id 5D1A6179EB for ; Fri, 13 Feb 2004 16:25:27 -0500 (EST) Mime-Version: 1.0 (Apple Message framework v612) To: pgsql-performance@postgresql.org Message-Id: <103862F9-5E68-11D8-AB22-0030658FB514@comvision.com> Content-Type: multipart/alternative; boundary=Apple-Mail-5--385242844 From: Leon Out Subject: Lengthy pg_restore and high iowait? Date: Fri, 13 Feb 2004 16:03:24 -0500 X-Mailer: Apple Mail (2.612) X-Sanitizer: Comvision mail filter X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/159 X-Sequence-Number: 5683 --Apple-Mail-5--385242844 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Hello again. I'm setting up a backup routine for my new db server. As part of my testing, I'm attempting to pg_restore a pg_dump'ed backup of my database. The database is about 4.3 GB, and the dump file is about 100 MB. I first did a schema-only restore, then started a data-only restore with --disable-triggers to get around the referential integrity issues of reloading the data. The data-only restore has been running for a couple of hours now, and I'm seeing high iowait numbers in top. 15:57:58 up 23:55, 2 users, load average: 2.04, 2.07, 2.01 60 processes: 57 sleeping, 3 running, 0 zombie, 0 stopped CPU states: cpu user nice system irq softirq iowait idle total 4.0% 0.0% 0.7% 0.0% 0.0% 43.5% 51.6% cpu00 0.0% 0.0% 0.3% 0.0% 0.0% 84.8% 14.7% cpu01 15.7% 0.0% 1.7% 0.0% 0.0% 2.7% 79.6% cpu02 0.1% 0.0% 0.7% 0.0% 0.0% 84.2% 14.7% cpu03 0.2% 0.0% 0.0% 0.0% 0.0% 2.4% 97.4% Mem: 3869544k av, 3849280k used, 20264k free, 0k shrd, 110544k buff 1297452k actv, 2298928k in_d, 57732k in_c Swap: 2040244k av, 0k used, 2040244k free 3576684k cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND 8366 postgres 16 0 954M 954M 952M R 4.3 25.2 21:58 1 postmaster 9282 postgres 15 0 0 0 0 RW 0.2 0.0 0:00 2 postmaster 1 root 15 0 496 496 444 S 0.0 0.0 0:05 3 init Questions: * Do these iowait numbers indicate a problem with my setup? * Does anyone have a good method for disabling indexes before a restore and restoring them afterwards? I've spent some time writing scripts to do this, but I have yet to come up with drop/recreate solution that returns my database to the same pre-drop state. Thanks in advance! Leon --Apple-Mail-5--385242844 Content-Type: text/enriched; charset="US-ASCII"; name="unnamed.txt" Content-Transfer-Encoding: 7bit Courier NewHello again. I'm setting up a backup routine for my new db server. As part of my testing, I'm attempting to pg_restore a pg_dump'ed backup of my database. The database is about 4.3 GB, and the dump file is about 100 MB. I first did a schema-only restore, then started a data-only restore with --disable-triggers to get around the referential integrity issues of reloading the data. The data-only restore has been running for a couple of hours now, and I'm seeing high iowait numbers in top. 15:57:58 up 23:55, 2 users, load average: 2.04, 2.07, 2.01 60 processes: 57 sleeping, 3 running, 0 zombie, 0 stopped CPU states: cpu user nice system irq softirq iowait idle total 4.0% 0.0% 0.7% 0.0% 0.0% 43.5% 51.6% cpu00 0.0% 0.0% 0.3% 0.0% 0.0% 84.8% 14.7% cpu01 15.7% 0.0% 1.7% 0.0% 0.0% 2.7% 79.6% cpu02 0.1% 0.0% 0.7% 0.0% 0.0% 84.2% 14.7% cpu03 0.2% 0.0% 0.0% 0.0% 0.0% 2.4% 97.4% Mem: 3869544k av, 3849280k used, 20264k free, 0k shrd, 110544k buff 1297452k actv, 2298928k in_d, 57732k in_c Swap: 2040244k av, 0k used, 2040244k free 3576684k cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND 8366 postgres 16 0 954M 954M 952M R 4.3 25.2 21:58 1 postmaster 9282 postgres 15 0 0 0 0 RW 0.2 0.0 0:00 2 postmaster 1 root 15 0 496 496 444 S 0.0 0.0 0:05 3 init Questions: * Do these iowait numbers indicate a problem with my setup? * Does anyone have a good method for disabling indexes before a restore and restoring them afterwards? I've spent some time writing scripts to do this, but I have yet to come up with drop/recreate solution that returns my database to the same pre-drop state. Thanks in advance! Leon --Apple-Mail-5--385242844-- From pgsql-performance-owner@postgresql.org Fri Feb 13 18:00:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E4369D1DA69 for ; Fri, 13 Feb 2004 22:00:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 61629-05 for ; Fri, 13 Feb 2004 18:00:19 -0400 (AST) 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 8E924D1D5B0 for ; Fri, 13 Feb 2004 18:00:11 -0400 (AST) Received: by bayswater1.ymogen.net (Postfix, from userid 99) id 9AA069ACAF; Fri, 13 Feb 2004 22:00:14 +0000 (GMT) Received: from 82.68.132.233 (SquirrelMail authenticated user matt@ymogen.net) by webmail.ymogen.com with HTTP; Fri, 13 Feb 2004 22:00:14 -0000 (GMT) Message-ID: <1980.82.68.132.233.1076709614.squirrel@webmail.ymogen.com> In-Reply-To: <268071B6-5E67-11D8-AB22-0030658FB514@comvision.com> References: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> <200402121226.33823.josh@agliodbs.com> <268071B6-5E67-11D8-AB22-0030658FB514@comvision.com> Date: Fri, 13 Feb 2004 22:00:14 -0000 (GMT) Subject: Re: Disappointing performance in db migrated from MS SQL From: matt@ymogen.net To: "Leon Out" Cc: pgsql-performance@postgresql.org User-Agent: SquirrelMail/1.4.2-0.1.7.x MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/160 X-Sequence-Number: 5684 > Josh, the disks in the new system should be substantially faster than > the old. Both are Ultra160 SCSI RAID 5 arrays, but the new system has > 15k RPM disks, as opposed to the 10k RPM disks in the old system. Spindle speed does not correlate with 'throughput' in any easy way. What controllers are you using for these disks? From pgsql-performance-owner@postgresql.org Fri Feb 13 18:01:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B5C20D1C515 for ; Fri, 13 Feb 2004 22:01:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 59279-09 for ; Fri, 13 Feb 2004 18:01:43 -0400 (AST) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 08758D1B911 for ; Fri, 13 Feb 2004 18:01:36 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id E7B133EA6 for ; Fri, 13 Feb 2004 17:01:42 -0500 (EST) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 40596-04-3 for ; Fri, 13 Feb 2004 17:01:42 -0500 (EST) Received: from lorax.kcilink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 49CDA3E7C for ; Fri, 13 Feb 2004 17:01:42 -0500 (EST) Received: (from news@localhost) by lorax.kcilink.com (8.12.9p2/8.12.9/Submit) id i1DM1gFm012303 for pgsql-performance@postgresql.org; Fri, 13 Feb 2004 17:01:42 -0500 (EST) (envelope-from news) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: Disappointing performance in db migrated from MS SQL Server Date: Fri, 13 Feb 2004 17:01:42 -0500 Organization: Khera Communications, Inc., Rockville, MD Lines: 15 Message-ID: References: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> <200402121226.33823.josh@agliodbs.com> <268071B6-5E67-11D8-AB22-0030658FB514@comvision.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1076709702 89830 65.205.34.180 (13 Feb 2004 22:01:42 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Fri, 13 Feb 2004 22:01:42 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, berkeley-unix) Cancel-Lock: sha1:6b2/kthBaFTLRYXsmBr/ST8hBog= X-Virus-Scanned: by amavisd-new at kcilink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/161 X-Sequence-Number: 5685 >>>>> "LO" == Leon Out writes: LO> Josh, the disks in the new system should be substantially faster than LO> the old. Both are Ultra160 SCSI RAID 5 arrays, but the new system has LO> 15k RPM disks, as opposed to the 10k RPM disks in the old system. If you've got the time, try making your 5 disk array into a RAID10 plus one spare. I found that with that few disks, RAID10 was a better performer for an even mix of read/write to the DB. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-301-869-4449 x806 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Fri Feb 13 18:03:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 022C5D1CACD for ; Fri, 13 Feb 2004 22:03:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 62306-05 for ; Fri, 13 Feb 2004 18:03:30 -0400 (AST) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 30EDDD1CAE4 for ; Fri, 13 Feb 2004 18:03:23 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id F1AF13EB8 for ; Fri, 13 Feb 2004 17:03:30 -0500 (EST) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 40596-04-5 for ; Fri, 13 Feb 2004 17:03:30 -0500 (EST) Received: from lorax.kcilink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 626B43EA6 for ; Fri, 13 Feb 2004 17:03:30 -0500 (EST) Received: (from news@localhost) by lorax.kcilink.com (8.12.9p2/8.12.9/Submit) id i1DM3Uge028149 for pgsql-performance@postgresql.org; Fri, 13 Feb 2004 17:03:30 -0500 (EST) (envelope-from news) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: Disappointing performance in db migrated from MS SQL Server Date: Fri, 13 Feb 2004 17:03:30 -0500 Organization: Khera Communications, Inc., Rockville, MD Lines: 19 Message-ID: References: <70CC4F08-5D89-11D8-AB22-0030658FB514@comvision.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1076709810 89830 65.205.34.180 (13 Feb 2004 22:03:30 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Fri, 13 Feb 2004 22:03:30 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, berkeley-unix) Cancel-Lock: sha1:yxxzWRyWucei5ZhGiiL/jRkyIB8= X-Virus-Scanned: by amavisd-new at kcilink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/162 X-Sequence-Number: 5686 >>>>> "LO" == Leon Out writes: LO> project. The results so far have been disappointing, with Postgres LO> performing queries in about the same time as SQL Server even though LO> Postgres is running on a dedicated box with about 4 times the clock LO> speed of the SQL Server box. For a chart of my results, please see LO> http://leonout.com/pggraph.pdf for a graph of some test results. Are you using transactions liberally? If you have large groups of inserts/updates, putting them inside transactions buys you a lot of improvement by batching the writes to the WAL. Also, increase your checkpoint_segments if you do a lot of writes. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-301-869-4449 x806 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Fri Feb 13 23:38:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 04767D1B4E1 for ; Sat, 14 Feb 2004 03:38:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 36738-01 for ; Fri, 13 Feb 2004 23:38:03 -0400 (AST) Received: from trade-india.com (unknown [61.16.154.82]) by svr1.postgresql.org (Postfix) with SMTP id 1431DD1C9CF for ; Fri, 13 Feb 2004 23:37:52 -0400 (AST) Received: (qmail 4524 invoked from network); 14 Feb 2004 03:39:01 -0000 Received: from system66.trade-india-local.com (HELO trade-india.com) (192.168.0.66) by system66.trade-india-local.com with SMTP; 14 Feb 2004 03:39:01 -0000 Message-ID: <402D9855.2020605@trade-india.com> Date: Sat, 14 Feb 2004 09:09:01 +0530 From: Rajesh Kumar Mallah Organization: Infocom Network Limited User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: slow GIST index creation Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/163 X-Sequence-Number: 5687 Greetings! Why does creation of gist indexes takes significantly more time than normal btree index. Can any configuration changes lead to faster index creation? query: CREATE INDEX co_name_index_idx ON profiles USING gist (co_name_index public.gist_txtidx_ops); regds mallah. From pgsql-performance-owner@postgresql.org Sat Feb 14 22:01:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E54B4D1D8AE for ; Sun, 15 Feb 2004 02:01:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 84048-10 for ; Sat, 14 Feb 2004 22:01:00 -0400 (AST) Received: from morework.geizhals.at (home.geizhals.at [213.229.14.34]) by svr1.postgresql.org (Postfix) with ESMTP id 5F0B1D1CA5F for ; Sat, 14 Feb 2004 22:00:57 -0400 (AST) Received: from localhost (morework [127.0.0.1]) by morework.geizhals.at (Postfix) with ESMTP id 6756B52413D; Sun, 15 Feb 2004 03:00:43 +0100 (CET) Received: from morework.geizhals.at ([127.0.0.1]) by localhost (morework [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01211-08; Sun, 15 Feb 2004 03:00:43 +0100 (CET) Received: from geizhals.at (chello080110242194.117.11.tuwien.teleweb.at [80.110.242.194]) by morework.geizhals.at (Postfix) with ESMTP id 13AA152413A; Sun, 15 Feb 2004 03:00:36 +0100 (CET) Message-ID: <402ED348.7000800@geizhals.at> Date: Sun, 15 Feb 2004 03:02:48 +0100 From: "Marinos J. Yannikos" User-Agent: Mozilla Thunderbird 0.5b (Windows/20040201) X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org Subject: Re: optimization ideas for frequent, large(ish) updates References: <402C213A.4030105@geizhals.at> <200402122228.41680.josh@agliodbs.com> In-Reply-To: <200402122228.41680.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p5 at geizhals.at X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/164 X-Sequence-Number: 5688 Josh Berkus wrote: > 800MB for sort mem? Are you sure you typed that correctly? You must be > counting on not having a lot of concurrent queries. It sure will speed up > index updating, though! 800MB is correct, yes... There are usually only 10-30 postgres processes active (imagine 5-10 people working on the web front-end while cron jobs access the db occasionally). Very few queries can use such large amounts of memory for sorting, but they do exist. > I think you might do well to experiment with using the checkpoint_delay and > checkpoint_sibilings settings in order to get more efficient batch processing > of updates while selects are going on. [commit_*?] I thought that could improve only concurrent transactions... > What have you set max_fsm_relations and max_fsm_pages to? The latter should > be very high for you, like 10,000,000 good guess ;-) the former is set to 10,000 (I'm not sure how useful this is for those temporary tables) > For that matter, what *version* of PostgreSQL are you running? 7.4.1 > Also, make sure that your tables get vaccuumed regularly. There is a noticeable difference between a properly vacuumed db (nightly "vacuum full") and a non-vacuumed one and people will start complaining immediately if something goes wrong there... > Well, a battery-backed RAID controller with a fast cache would certainly help. http://www.lsilogic.com/products/ultra320_scsi_megaraid_storage_adapters/320x4128t.html (RAID-5 with 9 15k rpm drives; at a hindsight, perhaps we should have tried a 0+1) > You'll also be glad to know that a *lot* of the improvements in the upcoming > PostgreSQL 7.5 are aimed at giving better peformance on large, high-activity > databases like yours. That's good to hear... Regards, Marinos From pgsql-performance-owner@postgresql.org Sun Feb 15 00:52:17 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EAF1BD1CA5F for ; Sun, 15 Feb 2004 04:52:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 12502-05 for ; Sun, 15 Feb 2004 00:52:20 -0400 (AST) Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) by svr1.postgresql.org (Postfix) with ESMTP id 17A3AD1C9FB for ; Sun, 15 Feb 2004 00:52:14 -0400 (AST) Received: from [203.221.247.244] (helo=familyhealth.com.au) by relay01.kbs.net.au with esmtp (Exim 3.36 #2) id 1AsEFu-0002aj-00; Sun, 15 Feb 2004 15:51:47 +1100 Message-ID: <402EFADD.4040100@familyhealth.com.au> Date: Sun, 15 Feb 2004 12:51:41 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Marinos J. Yannikos" Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: optimization ideas for frequent, large(ish) updates References: <402C213A.4030105@geizhals.at> <200402122228.41680.josh@agliodbs.com> <402ED348.7000800@geizhals.at> In-Reply-To: <402ED348.7000800@geizhals.at> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/165 X-Sequence-Number: 5689 > 800MB is correct, yes... There are usually only 10-30 postgres processes > active (imagine 5-10 people working on the web front-end while cron > jobs access the db occasionally). Very few queries can use such large > amounts of memory for sorting, but they do exist. But remember that means that if you have 4 people doign 2 sorts each at the same time, postgres will use 6.4GB RAM maximum. The sort_mem parameter means that if a sort is larger than the max, it will be done in disk swap. Chris From pgsql-performance-owner@postgresql.org Sun Feb 15 14:21:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 37243D1D9E6 for ; Sun, 15 Feb 2004 17:20:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 37290-01 for ; Sun, 15 Feb 2004 13:20:40 -0400 (AST) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 672BED1CAF3 for ; Sun, 15 Feb 2004 13:20:39 -0400 (AST) Received: (qmail 35716 invoked from network); 15 Feb 2004 17:20:43 -0000 Received: from unknown (HELO ?192.168.0.6?) (10.10.10.177) by 10.10.10.10 with SMTP; 15 Feb 2004 17:20:43 -0000 In-Reply-To: <402ED348.7000800@geizhals.at> References: <402C213A.4030105@geizhals.at> <200402122228.41680.josh@agliodbs.com> <402ED348.7000800@geizhals.at> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <460CEC02-5FDB-11D8-8142-000D9366F0C4@jefftrout.com> Content-Transfer-Encoding: 7bit Cc: pgsql-performance@postgresql.org, josh@agliodbs.com From: Jeff Trout Subject: Re: optimization ideas for frequent, large(ish) updates Date: Sun, 15 Feb 2004 12:20:38 -0500 To: "Marinos J. Yannikos" X-Mailer: Apple Mail (2.612) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/166 X-Sequence-Number: 5690 On Feb 14, 2004, at 9:02 PM, Marinos J. Yannikos wrote: > Josh Berkus wrote: > >> 800MB for sort mem? Are you sure you typed that correctly? You >> must be counting on not having a lot of concurrent queries. It sure >> will speed up index updating, though! > > 800MB is correct, yes... There are usually only 10-30 postgres > processes active (imagine 5-10 people working on the web front-end > while cron jobs access the db occasionally). Very few queries can use > such large amounts of memory for sorting, but they do exist. > Remember that it is going to allocate 800MB per sort. It is not "you can allocate up to 800MB, so if you need 1 meg, use one meg". Some queries may end up having a few sort steps. In terms of sort mem it is best to set a system default to a nice good value for most queries. and then in your reporting queries or other ones set sort_mem for that session (set sort_mem = 800000) then only that session will use the looney sort_mem It would be interesting to know if your machine is swapping. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Sun Feb 15 22:51:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 12F0ED1BB64 for ; Mon, 16 Feb 2004 02:51:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 66365-02 for ; Sun, 15 Feb 2004 22:51:18 -0400 (AST) Received: from morework.geizhals.at (home.geizhals.at [213.229.14.34]) by svr1.postgresql.org (Postfix) with ESMTP id 3D1FFD1B4C0 for ; Sun, 15 Feb 2004 22:51:14 -0400 (AST) Received: from localhost (morework [127.0.0.1]) by morework.geizhals.at (Postfix) with ESMTP id 2034B52413D; Mon, 16 Feb 2004 03:51:00 +0100 (CET) Received: from morework.geizhals.at ([127.0.0.1]) by localhost (morework [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03201-06; Mon, 16 Feb 2004 03:50:59 +0100 (CET) Received: from geizhals.at (chello080110242194.117.11.tuwien.teleweb.at [80.110.242.194]) by morework.geizhals.at (Postfix) with ESMTP id D2E1D52413A; Mon, 16 Feb 2004 03:50:59 +0100 (CET) Message-ID: <4030309B.7090807@geizhals.at> Date: Mon, 16 Feb 2004 03:53:15 +0100 From: "Marinos J. Yannikos" User-Agent: Mozilla Thunderbird 0.5b (Windows/20040201) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jeff Trout Cc: pgsql-performance@postgresql.org Subject: Re: optimization ideas for frequent, large(ish) updates References: <402C213A.4030105@geizhals.at> <200402122228.41680.josh@agliodbs.com> <402ED348.7000800@geizhals.at> <460CEC02-5FDB-11D8-8142-000D9366F0C4@jefftrout.com> In-Reply-To: <460CEC02-5FDB-11D8-8142-000D9366F0C4@jefftrout.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p5 at geizhals.at X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/168 X-Sequence-Number: 5692 Jeff Trout wrote: > Remember that it is going to allocate 800MB per sort. It is not "you > can allocate up to 800MB, so if you need 1 meg, use one meg". Some > queries may end up having a few sort steps. I didn't know that it always allocates the full amount of memory specificed in the configuration (e.g. the annotated configuration guide says: "Note that for a complex query, several sorts might be running in parallel, and each one _will be allowed to use_ as much memory as this value specifies before it starts to put data into temporary files."). The individual postgres processes don't look like they're using the full amount either (but that could be because the memory isn't written to). > In terms of sort mem it is best to set a system default to a nice good > value for most queries. and then in your reporting queries or other > ones set sort_mem for that session (set sort_mem = 800000) then only > that session will use the looney sort_mem Queries from the web front-end use up to ~130MB sort memory (according to pgsql_tmp), so I set this to 150MB - thanks. > It would be interesting to know if your machine is swapping. It's not being monitored closely (other than with the occasional "top"), but it's highly unlikely: Mem: 12441864k total, 10860648k used, 1581216k free, 84552k buffers Swap: 4008176k total, 2828k used, 4005348k free, 9762628k cached (that's a typical situation - the "2828k used" are probably some rarely used processes that have lower priority than the cache ...) Regards, Marinos From pgsql-performance-owner@postgresql.org Sun Feb 15 23:28:56 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8D510D1D779 for ; Mon, 16 Feb 2004 03:28:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 78012-02 for ; Sun, 15 Feb 2004 23:28:56 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id F1536D1D643 for ; Sun, 15 Feb 2004 23:28:51 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1G3SnDn017528; Sun, 15 Feb 2004 22:28:49 -0500 (EST) To: "Marinos J. Yannikos" Cc: Jeff Trout , pgsql-performance@postgresql.org Subject: Re: optimization ideas for frequent, large(ish) updates In-reply-to: <4030309B.7090807@geizhals.at> References: <402C213A.4030105@geizhals.at> <200402122228.41680.josh@agliodbs.com> <402ED348.7000800@geizhals.at> <460CEC02-5FDB-11D8-8142-000D9366F0C4@jefftrout.com> <4030309B.7090807@geizhals.at> Comments: In-reply-to "Marinos J. Yannikos" message dated "Mon, 16 Feb 2004 03:53:15 +0100" Date: Sun, 15 Feb 2004 22:28:48 -0500 Message-ID: <17527.1076902128@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/169 X-Sequence-Number: 5693 "Marinos J. Yannikos" writes: > Jeff Trout wrote: >> Remember that it is going to allocate 800MB per sort. > I didn't know that it always allocates the full amount of memory > specificed in the configuration It doesn't ... but it could use *up to* that much before starting to spill to disk. If you are certain your sorts won't use that much, then you could set the limit lower, hm? Also keep in mind that sort_mem controls hash table size as well as sort size. The hashtable code is not nearly as accurate as the sort code about honoring the specified limit exactly. So you really oughta figure that you could need some multiple of sort_mem per active backend. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Feb 16 13:47:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2C7F1D1B456 for ; Mon, 16 Feb 2004 16:51:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 98499-07 for ; Mon, 16 Feb 2004 12:51:41 -0400 (AST) Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3DA68D1C517 for ; Mon, 16 Feb 2004 12:51:40 -0400 (AST) Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) id 1Asly7-0004fd-Q8 for pgsql-performance@postgresql.org; Mon, 16 Feb 2004 17:51:39 +0100 Received: from [195.135.143.205] (helo=[195.135.143.205]) by emma.rox.net with asmtp (Exim 4.22) id 1Asly6-0004dn-Vt for pgsql-performance@postgresql.org; Mon, 16 Feb 2004 17:51:39 +0100 Mime-Version: 1.0 (Apple Message framework v612) Content-Transfer-Encoding: 7bit Message-Id: <62A9E13D-60A0-11D8-B420-000A95A6F0DC@cluster9.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: PgSQL Performance ML From: David Teran Subject: select max(id) from aTable is very slow Date: Mon, 16 Feb 2004 17:51:37 +0100 X-Mailer: Apple Mail (2.612) X-Scanned-By: rockenstein AG X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/170 X-Sequence-Number: 5694 Hi, we have a table with about 6.000.000 rows. There is an index on a column with the name id which is an integer and serves as primary key. When we execute select max(id) from theTable; it takes about 10 seconds. Explain analyze returns: ------------------------------------------------------------------------ -------------------------------------------------------- Aggregate (cost=153635.15..153635.15 rows=1 width=4) (actual time=9738.263..9738.264 rows=1 loops=1) -> Seq Scan on job_property (cost=0.00..137667.32 rows=6387132 width=4) (actual time=0.102..7303.649 rows=6387132 loops=1) Total runtime: 9738.362 ms (3 rows) I recreated the index on column id and ran vacuum analyze job_property but this did not help. I tried to force index usage with SET ENABLE_SEQSCAN TO OFF; but the explain analyze still looks like the query is done using a seqscan. Is the speed more or less normal for a 'dual G5 with 2 GHZ and 4 GB of Ram and a SATA hd' or do i miss something? regards David From pgsql-performance-owner@postgresql.org Mon Feb 16 13:58:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5E5BBD1D25D for ; Mon, 16 Feb 2004 17:57:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 31050-01 for ; Mon, 16 Feb 2004 13:57:07 -0400 (AST) Received: from easily.co.uk (mercury0.easily.co.uk [213.161.76.90]) by svr1.postgresql.org (Postfix) with ESMTP id 0DA76D1B456 for ; Mon, 16 Feb 2004 13:57:05 -0400 (AST) Received: from [213.152.63.90] (account f4vo5dsy5djd HELO chuckie.co.uk) by easily.co.uk (CommuniGate Pro SMTP 4.1.3) with ESMTP id 49067027; Mon, 16 Feb 2004 17:56:56 +0000 Message-ID: <4031045C.2070707@chuckie.co.uk> Date: Mon, 16 Feb 2004 17:56:44 +0000 From: Nick Barr User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Teran Cc: PgSQL Performance ML Subject: Re: select max(id) from aTable is very slow References: <62A9E13D-60A0-11D8-B420-000A95A6F0DC@cluster9.com> In-Reply-To: <62A9E13D-60A0-11D8-B420-000A95A6F0DC@cluster9.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/171 X-Sequence-Number: 5695 David Teran wrote: > Hi, > > we have a table with about 6.000.000 rows. There is an index on a > column with the name id which is an integer and serves as primary key. > > When we execute select max(id) from theTable; it takes about 10 > seconds. Explain analyze returns: > > ------------------------------------------------------------------------ > -------------------------------------------------------- > Aggregate (cost=153635.15..153635.15 rows=1 width=4) (actual > time=9738.263..9738.264 rows=1 loops=1) > -> Seq Scan on job_property (cost=0.00..137667.32 rows=6387132 > width=4) (actual time=0.102..7303.649 rows=6387132 loops=1) > Total runtime: 9738.362 ms > (3 rows) > > > > I recreated the index on column id and ran vacuum analyze > job_property but this did not help. I tried to force index usage > with SET ENABLE_SEQSCAN TO OFF; but the explain analyze still looks > like the query is done using a seqscan. > > Is the speed more or less normal for a 'dual G5 with 2 GHZ and 4 GB > of Ram and a SATA hd' or do i miss something? > > regards David > > > ---------------------------(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 Try using: SELECT id FROM theTable ORDER BY is DESC LIMIT 1; Using COUNT, MAX, MIN and any aggregate function on the table of that size will always result in a sequential scan. There is currently no way around it although there are a few work arounds. See the following for more information. http://archives.postgresql.org/pgsql-performance/2004-01/msg00045.php http://archives.postgresql.org/pgsql-performance/2004-01/msg00054.php http://archives.postgresql.org/pgsql-performance/2004-01/msg00059.php HTH Nick From pgsql-performance-owner@postgresql.org Mon Feb 16 14:13:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 968E4D1CACD for ; Mon, 16 Feb 2004 18:02:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 32787-02 for ; Mon, 16 Feb 2004 14:02:30 -0400 (AST) Received: from easily.co.uk (mercury0.easily.co.uk [213.161.76.90]) by svr1.postgresql.org (Postfix) with ESMTP id 3F292D1D643 for ; Mon, 16 Feb 2004 14:02:28 -0400 (AST) Received: from [213.152.63.90] (account f4vo5dsy5djd HELO chuckie.co.uk) by easily.co.uk (CommuniGate Pro SMTP 4.1.3) with ESMTP id 49070624; Mon, 16 Feb 2004 18:02:24 +0000 Message-ID: <403105A2.9040907@chuckie.co.uk> Date: Mon, 16 Feb 2004 18:02:10 +0000 From: Nick Barr User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Nick Barr Cc: David Teran , PgSQL Performance ML Subject: Re: select max(id) from aTable is very slow References: <62A9E13D-60A0-11D8-B420-000A95A6F0DC@cluster9.com> <4031045C.2070707@chuckie.co.uk> In-Reply-To: <4031045C.2070707@chuckie.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/172 X-Sequence-Number: 5696 Nick Barr wrote: > David Teran wrote: > >> Hi, >> >> we have a table with about 6.000.000 rows. There is an index on a >> column with the name id which is an integer and serves as primary key. >> >> When we execute select max(id) from theTable; it takes about 10 >> seconds. Explain analyze returns: >> >> ------------------------------------------------------------------------ >> -------------------------------------------------------- >> Aggregate (cost=153635.15..153635.15 rows=1 width=4) (actual >> time=9738.263..9738.264 rows=1 loops=1) >> -> Seq Scan on job_property (cost=0.00..137667.32 rows=6387132 >> width=4) (actual time=0.102..7303.649 rows=6387132 loops=1) >> Total runtime: 9738.362 ms >> (3 rows) >> >> >> >> I recreated the index on column id and ran vacuum analyze >> job_property but this did not help. I tried to force index usage >> with SET ENABLE_SEQSCAN TO OFF; but the explain analyze still looks >> like the query is done using a seqscan. >> >> Is the speed more or less normal for a 'dual G5 with 2 GHZ and 4 GB >> of Ram and a SATA hd' or do i miss something? >> >> regards David >> >> >> ---------------------------(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 > > > Try using: > > SELECT id FROM theTable ORDER BY is DESC LIMIT 1; > > Using COUNT, MAX, MIN and any aggregate function on the table of that > size will always result in a sequential scan. There is currently no > way around it although there are a few work arounds. See the following > for more information. > > http://archives.postgresql.org/pgsql-performance/2004-01/msg00045.php > http://archives.postgresql.org/pgsql-performance/2004-01/msg00054.php > http://archives.postgresql.org/pgsql-performance/2004-01/msg00059.php > > HTH > > Nick > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster Oops that should be SELECT id FROM theTable ORDER BY id DESC LIMIT 1; Nick From pgsql-performance-owner@postgresql.org Mon Feb 16 14:27:38 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5EF33D1D3DC for ; Mon, 16 Feb 2004 18:15:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 34980-06 for ; Mon, 16 Feb 2004 14:15:19 -0400 (AST) Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2A2A9D1D27F for ; Mon, 16 Feb 2004 14:15:18 -0400 (AST) Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) id 1AsnH4-0004If-N6; Mon, 16 Feb 2004 19:15:18 +0100 Received: from [195.135.143.205] (helo=[195.135.143.205]) by emma.rox.net with asmtp (Exim 4.22) id 1AsnH4-0004IR-2x; Mon, 16 Feb 2004 19:15:18 +0100 In-Reply-To: <403105A2.9040907@chuckie.co.uk> References: <62A9E13D-60A0-11D8-B420-000A95A6F0DC@cluster9.com> <4031045C.2070707@chuckie.co.uk> <403105A2.9040907@chuckie.co.uk> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <125FCD10-60AC-11D8-B420-000A95A6F0DC@cluster9.com> Content-Transfer-Encoding: 7bit Cc: PgSQL Performance ML From: David Teran Subject: Re: select max(id) from aTable is very slow Date: Mon, 16 Feb 2004 19:15:16 +0100 To: Nick Barr X-Mailer: Apple Mail (2.612) X-Scanned-By: rockenstein AG X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/173 X-Sequence-Number: 5697 Hi Nick, >> Try using: >> >> SELECT id FROM theTable ORDER BY is DESC LIMIT 1; >> >> Using COUNT, MAX, MIN and any aggregate function on the table of that >> size will always result in a sequential scan. There is currently no >> way around it although there are a few work arounds. See the >> following for more information. >> >> http://archives.postgresql.org/pgsql-performance/2004-01/msg00045.php >> http://archives.postgresql.org/pgsql-performance/2004-01/msg00054.php >> http://archives.postgresql.org/pgsql-performance/2004-01/msg00059.php >> thanks, that works fine! I will read the mail archive before asking such things again ;-) cheers David From pgsql-performance-owner@postgresql.org Tue Feb 17 02:35:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D5CCDD1CACD for ; Tue, 17 Feb 2004 06:35:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 31484-07 for ; Tue, 17 Feb 2004 02:35:24 -0400 (AST) Received: from ns2.khi.wol.net.pk (ns2.khi.wol.net.pk [202.154.255.21]) by svr1.postgresql.org (Postfix) with ESMTP id 05A6AD1BB5E for ; Tue, 17 Feb 2004 02:35:22 -0400 (AST) Received: from khi.wol.net.pk (panda.khi.wol.net.pk [202.154.255.22]) by ns2.khi.wol.net.pk (8.11.6/8.10.1) with SMTP id i1H6O2u16022; Tue, 17 Feb 2004 11:24:02 +0500 (PKT) Date: Tue, 17 Feb 2004 11:24:02 +0500 (PKT) Message-Id: <200402170624.i1H6O2u16022@ns2.khi.wol.net.pk> From: "Saleem Burhani Baloch" To: pgsql-performance@postgresql.org Importance: Normal X-Mailer: VisualMail 3.0 ( http://www.minter.com.ar/visualmail ) Subject: Slow response of PostgreSQL Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/174 X-Sequence-Number: 5698 Hello, I m checking Postgresql and MS-SQl database server for our new development. On a very first query Postresql is out performed and I think it is very disappointing. My query consists on a single table only on both machines. Table Structure Table "inv_detail" Attribute | Type | Modifier --------------+-----------------------+-------------------- inv_no | integer | not null unit_id | character(4) | not null item | character varying(90) | not null qty | double precision | not null default 0 rate | double precision | not null default 0 unit | character varying(20) | not null vl_ex_stax | double precision | not null default 0 stax_prc | double precision | not null default 0 adl_stax_prc | double precision | not null default 0 package | character varying(12) | Having 440,000 Records. My Query -------- select count(*), sum(vl_ex_stax) , sum(qty) , unit from inv_detail group by unit; on both databases. PostgreSQL return result in 50 sec every time. MS-SQL return result in 2 sec every time. MS-SQL Machine ************** Athlon 600Mhz. (Unbranded) 256 MB Ram. ( 133 Mhz) 40 GB Baracude NTFS File System. Windows 2000 Server Enterprise. MS-SQL 2000 Enterprise. (Default Settings) PostgreSQL Machine ****************** P-III 600Mhz (Dell Precision 220) 256 MB Ram (RD Ram) 40 GB Baracuda Ext2 File System. RedHat 7.2 PostgreSQL 7.1.3-2 My PostgreSQL Conf is ********************* log_connections = yes syslog = 2 effective_cache_size = 327680 sort_mem = 10485760 max_connections = 64 shared_buffers = 512 wal_buffers = 1024 NOTICE: QUERY PLAN: ******************** Aggregate (cost=inf..inf rows=44000 width=28) -> Group (cost=inf..inf rows=440000 width=28) -> Sort (cost=inf..inf rows=440000 width=28) -> Seq Scan on inv_detail (cost=0.00..11747.00 rows=440000 width=28) EXPLAIN Even if I dont compare postgres with any other database server the time taken is alarmingly high. These settings are not good I know, but the Postgres result is very un-acceptable. I m looking forward for comments to change the conf setting for acceptable results. And I have two more questions : 1- How can I lock a single record so that other users can only read it. ?? 2- one user executes a query it will be process and when another user executes the same query having the same result should not again go for processing. The result should be come from the cache. Is this possible in postgres ?? Saleem pgsql-performance@postgresql.org From pgsql-performance-owner@postgresql.org Tue Feb 17 02:54:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 682C0D1D29D for ; Tue, 17 Feb 2004 06:54:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 38451-03 for ; Tue, 17 Feb 2004 02:54:06 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 0D9FCD1CACD for ; Tue, 17 Feb 2004 02:54:04 -0400 (AST) Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i1H6re4v049314; Tue, 17 Feb 2004 14:53:40 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <4031BBBC.5050002@familyhealth.com.au> Date: Tue, 17 Feb 2004 14:59:08 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Saleem Burhani Baloch Cc: pgsql-performance@postgresql.org Subject: Re: Slow response of PostgreSQL References: <200402170624.i1H6O2u16022@ns2.khi.wol.net.pk> In-Reply-To: <200402170624.i1H6O2u16022@ns2.khi.wol.net.pk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/175 X-Sequence-Number: 5699 > select count(*), sum(vl_ex_stax) , sum(qty) , unit from inv_detail group by unit; > on both databases. > > PostgreSQL return result in 50 sec every time. > MS-SQL return result in 2 sec every time. > My PostgreSQL Conf is > ********************* > log_connections = yes > syslog = 2 > effective_cache_size = 327680 > sort_mem = 10485760 > max_connections = 64 > shared_buffers = 512 > wal_buffers = 1024 This is a shockingly bad postgresql.conf. I'm not surprised you have performance problems. Change this: effective_cache_size = 4000 sort_mem = 4096 shared_buffers = 1000 wal_buffers = 8 Also, you need a LOT more RAM in your PostgreSQL machine, at least half a gig for a basic database server. > 1- How can I lock a single record so that other users can only read it. ?? You cannot do that in PostgreSQL. > 2- one user executes a query it will be process and when another user executes the same query having the same result should not again go for processing. The result should be come from the cache. Is this possible in postgres ?? No, implement it in your application. Prepared queries and stored procedures might help you here. Chris From pgsql-performance-owner@postgresql.org Tue Feb 17 03:42:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2E129D1DA97 for ; Tue, 17 Feb 2004 07:42:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 34187-10 for ; Tue, 17 Feb 2004 03:42:49 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id AF1BAD1DA30 for ; Tue, 17 Feb 2004 03:42:47 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 310B3357AB; Mon, 16 Feb 2004 23:42:48 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 2FAB2357A4; Mon, 16 Feb 2004 23:42:48 -0800 (PST) Date: Mon, 16 Feb 2004 23:42:48 -0800 (PST) From: Stephan Szabo To: Saleem Burhani Baloch Cc: pgsql-performance@postgresql.org Subject: Re: Slow response of PostgreSQL In-Reply-To: <200402170624.i1H6O2u16022@ns2.khi.wol.net.pk> Message-ID: <20040216233912.L31376@megazone.bigpanda.com> References: <200402170624.i1H6O2u16022@ns2.khi.wol.net.pk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/176 X-Sequence-Number: 5700 On Tue, 17 Feb 2004, Saleem Burhani Baloch wrote: > select count(*), sum(vl_ex_stax) , sum(qty) , unit from inv_detail group by unit; > on both databases. > PostgreSQL Machine > ****************** > P-III 600Mhz (Dell Precision 220) > 256 MB Ram (RD Ram) > 40 GB Baracuda Ext2 File System. > RedHat 7.2 > PostgreSQL 7.1.3-2 Besides the comments on the conf file already sent, 7.1.3 is many versions behind the current version and definately has some deficiencies either fully or partially corrected in later versions. All in all, I'd suggest going all the way to 7.4.1 since the hash aggregate stuff might help the queries you're running. From pgsql-performance-owner@postgresql.org Tue Feb 17 03:46:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5CB55D1CB1D for ; Tue, 17 Feb 2004 07:46:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 46984-04 for ; Tue, 17 Feb 2004 03:46:08 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 30597D1B456 for ; Tue, 17 Feb 2004 03:46:06 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1H7jfWv008002; Tue, 17 Feb 2004 02:45:41 -0500 (EST) To: "Saleem Burhani Baloch" Cc: pgsql-performance@postgresql.org Subject: Re: Slow response of PostgreSQL In-reply-to: <200402170624.i1H6O2u16022@ns2.khi.wol.net.pk> References: <200402170624.i1H6O2u16022@ns2.khi.wol.net.pk> Comments: In-reply-to "Saleem Burhani Baloch" message dated "Tue, 17 Feb 2004 11:24:02 +0500" Date: Tue, 17 Feb 2004 02:45:40 -0500 Message-ID: <8001.1077003940@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/177 X-Sequence-Number: 5701 "Saleem Burhani Baloch" writes: > PostgreSQL 7.1.3-2 Aside from the config issues Chris mentioned, I'd recommend trying a somewhat less obsolete version of Postgres. I believe the poor performance with grouped aggregates should be fixed in 7.4 and later. (Red Hat 7.2 is a bit long in the tooth as well.) regards, tom lane From pgsql-performance-owner@postgresql.org Tue Feb 17 06:36:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 113EDD1D8F3 for ; Tue, 17 Feb 2004 10:36:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 79481-09 for ; Tue, 17 Feb 2004 06:36:40 -0400 (AST) Received: from expasy-ng.isb-sib.ch (expasy-f.unige.ch [192.33.215.142]) by svr1.postgresql.org (Postfix) with ESMTP id DFC06D1BB5E for ; Tue, 17 Feb 2004 06:36:36 -0400 (AST) Received: from caliente (router.isb-sib.ch [192.33.215.254]) (authenticated bits=0) by expasy-ng.isb-sib.ch (8.12.10/8.12.8) with ESMTP id i1HAaaYn000554 for ; Tue, 17 Feb 2004 11:36:37 +0100 Message-ID: <00bf01c3f541$ead47f60$c300000a@caliente> From: "Eric Jain" To: "pgsql-performance" References: <4cbacd4cb3c2.4cb3c24cbacd@jhmimail.jhmi.edu> <87u14q6b4c.fsf@mailbox.samurai.com> Subject: Re: very large db performance question Date: Tue, 17 Feb 2004 11:36:35 +0100 Organization: Swiss Institute of Bioinformatics 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 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-sib-MailScanner-Information: Please contact the ISP for more information X-sib-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/178 X-Sequence-Number: 5702 > IMHO the size of the DB is less relevant than the query workload. For > example, if you're storying 100GB of data but only doing a single > index scan on it every 10 seconds, any modern machine with enough HD > space should be fine. I agree that the workload is likely to be the main issue in most situations. However, if your queries involve lots of counting and aggregating, your databases contains several gigabytes of data, and you are using common hardware, be prepared to wait anywhere from minutes to hours, even if you are the only user. From pgsql-performance-owner@postgresql.org Tue Feb 17 06:50:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E890BD1B511 for ; Tue, 17 Feb 2004 10:50:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 07187-01 for ; Tue, 17 Feb 2004 06:50:45 -0400 (AST) Received: from ns2.khi.wol.net.pk (ns2.khi.wol.net.pk [202.154.255.21]) by svr1.postgresql.org (Postfix) with ESMTP id 10C93D1D5E4 for ; Tue, 17 Feb 2004 06:50:41 -0400 (AST) Received: from khi.wol.net.pk (panda.khi.wol.net.pk [202.154.255.22]) by ns2.khi.wol.net.pk (8.11.6/8.10.1) with SMTP id i1HAd9u25077; Tue, 17 Feb 2004 15:39:09 +0500 (PKT) Date: Tue, 17 Feb 2004 15:39:09 +0500 (PKT) Message-Id: <200402171039.i1HAd9u25077@ns2.khi.wol.net.pk> From: "Saleem Burhani Baloch" To: "Christopher Kings-Lynne" Cc: pgsql-performance@postgresql.org Importance: Normal X-Mailer: VisualMail 3.0 ( http://www.minter.com.ar/visualmail ) Subject: Re: Slow response of PostgreSQL Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/179 X-Sequence-Number: 5703 I changed the conf as you wrote. But now the time is changed from 50 sec to 65 sec. :( I have not more 256 MB ram now. When I execute the query the Postmaster takes about 1.8 MB Postgres session takes 18 MB ram only. & psql takes 1.3 MB. After the query finishes the Postgres session reducess memeory and just uses 10 MB ram. I have a question why MS-SQL with 256 MB RAM gives result in 2 sec ?? If I have low memory Postgres should give result in 10 sec as compared to MS-SQL. Looking forward for comments & suggestions Saleem > This is a shockingly bad postgresql.conf. I'm not surprised you have > performance problems. Change this: > > effective_cache_size = 4000 > sort_mem = 4096 > shared_buffers = 1000 > wal_buffers = 8 > > Also, you need a LOT more RAM in your PostgreSQL machine, at least half > a gig for a basic database server. > > > Chris From pgsql-performance-owner@postgresql.org Tue Feb 17 07:01:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C0DC6D1D5E4 for ; Tue, 17 Feb 2004 11:01:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 03990-04 for ; Tue, 17 Feb 2004 07:01:10 -0400 (AST) Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) by svr1.postgresql.org (Postfix) with ESMTP id 52D6DD1B511 for ; Tue, 17 Feb 2004 07:01:08 -0400 (AST) Received: from concord.pspl.co.in ([202.54.11.72]:61672 helo=frodo.hserus.net) by frodo.hserus.net with asmtp (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.30 #0) id 1At2yU-000J6M-9L by authid with plain for ; Tue, 17 Feb 2004 16:31:10 +0530 Message-ID: <4031F464.2040406@frodo.hserus.net> Date: Tue, 17 Feb 2004 16:30:52 +0530 From: Shridhar Daithankar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Slow response of PostgreSQL References: <200402171039.i1HAd9u25077@ns2.khi.wol.net.pk> In-Reply-To: <200402171039.i1HAd9u25077@ns2.khi.wol.net.pk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/180 X-Sequence-Number: 5704 Saleem Burhani Baloch wrote: > I changed the conf as you wrote. But now the time is changed from 50 sec to 65 sec. :( > I have not more 256 MB ram now. > When I execute the query the > Postmaster takes about 1.8 MB > Postgres session takes 18 MB ram only. > & psql takes 1.3 MB. > > After the query finishes the > Postgres session reducess memeory and just uses 10 MB ram. Can you post explain analyze result for the query? Shridhar From pgsql-performance-owner@postgresql.org Tue Feb 17 08:38:25 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DE7BAD1D174 for ; Tue, 17 Feb 2004 12:38:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 30229-10 for ; Tue, 17 Feb 2004 08:38:22 -0400 (AST) Received: from expasy-ng.isb-sib.ch (expasy-f.unige.ch [192.33.215.142]) by svr1.postgresql.org (Postfix) with ESMTP id 8A76AD1D202 for ; Tue, 17 Feb 2004 08:38:18 -0400 (AST) Received: from caliente (router.isb-sib.ch [192.33.215.254]) (authenticated bits=0) by expasy-ng.isb-sib.ch (8.12.10/8.12.8) with ESMTP id i1HCcKYn006984 for ; Tue, 17 Feb 2004 13:38:20 +0100 Message-ID: <00ed01c3f552$ec054e80$c300000a@caliente> From: "Eric Jain" To: "pgsql-performance" Subject: UPDATE with subquery too slow Date: Tue, 17 Feb 2004 13:38:19 +0100 Organization: Swiss Institute of Bioinformatics 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 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-sib-MailScanner-Information: Please contact the ISP for more information X-sib-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/181 X-Sequence-Number: 5705 I can't get the following statement to complete with reasonable time. I've had it running for over ten hours without getting anywhere. I suspect (hope) there may be a better way to accomplish what I'm trying to do (set fields containing unique values to null): UPDATE requests SET session = NULL WHERE session IN ( SELECT session FROM requests GROUP BY session HAVING COUNT(*) = 1 ); Output of EXPLAIN: Nested Loop (cost=170350.16..305352.37 rows=33533 width=98) -> HashAggregate (cost=170350.16..170350.16 rows=200 width=8) -> Subquery Scan "IN_subquery" (cost=169728.12..170261.30 rows=35545 width=8) -> HashAggregate (cost=169728.12..169905.85 rows=35545 width=8) Filter: (count(*) = 1) -> Seq Scan on requests (cost=0.00..139207.75 rows=6104075 width=8) -> Index Scan using requests_session_idx on requests (cost=0.00..672.92 rows=168 width=106) Index Cond: (requests."session" = "outer"."session") If I drop the index on requests(session): Hash Join (cost=170350.66..340414.12 rows=33533 width=98) Hash Cond: ("outer"."session" = "inner"."session") -> Seq Scan on requests (cost=0.00..139207.75 rows=6104075 width=106) -> Hash (cost=170350.16..170350.16 rows=200 width=8) -> HashAggregate (cost=170350.16..170350.16 rows=200 width=8) -> Subquery Scan "IN_subquery" (cost=169728.12..170261.30 rows=35545 width=8) -> HashAggregate (cost=169728.12..169905.85 rows=35545 width=8) Filter: (count(*) = 1) -> Seq Scan on requests (cost=0.00..139207.75 rows=6104075 width=8) The subquery itself requires 5-10 min to run on its own, and may return several million rows. Using EXISTS rather than IN (I'm using 7.4-RC2, not sure if IN queries were already improved in this release): UPDATE requests SET session = NULL WHERE NOT EXISTS ( SELECT r.session FROM requests r WHERE r.session = session AND NOT r.id = id ); With and without index: Result (cost=227855.74..415334.22 rows=8075449 width=101) One-Time Filter: (NOT $0) InitPlan -> Seq Scan on requests r (cost=0.00..227855.74 rows=201 width=8) Filter: (("session" = "session") AND (id <> id)) -> Seq Scan on requests (cost=0.00..187478.49 rows=8075449 width=101) I've been running this for more than an hour so far, and no end in sight, either... Any ideas? From pgsql-performance-owner@postgresql.org Tue Feb 17 08:49:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E896FD1D174 for ; Tue, 17 Feb 2004 12:49:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 34719-06 for ; Tue, 17 Feb 2004 08:49:45 -0400 (AST) Received: from usbb-lacimss1.unisys.com (usbb-lacimss1.unisys.com [192.63.108.51]) by svr1.postgresql.org (Postfix) with ESMTP id E3A6CD1CB1D for ; Tue, 17 Feb 2004 08:49:41 -0400 (AST) Received: from usbb-lacgw2.lac.uis.unisys.com ([129.226.160.22]unverified) by 192.63.108.51 with InterScan Messaging Security Suite; Tue, 17 Feb 2004 08:00:00 -0500 Received: from usbb-lacgw2.lac.uis.unisys.com ([129.226.160.25]) by usbb-lacgw2.lac.uis.unisys.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 17 Feb 2004 07:49:41 -0500 Received: from gbmk-eugw1.eu.uis.unisys.com ([129.221.133.28]) by usbb-lacgw2.lac.uis.unisys.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 17 Feb 2004 07:49:41 -0500 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Subject: Re: UPDATE with subquery too slow Date: Tue, 17 Feb 2004 12:49:29 -0000 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] UPDATE with subquery too slow Thread-Index: AcP1U01jdMrUW6GLRUW3AG8258homgAAL0xg From: "Leeuw van der, Tim" To: "Eric Jain" , "pgsql-performance" X-OriginalArrivalTime: 17 Feb 2004 12:49:41.0456 (UTC) FILETIME=[82A73500:01C3F554] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/182 X-Sequence-Number: 5706 Hi, This is not going to answer your question of course but did you already try= to do this in 2 steps? You said that the subquery itself doesn't take very long, so perhaps you ca= n create a temporary table based on the subquery, then in the update do a j= oin with the temporary table? This might not be desirable in the end, but it might be useful just to chec= k the performance of it. And - isn't it an option to upgrade to 7.4.1 instead? regards, --Tim THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MA= TERIAL and is thus for use only by the intended recipient. If you received = this in error, please contact the sender and delete the e-mail and its atta= chments from all computers.=20 -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Eric Jain Sent: dinsdag 17 februari 2004 13:38 To: pgsql-performance Subject: [PERFORM] UPDATE with subquery too slow I can't get the following statement to complete with reasonable time. I've had it running for over ten hours without getting anywhere. I suspect (hope) there may be a better way to accomplish what I'm trying to do (set fields containing unique values to null): UPDATE requests SET session =3D NULL WHERE session IN ( SELECT session FROM requests GROUP BY session HAVING COUNT(*) =3D 1 ); [...] From pgsql-performance-owner@postgresql.org Tue Feb 17 08:55:03 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id F0D14D1DD3B for ; Tue, 17 Feb 2004 12:54:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 37253-06 for ; Tue, 17 Feb 2004 08:54:59 -0400 (AST) Received: from umail.ru (umail.mtu.ru [195.34.32.101]) by svr1.postgresql.org (Postfix) with ESMTP id 4D3C7D1D315 for ; Tue, 17 Feb 2004 08:54:55 -0400 (AST) Received: from [81.195.8.74] (HELO [127.0.0.1]) by umail.ru (CommuniGate Pro SMTP 4.1.8) with ESMTP id 204044668 for pgsql-performance@postgresql.org; Tue, 17 Feb 2004 15:54:56 +0300 X-AntiVirus: Checked by Dr.Web [version: 4.31, engine: 4.31, virus records: 46220, updated: 17.02.2004] Date: Tue, 17 Feb 2004 15:54:54 +0300 From: Konstantin Tokar Reply-To: Konstantin Tokar X-Priority: 3 (Normal) Message-ID: <1379274019.20040217155454@tokar.ru> To: pgsql-performance@postgresql.org Subject: Tables on multiple disk drives MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/183 X-Sequence-Number: 5707 Hi! Does PostgreSQL allow to create tables and indices of a single database on multiple disk drives with a purpose of increase performance as Oracle database does? If a symbolic reference is the only method then the next question is: how can it be determined what file is referred to what table and index? From pgsql-performance-owner@postgresql.org Tue Feb 17 09:02:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8D753D1D202 for ; Tue, 17 Feb 2004 13:02:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 38186-05 for ; Tue, 17 Feb 2004 09:02:56 -0400 (AST) Received: from internet.potentialtech.com (h-66-167-251-6.PHLAPAFG.covad.net [66.167.251.6]) by svr1.postgresql.org (Postfix) with ESMTP id EF622D1CB1D for ; Tue, 17 Feb 2004 09:02:52 -0400 (AST) Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP id B3E3F69A71; Tue, 17 Feb 2004 08:02:54 -0500 (EST) Message-ID: <403210FB.5040209@potentialtech.com> Date: Tue, 17 Feb 2004 08:02:51 -0500 From: Bill Moran User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christopher Kings-Lynne Cc: Saleem Burhani Baloch , pgsql-performance@postgresql.org Subject: Re: Slow response of PostgreSQL References: <200402170624.i1H6O2u16022@ns2.khi.wol.net.pk> <4031BBBC.5050002@familyhealth.com.au> In-Reply-To: <4031BBBC.5050002@familyhealth.com.au> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/184 X-Sequence-Number: 5708 Christopher Kings-Lynne wrote: >> 1- How can I lock a single record so that other users can only read >> it. ?? > > You cannot do that in PostgreSQL. How about SELECT ... FOR UPDATE? -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Tue Feb 17 10:56:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E1F60D1D1CD for ; Tue, 17 Feb 2004 14:56:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 82709-06 for ; Tue, 17 Feb 2004 10:56:06 -0400 (AST) Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net [194.217.242.86]) by svr1.postgresql.org (Postfix) with ESMTP id DB494D1CACD for ; Tue, 17 Feb 2004 10:56:02 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 1At6dq-000DnO-0b; Tue, 17 Feb 2004 14:56:06 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id EA7691752D; Tue, 17 Feb 2004 14:56:04 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id BE84D161EF; Tue, 17 Feb 2004 14:56:02 +0000 (GMT) From: Richard Huxton To: Konstantin Tokar , pgsql-performance@postgresql.org Subject: Re: Tables on multiple disk drives Date: Tue, 17 Feb 2004 14:56:02 +0000 User-Agent: KMail/1.5 References: <1379274019.20040217155454@tokar.ru> In-Reply-To: <1379274019.20040217155454@tokar.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402171456.02740.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/185 X-Sequence-Number: 5709 On Tuesday 17 February 2004 12:54, Konstantin Tokar wrote: > Hi! > Does PostgreSQL allow to create tables and indices of a single > database on multiple disk drives with a purpose of increase > performance as Oracle database does? If a symbolic reference is the > only method then the next question is: how can it be determined what > file is referred to what table and index? Yep, symlinks are the way at present (though I think someone is working on tablespace support). The files are named after the OID of the object they represent - there is a useful oid2name utility in the contrib/ folder. You might want to check the archives though, and see what RAID setups people prefer - less trouble to maintain than symlinking. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Tue Feb 17 11:03:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 02697D1DAB0 for ; Tue, 17 Feb 2004 15:03:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 90763-04 for ; Tue, 17 Feb 2004 11:03:29 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id F03FDD1DAA0 for ; Tue, 17 Feb 2004 11:03:09 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1HF2bn7010349; Tue, 17 Feb 2004 10:02:37 -0500 (EST) To: "Saleem Burhani Baloch" Cc: "Christopher Kings-Lynne" , pgsql-performance@postgresql.org Subject: Re: Slow response of PostgreSQL In-reply-to: <200402171039.i1HAd9u25077@ns2.khi.wol.net.pk> References: <200402171039.i1HAd9u25077@ns2.khi.wol.net.pk> Comments: In-reply-to "Saleem Burhani Baloch" message dated "Tue, 17 Feb 2004 15:39:09 +0500" Date: Tue, 17 Feb 2004 10:02:37 -0500 Message-ID: <10348.1077030157@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/186 X-Sequence-Number: 5710 "Saleem Burhani Baloch" writes: > I have a question why MS-SQL with 256 MB RAM gives result in 2 sec ?? If I have low memory Postgres should give result in 10 sec as compared to MS-SQL. Are you still running 7.1? regards, tom lane From pgsql-performance-owner@postgresql.org Tue Feb 17 11:25:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6E7B8D1DAA9 for ; Tue, 17 Feb 2004 15:25:28 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 93639-09 for ; Tue, 17 Feb 2004 11:25:24 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id C8F61D1BB5E for ; Tue, 17 Feb 2004 11:25:16 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1HFOHAo005598; Tue, 17 Feb 2004 08:24:18 -0700 (MST) Date: Tue, 17 Feb 2004 08:17:44 -0700 (MST) From: "scott.marlowe" To: Cc: Leon Out , Subject: Re: Disappointing performance in db migrated from MS SQL In-Reply-To: <1980.82.68.132.233.1076709614.squirrel@webmail.ymogen.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/187 X-Sequence-Number: 5711 On Fri, 13 Feb 2004 matt@ymogen.net wrote: > > Josh, the disks in the new system should be substantially faster than > > the old. Both are Ultra160 SCSI RAID 5 arrays, but the new system has > > 15k RPM disks, as opposed to the 10k RPM disks in the old system. > > Spindle speed does not correlate with 'throughput' in any easy way. What > controllers are you using for these disks? This is doubly so with a good RAID card with battery backed cache. I'd bet that 10k rpm drives on a cached array card will beat an otherwise equal setup with 15k rpm disks and no cache. I know that losing the cache slows my system down to a crawl (i.e. set it to write thru instead of write back.) comparitively speaking. From pgsql-performance-owner@postgresql.org Tue Feb 17 13:07:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C2C38D1DAB1 for ; Tue, 17 Feb 2004 17:07:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 45921-07 for ; Tue, 17 Feb 2004 13:07:30 -0400 (AST) Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) by svr1.postgresql.org (Postfix) with ESMTP id 85C2FD1DA83 for ; Tue, 17 Feb 2004 13:07:28 -0400 (AST) Received: from juarez (c-67-164-12-23.client.comcast.net[67.164.12.23]) by comcast.net (sccrmhc13) with SMTP id <20040217170655016003a7gne> (Authid: the_pongo@comcast.net); Tue, 17 Feb 2004 17:07:05 +0000 From: "Todd Fulton" To: Subject: long running query running too long Date: Tue, 17 Feb 2004 09:06:48 -0800 Message-ID: <001301c3f578$7649bb10$326aa8c0@juarez> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0014_01C3F535.68267B10" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/188 X-Sequence-Number: 5712 This is a multi-part message in MIME format. ------=_NextPart_000_0014_01C3F535.68267B10 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Hi All, I'm really like this list. Thank you for all the invaluable information! May I ask a question? I've got a table with about 8 million rows and growing. I must run reports daily off this table, and another smaller one. Typical query - joins, groupings and aggregates included. This certain report takes about 10 minutes on average and is getting longer. I've created all the indices I think are necessary. Any advice on how I can get this puppy to go faster? Hardware changes are not an option at this point, so I'm hoping there is something else I can poke at. Anyone? Todd POSTGRESQL CONF: #log_connections = on #fsync = off #max_connections = 64 # 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 set at run-time with the 'SET' SQL command. # See /usr/share/doc/postgresql/README.postgresql.conf.gz for a full list # of the allowable options debug_level = 0 log_connections = on log_pid = on log_timestamp = on syslog = 0 # if syslog is 0, turn silent_mode off! silent_mode = off syslog_facility = LOCAL0 trace_notify = off max_connections = 128 # shared_buffers must be at least twice max_connections, and not less than 16 shared_buffers = 256 # TCP/IP access is allowed by default, but the default access given in # pg_hba.conf will permit it only from localhost, not other machines. tcpip_socket = 1 EXPLAIN ANALYZE for the query: prod=# explain analyze SELECT t.tgpid, t.directoryname, t.templateid, count(*) AS requested FROM (spk_tgp t JOIN spk_tgplog l ON ((t.tgpid = l.tgpid))) GROUP BY t.tgpid, t.directoryname, t.templateid; NOTICE: QUERY PLAN: Aggregate (cost=2740451.66..2820969.41 rows=805178 width=48) (actual time=460577.85..528968.17 rows=1875 loops=1) -> Group (cost=2740451.66..2800839.97 rows=8051775 width=48) (actual time=460577.57..516992.19 rows=8117748 loops=1) -> Sort (cost=2740451.66..2740451.66 rows=8051775 width=48) (actual time=460577.55..474657.59 rows=8117748 loops=1) -> Hash Join (cost=128.26..409517.83 rows=8051775 width=48) (actual time=11.45..85332.88 rows=8117748 loops=1) -> Seq Scan on spk_tgplog l (cost=0.00..187965.75 rows=8051775 width=8) (actual time=0.03..28926.67 rows=8125690 loops=1) -> Hash (cost=123.41..123.41 rows=1941 width=40) (actual time=11.28..11.28 rows=0 loops=1) -> Seq Scan on spk_tgp t (cost=0.00..123.41 rows=1941 width=40) (actual time=0.06..7.60 rows=1880 loops=1) Total runtime: 529542.66 msec ------=_NextPart_000_0014_01C3F535.68267B10 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable

Hi All,

 

I’m really like this list.  Thank you for all the invaluable information!  May I ask a ques= tion?

 

I’ve got a table with about 8 million rows and growing.  I must run reports d= aily off this table, and another smaller one.  Typical query – joins, groupings and aggregates included.  This cer= tain report takes about 10 minutes on average and is getting longer.  I’ve created all the indices= I think are necessary.

 

Any advice on how I can get this puppy to go faster?  Hardware changes are not an option= at this point, so I’m hoping there is something else I can poke at.  Anyone?=

 

 

Todd

 

 

 

= POSTGRESQ= L = CONF:

 

#log_connections =3D on=

#fsync =3D off

#max_connections =3D 64=

 

# Any option can also be give= n as a command line switch to the

# postmaster, e.g., 'postmast= er -c log_connections=3Don'. Some options=

# can be set at run-time with the 'SET' S<= st1:PersonName>Q= L = command.

 

# See /usr/share/doc/postgresql/REA= DME.postgresql.conf.gz for a full list

# of the allowable options

 

debug_level = =3D 0

log_connections<= /span> = =3D on

log_pid = =3D on

log_timestamp = =3D on

syslog = =3D 0

# if sys= log is 0, turn silent_mode off!

silent_mode = =3D off

syslog_facility<= /span> = =3D LOCAL0

trace_notify = =3D off

max_connections<= /span> = =3D 128

# shared_buffer= s must be at least twice max_connections, and not= less than 16

shared_buffers = =3D 256

# TCP/IP access is allowed by default, but the default access given in

# pg_hba.conf will permit it only from localhost, not other machines.

tcpip_socket = =3D 1

 

 

= EXPLAIN ANALYZE for the query:=

 

prod= =3D# explain analyze SELECT t.tgpid, t.= directoryname, t.templateid, count(*) AS requested FROM (spk_tgp t JOIN spk_tgplog= l ON ((t.tgpid =3D l.tgpid))) GR= OUP BY t.tgpid, t.directoryname,= t.templateid;

NOTICE:  Q= UE= RY PLAN:

 

Aggregate  (cost=3D2740= 451.66..2820969.41 rows=3D805178 width=3D48) (actual time=3D460577.85..528968.17 rows=3D1875 l= oops=3D1)

  ->  Group  (cost=3D2740451.66..2800839.97 rows=3D8051775 width=3D48) (actual time=3D460577.57..516992.19 rows=3D8117748 loops=3D1)

    = ;    ->  Sort  (cost=3D2740451.66..2740451.66 row= s=3D8051775 width=3D48) (actual time=3D460577.55..474657.59 rows=3D8117748 loops=3D1)

    = ;          ->  Hash Join  (cost=3D128.26..409517.83 rows=3D8= 051775 width=3D48) (actual time=3D11.45..85332.88 rows=3D8117748 loops=3D1)

    = ;            &n= bsp;   ->  Seq Scan on spk_tgplog l  (cost=3D0.00..187965.75 rows=3D8051775 width=3D8) (actual time=3D0.0= 3..28926.67 rows=3D8125690 loops=3D1)

    = ;            &n= bsp;   ->  Hash  (cost=3D123.41..123.41 rows=3D1941= width=3D40) (actual time=3D11.28..11.28 rows=3D0 loops=3D1)

    = ;            &n= bsp;         ->  Seq Scan on spk_tgp t  (cost=3D0.00..123.41 rows=3D1941 w= idth=3D40) (actual time=3D0.06..7.60 rows=3D1880 loops=3D1)

Total runtime: 529542.66 msec

 

 

 

 

 

------=_NextPart_000_0014_01C3F535.68267B10-- From pgsql-performance-owner@postgresql.org Tue Feb 17 13:25:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id AAE15D1D174 for ; Tue, 17 Feb 2004 17:25:56 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 55172-07 for ; Tue, 17 Feb 2004 13:25:53 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id CA2E8D1CACD for ; Tue, 17 Feb 2004 13:25:51 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1HHMKAo017984; Tue, 17 Feb 2004 10:22:20 -0700 (MST) Date: Tue, 17 Feb 2004 10:15:46 -0700 (MST) From: "scott.marlowe" To: Saleem Burhani Baloch Cc: Subject: Re: Slow response of PostgreSQL In-Reply-To: <200402170624.i1H6O2u16022@ns2.khi.wol.net.pk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/189 X-Sequence-Number: 5713 Easy two step procedure for speeding this up: 1: Upgrade to 7.4.1 2: Read this: http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html From pgsql-performance-owner@postgresql.org Tue Feb 17 13:27:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id AB44ED1B484 for ; Tue, 17 Feb 2004 17:27:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 51444-10 for ; Tue, 17 Feb 2004 13:27:16 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 68B70D1B49E for ; Tue, 17 Feb 2004 13:27:10 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1HHOxAo018308; Tue, 17 Feb 2004 10:25:00 -0700 (MST) Date: Tue, 17 Feb 2004 10:18:25 -0700 (MST) From: "scott.marlowe" To: Konstantin Tokar Cc: Subject: Re: Tables on multiple disk drives In-Reply-To: <1379274019.20040217155454@tokar.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/190 X-Sequence-Number: 5714 On Tue, 17 Feb 2004, Konstantin Tokar wrote: > Hi! > Does PostgreSQL allow to create tables and indices of a single > database on multiple disk drives with a purpose of increase > performance as Oracle database does? If a symbolic reference is the > only method then the next question is: how can it be determined what > file is referred to what table and index? You're life will be simpler, and your setup will be faster without having to muck about with it, if you just buy a good RAID controller with battery backed cache. LSI/Megaraid and Adaptec both make serviceable controllers for reasonable prices, and as you add drives, the speed just goes up, no muddling around with sym links. From pgsql-performance-owner@postgresql.org Tue Feb 17 13:35:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B2C8ED1D1CD for ; Tue, 17 Feb 2004 17:35:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 62595-02 for ; Tue, 17 Feb 2004 13:35:41 -0400 (AST) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by svr1.postgresql.org (Postfix) with ESMTP id 47BE8D1CAF3 for ; Tue, 17 Feb 2004 13:35:40 -0400 (AST) Received: from fire-1.osdl.org (air1.pdx.osdl.net [172.20.0.5]) by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i1HHZcE10517; Tue, 17 Feb 2004 09:35:38 -0800 From: Craig Thomas Received: from osdl.org (fire.osdl.org [65.172.181.4]) by fire-1.osdl.org (8.12.8/8.12.8) with SMTP id i1HHZbrK005014; Tue, 17 Feb 2004 09:35:37 -0800 Received: from 4.5.9.170 (SquirrelMail authenticated user craiger) by www.osdl.org with HTTP; Tue, 17 Feb 2004 09:35:38 -0800 (PST) Message-ID: <64789.4.5.9.170.1077039338.squirrel@www.osdl.org> Date: Tue, 17 Feb 2004 09:35:38 -0800 (PST) Subject: Re: Tables on multiple disk drives To: In-Reply-To: References: <1379274019.20040217155454@tokar.ru> X-Priority: 3 Importance: Normal Cc: , X-Mailer: SquirrelMail (version 1.2.11) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-MIMEDefang-Filter: osdl$Revision: 1.48 $ X-Scanned-By: MIMEDefang 2.36 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/191 X-Sequence-Number: 5715 > On Tue, 17 Feb 2004, Konstantin Tokar wrote: > >> Hi! >> Does PostgreSQL allow to create tables and indices of a single >> database on multiple disk drives with a purpose of increase >> performance as Oracle database does? If a symbolic reference is the >> only method then the next question is: how can it be determined what >> file is referred to what table and index? > > You're life will be simpler, and your setup will be faster without > having to muck about with it, if you just buy a good RAID controller > with battery backed cache. LSI/Megaraid and Adaptec both make > serviceable controllers for reasonable prices, and as you add drives, > the speed just goes up, no muddling around with sym links. This works to a limited extent. For very large databases, maximum throughput of I/O is the paramount factor for database performance. With raid controllers, your LUN is still limited to a small number of disks. PostgreSQL can only write on a file system, but Oracle, SAP DB, DB2, etc can write directly to disk (raw I/O). With large databases it is advantageous to spread a table across 100's of disks, if the table is quite large. I don't know of any manufacturer that creates a 100 disk raid array yet. Some of the problem can be addressed by using a volume manager (such as LVM in Linux, or Veritas on Unix-like systems). This allows one to create a volume using partitions from many disks. One can then create a file system and mount it on the volume. However, to get the best performance, Raw I/O capability is the best way to go. > > > ---------------------------(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 From pgsql-performance-owner@postgresql.org Tue Feb 17 14:00:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 89DFAD1D174 for ; Tue, 17 Feb 2004 18:00:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 63751-10 for ; Tue, 17 Feb 2004 14:00:38 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 1B40FD1CACD for ; Tue, 17 Feb 2004 14:00:37 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1HHxcAo021990; Tue, 17 Feb 2004 10:59:38 -0700 (MST) Date: Tue, 17 Feb 2004 10:53:04 -0700 (MST) From: "scott.marlowe" To: Craig Thomas Cc: , Subject: Re: Tables on multiple disk drives In-Reply-To: <64789.4.5.9.170.1077039338.squirrel@www.osdl.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/192 X-Sequence-Number: 5716 On Tue, 17 Feb 2004, Craig Thomas wrote: > > On Tue, 17 Feb 2004, Konstantin Tokar wrote: > > > >> Hi! > >> Does PostgreSQL allow to create tables and indices of a single > >> database on multiple disk drives with a purpose of increase > >> performance as Oracle database does? If a symbolic reference is the > >> only method then the next question is: how can it be determined what > >> file is referred to what table and index? > > > > You're life will be simpler, and your setup will be faster without > > having to muck about with it, if you just buy a good RAID controller > > with battery backed cache. LSI/Megaraid and Adaptec both make > > serviceable controllers for reasonable prices, and as you add drives, > > the speed just goes up, no muddling around with sym links. > > This works to a limited extent. For very large databases, maximum > throughput of I/O is the paramount factor for database performance. With > raid controllers, your LUN is still limited to a small number of disks. > PostgreSQL can only write on a file system, but Oracle, SAP DB, DB2, etc > can write directly to disk (raw I/O). With large databases it is > advantageous to spread a table across 100's of disks, if the table is > quite large. I don't know of any manufacturer that creates a 100 disk > raid array yet. You can run up to four LSI / Megaraids in one box, each with 3 UW SCSI interfaces, and they act as one unit. That's 3*4*15 = 180 disks max. With FC AL connections and four cards, it would be possible to approach 1000 drives. Of course, I'm not sure how fast any RAID card setup is gonna be with that many drives, but ya never know. My guess is that before you go there you buy a big external RAID box built for speed. We have a couple of 200+ drive external RAID5 storage boxes at work that are quite impressive. > Some of the problem can be addressed by using a volume manager (such as > LVM in Linux, or Veritas on Unix-like systems). This allows one to > create a volume using partitions from many disks. One can then create > a file system and mount it on the volume. Pretty much RAID arrays in software, which means no battery backed cache, which means it'll be fast at reading, but probably pretty slow at writes, epsecially if there's a lot of parallel access waiting to write to the database. > However, to get the best performance, Raw I/O capability is the best > way to go. Unsupported statement made as fact. I'm not saying it can't or isn't true, but my experience has been that large RAID5 arrays are a great compromise between maximum performance and reliability, giving a good measure of each. It doesn't take 100 drives to do well, even a dozen to two dozen will get you in the same basic range as splitting out files by hand with sym links without all the headache of chasing down the files, shutting down the database, linking it over etc... From pgsql-performance-owner@postgresql.org Tue Feb 17 14:22:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1CFB6D1D1CD for ; Tue, 17 Feb 2004 18:16:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 72519-06 for ; Tue, 17 Feb 2004 14:16:24 -0400 (AST) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by svr1.postgresql.org (Postfix) with ESMTP id EE41AD1B49E for ; Tue, 17 Feb 2004 14:16:22 -0400 (AST) Received: from fire-1.osdl.org (air1.pdx.osdl.net [172.20.0.5]) by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i1HIGNE16936; Tue, 17 Feb 2004 10:16:23 -0800 From: Craig Thomas Received: from osdl.org (fire.osdl.org [65.172.181.4]) by fire-1.osdl.org (8.12.8/8.12.8) with SMTP id i1HIGMrK008156; Tue, 17 Feb 2004 10:16:22 -0800 Received: from 4.5.9.170 (SquirrelMail authenticated user craiger) by www.osdl.org with HTTP; Tue, 17 Feb 2004 10:16:22 -0800 (PST) Message-ID: <64865.4.5.9.170.1077041782.squirrel@www.osdl.org> Date: Tue, 17 Feb 2004 10:16:22 -0800 (PST) Subject: Re: Tables on multiple disk drives To: In-Reply-To: References: <64789.4.5.9.170.1077039338.squirrel@www.osdl.org> X-Priority: 3 Importance: Normal Cc: , , X-Mailer: SquirrelMail (version 1.2.11) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-MIMEDefang-Filter: osdl$Revision: 1.48 $ X-Scanned-By: MIMEDefang 2.36 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/193 X-Sequence-Number: 5717 > On Tue, 17 Feb 2004, Craig Thomas wrote: > >> > On Tue, 17 Feb 2004, Konstantin Tokar wrote: >> > >> >> Hi! >> >> Does PostgreSQL allow to create tables and indices of a single >> database on multiple disk drives with a purpose of increase >> >> performance as Oracle database does? If a symbolic reference is the >> only method then the next question is: how can it be determined >> what file is referred to what table and index? >> > >> > You're life will be simpler, and your setup will be faster without >> having to muck about with it, if you just buy a good RAID >> controller with battery backed cache. LSI/Megaraid and Adaptec >> both make serviceable controllers for reasonable prices, and as you >> add drives, the speed just goes up, no muddling around with sym >> links. >> >> This works to a limited extent. For very large databases, maximum >> throughput of I/O is the paramount factor for database performance. >> With raid controllers, your LUN is still limited to a small number of >> disks. PostgreSQL can only write on a file system, but Oracle, SAP DB, >> DB2, etc can write directly to disk (raw I/O). With large databases >> it is advantageous to spread a table across 100's of disks, if the >> table is quite large. I don't know of any manufacturer that creates a >> 100 disk raid array yet. > > You can run up to four LSI / Megaraids in one box, each with 3 UW SCSI > interfaces, and they act as one unit. That's 3*4*15 = 180 disks max. > > With FC AL connections and four cards, it would be possible to approach > 1000 drives. > > Of course, I'm not sure how fast any RAID card setup is gonna be with > that many drives, but ya never know. My guess is that before you go > there you buy a big external RAID box built for speed. We have a > couple of 200+ drive external RAID5 storage boxes at work that are > quite impressive. That's a good point. But it seems that the databases that are the leaders of the TPC numbers seem to be the Oracles of the world. I know that a former company I worked for publised TPC numbers using Oracle with Raw I/O to get the performance up. However, it would be interesting for us to conduct a small scale test using a couple of HW Raid systems configured so that a single file system can be mounted, then run the OSDL dbt workloads. The resluts could then be compared with current results that have been captured. > >> Some of the problem can be addressed by using a volume manager (such >> as LVM in Linux, or Veritas on Unix-like systems). This allows one to >> create a volume using partitions from many disks. One can then create >> a file system and mount it on the volume. > > Pretty much RAID arrays in software, which means no battery backed > cache, which means it'll be fast at reading, but probably pretty slow > at writes, epsecially if there's a lot of parallel access waiting to > write to the database. > >> However, to get the best performance, Raw I/O capability is the best >> way to go. > > Unsupported statement made as fact. I'm not saying it can't or isn't > true, but my experience has been that large RAID5 arrays are a great > compromise between maximum performance and reliability, giving a good > measure of each. It doesn't take 100 drives to do well, even a dozen to > two dozen will get you in the same basic range as splitting out files > by hand with sym links without all the headache of chasing down the > files, shutting down the database, linking it over etc... Whoops, you're right. I was typing faster than I was thinking. I was assuming a JBOD set up rather than a RAID storage subsystem. SAN units such as an EMC or Shark usualy have 4-16 GB cache and thus the I/O's go pretty quick for really large databases. > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Tue Feb 17 14:37:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A26B8D1D174 for ; Tue, 17 Feb 2004 18:30:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 78619-09 for ; Tue, 17 Feb 2004 14:30:29 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id E48D8D1D8DA for ; Tue, 17 Feb 2004 14:30:26 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1HITiAo024953; Tue, 17 Feb 2004 11:29:44 -0700 (MST) Date: Tue, 17 Feb 2004 11:23:09 -0700 (MST) From: "scott.marlowe" To: Craig Thomas Cc: , Subject: Re: Tables on multiple disk drives In-Reply-To: <64865.4.5.9.170.1077041782.squirrel@www.osdl.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/194 X-Sequence-Number: 5718 On Tue, 17 Feb 2004, Craig Thomas wrote: > > On Tue, 17 Feb 2004, Craig Thomas wrote: > > > >> > On Tue, 17 Feb 2004, Konstantin Tokar wrote: > >> > > >> >> Hi! > >> >> Does PostgreSQL allow to create tables and indices of a single > >> database on multiple disk drives with a purpose of increase > >> >> performance as Oracle database does? If a symbolic reference is the > >> only method then the next question is: how can it be determined > >> what file is referred to what table and index? > >> > > >> > You're life will be simpler, and your setup will be faster without > >> having to muck about with it, if you just buy a good RAID > >> controller with battery backed cache. LSI/Megaraid and Adaptec > >> both make serviceable controllers for reasonable prices, and as you > >> add drives, the speed just goes up, no muddling around with sym > >> links. > >> > >> This works to a limited extent. For very large databases, maximum > >> throughput of I/O is the paramount factor for database performance. > >> With raid controllers, your LUN is still limited to a small number of > >> disks. PostgreSQL can only write on a file system, but Oracle, SAP DB, > >> DB2, etc can write directly to disk (raw I/O). With large databases > >> it is advantageous to spread a table across 100's of disks, if the > >> table is quite large. I don't know of any manufacturer that creates a > >> 100 disk raid array yet. > > > > You can run up to four LSI / Megaraids in one box, each with 3 UW SCSI > > interfaces, and they act as one unit. That's 3*4*15 = 180 disks max. > > > > With FC AL connections and four cards, it would be possible to approach > > 1000 drives. > > > > Of course, I'm not sure how fast any RAID card setup is gonna be with > > that many drives, but ya never know. My guess is that before you go > > there you buy a big external RAID box built for speed. We have a > > couple of 200+ drive external RAID5 storage boxes at work that are > > quite impressive. > > That's a good point. But it seems that the databases that are the > leaders of the TPC numbers seem to be the Oracles of the world. I > know that a former company I worked for publised TPC numbers using > Oracle with Raw I/O to get the performance up. But keep in mind, that in the TPC benchmarks, doing things that require lots of dba work don't tend to make the cost in the test go up (you can hide a lot of admin work in those things) while in real life, they do drive up the real cost of maintenance. I'd imagine that with Postgresql coming along nicely, it may well be that in a year or two, in the real world, you can just take the money you'd have spend on Oracle licenses and Oracle DBAs and just throw more drives at a problem to solve it. And still spend less money than you would on Oracle. :-) From pgsql-performance-owner@postgresql.org Tue Feb 17 16:25:01 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DB3B5D1D1CD for ; Tue, 17 Feb 2004 20:05:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 21400-02 for ; Tue, 17 Feb 2004 16:05:38 -0400 (AST) Received: from OMEGA.denver.ibsncentral.com (mail.ibsncentral.com [69.44.125.178]) by svr1.postgresql.org (Postfix) with ESMTP id 3BC3DD1BB5E for ; Tue, 17 Feb 2004 16:05:36 -0400 (AST) Received: from [10.0.0.100] ([67.166.16.116]) by OMEGA.denver.ibsncentral.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 17 Feb 2004 13:05:18 -0700 In-Reply-To: <001301c3f578$7649bb10$326aa8c0@juarez> References: <001301c3f578$7649bb10$326aa8c0@juarez> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Message-Id: <99C04A9E-6184-11D8-9183-000393BDC2FE@ibsncentral.com> Content-Transfer-Encoding: quoted-printable Cc: From: PC Drew Subject: Re: long running query running too long Date: Tue, 17 Feb 2004 13:05:15 -0700 To: "Todd Fulton" X-Mailer: Apple Mail (2.612) X-OriginalArrivalTime: 17 Feb 2004 20:05:18.0707 (UTC) FILETIME=[5DAB3430:01C3F591] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/195 X-Sequence-Number: 5719 On Feb 17, 2004, at 10:06 AM, Todd Fulton wrote: > > > I=92ve got a table with about 8 million rows and growing.=A0 I must run= =20 > reports daily off this table, and another smaller one.=A0 Typical query= =20 > =96 joins, groupings and aggregates included.=A0 This certain report take= s=20 > about 10 minutes on average and is getting longer.=A0 I=92ve created all= =20 > the indices I think are necessary. > > What indexes have you created? The query is not using any indexes, so=20 there might be a problem there. Can you disable seqscans temporarily=20 to test this? > > prod=3D# explain analyze SELECT t.tgpid, t.directoryname, t.templateid,= =20 > count(*) AS requested FROM (spk_tgp t JOIN spk_tgplog l ON ((t.tgpid =3D= =20 > l.tgpid))) GROUP BY t.tgpid, t.directoryname, t.templateid; Can you please send the results of the following commands: psql=3D# \d spk_tgp and psql=3D# \d spk_tgplog You might also want to try using a sub-query instead of a join. I'm=20 assuming that the spk_tgplog table has a lot of rows and spk_tgp has=20 very few rows. It might make sense to try something like this: EXPLAIN ANALYZE SELECT t.tgpid, t.directoryname, t.templateid, r.requested FROM (SELECT tgpid, count(*) AS requested FROM spk_tgplog GROUP BY=20 tgpid) r, spk_tgp t WHERE r.tgpid =3D t.tgpid; -- PC Drew From pgsql-performance-owner@postgresql.org Tue Feb 17 16:51:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A7805D1D6B9 for ; Tue, 17 Feb 2004 20:42:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 35922-04 for ; Tue, 17 Feb 2004 16:42:05 -0400 (AST) Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) by svr1.postgresql.org (Postfix) with ESMTP id 19C9AD1D69B for ; Tue, 17 Feb 2004 16:42:03 -0400 (AST) Received: from juarez (c-67-164-12-23.client.comcast.net[67.164.12.23]) by comcast.net (sccrmhc13) with SMTP id <20040217204154016003b6nme> (Authid: the_pongo@comcast.net); Tue, 17 Feb 2004 20:41:55 +0000 From: "Todd Fulton" To: "'PC Drew'" Cc: Subject: Re: long running query running too long Date: Tue, 17 Feb 2004 12:41:51 -0800 Message-ID: <00b401c3f596$78f92800$326aa8c0@juarez> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 In-Reply-To: <99C04A9E-6184-11D8-9183-000393BDC2FE@ibsncentral.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/196 X-Sequence-Number: 5720 Hey! I think I have appropriate indexes, but might now. You're absolutely right on my join -- spk_tgplog has the 8.5 million rows, spk_tgp around 2400. I'll try the sub-select. Here is the output you asked for: spank_prod=3D# \d spk_tgp; Table "spk_tgp" Column | Type | Modifiers ----------------+--------------------------+---------------------------- --------------------------------- tgpid | bigint | not null directoryname | character varying(64) | not null directoryurl | character varying(1028) | not null submiturl | character varying(1028) | submitdate | date | acceptdate | date | templateid | character varying(64) | not null reciprocalcode | character varying(2056) | notes | character varying(2056) | createdate | timestamp with time zone | not null default ('now'::text)::timestamp(6) with time zone modifydate | timestamp with time zone | not null default ('now'::text)::timestamp(6) with time zone requested | integer | hostid | integer | default 1 Indexes: idx_spk_tgp_tgpid Primary key: pk_spk_tgp spank_prod=3D# \d idx_spk_tgp_tgpid Index "idx_spk_tgp_tgpid" Column | Type ---------------+----------------------- tgpid | bigint directoryname | character varying(64) btree spank_prod=3D# \d spk_tgplog; Table "spk_tgplog" Column | Type | Modifiers ---------------+--------------------------+----------------------------- -------------------------------- remoteaddress | character varying(32) | not null tgpid | bigint | not null referer | character varying(256) | createdate | timestamp with time zone | not null default ('now'::text)::timestamp(6) with time zone Indexes: idx_spk_tgplog_createdate, idx_spk_tgplog_tgpid spank_prod=3D# \d idx_spk_tgplog_createdate Index "idx_spk_tgplog_createdate" Column | Type ------------+-------------------------- createdate | timestamp with time zone btree spank_prod=3D# \d idx_spk_tgplog_tgpid Index "idx_spk_tgplog_tgpid" Column | Type --------+-------- tgpid | bigint btree Todd -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of PC Drew Sent: Tuesday, February 17, 2004 12:05 PM To: Todd Fulton Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] long running query running too long On Feb 17, 2004, at 10:06 AM, Todd Fulton wrote: > > > I=92ve got a table with about 8 million rows and growing.=A0 I must run= =20 > reports daily off this table, and another smaller one.=A0 Typical query= =20 > =96 joins, groupings and aggregates included.=A0 This certain report takes > about 10 minutes on average and is getting longer.=A0 I=92ve created all= =20 > the indices I think are necessary. > > What indexes have you created? The query is not using any indexes, so=20 there might be a problem there. Can you disable seqscans temporarily=20 to test this? > > prod=3D# explain analyze SELECT t.tgpid, t.directoryname, t.templateid,= =20 > count(*) AS requested FROM (spk_tgp t JOIN spk_tgplog l ON ((t.tgpid =3D > l.tgpid))) GROUP BY t.tgpid, t.directoryname, t.templateid; Can you please send the results of the following commands: psql=3D# \d spk_tgp and psql=3D# \d spk_tgplog You might also want to try using a sub-query instead of a join. I'm=20 assuming that the spk_tgplog table has a lot of rows and spk_tgp has=20 very few rows. It might make sense to try something like this: EXPLAIN ANALYZE SELECT t.tgpid, t.directoryname, t.templateid, r.requested FROM (SELECT tgpid, count(*) AS requested FROM spk_tgplog GROUP BY=20 tgpid) r, spk_tgp t WHERE r.tgpid =3D t.tgpid; -- PC Drew ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Tue Feb 17 17:54:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B01F6D1D4E7 for ; Tue, 17 Feb 2004 21:54:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 51891-08 for ; Tue, 17 Feb 2004 17:54:04 -0400 (AST) Received: from pomeray.duluoz.net (c-24-20-13-125.client.comcast.net [24.20.13.125]) by svr1.postgresql.org (Postfix) with ESMTP id 87790D1DD71 for ; Tue, 17 Feb 2004 17:53:46 -0400 (AST) Received: (qmail 1647 invoked by uid 1000); 17 Feb 2004 13:53:46 -0800 Date: Tue, 17 Feb 2004 13:53:42 -0800 From: Mike Glover To: pgsql-performance@postgresql.org Subject: RAID or manual split? Message-Id: <20040217135342.1924326f.mpg4@duluoz.net> X-Mailer: Sylpheed version 0.9.0claws (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="=.,2v/h'VCiHrz?i" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/197 X-Sequence-Number: 5721 --=.,2v/h'VCiHrz?i Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit It seems, that if I know the type and frequency of the queries a database will be seeing, I could split the database by hand over multiple disks and get better performance that I would with a RAID array with similar hardware. Most of the data is volatile and easily replaceable (and the rest is backed up independently), so redundancy isn't importand, and I'm willing to do some ongoing maintenance if I can get a decent speed boost. Am I misguided, or might this work? details of my setup are below: Six large (3-7 Mrow) 'summary' tables, each being updated continuously by 5-20 processes with about 0.5 transactions/second/process. Periodically (currently every two weeks), join queries are performed between one of the 'summary' tables(same one each time) and each of the other five. Each join touches most rows of both tables, indexes aren't used. Results are written into a separate group of 'inventory' tables (about 500 Krow each), one for each join. There are frequent (100-1000/day) queries of both the inventory and summary tables using the primary key -- always using the index and returning < 10 rows. We're currently getting (barely) acceptable performance from a single 15k U160 SCSI disk, but db size and activity are growing quickly. I've got more disks and a battery-backed LSI card on order. -mike -- Mike Glover GPG Key ID BFD19F2C --=.,2v/h'VCiHrz?i Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFAMo1qZrNpxr/RnywRAsMpAJ98xSVSsJ0KhrVHueQYHvmYsFxJKwCbBEsM XMVL8I+rk0Xz+JWdCZirbio= =LxYr -----END PGP SIGNATURE----- --=.,2v/h'VCiHrz?i-- From pgsql-performance-owner@postgresql.org Sat Feb 21 02:18:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id AD06ED1DD42 for ; Tue, 17 Feb 2004 22:17:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 68228-03 for ; Tue, 17 Feb 2004 18:17:13 -0400 (AST) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id 536BFD1DD1F for ; Tue, 17 Feb 2004 18:16:55 -0400 (AST) Received: from [134.22.68.145] (dyn-68-145.tor.dsl.tht.net [134.22.68.145]) by tht.net (Postfix) with ESMTP id 4F03676A90; Tue, 17 Feb 2004 17:17:00 -0500 (EST) Subject: Re: RAID or manual split? From: Rod Taylor To: Mike Glover Cc: Postgresql Performance In-Reply-To: <20040217135342.1924326f.mpg4@duluoz.net> References: <20040217135342.1924326f.mpg4@duluoz.net> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-80Mh6uoEnkX9riQR0X7U" Message-Id: <1077056235.18564.207.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Tue, 17 Feb 2004 17:17:15 -0500 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/246 X-Sequence-Number: 5770 --=-80Mh6uoEnkX9riQR0X7U Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > There are frequent (100-1000/day) queries of both the > inventory and summary tables using the primary key -- always using the > index and returning < 10 rows. For this query frequency I don't think splitting the drives will do much -- you just need more IO. Look at optimizing the query themselves, specifically ensuring the useful information is already in memory. If the 10 rows are recent, you might try using partial indexes with the last days worth of information instead of an index across the entire table. > We're currently getting (barely) acceptable performance from a single > 15k U160 SCSI disk, but db size and activity are growing quickly.=20 > I've got more disks and a battery-backed LSI card on order. Configure for Raid 10 and you're off. --=20 Rod Taylor Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL PGP Key: http://www.rbt.ca/signature.asc --=-80Mh6uoEnkX9riQR0X7U 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 (FreeBSD) iD8DBQBAMpLq6DETLow6vwwRAnRIAJ0Q3Wg89YwsG92J/zpuLAMR3rcFjACfQHJR Y+agrYG0movTSsjA7b7WRf8= =/NTI -----END PGP SIGNATURE----- --=-80Mh6uoEnkX9riQR0X7U-- From pgsql-performance-owner@postgresql.org Tue Feb 17 19:17:38 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 93D3AD1DD2C for ; Tue, 17 Feb 2004 23:17:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 84824-08 for ; Tue, 17 Feb 2004 19:17:37 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 9BA45D1D3DC for ; Tue, 17 Feb 2004 19:17:34 -0400 (AST) 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 i1HNHY1Y070268 for ; Tue, 17 Feb 2004 23:17:34 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i1HN29CI068271 for pgsql-performance@postgresql.org; Tue, 17 Feb 2004 23:02:09 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Tables on multiple disk drives Date: Tue, 17 Feb 2004 17:31:11 -0500 Organization: cbbrowne Computing Inc Lines: 36 Message-ID: References: <1379274019.20040217155454@tokar.ru> 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:nAeZUywxeQFIylphoBEbN80NlPw= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/200 X-Sequence-Number: 5724 lists2@tokar.ru (Konstantin Tokar) wrote: > Hi! > Does PostgreSQL allow to create tables and indices of a single > database on multiple disk drives with a purpose of increase > performance as Oracle database does? If a symbolic reference is the > only method then the next question is: how can it be determined what > file is referred to what table and index? It is possible to do this, albeit not trivially easily, by shutting down the database, moving the index to another filesystem, and using a symbolic link to connect it back in. The system table pg_class contains the relevant linkages. But it seems likely to me that using a smart RAID controller (e.g. - LSILogic MegaRAID) to link a whole lot of disks together to generate one enormous striped filesystem would be a more effective strategy, in the long run. Doing that, with a substantial array of disk drives, allows your disk subsystem to provide an analagous sort of performance increase without there being any need for a DBA to fiddle around with anything. If you have the DBA do the work, this means consuming some not-insubstantial amount of time for analysis as well as down-time for maintenance. And it will be necessary to have a somewhat-fragile "registry" of configuration information indicating what customizations were done. In contrast, throwing a smarter RAID controller at the problem costs only a few hundred dollars, and requires little or no analysis effort. And the RAID controller will affect _all_ cases where there could be I/O benefits from striping tables across multiple drives. -- If this was helpful, rate me http://cbbrowne.com/info/x.html The way to a man's heart is through the left ventricle. From pgsql-performance-owner@postgresql.org Tue Feb 17 18:35:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2408ED1D8AE for ; Tue, 17 Feb 2004 22:35:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 67889-06 for ; Tue, 17 Feb 2004 18:35:08 -0400 (AST) 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 08810D1D4E7 for ; Tue, 17 Feb 2004 18:35:06 -0400 (AST) Received: by bayswater1.ymogen.net (Postfix, from userid 99) id 6EE589AD7A; Tue, 17 Feb 2004 22:34:52 +0000 (GMT) Received: from 82.68.132.233 (SquirrelMail authenticated user matt@ymogen.net) by webmail.ymogen.com with HTTP; Tue, 17 Feb 2004 22:34:52 -0000 (GMT) Message-ID: <1634.82.68.132.233.1077057292.squirrel@webmail.ymogen.com> In-Reply-To: <20040217135342.1924326f.mpg4@duluoz.net> References: <20040217135342.1924326f.mpg4@duluoz.net> Date: Tue, 17 Feb 2004 22:34:52 -0000 (GMT) Subject: Re: RAID or manual split? From: matt@ymogen.net To: "Mike Glover" Cc: pgsql-performance@postgresql.org User-Agent: SquirrelMail/1.4.2-0.1.7.x MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/198 X-Sequence-Number: 5722 > It seems, that if I know the type and frequency of the queries a > database will be seeing, I could split the database by hand over > multiple disks and get better performance that I would with a RAID array > with similar hardware. Unlikely, but possible if you had radically different hardware for different tables. > Six large (3-7 Mrow) 'summary' tables, each being updated continuously > by 5-20 processes with about 0.5 transactions/second/process. Well you should get close to an order of magnitude better performance from a RAID controller with write-back cache on those queries. > Periodically (currently every two weeks), join queries are > performed between one of the 'summary' tables(same one each time) and > each of the other five. Each join touches most rows of both tables, > indexes aren't used. Results are written into a separate group of > 'inventory' tables (about 500 Krow each), one for each join. The more disks the data is spread over the better (the RAID controller will help here with striping). > There are frequent (100-1000/day) queries of both the > inventory and summary tables using the primary key -- always using the > index and returning < 10 rows. RAM is what you need, to cache the data and indexes, and then as much CPU power as you can get. > We're currently getting (barely) acceptable performance from a single > 15k U160 SCSI disk, but db size and activity are growing quickly. > I've got more disks and a battery-backed LSI card on order. 3 or more disks in a stripe set, with write back caching, will almost certainly give a huge performance boost. Try that first, and only if you have issues should you think about futzing with symlinks etc. M From pgsql-performance-owner@postgresql.org Tue Feb 17 19:17:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 79A80D1CB1D for ; Tue, 17 Feb 2004 23:17:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 83467-09 for ; Tue, 17 Feb 2004 19:17:08 -0400 (AST) Received: from OMEGA.denver.ibsncentral.com (mail.ibsncentral.com [69.44.125.178]) by svr1.postgresql.org (Postfix) with ESMTP id 91D15D1B484 for ; Tue, 17 Feb 2004 19:17:05 -0400 (AST) Received: from [10.0.0.100] ([67.166.16.116]) by OMEGA.denver.ibsncentral.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 17 Feb 2004 16:17:07 -0700 In-Reply-To: <00b401c3f596$78f92800$326aa8c0@juarez> References: <00b401c3f596$78f92800$326aa8c0@juarez> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <668C432F-619F-11D8-9183-000393BDC2FE@ibsncentral.com> Content-Transfer-Encoding: 7bit Cc: From: PC Drew Subject: Re: long running query running too long Date: Tue, 17 Feb 2004 16:17:05 -0700 To: "Todd Fulton" X-Mailer: Apple Mail (2.612) X-OriginalArrivalTime: 17 Feb 2004 23:17:07.0765 (UTC) FILETIME=[299A1650:01C3F5AC] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/199 X-Sequence-Number: 5723 On Feb 17, 2004, at 1:41 PM, Todd Fulton wrote: > > spank_prod=# \d idx_spk_tgp_tgpid > Index "idx_spk_tgp_tgpid" > Column | Type > ---------------+----------------------- > tgpid | bigint > directoryname | character varying(64) > btree > A couple of things to note: 1. What version of PostgreSQL are you running? I'm currently running 7.3.4 and my output of \d on a table shows more index information than yours does. If you're running anything earlier than 7.3, I'd definitely recommend that you upgrade. 2. Why are you using a multicolumn index in this case? You might want to read the page in the documentation that discusses multi-column indexes specifically. http://www.postgresql.org/docs/7.4/interactive/indexes-multicolumn.html In any case, it might even be the case that the index isn't being used at all. Does anyone know if indexes are used in a case like this: > spk_tgp t JOIN spk_tgplog l ON (t.tgpid = l.tgpid) My hunch is that it's not used. My understanding is that an index acts more as a shortcut so the database doesn't have to go through the entire table to look for specific values. When joining two tables, however, you inherently have to go through the entire table. If anyone can clarify this, that'd be great. -- PC Drew From pgsql-performance-owner@postgresql.org Tue Feb 17 19:55:47 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 14835D1D5E4 for ; Tue, 17 Feb 2004 23:55:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 02117-02 for ; Tue, 17 Feb 2004 19:55:47 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 12B69D1D59C for ; Tue, 17 Feb 2004 19:55:44 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1HNtheY019024; Tue, 17 Feb 2004 18:55:43 -0500 (EST) To: "Todd Fulton" Cc: pgsql-performance@postgresql.org Subject: Re: long running query running too long In-reply-to: <001301c3f578$7649bb10$326aa8c0@juarez> References: <001301c3f578$7649bb10$326aa8c0@juarez> Comments: In-reply-to "Todd Fulton" message dated "Tue, 17 Feb 2004 09:06:48 -0800" Date: Tue, 17 Feb 2004 18:55:42 -0500 Message-ID: <19023.1077062142@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/201 X-Sequence-Number: 5725 "Todd Fulton" writes: > prod=# explain analyze SELECT t.tgpid, t.directoryname, t.templateid, > count(*) AS requested FROM (spk_tgp t JOIN spk_tgplog l ON ((t.tgpid = > l.tgpid))) GROUP BY t.tgpid, t.directoryname, t.templateid; > NOTICE: QUERY PLAN: > Aggregate (cost=2740451.66..2820969.41 rows=805178 width=48) (actual > time=460577.85..528968.17 rows=1875 loops=1) > -> Group (cost=2740451.66..2800839.97 rows=8051775 width=48) (actual > time=460577.57..516992.19 rows=8117748 loops=1) > -> Sort (cost=2740451.66..2740451.66 rows=8051775 width=48) > (actual time=460577.55..474657.59 rows=8117748 loops=1) > -> Hash Join (cost=128.26..409517.83 rows=8051775 > width=48) (actual time=11.45..85332.88 rows=8117748 loops=1) > -> Seq Scan on spk_tgplog l (cost=0.00..187965.75 > rows=8051775 width=8) (actual time=0.03..28926.67 rows=8125690 loops=1) > -> Hash (cost=123.41..123.41 rows=1941 width=40) > (actual time=11.28..11.28 rows=0 loops=1) > -> Seq Scan on spk_tgp t (cost=0.00..123.41 > rows=1941 width=40) (actual time=0.06..7.60 rows=1880 loops=1) > Total runtime: 529542.66 msec The join itself is being done fine --- I doubt there is another option that will go faster, given the difference in the table sizes. Note the join step completes in only 85 seconds. What is killing you is the sorting/grouping operation. You could try increasing sort_mem to see if that makes it go any faster, but I suspect the best answer would be to update to PG 7.4. 7.4 will probably use hash aggregation for this and avoid the sort altogether. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Feb 17 21:44:12 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C42ABD1D501 for ; Wed, 18 Feb 2004 01:44:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 21098-10 for ; Tue, 17 Feb 2004 21:44:05 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id A7092D1DD60 for ; Tue, 17 Feb 2004 21:43:59 -0400 (AST) Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i1I1hI4v061195; Wed, 18 Feb 2004 09:43:19 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <4032C4C8.2090200@familyhealth.com.au> Date: Wed, 18 Feb 2004 09:50:00 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bill Moran Cc: Saleem Burhani Baloch , pgsql-performance@postgresql.org Subject: Re: Slow response of PostgreSQL References: <200402170624.i1H6O2u16022@ns2.khi.wol.net.pk> <4031BBBC.5050002@familyhealth.com.au> <403210FB.5040209@potentialtech.com> In-Reply-To: <403210FB.5040209@potentialtech.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/202 X-Sequence-Number: 5726 >>> 1- How can I lock a single record so that other users can only read >>> it. ?? >> >> >> You cannot do that in PostgreSQL. > > > How about SELECT ... FOR UPDATE? No, because users cannot read the locked row in that case. Chris From pgsql-performance-owner@postgresql.org Tue Feb 17 21:58:05 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E795BD1DF05 for ; Wed, 18 Feb 2004 01:58:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 33844-03 for ; Tue, 17 Feb 2004 21:58:01 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 4E242D1DAB0 for ; Tue, 17 Feb 2004 21:57:57 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1I1uiVo003634; Tue, 17 Feb 2004 18:56:44 -0700 (MST) Date: Tue, 17 Feb 2004 18:50:08 -0700 (MST) From: "scott.marlowe" To: Christopher Kings-Lynne Cc: Bill Moran , Saleem Burhani Baloch , Subject: Re: Slow response of PostgreSQL In-Reply-To: <4032C4C8.2090200@familyhealth.com.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/203 X-Sequence-Number: 5727 On Wed, 18 Feb 2004, Christopher Kings-Lynne wrote: > >>> 1- How can I lock a single record so that other users can only read > >>> it. ?? > >> > >> > >> You cannot do that in PostgreSQL. > > > > > > How about SELECT ... FOR UPDATE? > > No, because users cannot read the locked row in that case. I just tested it (within transactions) and it appeared that I could still view the rows selected for update. From pgsql-performance-owner@postgresql.org Tue Feb 17 22:21:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 221D6D1D501 for ; Wed, 18 Feb 2004 02:21:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 36604-05 for ; Tue, 17 Feb 2004 22:21:35 -0400 (AST) Received: from internet.potentialtech.com (h-66-167-251-6.PHLAPAFG.covad.net [66.167.251.6]) by svr1.postgresql.org (Postfix) with ESMTP id 5585DD1B484 for ; Tue, 17 Feb 2004 22:21:31 -0400 (AST) Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP id A539669A71; Tue, 17 Feb 2004 21:21:34 -0500 (EST) Message-ID: <4032CC2B.9030208@potentialtech.com> Date: Tue, 17 Feb 2004 21:21:31 -0500 From: Bill Moran User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "scott.marlowe" Cc: Christopher Kings-Lynne , Saleem Burhani Baloch , pgsql-performance@postgresql.org Subject: Re: Slow response of PostgreSQL References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/204 X-Sequence-Number: 5728 scott.marlowe wrote: > On Wed, 18 Feb 2004, Christopher Kings-Lynne wrote: > >>>>>1- How can I lock a single record so that other users can only read >>>>>it. ?? >>>> >>>> >>>>You cannot do that in PostgreSQL. >>> >>> >>>How about SELECT ... FOR UPDATE? >> >>No, because users cannot read the locked row in that case. > > I just tested it (within transactions) and it appeared that I could still > view the rows selected for update. Thank you. I was just about to test it myself. The user's guide, section 9.3.2 states that this is the case: i.e. select for update will prevent concurrent updating of the row, while allowing queries utilizing that row to succeed. -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Wed Feb 18 00:49:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B7858D1DD99 for ; Wed, 18 Feb 2004 04:49:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 71627-07 for ; Wed, 18 Feb 2004 00:49:47 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 230A3D1DD84 for ; Wed, 18 Feb 2004 00:49:46 -0400 (AST) Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i1I4nA4v083195; Wed, 18 Feb 2004 12:49:10 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <4032EFA7.2040106@familyhealth.com.au> Date: Wed, 18 Feb 2004 12:52:55 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "scott.marlowe" Cc: Bill Moran , Saleem Burhani Baloch , pgsql-performance@postgresql.org Subject: Re: Slow response of PostgreSQL References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/205 X-Sequence-Number: 5729 >>>How about SELECT ... FOR UPDATE? >> >>No, because users cannot read the locked row in that case. > > > I just tested it (within transactions) and it appeared that I could still > view the rows selected for update. Ah, true. My mistake. OK, well you can do it in postgres then... Chris From pgsql-performance-owner@postgresql.org Wed Feb 18 02:52:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4B683D1DD59 for ; Wed, 18 Feb 2004 06:52:29 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 89358-08 for ; Wed, 18 Feb 2004 02:52:28 -0400 (AST) Received: from filer (c-24-6-183-218.client.comcast.net [24.6.183.218]) by svr1.postgresql.org (Postfix) with ESMTP id 2F2DFD1D25D for ; Wed, 18 Feb 2004 02:52:27 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Tue, 17 Feb 2004 22:52:26 -0800 Date: Tue, 17 Feb 2004 22:52:26 -0800 From: Kevin Brown To: pgsql-performance Subject: Re: UPDATE with subquery too slow Message-ID: <20040218065225.GB3090@filer> Mail-Followup-To: Kevin Brown , pgsql-performance References: <00ed01c3f552$ec054e80$c300000a@caliente> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <00ed01c3f552$ec054e80$c300000a@caliente> Organization: Frobozzco International User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/206 X-Sequence-Number: 5730 Eric Jain wrote: > I can't get the following statement to complete with reasonable time. > I've had it running for over ten hours without getting anywhere. I > suspect (hope) there may be a better way to accomplish what I'm trying > to do (set fields containing unique values to null): [...] > Using EXISTS rather than IN (I'm using 7.4-RC2, not sure if IN queries > were already improved in this release): > > UPDATE requests > SET session = NULL > WHERE NOT EXISTS > ( > SELECT r.session > FROM requests r > WHERE > r.session = session > AND NOT r.id = id > ); I suppose you could try: UPDATE requests SET session = NULL WHERE EXISTS ( SELECT r.session FROM requests r WHERE r.session = session GROUP BY r.session HAVING count(*) = 1 ); but I don't know that you'll get much different results than your version. -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Wed Feb 18 11:25:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6361FD1E0DA for ; Wed, 18 Feb 2004 15:25:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 62367-03 for ; Wed, 18 Feb 2004 11:25:12 -0400 (AST) Received: from yapok.nexcerpt.com (mail.nexcerpt.com [64.147.202.2]) by svr1.postgresql.org (Postfix) with ESMTP id B6AE0D1E0D4 for ; Wed, 18 Feb 2004 11:25:07 -0400 (AST) Received: from nexcerpt.com (DSL-NE-21.qtm.net [216.163.37.21]) (authenticated bits=0) by yapok.nexcerpt.com (8.12.8/8.12.8) with ESMTP id i1IFOp8W001486 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=OK); Wed, 18 Feb 2004 10:24:55 -0500 Message-ID: <403383A6.7090101@nexcerpt.com> Date: Wed, 18 Feb 2004 10:24:22 -0500 From: Jeff Boes Organization: Nexcerpt, Inc. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance Subject: Optimizer difference using function index between 7.3 and 7.4 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/207 X-Sequence-Number: 5731 We have a large (several million row) table with a field containing URLs. Now, funny thing about URLs: they mostly start with a common substring ("http://www."). But not all the rows start with this, so we can't just lop off the first N characters. However, we noticed some time ago that an index on this field wasn't as effective as an index on the REVERSE of the field. So ... CREATE OR REPLACE FUNCTION fn_urlrev(text) returns text as ' return reverse(lc($_[0])) ' language 'plperl' with (iscachable,isstrict); and then CREATE UNIQUE INDEX ix_links_3 ON links (fn_urlrev(path_base)); seemed to be much faster. When we have to look up a single entry in "links", we do so by something like -- SELECT * FROM links WHERE fn_urlrev(path_base) = ?; and it's rather fast. When we have a bunch of them to do, under 7.3 we found it useful to create a temporary table, fill it with reversed URLs, and join: INSERT INTO temp_link_urls VALUES (fn_urlrev(?)); SELECT l.path_base,l.link_id FROM links l JOIN temp_link_urls t ON (fn_urlrev(l.path_base) = t.rev_path_base); Here are query plans from the two versions (using a temp table with 200 rows, after ANALYZE on the temp table): 7.3: # explain select link_id from links l join clm_tmp_links t on (fn_urlrev(l.path_base) = t.rev_path_base); QUERY PLAN ----------------------------------------------------------------------------------------- Nested Loop (cost=0.00..3936411.13 rows=2000937 width=152) -> Seq Scan on clm_tmp_links t (cost=0.00..5.00 rows=200 width=74) -> Index Scan using ix_links_3 on links l (cost=0.00..19531.96 rows=10005 width=78) Index Cond: (fn_urlrev(l.path_base) = "outer".rev_path_base) (4 rows) 7.4: # explain select link_id from links l join clm_tmp_links t on (fn_urlrev(l.path_base) = t.rev_path_base); QUERY PLAN ------------------------------------------------------------------------------ Hash Join (cost=5.50..88832.88 rows=1705551 width=4) Hash Cond: (fn_urlrev("outer".path_base) = "inner".rev_path_base) -> Seq Scan on links l (cost=0.00..50452.50 rows=1705550 width=78) -> Hash (cost=5.00..5.00 rows=200 width=74) -> Seq Scan on clm_tmp_links t (cost=0.00..5.00 rows=200 width=74) (5 rows) Although the cost for the 7.4 query is lower, the 7.3 plan executes in about 3 seconds, while the 7.4 plan executes in 59.8 seconds! Now the odd part: if I change the query to this: # explain analyze select link_id from links l join clm_tmp_links t on (fn_urlrev(l.path_base) = fn_urlrev(t.rev_path_base)); QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- Merge Join (cost=12.64..219974.16 rows=1705551 width=4) (actual time=17.928..17.928 rows=0 loops=1) Merge Cond: (fn_urlrev("outer".path_base) = "inner"."?column2?") -> Index Scan using ix_links_3 on links l (cost=0.00..173058.87 rows=1705550 width=78) (actual time=0.229..0.285 rows=7 loops=1) -> Sort (cost=12.64..13.14 rows=200 width=74) (actual time=9.652..9.871 rows=200 loops=1) Sort Key: fn_urlrev(t.rev_path_base) -> Seq Scan on clm_tmp_links t (cost=0.00..5.00 rows=200 width=74) (actual time=0.166..5.753 rows=200 loops=1) Total runtime: 18.125 ms (i.e., apply the function to the data in the temp table), it runs a whole lot faster! Is this a bug in the optimizer? Or did something change about the way functional indexes are used? -- Jeff Boes vox 269.226.9550 ext 24 Database Engineer fax 269.349.9076 Nexcerpt, Inc. http://www.nexcerpt.com ...Nexcerpt... Extend your Expertise From pgsql-performance-owner@postgresql.org Wed Feb 18 12:55:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BDEEED1B456 for ; Wed, 18 Feb 2004 16:55:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 93743-07 for ; Wed, 18 Feb 2004 12:55:26 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id ECA90D1E0EF for ; Wed, 18 Feb 2004 12:55:24 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1IGtM5S024253; Wed, 18 Feb 2004 11:55:23 -0500 (EST) To: Jeff Boes Cc: pgsql-performance Subject: Re: Optimizer difference using function index between 7.3 and 7.4 In-reply-to: <403383A6.7090101@nexcerpt.com> References: <403383A6.7090101@nexcerpt.com> Comments: In-reply-to Jeff Boes message dated "Wed, 18 Feb 2004 10:24:22 -0500" Date: Wed, 18 Feb 2004 11:55:22 -0500 Message-ID: <24252.1077123322@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/208 X-Sequence-Number: 5732 Jeff Boes writes: > Is this a bug in the optimizer? Or did something > change about the way functional indexes are used? In 7.3, the only possible plan for these queries was a nestloop or nestloop with inner indexscan, because the planner could not generate merge or hash joins on join conditions more complex than "var1 = var2". You were fortunate that a nestloop was fast enough for your situation. In 7.4 the planner can (as you see) generate both merge and hash options for this query. What it's not very good at yet is picking the best option to use, because it doesn't have any statistics about the distribution of functional indexes, and so it's pretty much guessing about selectivity. As of just a couple days ago, there is code in CVS tip that keeps and uses stats about the values of functional index columns. It seems likely that this would help out tremendously in terms of estimating the costs well for your problem. Don't suppose you'd like to try setting up a test system with your data and trying it ... BTW, as best I can tell, the amazing speed for the mergejoin is a bit of a fluke. > Merge Join (cost=12.64..219974.16 rows=1705551 width=4) (actual > time=17.928..17.928 rows=0 loops=1) > Merge Cond: (fn_urlrev("outer".path_base) = "inner"."?column2?") > -> Index Scan using ix_links_3 on links l (cost=0.00..173058.87 > rows=1705550 width=78) (actual time=0.229..0.285 rows=7 loops=1) > -> Sort (cost=12.64..13.14 rows=200 width=74) (actual > time=9.652..9.871 rows=200 loops=1) > Sort Key: fn_urlrev(t.rev_path_base) > -> Seq Scan on clm_tmp_links t (cost=0.00..5.00 rows=200 > width=74) (actual time=0.166..5.753 rows=200 loops=1) > Total runtime: 18.125 ms Notice how the indexscan on links is reporting that it only returned 7 rows. Ordinarily you'd expect that it'd scan the whole table (and that's what the cost estimate is expecting). I think what must have happened is that the scan stopped only a little way into the table, because the sequence of values from the temp table ended with a value that was close to the start of the range of values in the main table. Mergejoin stops fetching as soon as it exhausts either input table. This was good luck for you in this case but would likely not hold up with another set of temp values. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Feb 18 15:12:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DAEA8D1E12F for ; Wed, 18 Feb 2004 19:12:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 54813-02 for ; Wed, 18 Feb 2004 15:12:27 -0400 (AST) Received: from expasy-ng.isb-sib.ch (expasy-f.unige.ch [192.33.215.142]) by svr1.postgresql.org (Postfix) with ESMTP id 8DB08D1D315 for ; Wed, 18 Feb 2004 15:12:24 -0400 (AST) Received: from caliente (router.isb-sib.ch [192.33.215.254]) (authenticated bits=0) by expasy-ng.isb-sib.ch (8.12.10/8.12.8) with ESMTP id i1IJC1Yn032358 for ; Wed, 18 Feb 2004 20:12:02 +0100 Message-ID: <013401c3f653$14f95970$c300000a@caliente> From: "Eric Jain" To: "pgsql-performance" References: <00ed01c3f552$ec054e80$c300000a@caliente> Subject: Re: UPDATE with subquery too slow Date: Wed, 18 Feb 2004 20:11:58 +0100 Organization: Swiss Institute of Bioinformatics 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 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-sib-MailScanner-Information: Please contact the ISP for more information X-sib-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/209 X-Sequence-Number: 5733 > I can't get the following statement to complete with reasonable time. Upgraded to 7.4.1, and realized that NOT IN is far more efficient than IN, EXISTS or NOT EXISTS, at least for the amount and distribution of data that I have. Here are some numbers from before and after performing the problematic clean up operation: | Before | After ------------------------+-----------+----------- COUNT(*) | 6'104'075 | 6'104'075 COUNT(session) | 5'945'272 | 3'640'659 COUNT(DISTINCT session) | 2'865'570 | 560'957 The following query completes within less than three hours on a machine with a high load, versa many many hours for any of the alternatives: UPDATE requests SET session = NULL WHERE session NOT IN ( SELECT r.session FROM requests r WHERE r.session IS NOT NULL GROUP BY r.session HAVING COUNT(*) > 1 ); Note that in order to correctly reverse an IN subquery, IS NOT NULL needs to be added. Interestingly, the query planner believes that using EXISTS would be more efficient than NOT IN, and IN only slightly less efficient; I assume the query planner is not able to accurately estimate the number of rows returned by the subquery. EXISTS 351'511 NOT IN 376'577 IN 386'780 LEFT JOIN 18'263'826 NOT EXISTS 7'241'815'330 From pgsql-performance-owner@postgresql.org Sat Feb 21 02:09:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 99829D1D1A4 for ; Wed, 18 Feb 2004 22:53:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 23927-09 for ; Wed, 18 Feb 2004 18:53:23 -0400 (AST) Received: from smtp811.mail.sc5.yahoo.com (smtp811.mail.sc5.yahoo.com [66.163.170.81]) by svr1.postgresql.org (Postfix) with SMTP id AB24FD1E0F4 for ; Wed, 18 Feb 2004 18:53:19 -0400 (AST) Received: from unknown (HELO ANDYXP) (drlaz@sbcglobal.net@64.160.53.113 with login) by smtp811.mail.sc5.yahoo.com with SMTP; 18 Feb 2004 22:52:18 -0000 Message-ID: <0a0c01c3f671$ceb08c80$847ba8c0@ANDYXP> From: "Andrew Lazarus" To: Subject: JOIN order, 15K, 15K, 7MM rows Date: Wed, 18 Feb 2004 14:51:52 -0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0A09_01C3F62E.BE85BCB0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=BAYES_44, HTML_MESSAGE, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200402/245 X-Sequence-Number: 5769 This is a multi-part message in MIME format. ------=_NextPart_000_0A09_01C3F62E.BE85BCB0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable All three tables have the same integer key, and it's indexed. I parenthesized the joins to do the two small tables first. I'm running and INSERT INTO ... SELECT query with this join (one record add= ed per record in join), 4 hours down and all I have to show for it is 100 r= ecycled transaction logs. ? If it ever returns, I can post the Explain output. ------=_NextPart_000_0A09_01C3F62E.BE85BCB0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
All three tables have the same int= eger key,=20 and it's indexed.
 
I parenthesized the joins to do th= e two=20 small tables first.
 
I'm running and INSERT INTO ... SE= LECT=20 query with this join (one record added per record in join), 4 hours down an= d all=20 I have to show for it is 100 recycled transaction logs. ?
 
If it ever returns, I can post the= Explain=20 output.
------=_NextPart_000_0A09_01C3F62E.BE85BCB0-- From pgsql-performance-owner@postgresql.org Wed Feb 18 20:11:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EB6D7D1E13A for ; Thu, 19 Feb 2004 00:11:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 55215-01 for ; Wed, 18 Feb 2004 20:11:42 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id D7AC2D1E145 for ; Wed, 18 Feb 2004 20:11:38 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4453408 for pgsql-performance@postgresql.org; Wed, 18 Feb 2004 16:12:32 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "pgsql-performance" Subject: Forcing filter/join order? Date: Wed, 18 Feb 2004 16:10:31 -0800 User-Agent: KMail/1.5.4 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402181610.31978.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/210 X-Sequence-Number: 5734 Folks, Have an interesting issue with a complex query, where apparently I need to twist the query planner's arm, and am looking for advice on how to do so. The situation: I have a table, events, with about 300,000 records. It does an outer join to a second table, cases, with about 150,000 records. A very simplified version query would be like SELECT * FROM events LEFT OUTER JOIN cases ON events.case_id = cases.case_id WHERE events.event_date BETWEEN 'date1' AND 'date2' This join is very expensive, as you can imagine. Yet I can't seem to force the query planner to apply the filter conditions to the events table *before* attempting to join it to cases. Here's the crucial explain lines: -> Merge Left Join (cost=0.00..11880.82 rows=15879 width=213) (actual time=5.777..901.899 rows=648 loops=1) Merge Cond: ("outer".case_id = "inner".case_id) Join Filter: (("outer".link_type)::text = 'case'::text) -> Index Scan using idx_event_ends on events (cost=0.00..4546.15 rows=15879 width=80 ) (actual time=4.144..333.769 rows=648 loops=1) Filter: ((status <> 0) AND ((event_date + duration) >= '2004-02-18 00:00:00'::timestamp without time zone) AND (event_date <= '2004-03-05 23:59:00'::timestamp without time zone)) -> Index Scan using cases_pkey on cases (cost=0.00..6802.78 rows=117478 width=137) ( actual time=0.139..402.363 rows=116835 loops=1) As you can see, part of the problem is a pretty drastic (20x) mis-estimation of the selectivity of the date limits on events -- and results in 90% of the execution time of my query on this one join. I've tried raising the statistics on event_date, duration, and case_id (to 1000), but this doesn't seem to affect the estimate or the query plan. In the above test, idx_event_ends indexes (case_id, status, event_date, (event_date + duration)), but as you can see the planner uses only the first column. This was an attempt to circumvent the planner's tendency to completely ignoring any index on (event_date, (event_date + duration)) -- even though that index is the most selective combination on the events table. Is there anything I can do to force the query planner to filter on events before joining cases, other than waiting for version 7.5? -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Feb 18 20:31:42 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DAE3AD1E140 for ; Thu, 19 Feb 2004 00:31:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 59429-05 for ; Wed, 18 Feb 2004 20:31:35 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 503D4D1E0D4 for ; Wed, 18 Feb 2004 20:31:32 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4453533 for pgsql-performance@postgresql.org; Wed, 18 Feb 2004 16:32:41 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "pgsql-performance" Subject: Re: Forcing filter/join order? Date: Wed, 18 Feb 2004 16:30:43 -0800 User-Agent: KMail/1.5.4 References: <200402181610.31978.josh@agliodbs.com> In-Reply-To: <200402181610.31978.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402181630.43503.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/212 X-Sequence-Number: 5736 Folks, Hmmm posted too soon. Figured out the problem: The planner can't, or doesn't want to, use an index on (event_date, (event_date + duration)) where the first column is an ascending sort and the second a descending sort. So I've coded a workaround that's quite inelegant but does get the correct results in 0.3 seconds (as opposed to the 2.2 seconds taken by the example plan). Is this the sort of thing which is ever likely to get fixed, or just a fundamental limitation of index algorithms? Would using a non B-Tree index allow me to work around this? -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Feb 18 20:32:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 465E5D1E0CD for ; Thu, 19 Feb 2004 00:32:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 62047-03 for ; Wed, 18 Feb 2004 20:32:42 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 9B3F9D1E0C7 for ; Wed, 18 Feb 2004 20:32:38 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4453535; Wed, 18 Feb 2004 16:33:50 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Peter Darley" , "pgsql-performance" Subject: Re: Forcing filter/join order? Date: Wed, 18 Feb 2004 16:31:54 -0800 User-Agent: KMail/1.5.4 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402181631.54175.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/213 X-Sequence-Number: 5737 Peter, > I'm sure the big brains have a better suggestion, but in the mean time > could you do something as simple as: > > SELECT * > FROM (select * from events where event_date BETWEEN 'date1' AND 'date2') e > LEFT OUTER JOIN cases ON e.case_id = cases.case_id; Thanks, but that doens't work; the planner will collapse the subquery into the main query, which most of the time is the right thing to do. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Feb 18 20:30:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 79836D1E13A for ; Thu, 19 Feb 2004 00:30:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 59666-04 for ; Wed, 18 Feb 2004 20:30:00 -0400 (AST) Received: from mail5.speakeasy.net (mail5.speakeasy.net [216.254.0.205]) by svr1.postgresql.org (Postfix) with ESMTP id EE78FD1E0C7 for ; Wed, 18 Feb 2004 20:29:56 -0400 (AST) Received: (qmail 15994 invoked from network); 19 Feb 2004 00:29:54 -0000 Received: from mail.kinesis-cem.com (HELO pdarley) ([64.81.9.230]) (envelope-sender ) by mail5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 19 Feb 2004 00:29:54 -0000 From: "Peter Darley" To: , "pgsql-performance" Subject: Re: Forcing filter/join order? Date: Wed, 18 Feb 2004 16:40:33 -0800 Message-ID: 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 IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: <200402181610.31978.josh@agliodbs.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/211 X-Sequence-Number: 5735 Josh, I'm sure the big brains have a better suggestion, but in the mean time could you do something as simple as: SELECT * FROM (select * from events where event_date BETWEEN 'date1' AND 'date2') e LEFT OUTER JOIN cases ON e.case_id = cases.case_id; Thanks, Peter Darley -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Josh Berkus Sent: Wednesday, February 18, 2004 4:11 PM To: pgsql-performance Subject: [PERFORM] Forcing filter/join order? Folks, Have an interesting issue with a complex query, where apparently I need to twist the query planner's arm, and am looking for advice on how to do so. The situation: I have a table, events, with about 300,000 records. It does an outer join to a second table, cases, with about 150,000 records. A very simplified version query would be like SELECT * FROM events LEFT OUTER JOIN cases ON events.case_id = cases.case_id WHERE events.event_date BETWEEN 'date1' AND 'date2' This join is very expensive, as you can imagine. Yet I can't seem to force the query planner to apply the filter conditions to the events table *before* attempting to join it to cases. Here's the crucial explain lines: -> Merge Left Join (cost=0.00..11880.82 rows=15879 width=213) (actual time=5.777..901.899 rows=648 loops=1) Merge Cond: ("outer".case_id = "inner".case_id) Join Filter: (("outer".link_type)::text = 'case'::text) -> Index Scan using idx_event_ends on events (cost=0.00..4546.15 rows=15879 width=80 ) (actual time=4.144..333.769 rows=648 loops=1) Filter: ((status <> 0) AND ((event_date + duration) >= '2004-02-18 00:00:00'::timestamp without time zone) AND (event_date <= '2004-03-05 23:59:00'::timestamp without time zone)) -> Index Scan using cases_pkey on cases (cost=0.00..6802.78 rows=117478 width=137) ( actual time=0.139..402.363 rows=116835 loops=1) As you can see, part of the problem is a pretty drastic (20x) mis-estimation of the selectivity of the date limits on events -- and results in 90% of the execution time of my query on this one join. I've tried raising the statistics on event_date, duration, and case_id (to 1000), but this doesn't seem to affect the estimate or the query plan. In the above test, idx_event_ends indexes (case_id, status, event_date, (event_date + duration)), but as you can see the planner uses only the first column. This was an attempt to circumvent the planner's tendency to completely ignoring any index on (event_date, (event_date + duration)) -- even though that index is the most selective combination on the events table. Is there anything I can do to force the query planner to filter on events before joining cases, other than waiting for version 7.5? -- -Josh Berkus Aglio Database Solutions San Francisco ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings From pgsql-performance-owner@postgresql.org Wed Feb 18 20:56:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BF485D1E13A for ; Thu, 19 Feb 2004 00:56:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 63617-07 for ; Wed, 18 Feb 2004 20:56:37 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 8B3C4D1E14B for ; Wed, 18 Feb 2004 20:56:34 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 9D567352E2; Wed, 18 Feb 2004 16:56:22 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 9BE9135291; Wed, 18 Feb 2004 16:56:22 -0800 (PST) Date: Wed, 18 Feb 2004 16:56:22 -0800 (PST) From: Stephan Szabo To: Josh Berkus Cc: pgsql-performance Subject: Re: Forcing filter/join order? In-Reply-To: <200402181630.43503.josh@agliodbs.com> Message-ID: <20040218165410.G36125@megazone.bigpanda.com> References: <200402181610.31978.josh@agliodbs.com> <200402181630.43503.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/214 X-Sequence-Number: 5738 On Wed, 18 Feb 2004, Josh Berkus wrote: > The planner can't, or doesn't want to, use an index on (event_date, > (event_date + duration)) where the first column is an ascending sort and the > second a descending sort. So I've coded a workaround that's quite > inelegant but does get the correct results in 0.3 seconds (as opposed to the > 2.2 seconds taken by the example plan). Can you give more information? I know that I'm not exactly certain what the situation is from the above and the original query/explain piece. From pgsql-performance-owner@postgresql.org Wed Feb 18 21:19:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 804C7D1E0CD for ; Thu, 19 Feb 2004 01:19:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 62220-08 for ; Wed, 18 Feb 2004 21:19:13 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 51400D1E0C7 for ; Wed, 18 Feb 2004 21:19:10 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4453754; Wed, 18 Feb 2004 17:20:19 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Stephan Szabo Subject: Re: Forcing filter/join order? Date: Wed, 18 Feb 2004 17:18:22 -0800 User-Agent: KMail/1.5.4 Cc: pgsql-performance References: <200402181610.31978.josh@agliodbs.com> <200402181630.43503.josh@agliodbs.com> <20040218165410.G36125@megazone.bigpanda.com> In-Reply-To: <20040218165410.G36125@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402181718.22687.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/215 X-Sequence-Number: 5739 Stephan, > Can you give more information? I know that I'm not exactly certain what > the situation is from the above and the original query/explain piece. > Believe me, if I posted the query it wouldn't help. Heck, I'd have trouble following it without my notes. a simplifed version: SELECT events.*, cases.case_name FROM events LEFT OUTER JOIN cases ON events.case_id = cases.case_id WHERE (event_date >= '2004-03-05' OR (event_date + duration) <= '2004-02-18') AND events.status <> 0; ... this is to get me all vaild events which overlap with the range '2004-02-18' to '2004-03-05'. I had thought, in 7.4, that adding an index on (event_date, (event_date + duration)) would improve the execution of this query. It doesn't, presumably because the multi-column index can't be used for both ascending and descending sorts at the same time, and event_date >= '2004-03-05' isn't selective enough. There was a workaround for this posted on hackers about a year ago as I recally, that involved creating custom operators for indexing. Too much trouble when there's a hackish workaround (due to the fact that events have to be less than a month long). -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Feb 18 23:14:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 86AF8D1E0DB for ; Thu, 19 Feb 2004 03:14:52 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 87715-09 for ; Wed, 18 Feb 2004 23:14:51 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 7188FD1E0DE for ; Wed, 18 Feb 2004 23:14:47 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 172EE357B5; Wed, 18 Feb 2004 19:14:52 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 15AE3357B2; Wed, 18 Feb 2004 19:14:52 -0800 (PST) Date: Wed, 18 Feb 2004 19:14:52 -0800 (PST) From: Stephan Szabo To: Josh Berkus Cc: pgsql-performance Subject: Re: Forcing filter/join order? In-Reply-To: <200402181718.22687.josh@agliodbs.com> Message-ID: <20040218185530.A38717@megazone.bigpanda.com> References: <200402181610.31978.josh@agliodbs.com> <200402181630.43503.josh@agliodbs.com> <20040218165410.G36125@megazone.bigpanda.com> <200402181718.22687.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/216 X-Sequence-Number: 5740 On Wed, 18 Feb 2004, Josh Berkus wrote: > Stephan, > > > Can you give more information? I know that I'm not exactly certain what > > the situation is from the above and the original query/explain piece. > > > > Believe me, if I posted the query it wouldn't help. Heck, I'd have trouble > following it without my notes. > > a simplifed version: > > SELECT events.*, cases.case_name > FROM events LEFT OUTER JOIN cases ON events.case_id = cases.case_id > WHERE (event_date >= '2004-03-05' OR (event_date + duration) <= '2004-02-18') > AND events.status <> 0; > > ... this is to get me all vaild events which overlap with the range > '2004-02-18' to '2004-03-05'. > > I had thought, in 7.4, that adding an index on (event_date, (event_date + > duration)) would improve the execution of this query. It doesn't, > presumably because the multi-column index can't be used for both ascending > and descending sorts at the same time, and event_date >= '2004-03-05' isn't > selective enough. I don't think the direction issue is the problem in the above. I think the problem is that given a condition like: a>value or bvalue alone since that'd do the wrong thing. Testing on a two column table, I see behavior like the following (with seqscan off) sszabo=# create table q2(a int, b int); CREATE TABLE sszabo=# create index q2ind on q2(a,b); CREATE INDEX sszabo=# set enable_seqscan=off; SET sszabo=# explain select * from q2 where a>3 and b<5; QUERY PLAN ------------------------------------------------------------------- Index Scan using q2ind on q2 (cost=0.00..42.79 rows=112 width=8) Index Cond: ((a > 3) AND (b < 5)) (2 rows) sszabo=# explain select * from q2 where a>3 or b<5; QUERY PLAN -------------------------------------------------------------------- Seq Scan on q2 (cost=100000000.00..100000025.00 rows=556 width=8) Filter: ((a > 3) OR (b < 5)) (2 rows) sszabo=# create index q2ind2 on q2(b); CREATE INDEX sszabo=# explain select * from q2 where a>3 or b<5; QUERY PLAN --------------------------------------------------------------------------- Index Scan using q2ind, q2ind2 on q2 (cost=0.00..92.68 rows=556 width=8) Index Cond: ((a > 3) OR (b < 5)) (2 rows) From pgsql-performance-owner@postgresql.org Thu Feb 19 00:26:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D224CD1E15F for ; Thu, 19 Feb 2004 04:26:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 16357-03 for ; Thu, 19 Feb 2004 00:26:30 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id D5161D1E164 for ; Thu, 19 Feb 2004 00:26:23 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1J4QAtr028697; Wed, 18 Feb 2004 23:26:10 -0500 (EST) To: josh@agliodbs.com Cc: Stephan Szabo , pgsql-performance Subject: Re: Forcing filter/join order? In-reply-to: <200402181718.22687.josh@agliodbs.com> References: <200402181610.31978.josh@agliodbs.com> <200402181630.43503.josh@agliodbs.com> <20040218165410.G36125@megazone.bigpanda.com> <200402181718.22687.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Wed, 18 Feb 2004 17:18:22 -0800" Date: Wed, 18 Feb 2004 23:26:10 -0500 Message-ID: <28696.1077164770@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/217 X-Sequence-Number: 5741 Josh Berkus writes: > SELECT events.*, cases.case_name > FROM events LEFT OUTER JOIN cases ON events.case_id = cases.case_id > WHERE (event_date >= '2004-03-05' OR (event_date + duration) <= '2004-02-18') > AND events.status <> 0; > ... this is to get me all vaild events which overlap with the range > '2004-02-18' to '2004-03-05'. Did you mean events that *don't* overlap with the range? Seems like what you say you want should be expressed as event_date <= 'end-date' AND (event_date + duration) >= 'start-date' This assumes duration is never negative of course. I think you could make this btree-indexable by negating the second clause. Imagine create index evi on events (event_date, (-(event_date+duration))) and then transforming the query to event_date <= 'end-date' AND -(event_date + duration) <= -'start-date' but that doesn't quite work because there's no unary minus for date or timestamp types. Is this too ugly for you? create index evi on events (event_date, ('ref-date'-event_date-duration)) event_date <= 'end-date' AND ('ref-date'-event_date-duration) <= 'ref-date'-'start-date' where 'ref-date' is any convenient fixed reference date, say 1-1-2000. Now, what this will look like to the planner is a one-sided two-column restriction, and I'm not certain that the planner will assign a sufficiently small selectivity estimate. But in theory it could work. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Feb 19 00:50:38 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E07D5D1E0C7 for ; Thu, 19 Feb 2004 04:50:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 17714-08 for ; Thu, 19 Feb 2004 00:50:41 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 125C2D1B456 for ; Thu, 19 Feb 2004 00:50:35 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4454626; Wed, 18 Feb 2004 20:51:46 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Tom Lane Subject: Re: Forcing filter/join order? Date: Wed, 18 Feb 2004 20:49:49 -0800 User-Agent: KMail/1.5.4 Cc: Stephan Szabo , pgsql-performance References: <200402181610.31978.josh@agliodbs.com> <200402181718.22687.josh@agliodbs.com> <28696.1077164770@sss.pgh.pa.us> In-Reply-To: <28696.1077164770@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402182049.49111.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/218 X-Sequence-Number: 5742 Tom, First off, you are correct, I swapped the dates when typing the simplified query into e-mail. > create index evi on events (event_date, ('ref-date'-event_date-duration)) > > event_date <= 'end-date' > AND ('ref-date'-event_date-duration) <= 'ref-date'-'start-date' > > where 'ref-date' is any convenient fixed reference date, say 1-1-2000. > > Now, what this will look like to the planner is a one-sided two-column > restriction, and I'm not certain that the planner will assign a > sufficiently small selectivity estimate. But in theory it could work. Interesting idea. I'll try it just to see if it works when I have a chance. In the meantime, for production, I'll stick with the hackish solution I was using under 7.2. Knowing that events are never more than one month long for this application, I can do: "WHERE event.event_date >= (begin_date - '1 month) AND event.event_date <= end_date" ... which works because I have a child table which has event information by day: AND events.event_id IN (SELECT event_id FROM event_day WHERE calendar_day BETWEEN begin_date AND end_date); Note that this subselect isn't sufficent on its own, because once again the query planner is unable to correctly estimate the selectivity of the subselect. It needs the "help" of the filter against events.event_date. This is the workaround I was using with 7.2. I had just hoped that some of the improvements that Tom has made over the last two versions would cure the problem, but no dice. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Feb 19 00:57:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EB5EAD1B49E for ; Thu, 19 Feb 2004 04:57:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 19558-08 for ; Thu, 19 Feb 2004 00:57:39 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 1E46ED1B456 for ; Thu, 19 Feb 2004 00:57:33 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4454651; Wed, 18 Feb 2004 20:58:44 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "scott.marlowe" , Craig Thomas Subject: Re: Tables on multiple disk drives Date: Wed, 18 Feb 2004 20:56:47 -0800 User-Agent: KMail/1.5.4 Cc: , References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402182056.47376.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/219 X-Sequence-Number: 5743 Konstantin, > > >> Does PostgreSQL allow to create tables and indices of a single > > >> database on multiple disk drives with a purpose of increase > > >> performance as Oracle database does? If a symbolic reference is the > > >> only method then the next question is: how can it be determined what > > >> file is referred to what table and index? Howdy! I bet you're a bit taken aback by the discussion that ensued, and even more confused than before. You are actually asking about two related features: Tablespaces, which allows designating different directories/volumes for specific tables and indexes at creation time, and: Partitioned Tables, which allows the division of large tables and/or indexes horizontally along pre-defined criteria. The first, tablespaces, are under development and may make it for 7.5, or maybe not, but certainly in the version after that. The second, partitioned tables, is NOT under development because this feature lacks both a programmer and a clear specification. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Feb 19 01:08:21 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1C203D1E15D for ; Thu, 19 Feb 2004 05:08:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 24785-03 for ; Thu, 19 Feb 2004 01:08:24 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 0F0EDD1E141 for ; Thu, 19 Feb 2004 01:08:18 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1J58K4E028949; Thu, 19 Feb 2004 00:08:20 -0500 (EST) To: josh@agliodbs.com Cc: Stephan Szabo , pgsql-performance Subject: Re: Forcing filter/join order? In-reply-to: <200402182049.49111.josh@agliodbs.com> References: <200402181610.31978.josh@agliodbs.com> <200402181718.22687.josh@agliodbs.com> <28696.1077164770@sss.pgh.pa.us> <200402182049.49111.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Wed, 18 Feb 2004 20:49:49 -0800" Date: Thu, 19 Feb 2004 00:08:19 -0500 Message-ID: <28948.1077167299@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/220 X-Sequence-Number: 5744 Josh Berkus writes: > Knowing that events are never more than one month long for this > application, I can do: > "WHERE event.event_date >= (begin_date - '1 month) AND event.event_date <= > end_date" > ... which works because I have a child table which has event information by > day: Uh, why do you need the child table? Seems like the correct incantation given an assumption about maximum duration is event_date <= 'end-date' AND (event_date + duration) >= 'start-date' AND event_date >= 'start-date' - 'max-duration' The last clause is redundant with the one involving the duration field, but it provides a lower bound for the index scan on event_date. The only index you really need here is one on event_date, but possibly one on (event_date, (event_date + duration)) would be marginally faster. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Feb 19 05:12:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C7224D1D283 for ; Thu, 19 Feb 2004 09:12:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 78076-01 for ; Thu, 19 Feb 2004 05:12:42 -0400 (AST) Received: from ns2.khi.wol.net.pk (ns2.khi.wol.net.pk [202.154.255.21]) by svr1.postgresql.org (Postfix) with ESMTP id DE82DD1DF93 for ; Thu, 19 Feb 2004 05:12:32 -0400 (AST) Received: from khi.wol.net.pk (panda.khi.wol.net.pk [202.154.255.22]) by ns2.khi.wol.net.pk (8.11.6/8.10.1) with SMTP id i1J91KY07596; Thu, 19 Feb 2004 14:01:20 +0500 (PKT) Date: Thu, 19 Feb 2004 14:01:20 +0500 (PKT) Message-Id: <200402190901.i1J91KY07596@ns2.khi.wol.net.pk> From: "Saleem Burhani Baloch" To: pgsql-performance@postgresql.org Importance: Normal X-Mailer: VisualMail 3.0 ( http://www.minter.com.ar/visualmail ) Subject: Re: Slow response of PostgreSQL Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/221 X-Sequence-Number: 5745 Hi, Thanks every one for helping me. I have upgraded to 7.4.1 on redhat 8 ( rh 9 require a lot of lib's) and set the configuration sent by Chris. Now the query results in 6.3 sec waooo. I m thinking that why the 7.1 process aggregate slowly. Anyway. I still have to go for 2 sec result and now I m thinking to go for Free BSD 5.2. The record locking by "select ..... update for" is working fine, but a situation arrises when the second user goes for locking the record, the task will wait untill the first user ends up his work. IS their is a way that we can know or get a message that the row/record is already locked by some one else. Thanks for help. Saleem From pgsql-performance-owner@postgresql.org Thu Feb 19 05:26:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8460ED1D0B8 for ; Thu, 19 Feb 2004 09:26:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 62521-10 for ; Thu, 19 Feb 2004 05:26:28 -0400 (AST) Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) by svr1.postgresql.org (Postfix) with ESMTP id A2E42D1CB1D for ; Thu, 19 Feb 2004 05:26:20 -0400 (AST) Received: from concord.pspl.co.in ([202.54.11.72]:63314 helo=ps0499.intranet.pspl.co.in) by frodo.hserus.net with asmtp (Cipher TLSv1:RC4-MD5:128) (Exim 4.30 #0) id 1AtkRt-0008oc-AT by authid with plain; Thu, 19 Feb 2004 14:56:25 +0530 From: Shridhar Daithankar Reply-To: shridhar@frodo.hserus.net To: "Saleem Burhani Baloch" Subject: Re: Slow response of PostgreSQL Date: Thu, 19 Feb 2004 14:56:19 +0530 User-Agent: KMail/1.6 References: <200402190901.i1J91KY07596@ns2.khi.wol.net.pk> In-Reply-To: <200402190901.i1J91KY07596@ns2.khi.wol.net.pk> Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200402191456.19032.shridhar@frodo.hserus.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/222 X-Sequence-Number: 5746 On Thursday 19 February 2004 14:31, Saleem Burhani Baloch wrote: > Hi, > > Thanks every one for helping me. I have upgraded to 7.4.1 on redhat 8 ( rh > 9 require a lot of lib's) and set the configuration sent by Chris. Now the > query results in 6.3 sec waooo. I m thinking that why the 7.1 process > aggregate slowly. Anyway. > > I still have to go for 2 sec result and now I m thinking to go for Free BSD > 5.2. Before that you can try something with kernel 2.6.3. I think it could make the difference you are looking at. > The record locking by "select ..... update for" is working fine, but a > situation arrises when the second user goes for locking the record, the > task will wait untill the first user ends up his work. IS their is a way > that we can know or get a message that the row/record is already locked by > some one else. Right now, it is hotly debated on HACKERS about adding a NOWAIT clause to SELECT FOR UPDATE. If you think your application deployment is away for months and can try CVS head, you can expect some action on it in coming few days. As a side bonus you would be benefitted by performance and scalability additions that won't make there way in 7.4 stream. HTH Shridhar From pgsql-performance-owner@postgresql.org Thu Feb 19 09:52:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 77033D1E140 for ; Thu, 19 Feb 2004 13:52:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 62234-02 for ; Thu, 19 Feb 2004 09:52:58 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id ACA06D1E0CD for ; Thu, 19 Feb 2004 09:52:48 -0400 (AST) Received: from houston.familyhealth.com.au (chriskl@localhost [127.0.0.1]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i1JDqn4v088458; Thu, 19 Feb 2004 21:52:49 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from localhost (chriskl@localhost) by houston.familyhealth.com.au (8.12.9p1/8.12.9/Submit) with ESMTP id i1JDqmrG088439; Thu, 19 Feb 2004 21:52:48 +0800 (WST) X-Authentication-Warning: houston.familyhealth.com.au: chriskl owned process doing -bs Date: Thu, 19 Feb 2004 21:52:48 +0800 (WST) From: Christopher Kings-Lynne To: Saleem Burhani Baloch Cc: pgsql-performance@postgresql.org Subject: Re: Slow response of PostgreSQL In-Reply-To: <200402190901.i1J91KY07596@ns2.khi.wol.net.pk> Message-ID: <20040219213912.Y86502-100000@houston.familyhealth.com.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/223 X-Sequence-Number: 5747 > Thanks every one for helping me. I have upgraded to 7.4.1 on redhat 8 ( > rh 9 require a lot of lib's) and set the configuration sent by Chris. > Now the query results in 6.3 sec waooo. I m thinking that why the 7.1 > process aggregate slowly. Anyway. I'm glad we could help you Saleem :) We knew PostgreSQL wasn't that slow :P Chris From pgsql-performance-owner@postgresql.org Thu Feb 19 13:01:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B2563D1E157 for ; Thu, 19 Feb 2004 17:01:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 38953-02 for ; Thu, 19 Feb 2004 13:01:50 -0400 (AST) Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) by svr1.postgresql.org (Postfix) with ESMTP id ABD8AD1E154 for ; Thu, 19 Feb 2004 13:01:48 -0400 (AST) 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_01C3F705.7896B676" Subject: Postgresql on SAN Date: Thu, 19 Feb 2004 11:28:56 -0500 Message-ID: <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C847@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Postgresql on SAN Thread-Index: AcP3BXiwzxzbgyDCTVioz1RJCuwZMA== From: "Anjan Dave" To: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/224 X-Sequence-Number: 5748 This is a multi-part message in MIME format. ------_=_NextPart_001_01C3F705.7896B676 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, =20 Has anyone designed/implemented postgresql server on storage networks? =20 Are there any design considerations? =20 Are there any benchmarks for storage products (HBAs, Switches, Storage Arrays)? =20 Any recommendation on the design, resources, references, keeping PG in mind? =20 =20 Thanks, Anjan =20 ************************************************************************ **=20 This e-mail and any files transmitted with it are intended for the use of the addressee(s) only and may be confidential and covered by the attorney/client and other privileges. If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system. Any other use of this e-mail is prohibited. =20 ------_=_NextPart_001_01C3F705.7896B676 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Message
Hello,
 
Has anyon= e=20 designed/implemented postgresql server on storage networks?
 
Are there= any design=20 considerations?
 
Are there= any=20 benchmarks for storage products (HBAs, Switches, Storage=20 Arrays)?
 
Any recom= mendation=20 on the design, resources, references, keeping PG in mind?
 
 
Thanks,
Anjan
 

************************************************************************= **=20

This e-mail and any files transmitted with it are intended for the use o= f the=20 addressee(s) only and may be confidential and covered by the attorney/clien= t and=20 other privileges. If you received this e-mail in error, please notify the= =20 sender; do not disclose, copy, distribute, or take any action in reliance o= n the=20 contents of this information; and delete it from your system. Any other use= of=20 this e-mail is prohibited.

 
=00 ------_=_NextPart_001_01C3F705.7896B676-- From pgsql-performance-owner@postgresql.org Thu Feb 19 13:40:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B76EED1E149 for ; Thu, 19 Feb 2004 17:37:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 48954-05 for ; Thu, 19 Feb 2004 13:37:42 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 7C1ACD1E137 for ; Thu, 19 Feb 2004 13:37:41 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4457194; Thu, 19 Feb 2004 09:38:48 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Anjan Dave" , Subject: Re: Postgresql on SAN Date: Thu, 19 Feb 2004 09:36:47 -0800 User-Agent: KMail/1.5.4 References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C847@vt-pe2550-001.vantage.vantage.com> In-Reply-To: <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C847@vt-pe2550-001.vantage.vantage.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402190936.47208.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/225 X-Sequence-Number: 5749 Anjan, > Has anyone designed/implemented postgresql server on storage networks? Yes, Zapatec.com runs their stuff this way. Probably others as well. > Are there any design considerations? I don't know. Probably. > Are there any benchmarks for storage products (HBAs, Switches, Storage > Arrays)? Not specific to PostgreSQL. I'm sure there are generic benchmarks. Keep in mind that PostgreSQL needs lots of 2-way I/O, batch writes, and random reads. > Any recommendation on the design, resources, references, keeping PG in > mind? See above. Also keep in mind that PostgreSQL's use of I/O should improve 100% in version 7.5. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Feb 19 13:58:50 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 149AED1E0FF for ; Thu, 19 Feb 2004 17:40:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 48079-06 for ; Thu, 19 Feb 2004 13:40:03 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id EF433D1E0CD for ; Thu, 19 Feb 2004 13:40:01 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4457211; Thu, 19 Feb 2004 09:41:08 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Tom Lane Subject: Re: Forcing filter/join order? Date: Thu, 19 Feb 2004 09:39:12 -0800 User-Agent: KMail/1.5.4 Cc: Stephan Szabo , pgsql-performance References: <200402181610.31978.josh@agliodbs.com> <200402182049.49111.josh@agliodbs.com> <28948.1077167299@sss.pgh.pa.us> In-Reply-To: <28948.1077167299@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402190939.12479.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/226 X-Sequence-Number: 5750 Tom, > Uh, why do you need the child table? Because there's linked information which needs to be kept by day for multi-day events. Also, it makes calendar reports easier, where one wants each day of a multi-day event to appear on each day of the calendar. >Seems like the correct incantation > given an assumption about maximum duration is > > event_date <= 'end-date' AND (event_date + duration) >= 'start-date' > AND event_date >= 'start-date' - 'max-duration' Hmmmm ... so the same as what I have, only with the extra condition for event_date+duration and without the IN clause. I'll try it, thanks! -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Feb 19 14:23:19 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 183E3D1E078 for ; Thu, 19 Feb 2004 18:06:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 59444-05 for ; Thu, 19 Feb 2004 14:06:21 -0400 (AST) Received: from easily.co.uk (mercury0.easily.co.uk [213.161.76.90]) by svr1.postgresql.org (Postfix) with ESMTP id 6DD0FD1DF93 for ; Thu, 19 Feb 2004 14:06:18 -0400 (AST) Received: from [213.152.63.90] (account f4vo5dsy5djd HELO chuckie.co.uk) by easily.co.uk (CommuniGate Pro SMTP 4.1.3) with ESMTP id 49684497; Thu, 19 Feb 2004 18:06:14 +0000 Message-ID: <4034FB11.7070305@chuckie.co.uk> Date: Thu, 19 Feb 2004 18:06:09 +0000 From: Nick Barr User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: Anjan Dave , pgsql-performance@postgresql.org Subject: Re: Postgresql on SAN References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C847@vt-pe2550-001.vantage.vantage.com> <200402190936.47208.josh@agliodbs.com> In-Reply-To: <200402190936.47208.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/227 X-Sequence-Number: 5751 Josh Berkus wrote: >Anjan, > > > >>Has anyone designed/implemented postgresql server on storage networks? >> >> > >Yes, Zapatec.com runs their stuff this way. Probably others as well. > > > >>Are there any design considerations? >> >> > >I don't know. Probably. > > > >>Are there any benchmarks for storage products (HBAs, Switches, Storage >>Arrays)? >> >> > >Not specific to PostgreSQL. I'm sure there are generic benchmarks. Keep >in mind that PostgreSQL needs lots of 2-way I/O, batch writes, and random >reads. > > > >>Any recommendation on the design, resources, references, keeping PG in >>mind? >> >> > >See above. Also keep in mind that PostgreSQL's use of I/O should improve >100% in version 7.5. > > > We run PG on a SAN array. We currently have it setup so a single PG instance runs off of a single LUN, this includes the WAL logs. Apart from that we have made no other special considerations; we just treat it as a fast RAID array. We haven't got to the stage where the speed of the SAN is a problem as load hasn't increased as expected. This will change, when it does I am sure the performance list will be hearing from us ;-). Out current limitations, as I see it, are amount of memory and then processing power. The only problem we have had was a dodgy set of kernel modules (drivers) for the fibre cards, this was because they were beta drivers and obviously still had a few bugs. This was solved by reverting to an older version. Everything has run smoothly since then (uptime is 153 days :-)). Nick From pgsql-performance-owner@postgresql.org Thu Feb 19 16:47:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 23A68D1E157 for ; Thu, 19 Feb 2004 20:47:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 14745-08 for ; Thu, 19 Feb 2004 16:47:19 -0400 (AST) Received: from fuji.krosing.net (217-159-136-226-dsl.kt.estpak.ee [217.159.136.226]) by svr1.postgresql.org (Postfix) with ESMTP id 6EEFFD1E0CE for ; Thu, 19 Feb 2004 16:47:01 -0400 (AST) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id i1JKks9l006021; Thu, 19 Feb 2004 22:46:55 +0200 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id i1JKkqZO006019; Thu, 19 Feb 2004 22:46:52 +0200 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: Slow response of PostgreSQL From: Hannu Krosing To: Saleem Burhani Baloch Cc: pgsql-performance@postgresql.org In-Reply-To: <200402190901.i1J91KY07596@ns2.khi.wol.net.pk> References: <200402190901.i1J91KY07596@ns2.khi.wol.net.pk> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1077223611.5190.0.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Thu, 19 Feb 2004 22:46:51 +0200 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/228 X-Sequence-Number: 5752 Saleem Burhani Baloch kirjutas N, 19.02.2004 kell 11:01: > Hi, > > Thanks every one for helping me. I have upgraded to 7.4.1 on > redhat 8 ( rh 9 require a lot of lib's) and set the configuration > sent by Chris. Now the query results in 6.3 sec waooo. I m thinking > that why the 7.1 process aggregate slowly. Anyway. > > I still have to go for 2 sec result What is the plan now ? ---------------- Hannu From pgsql-performance-owner@postgresql.org Thu Feb 19 16:58:15 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0802DD1B456 for ; Thu, 19 Feb 2004 20:58:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 23464-03 for ; Thu, 19 Feb 2004 16:58:12 -0400 (AST) Received: from cmailg3.svr.pol.co.uk (cmailg3.svr.pol.co.uk [195.92.195.173]) by svr1.postgresql.org (Postfix) with ESMTP id CC22AD1D16D for ; Thu, 19 Feb 2004 16:58:09 -0400 (AST) Received: from modem-3186.llama.dialup.pol.co.uk ([217.135.188.114] helo=LaptopDellXP) by cmailg3.svr.pol.co.uk with esmtp (Exim 4.14) id 1AtvFJ-0000BI-RK; Thu, 19 Feb 2004 20:58:10 +0000 Reply-To: From: "Simon Riggs" To: "'Jeff Boes'" , "'pgsql-performance'" Subject: Re: Optimizer difference using function index between 7.3 and 7.4 Date: Thu, 19 Feb 2004 20:58:03 -0000 Organization: 2nd Quadrant Message-ID: <001901c3f72b$119b2320$0200000a@LaptopDellXP> 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.2627 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 In-Reply-To: <403383A6.7090101@nexcerpt.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/229 X-Sequence-Number: 5753 >Jeff Boes writes > # explain select link_id from links l join clm_tmp_links t on > (fn_urlrev(l.path_base) = t.rev_path_base); > executes in 59.8 seconds! > Now the odd part: if I change the query to this: > > # explain analyze select link_id from links l join clm_tmp_links t on > (fn_urlrev(l.path_base) = fn_urlrev(t.rev_path_base)); > Total runtime: 18.125 ms > > (i.e., apply the function to the data in the temp table), it runs a > whole lot faster! Is this a bug in the optimizer? Or did something > change about the way functional indexes are used? Erm..I may have misunderstood your example, but surely the second formulation of your query returns the wrong answer? It looks to me as if you are comparing a reversed URL with a twice-reversed URL; if that's true that would explain why it runs faster: They don't ever match. Is that right? Thanks for the idea of reversing the URLs, nice touch. I'd been thinking about reverse key indexes as a way of relieving the hotspot down the rightmost edge of an index during heavy insert traffic. I hadn't thought this would also speed up the access also. Best Regards, Simon Riggs From pgsql-performance-owner@postgresql.org Thu Feb 19 17:18:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0DE9CD1B52F for ; Thu, 19 Feb 2004 21:18:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 25518-07 for ; Thu, 19 Feb 2004 17:18:31 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 42EE5D1E0FF for ; Thu, 19 Feb 2004 17:18:29 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4458370; Thu, 19 Feb 2004 13:19:37 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Tom Lane Subject: Re: Forcing filter/join order? Date: Thu, 19 Feb 2004 13:17:35 -0800 User-Agent: KMail/1.5.4 Cc: Stephan Szabo , pgsql-performance References: <200402181610.31978.josh@agliodbs.com> <200402182049.49111.josh@agliodbs.com> <28948.1077167299@sss.pgh.pa.us> In-Reply-To: <28948.1077167299@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402191317.35344.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/230 X-Sequence-Number: 5754 Tom, > event_date <= 'end-date' AND (event_date + duration) >= 'start-date' > AND event_date >= 'start-date' - 'max-duration' Great suggestion! We're down to 160ms, from about 370ms with my subselect workaround. Thanks! -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-admin-owner@postgresql.org Fri Feb 20 15:18:39 2004 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B80ADD1DF7F for ; Fri, 20 Feb 2004 07:02:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 64619-04 for ; Fri, 20 Feb 2004 03:01:52 -0400 (AST) Received: from delhimail.tbdelhi.com (unknown [208.179.178.248]) by svr1.postgresql.org (Postfix) with ESMTP id EC994D1DD5D for ; Fri, 20 Feb 2004 03:01:43 -0400 (AST) Received: from VICHITRA (delhiwg1-opt.techbooks.com [208.179.178.190] (may be forged)) by delhimail.tbdelhi.com (8.9.2/8.9.2) with SMTP id MAA02790 for ; Fri, 20 Feb 2004 12:29:02 +0530 (DST) Message-ID: <008401c3f77e$a78f1d20$18dda8c0@VICHITRA> From: "V Chitra" To: Subject: Index called with Union but not with OR clause Date: Fri, 20 Feb 2004 12:26:22 +0530 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0081_01C3F7AC.C0117130" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=BAYES_44, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200402/302 X-Sequence-Number: 12476 This is a multi-part message in MIME format. ------=_NextPart_000_0081_01C3F7AC.C0117130 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi All, I have a select statement=20 select * from v_func_actual_costs where parent_project=3D'10478' or proj_pk =3D '10478' both the fields parent_project and proj_pk have indexes based on them, but = when I ran explain plan on this statement I found that none of the indexes = are being called. But, if I make two separate statement and combine them wi= th Union ALL, the indexes are being called. The select statement in this ca= se is select * from ct_admin.v_func_actual_costs where parent_project=3D'10478' union all select * from ct_admin.v_func_actual_costs where proj_pk =3D '10478'=20 Can anybody help me to find a reason for the same. This is just a part of t= he query so I cannot use the Union ALL clause. Thanks in advance Chitra ------=_NextPart_000_0081_01C3F7AC.C0117130 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi All,
 
I have a select statement 
 
select * from v_func_actual_costs
where= =20 parent_project=3D'10478' or proj_pk =3D '10478'
 
both the fields parent_project and proj_pk= have=20 indexes based on them, but when I ran explain plan on this statement I= =20 found that none of the indexes are being called. But, if I make two separat= e=20 statement and combine them with Union ALL, the indexes are being called. Th= e=20 select statement in this case is
 
select * from ct_admin.v_func_actual_costs=
where=20 parent_project=3D'10478'
union all
select * from=20 ct_admin.v_func_actual_costs
where proj_pk =3D '10478'
 
Can anybody help me to find a reason for t= he same.=20 This is just a part of the query so I cannot use the Union ALL=20 clause.
 
Thanks in advance

Chitra
------=_NextPart_000_0081_01C3F7AC.C0117130-- From pgsql-performance-owner@postgresql.org Fri Feb 20 05:14:54 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 96151D1DF05 for ; Fri, 20 Feb 2004 09:14:52 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 98781-02 for ; Fri, 20 Feb 2004 05:14:39 -0400 (AST) Received: from relay.nic.in (relay.nic.in [164.100.10.106]) by svr1.postgresql.org (Postfix) with ESMTP id 02D57D1B4C5 for ; Fri, 20 Feb 2004 05:14:35 -0400 (AST) Received: from relay.nic.in (localhost [127.0.0.1]) by relay.nic.in (8.12.10/8.12.5) with ESMTP id i1K8dotK015408 for ; Fri, 20 Feb 2004 14:09:50 +0530 Received: from banas.guj.nic.in (banas.guj.nic.in [164.100.245.211]) by relay.nic.in (8.12.10/8.12.5) with ESMTP id i1K8dcBI015336 for ; Fri, 20 Feb 2004 14:09:42 +0530 Received: from BANAS/SpoolDir by banas.guj.nic.in (Mercury 1.44); 20 Feb 04 14:46:35 +05:30 Received: from SpoolDir by BANAS (Mercury 1.44); 20 Feb 04 14:46:17 +05:30 From: Organization: Banas Dairy, Palanpur To: pgsql-performance@postgresql.org Date: Fri, 20 Feb 2004 14:46:15 +0530 MIME-Version: 1.0 Subject: Slow in morning hours Cc: vathakar@banas.guj.nic.in Message-ID: <40361DBE.3636.10FEBF@localhost> In-reply-to: <200402190936.47208.josh@agliodbs.com> References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C847@vt-pe2550-001.vantage.vantage.com> X-mailer: Pegasus Mail for Windows (v4.12a) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/231 X-Sequence-Number: 5755 Hi All, I am using Linux 7.2 and postgresql 7.2. Our Office hours are over at 6pm but we use to keep our server running 24 hours a day. On the second day morning, Our PGSQL Server becomes very slow. After continuous usage of one hour, It gradually starts responding faster ! This has become every day routine ! do u have any idea related to this !!!! Is there any other reason that I need to check up? Please any any idea to get relief daily morning problem !! Thanxs, Vishal From pgsql-performance-owner@postgresql.org Fri Feb 20 08:20:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id AD2A2D1D14B for ; Fri, 20 Feb 2004 12:20:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 49929-04 for ; Fri, 20 Feb 2004 08:19:47 -0400 (AST) Received: from fep01-mail.bloor.is.net.cable.rogers.com (fep01-mail.bloor.is.net.cable.rogers.com [66.185.86.71]) by svr1.postgresql.org (Postfix) with ESMTP id 27D40D1B4DE for ; Fri, 20 Feb 2004 08:19:43 -0400 (AST) Received: from phlogiston.dydns.org ([65.49.121.67]) by fep01-mail.bloor.is.net.cable.rogers.com (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id <20040220121928.BPVN83660.fep01-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> for ; Fri, 20 Feb 2004 07:19:28 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 70F733F40; Fri, 20 Feb 2004 07:19:45 -0500 (EST) Date: Fri, 20 Feb 2004 07:19:45 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Slow in morning hours Message-ID: <20040220121945.GB15383@phlogiston.dyndns.org> Mail-Followup-To: pgsql-performance@postgresql.org References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C847@vt-pe2550-001.vantage.vantage.com> <40361DBE.3636.10FEBF@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <40361DBE.3636.10FEBF@localhost> User-Agent: Mutt/1.5.4i X-Authentication-Info: Submitted using SMTP AUTH LOGIN at fep01-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] using ID at Fri, 20 Feb 2004 07:19:28 -0500 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/232 X-Sequence-Number: 5756 On Fri, Feb 20, 2004 at 02:46:15PM +0530, vathakar@banas.guj.nic.in wrote: > > After continuous usage of one hour, It gradually starts responding > faster ! This has become every day routine ! > > do u have any idea related to this !!!! Is there any other reason that I > need to check up? What's running on the machine during those hours? Maybe VACUUM is sucking up all your bandwidth. Or your backups. Or some other cron job. Note that 7.2 is pretty old. There are several performance improvements in subsequent versions. A -- Andrew Sullivan From pgsql-performance-owner@postgresql.org Fri Feb 20 09:49:00 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 61953D1E136 for ; Fri, 20 Feb 2004 13:48:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 80228-01 for ; Fri, 20 Feb 2004 09:48:58 -0400 (AST) Received: from internet.potentialtech.com (h-66-167-251-6.PHLAPAFG.covad.net [66.167.251.6]) by svr1.postgresql.org (Postfix) with ESMTP id 6A0F3D1E0F1 for ; Fri, 20 Feb 2004 09:48:54 -0400 (AST) Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP id A469669A77; Fri, 20 Feb 2004 08:48:57 -0500 (EST) Message-ID: <40361046.9050708@potentialtech.com> Date: Fri, 20 Feb 2004 08:48:54 -0500 From: Bill Moran User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 X-Accept-Language: en-us, en MIME-Version: 1.0 To: vathakar@banas.guj.nic.in Cc: pgsql-performance@postgresql.org Subject: Re: Slow in morning hours References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C847@vt-pe2550-001.vantage.vantage.com> <40361DBE.3636.10FEBF@localhost> In-Reply-To: <40361DBE.3636.10FEBF@localhost> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/233 X-Sequence-Number: 5757 vathakar@banas.guj.nic.in wrote: > Hi All, > > I am using Linux 7.2 and postgresql 7.2. > > Our Office hours are over at 6pm but we use to keep our server > running 24 hours a day. On the second day morning, Our PGSQL > Server becomes very slow. > > After continuous usage of one hour, It gradually starts responding > faster ! This has become every day routine ! > > do u have any idea related to this !!!! Is there any other reason that I > need to check up? > > Please any any idea to get relief daily morning problem !! I've seen this happen, and not just with PostgreSQL. The reasons are many an varied, but here's my experience on the most common. 1) As someone else suggested, there may be some daily maintenance process (i.e. backup) that's still running when you come in. Check this, and reschedule if necessary. 2) Even if these nightly maintenance processes are finished when you first come in, they've probably completely rearranged the contents of RAM. Meaning, data that Linux had cached that made Postgres fast now needs to be fetched from disk again. There are some things you can do, such as adding RAM or getting faster disks, but this is a difficult problem to solve. Some of the nightly processes could be safely disabled, possibly, such as rebuilding the located database (if you don't use locate) Possibly (I'm guessing here) if you scheduled pg_dump to be the last process to run at night, it might put the cache back in a better state? 3) First thing AM load. It's quite common for load to be higher at certain times of the day, and first thing in the morning is a common time for load to be higher than usual (especially for email servers). Check the load on the machine with tools like top and see if it isn't just busier in the morning than other times during the day. There might even be one or two particular queries that people only run first thing that bog the machine down. Depending on what you find, you may be able to optomise some queries. Possibly some fine-tuning could correct the problem. Or you might be forced to upgrade hardware if you want the machine to handle the higher morning load faster. First thing to determine, though, is whether or not the load is higher or the same. Without more detail on the load, setting, etc of your system, these are all guesses. Hopefully the information is helpful, though. -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Fri Feb 20 10:34:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 543A8D1E0CD for ; Fri, 20 Feb 2004 14:34:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 93247-04 for ; Fri, 20 Feb 2004 10:34:34 -0400 (AST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id AF52DD1DA34 for ; Fri, 20 Feb 2004 10:34:30 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by bob.samurai.com (Postfix) with ESMTP id 490E81EC7; Fri, 20 Feb 2004 09:34:34 -0500 (EST) Received: from bob.samurai.com ([127.0.0.1]) by localhost (bob.samurai.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 37935-01-7; Fri, 20 Feb 2004 09:34:33 -0500 (EST) Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) by bob.samurai.com (Postfix) with ESMTP id 7DC301E96; Fri, 20 Feb 2004 09:34:32 -0500 (EST) To: shridhar@frodo.hserus.net Cc: "Saleem Burhani Baloch" , pgsql-performance@postgresql.org Subject: Re: Slow response of PostgreSQL From: Neil Conway In-Reply-To: <200402191456.19032.shridhar@frodo.hserus.net> (Shridhar Daithankar's message of "Thu, 19 Feb 2004 14:56:19 +0530") References: <200402190901.i1J91KY07596@ns2.khi.wol.net.pk> <200402191456.19032.shridhar@frodo.hserus.net> Date: Fri, 20 Feb 2004 09:34:31 -0500 Message-ID: <87d689es5k.fsf@mailbox.samurai.com> User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/234 X-Sequence-Number: 5758 Shridhar Daithankar writes: > Right now, it is hotly debated on HACKERS about adding a NOWAIT > clause to SELECT FOR UPDATE. If you think your application > deployment is away for months and can try CVS head, you can expect > some action on it in coming few days. You can also try using the statement_timeout configuration variable that is already included with 7.4. It's not exactly "don't wait for locks", but should approximate that behavior well enough. http://www.postgresql.org/docs/7.4/static/runtime-config.html#RUNTIME-CONFIG-CLIENT -Neil From pgsql-performance-owner@postgresql.org Fri Feb 20 10:51:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8548DD1E15F for ; Fri, 20 Feb 2004 14:51:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 97909-07 for ; Fri, 20 Feb 2004 10:51:02 -0400 (AST) Received: from server.pyrenet.fr (server.pyrenet.fr [194.250.190.1]) by svr1.postgresql.org (Postfix) with ESMTP id ED556D1E150 for ; Fri, 20 Feb 2004 10:50:57 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by localhost.pyrenet.fr (Postfix) with ESMTP id C20012A981; Fri, 20 Feb 2004 15:51:01 +0100 (MET) Received: from server.pyrenet.fr ([127.0.0.1]) by localhost (server [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 29932-06; Fri, 20 Feb 2004 15:51:00 +0100 (MET) Received: from server.pyrenet.fr (server.pyrenet.fr [194.250.190.1]) by server.pyrenet.fr (Postfix) with ESMTP id 3BF4E2A980; Fri, 20 Feb 2004 15:51:00 +0100 (MET) Date: Fri, 20 Feb 2004 15:51:00 +0100 (MET) From: ohp@pyrenet.fr Reply-To: ohp@pyrenet.fr To: vathakar@banas.guj.nic.in Cc: pgsql-performance@postgresql.org Subject: Re: Slow in morning hours In-Reply-To: <40361DBE.3636.10FEBF@localhost> Message-ID: References: <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C847@vt-pe2550-001.vantage.vantage.com> <40361DBE.3636.10FEBF@localhost> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at pyrenet.fr X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/235 X-Sequence-Number: 5759 Have you tried VACUUM ANALYZE at least one a day? Regards On Fri, 20 Feb 2004 vathakar@banas.guj.nic.in wrote: > Date: Fri, 20 Feb 2004 14:46:15 +0530 > From: vathakar@banas.guj.nic.in > To: pgsql-performance@postgresql.org > Cc: vathakar@banas.guj.nic.in > Subject: [PERFORM] Slow in morning hours > > Hi All, > > I am using Linux 7.2 and postgresql 7.2. > > Our Office hours are over at 6pm but we use to keep our server > running 24 hours a day. On the second day morning, Our PGSQL > Server becomes very slow. > > After continuous usage of one hour, It gradually starts responding > faster ! This has become every day routine ! > > do u have any idea related to this !!!! Is there any other reason that I > need to check up? > > Please any any idea to get relief daily morning problem !! > > Thanxs, > Vishal > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > -- Olivier PRENANT Tel: +33-5-61-50-97-00 (Work) 6, Chemin d'Harraud Turrou +33-5-61-50-97-01 (Fax) 31190 AUTERIVE +33-6-07-63-80-64 (GSM) FRANCE Email: ohp@pyrenet.fr ------------------------------------------------------------------------------ Make your life a dream, make your dream a reality. (St Exupery) From pgsql-performance-owner@postgresql.org Fri Feb 20 11:35:41 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 86BD9D1D25D for ; Fri, 20 Feb 2004 15:35:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 14983-05 for ; Fri, 20 Feb 2004 11:35:35 -0400 (AST) Received: from internet.potentialtech.com (h-66-167-251-6.PHLAPAFG.covad.net [66.167.251.6]) by svr1.postgresql.org (Postfix) with ESMTP id 8941ED1C511 for ; Fri, 20 Feb 2004 11:35:31 -0400 (AST) Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP id 29C5069A71 for ; Fri, 20 Feb 2004 10:35:35 -0500 (EST) Message-ID: <40362944.2060809@potentialtech.com> Date: Fri, 20 Feb 2004 10:35:32 -0500 From: Bill Moran User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: cacheable stored functions? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/236 X-Sequence-Number: 5760 I'm converting a SQL application to PostgreSQL. The majority of the logic in this application is in the stored functions in the database. Somewhere, I saw a reference to "WITH (iscachable)" for stored functions, looking again, I'm unable to find any reference to this directive. I have a single function that is _obviously_ safe to cache using this, and it generates no errors or problems that I can see. Now I'm looking at a lot of other functions that, if cached, would speed up performance considerably. Yet I'm reluctant to use this directive since I can't find documentation on it anywhere. Can anyone say whether this is a supported feature in plpgsql, and is safe to use? Is it simply undocumented, or am I just looking in the wrong place? (to reduce ambiguity, the manner in which I'm using this is: CREATE FUNCTION getconstant(VARCHAR) RETURNS int AS ' DECLARE BEGIN IF $1 = ''phrase'' THEN RETURN 1; END IF; ... END; ' LANGUAGE 'plpgsql' WITH (iscacheable); -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Fri Feb 20 11:47:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 63E98D1D1A4 for ; Fri, 20 Feb 2004 15:47:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 14656-08 for ; Fri, 20 Feb 2004 11:47:33 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id F192ED1C511 for ; Fri, 20 Feb 2004 11:47:28 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 9E593357DB; Fri, 20 Feb 2004 07:47:33 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 9D3C1357CF; Fri, 20 Feb 2004 07:47:33 -0800 (PST) Date: Fri, 20 Feb 2004 07:47:33 -0800 (PST) From: Stephan Szabo To: Bill Moran Cc: pgsql-performance@postgresql.org Subject: Re: cacheable stored functions? In-Reply-To: <40362944.2060809@potentialtech.com> Message-ID: <20040220074336.G82937@megazone.bigpanda.com> References: <40362944.2060809@potentialtech.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/237 X-Sequence-Number: 5761 On Fri, 20 Feb 2004, Bill Moran wrote: > I'm converting a SQL application to PostgreSQL. The majority of the logic > in this application is in the stored functions in the database. > > Somewhere, I saw a reference to "WITH (iscachable)" for stored functions, > looking again, I'm unable to find any reference to this directive. I have > a single function that is _obviously_ safe to cache using this, and it > generates no errors or problems that I can see. It's been basically superceded by IMMUTABLE, and I believe they're described in the create function reference page. Note that it doesn't involve caching as much as the fact that it can be evaluated once and treated as a constant. From pgsql-performance-owner@postgresql.org Fri Feb 20 11:56:46 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EA6F9D1DFFE for ; Fri, 20 Feb 2004 15:56:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 19163-09 for ; Fri, 20 Feb 2004 11:56:39 -0400 (AST) Received: from serwer.skawsoft.com.pl (skawina.eu.org [80.48.213.66]) by svr1.postgresql.org (Postfix) with ESMTP id F412DD1B456 for ; Fri, 20 Feb 2004 11:56:33 -0400 (AST) Received: from klaster.net (backbone.zab.citynet.pl [212.244.6.69]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id E0DE02B3CB; Fri, 20 Feb 2004 16:56:20 +0100 (CET) Message-ID: <40362EEB.9050103@klaster.net> Date: Fri, 20 Feb 2004 16:59:39 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.6) Gecko/20040113 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Bill Moran Cc: pgsql-performance@postgresql.org Subject: Re: cacheable stored functions? References: <40362944.2060809@potentialtech.com> In-Reply-To: <40362944.2060809@potentialtech.com> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/238 X-Sequence-Number: 5762 Dnia 2004-02-20 16:35, U�ytkownik Bill Moran napisa�: > Can anyone say whether this is a supported feature in plpgsql, and is > safe to use? Is it simply undocumented, or am I just looking in the > wrong place? "iscachable" is only for backward compatibility - it's changed now to "IMMUTABLE" You can read more about immutable, stable and volatile functions in Postgresql documentation - chapter SQL Commands/CREATE FUNCTION. Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Fri Feb 20 12:01:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 52A6BD1D570 for ; Fri, 20 Feb 2004 16:01:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 28695-05 for ; Fri, 20 Feb 2004 12:01:34 -0400 (AST) 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 18787D1D4E7 for ; Fri, 20 Feb 2004 12:01:34 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) id 1AuD5o-0008K3-0V; Fri, 20 Feb 2004 16:01:32 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 33A0A163B3; Fri, 20 Feb 2004 16:01:31 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 3004615951; Fri, 20 Feb 2004 16:01:29 +0000 (GMT) From: Richard Huxton To: Bill Moran , pgsql-performance@postgresql.org Subject: Re: cacheable stored functions? Date: Fri, 20 Feb 2004 16:01:28 +0000 User-Agent: KMail/1.5 References: <40362944.2060809@potentialtech.com> In-Reply-To: <40362944.2060809@potentialtech.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402201601.28789.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/239 X-Sequence-Number: 5763 On Friday 20 February 2004 15:35, Bill Moran wrote: > I'm converting a SQL application to PostgreSQL. The majority of the logic > in this application is in the stored functions in the database. > > Somewhere, I saw a reference to "WITH (iscachable)" for stored functions, > looking again, I'm unable to find any reference to this directive. I have > a single function that is _obviously_ safe to cache using this, and it > generates no errors or problems that I can see. > > Now I'm looking at a lot of other functions that, if cached, would speed > up performance considerably. Yet I'm reluctant to use this directive > since I can't find documentation on it anywhere. From memory, "iscachable" was replaced in version 7.3 by the three finer-grained settings IMMUTABLE, STABLE, VOLATILE. I'm guessing the old behaviour is still there for backwards compatibility, but it's probably best to use the new versions. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Fri Feb 20 12:48:47 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 77B93D1E15B for ; Fri, 20 Feb 2004 16:48:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 41443-05 for ; Fri, 20 Feb 2004 12:48:28 -0400 (AST) Received: from internet.potentialtech.com (h-66-167-251-6.PHLAPAFG.covad.net [66.167.251.6]) by svr1.postgresql.org (Postfix) with ESMTP id 65E0DD1D570 for ; Fri, 20 Feb 2004 12:48:28 -0400 (AST) Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP id 0C35469A71 for ; Fri, 20 Feb 2004 11:48:27 -0500 (EST) Message-ID: <40363A58.5020609@potentialtech.com> Date: Fri, 20 Feb 2004 11:48:24 -0500 From: Bill Moran User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: cacheable stored functions? References: <40362944.2060809@potentialtech.com> <200402201601.28789.dev@archonet.com> In-Reply-To: <200402201601.28789.dev@archonet.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/240 X-Sequence-Number: 5764 Richard Huxton wrote: > On Friday 20 February 2004 15:35, Bill Moran wrote: > >>I'm converting a SQL application to PostgreSQL. The majority of the logic >>in this application is in the stored functions in the database. >> >>Somewhere, I saw a reference to "WITH (iscachable)" for stored functions, >>looking again, I'm unable to find any reference to this directive. I have >>a single function that is _obviously_ safe to cache using this, and it >>generates no errors or problems that I can see. >> >>Now I'm looking at a lot of other functions that, if cached, would speed >>up performance considerably. Yet I'm reluctant to use this directive >>since I can't find documentation on it anywhere. > >>From memory, "iscachable" was replaced in version 7.3 by the three > finer-grained settings IMMUTABLE, STABLE, VOLATILE. > > I'm guessing the old behaviour is still there for backwards compatibility, but > it's probably best to use the new versions. Thanks to everyone who replied (with more or less the same answer ;) This has explained away my confusion, and I now have a reference to read. -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Fri Feb 20 15:53:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A79E4D1E125 for ; Fri, 20 Feb 2004 19:17:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 06179-04 for ; Fri, 20 Feb 2004 15:17:22 -0400 (AST) Received: from stork.mail.pas.earthlink.net (stork.mail.pas.earthlink.net [207.217.120.188]) by svr1.postgresql.org (Postfix) with ESMTP id D2888D1C511 for ; Fri, 20 Feb 2004 15:17:20 -0400 (AST) Received: from dpc6682165056.direcpc.com ([66.82.165.56] helo=earthlink.net) by stork.mail.pas.earthlink.net with asmtp (Exim 3.33 #1) id 1AuG9G-0007T7-00 for pgsql-performance@postgresql.org; Fri, 20 Feb 2004 11:17:19 -0800 Message-ID: <40365D36.5090708@earthlink.net> Date: Fri, 20 Feb 2004 14:17:10 -0500 From: Sean Shanny User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: General performance questions about postgres on Apple hardware... Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ELNK-Trace: 6ca696a38bf90a1a1de288fa2098067a1aa676d7e74259b7b3291a7d08dfec79ae42e745bff6d125c01eafbe5a077b0a350badd9bab72f9c350badd9bab72f9c X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/241 X-Sequence-Number: 5765 To all, This is a 2 question email. First is asking about general tuning of the Apple hardware/postgres combination. The second is whether is is possible to speed up a particular query. PART 1 Hardware: Apple G5 dual 2.0 with 8GB memory attached via dual fibre channel to a fully loaded 3.5TB XRaid. The XRaid is configured as two 7 disk hardware based RAID5 sets software striped to form a RAID50 set. The DB, WALS, etc are all on that file set. Running OSX journaled file system Running postgres 7.4.1. OSX Server 10.3.2 Postgres is compiled locally with '--enable-recode' '--enable-multibyte=UNICODE' 'CFLAGS=-mcpu=970 -mtune=970 -mpowerpc64 -O3' Config stuff that we have changed: tcpip_socket = true max_connections = 100 # - Memory - shared_buffers = 16000 # min 16, at least max_connections*2, 8KB each sort_mem = 256000 # min 64, size in KB vacuum_mem = 64000 # min 1024, size in KB fsync = true # turns forced synchronization on or off wal_sync_method = open_sync # the default varies across platforms: # fsync, fdatasync, open_sync, or open_datasync wal_buffers = 64 # min 4, 8KB each checkpoint_segments = 300 # in logfile segments, min 1, 16MB each checkpoint_timeout = 30 # range 30-3600, in seconds effective_cache_size = 400000 # typically 8KB each random_page_cost = 1 # units are one sequential page fetch cost default_statistics_target = 1000 # range 1-1000 We are generally getting poor performance out of the RAID set, they claim 200/MB/sec per channel, the best we can get with straight OS based data transfers is 143MB/sec. :-( (we have a call into apple about this) When I execute the following, d_url is a big table, create table temp_url as select * from d_url ; I would expect to bound by IO but via iostat we are seeing only about 30mb/sec with bursts of 100+ when the WAL is written. sy is high as well and the tps seems low. Can anyone shed some light on what we might do to improve performance for postgres on this platform? Also, is there a test that is available that would we could run to show the maximum postgres can do on this platform? This is a data warehouse system so generally we only have 1-3 queries running at anytime. More often only 1. We are obviously working with very large tables so we are interested in maximizing our IO throughput. disk1 disk2 disk0 cpu KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us sy id 17.04 961 15.99 17.16 957 16.03 8.83 6 0.05 12 32 56 22.75 580 12.89 22.79 578 12.87 0.00 0 0.00 10 34 56 24.71 586 14.14 24.67 587 14.14 0.00 0 0.00 12 40 48 21.98 648 13.91 21.97 648 13.91 0.00 0 0.00 16 27 56 22.07 608 13.10 22.09 607 13.09 0.00 0 0.00 14 29 57 26.54 570 14.77 26.37 575 14.80 0.00 0 0.00 12 34 54 18.91 646 11.93 18.90 646 11.93 0.00 0 0.00 9 33 58 15.12 636 9.38 15.12 636 9.38 0.00 0 0.00 14 22 64 16.22 612 9.69 16.23 611 9.68 0.00 0 0.00 20 27 54 15.02 573 8.41 15.01 574 8.41 0.00 0 0.00 14 29 57 15.54 593 9.00 15.52 595 9.02 0.00 0 0.00 13 28 59 22.35 596 13.01 22.42 593 12.99 0.00 0 0.00 9 32 58 61.57 887 53.33 60.73 901 53.43 4.00 1 0.00 8 48 44 11.13 2173 23.62 11.13 2167 23.54 0.00 0 0.00 10 68 22 10.07 2402 23.63 10.20 2368 23.58 4.00 1 0.00 10 72 18 14.75 1110 15.99 14.74 1116 16.06 8.92 6 0.05 12 42 46 22.79 510 11.36 22.79 510 11.36 0.00 0 0.00 16 28 56 23.65 519 11.99 23.50 522 11.98 0.00 0 0.00 13 42 46 22.45 592 12.98 22.45 592 12.98 0.00 0 0.00 14 27 58 25.38 579 14.35 25.37 579 14.35 0.00 0 0.00 8 36 56 PART 2 Trying to understand if there is a faster way to do this? This is part of our nightly bulk load of a data warehouse. We are reading in new data, pulling out the relevant bits, and then need to check to see if they already exist in the dimension tables. Use to do this via separate lookups for each value, not very fast. Trying to do this all in the DB now. The query is SELECT t1.id, t2.md5, t2.url FROM referral_temp t2 LEFT OUTER JOIN d_referral t1 ON t2.md5 = t1.referral_md5; \d d_referral id | integer | not null referral_md5 | text | not null referral_raw_url | text | not null referral_host | text | referral_path | text | referral_query | text | job_control_number | integer | not null \d referral_temp md5 | text | url | text | Actual row count in the temp table: select count(*) from referral_temp ; 502347 Actual row count in d_referral table: select count(*) from d_referral ; 27908024 Note: that an analyze had not been performed on the referral_temp table prior to the explain analyze run. explain analyze SELECT t1.id, t2.md5, t2.url from referral_temp t2 LEFT OUTER JOIN d_referral t1 ON t2.md5 = t1.referral_md5 Nested Loop Left Join (cost=0.00..3046.00 rows=1001 width=68) (actual time=136.513..6440616.541 rows=502347 loops=1) -> Seq Scan on referral_temp t2 (cost=0.00..20.00 rows=1000 width=64) (actual time=21.730..10552.421 rows=502347 loops=1) -> Index Scan using d_referral_referral_md5_key on d_referral t1 (cost=0.00..3.01 rows=1 width=40) (actual time=12.768..14.022 rows=1 loops=502347) Index Cond: ("outer".md5 = t1.referral_md5) Thanks. --sean Total runtime: 6441969.698 ms (5 rows) Here is an explain analyze after the analyze was done. Unfortunately I think a lot of the data was still in cache when I did this again :-( explain analyze SELECT t1.id, t2.md5, t2.url from referral_temp t2 LEFT OUTER JOIN d_referral t1 ON t2.md5 = t1.referral_md5; Nested Loop Left Join (cost=0.00..1468759.69 rows=480082 width=149) (actual time=69.576..3226854.850 rows=502347 loops=1) -> Seq Scan on referral_temp t2 (cost=0.00..16034.81 rows=480081 width=145) (actual time=11.206..4003.521 rows=502347 loops=1) -> Index Scan using d_referral_referral_md5_key on d_referral t1 (cost=0.00..3.01 rows=1 width=40) (actual time=6.396..6.402 rows=1 loops=502347) Index Cond: ("outer".md5 = t1.referral_md5) Total runtime: 3227830.752 ms From pgsql-admin-owner@postgresql.org Fri Feb 20 16:37:57 2004 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2B037D1DD04 for ; Fri, 20 Feb 2004 20:09:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 29623-01 for ; Fri, 20 Feb 2004 16:09:33 -0400 (AST) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 6E054D1D432 for ; Fri, 20 Feb 2004 16:09:31 -0400 (AST) Received: (qmail 29350 invoked by uid 500); 20 Feb 2004 20:11:39 -0000 Date: Fri, 20 Feb 2004 14:11:39 -0600 From: Bruno Wolff III To: V Chitra Cc: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org Subject: Re: Index called with Union but not with OR clause Message-ID: <20040220201139.GA25578@wolff.to> Mail-Followup-To: pgsql-performance@postgresql.org, vchitra@techbooks.com References: <008401c3f77e$a78f1d20$18dda8c0@VICHITRA> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <008401c3f77e$a78f1d20$18dda8c0@VICHITRA> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/312 X-Sequence-Number: 12486 This discussion really belongs on the performance list and I am copying that list with mail-followup-to set. On Fri, Feb 20, 2004 at 12:26:22 +0530, V Chitra wrote: > Hi All, > > I have a select statement > > select * from v_func_actual_costs > where parent_project='10478' or proj_pk = '10478' > > both the fields parent_project and proj_pk have indexes based on them, but when I ran explain plan on this statement I found that none of the indexes are being called. But, if I make two separate statement and combine them with Union ALL, the indexes are being called. The select statement in this case is > > select * from ct_admin.v_func_actual_costs > where parent_project='10478' > union all > select * from ct_admin.v_func_actual_costs > where proj_pk = '10478' > > Can anybody help me to find a reason for the same. This is just a part of the query so I cannot use the Union ALL clause. Have you analyzed the databases recently? Can you supply explain analyze output for the queries? It isn't necessarily faster to use two index scans instead of one sequential scan depending on the fraction of the table being returned and some other factors. If the planner is making the wrong choice in your case, you need to supply the list with more information to get help figuring out why the wrong choice is being made. From pgsql-performance-owner@postgresql.org Fri Feb 20 19:50:00 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BBB2ED1F6A9 for ; Fri, 20 Feb 2004 21:43:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 50439-01 for ; Fri, 20 Feb 2004 17:43:42 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 3A991D1F695 for ; Fri, 20 Feb 2004 17:43:40 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1KLH5Ir017068; Fri, 20 Feb 2004 14:17:05 -0700 (MST) Date: Fri, 20 Feb 2004 14:10:07 -0700 (MST) From: "scott.marlowe" To: Sean Shanny Cc: Subject: Re: General performance questions about postgres on Apple In-Reply-To: <40365D36.5090708@earthlink.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/244 X-Sequence-Number: 5768 On Fri, 20 Feb 2004, Sean Shanny wrote: > max_connections = 100 > > # - Memory - > > shared_buffers = 16000 # min 16, at least max_connections*2, > 8KB each > sort_mem = 256000 # min 64, size in KB You might wanna drop sort_mem somewhat and just set it during your imports to something big like 512000 or larger. That way with 100 users during the day you won't have to worry about swap storms, and when you run your updates, you get all that sort_mem. > Actual row count in the temp table: > > select count(*) from referral_temp ; > 502347 > > Actual row count in d_referral table: > > select count(*) from d_referral ; > 27908024 > > > Note: that an analyze had not been performed on the referral_temp table > prior to the explain analyze run. > > explain analyze SELECT t1.id, t2.md5, t2.url from referral_temp t2 LEFT > OUTER JOIN d_referral t1 ON t2.md5 = t1.referral_md5 > > Nested Loop Left Join (cost=0.00..3046.00 rows=1001 width=68) (actual > time=136.513..6440616.541 rows=502347 loops=1) > -> Seq Scan on referral_temp t2 (cost=0.00..20.00 rows=1000 > width=64) (actual time=21.730..10552.421 rows=502347 loops=1) > -> Index Scan using d_referral_referral_md5_key on d_referral t1 > (cost=0.00..3.01 rows=1 width=40) (actual time=12.768..14.022 rows=1 > loops=502347) > Index Cond: ("outer".md5 = t1.referral_md5) > > > Thanks. > > --sean > Total runtime: 6441969.698 ms > (5 rows) > > > Here is an explain analyze after the analyze was done. Unfortunately I > think a lot of the data was still in cache when I did this again :-( > > explain analyze SELECT t1.id, t2.md5, t2.url from referral_temp t2 LEFT > OUTER JOIN d_referral t1 ON t2.md5 = t1.referral_md5; > > Nested Loop Left Join (cost=0.00..1468759.69 rows=480082 width=149) > (actual time=69.576..3226854.850 rows=502347 loops=1) > -> Seq Scan on referral_temp t2 (cost=0.00..16034.81 rows=480081 > width=145) (actual time=11.206..4003.521 rows=502347 loops=1) > -> Index Scan using d_referral_referral_md5_key on d_referral t1 > (cost=0.00..3.01 rows=1 width=40) (actual time=6.396..6.402 rows=1 > loops=502347) > Index Cond: ("outer".md5 = t1.referral_md5) > Total runtime: 3227830.752 ms Hmmm. It looks like postgresql is still picking a nested loop when it should be sorting something faster. Try doing a "set enable_nestloop = off" and see what you get. If that makes it faster, you may want to adjust the costs of the cpu_* stuff higher to see if that can force it to do the right thing. Looking at the amount of time taken by the nested loop, it looks like the problem to me. And why are you doing a left join of ONE row from one table against the whole temp table? Do you really need to do that? since there's only one row in the source table, and I'd guess is only matches one or a few rows from the temp table, this means you're gonna have that one row and a bunch of null filled rows to go with it. From pgsql-performance-owner@postgresql.org Fri Feb 20 18:29:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3E896D1F693 for ; Fri, 20 Feb 2004 21:58:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 50285-08 for ; Fri, 20 Feb 2004 17:58:02 -0400 (AST) Received: from stork.mail.pas.earthlink.net (stork.mail.pas.earthlink.net [207.217.120.188]) by svr1.postgresql.org (Postfix) with ESMTP id 2E02BD1F696 for ; Fri, 20 Feb 2004 17:58:00 -0400 (AST) Received: from dpc6682165056.direcpc.com ([66.82.165.56] helo=earthlink.net) by stork.mail.pas.earthlink.net with asmtp (Exim 3.33 #1) id 1AuIei-0002C1-00 for pgsql-performance@postgresql.org; Fri, 20 Feb 2004 13:57:59 -0800 Message-ID: <403682D6.60807@earthlink.net> Date: Fri, 20 Feb 2004 16:57:42 -0500 From: Sean Shanny User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: General performance questions about postgres on Apple References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ELNK-Trace: 6ca696a38bf90a1a1de288fa2098067a1aa676d7e74259b7b3291a7d08dfec792fe6a6948540acc70a2ecd975965c1a9350badd9bab72f9c350badd9bab72f9c X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/243 X-Sequence-Number: 5767 scott.marlowe wrote: >On Fri, 20 Feb 2004, Sean Shanny wrote: > > > >>max_connections = 100 >> >># - Memory - >> >>shared_buffers = 16000 # min 16, at least max_connections*2, >>8KB each >>sort_mem = 256000 # min 64, size in KB >> >> > >You might wanna drop sort_mem somewhat and just set it during your imports >to something big like 512000 or larger. That way with 100 users during >the day you won't have to worry about swap storms, and when you run your >updates, you get all that sort_mem. > > > >>Actual row count in the temp table: >> >>select count(*) from referral_temp ; >> 502347 >> >>Actual row count in d_referral table: >> >>select count(*) from d_referral ; >> 27908024 >> >> >>Note: that an analyze had not been performed on the referral_temp table >>prior to the explain analyze run. >> >>explain analyze SELECT t1.id, t2.md5, t2.url from referral_temp t2 LEFT >>OUTER JOIN d_referral t1 ON t2.md5 = t1.referral_md5 >> >>Nested Loop Left Join (cost=0.00..3046.00 rows=1001 width=68) (actual >>time=136.513..6440616.541 rows=502347 loops=1) >> -> Seq Scan on referral_temp t2 (cost=0.00..20.00 rows=1000 >>width=64) (actual time=21.730..10552.421 rows=502347 loops=1) >> -> Index Scan using d_referral_referral_md5_key on d_referral t1 >>(cost=0.00..3.01 rows=1 width=40) (actual time=12.768..14.022 rows=1 >>loops=502347) >> Index Cond: ("outer".md5 = t1.referral_md5) >> >> >>Thanks. >> >>--sean >> Total runtime: 6441969.698 ms >>(5 rows) >> >> >>Here is an explain analyze after the analyze was done. Unfortunately I >>think a lot of the data was still in cache when I did this again :-( >> >>explain analyze SELECT t1.id, t2.md5, t2.url from referral_temp t2 LEFT >>OUTER JOIN d_referral t1 ON t2.md5 = t1.referral_md5; >> >>Nested Loop Left Join (cost=0.00..1468759.69 rows=480082 width=149) >>(actual time=69.576..3226854.850 rows=502347 loops=1) >> -> Seq Scan on referral_temp t2 (cost=0.00..16034.81 rows=480081 >>width=145) (actual time=11.206..4003.521 rows=502347 loops=1) >> -> Index Scan using d_referral_referral_md5_key on d_referral t1 >>(cost=0.00..3.01 rows=1 width=40) (actual time=6.396..6.402 rows=1 >>loops=502347) >> Index Cond: ("outer".md5 = t1.referral_md5) >> Total runtime: 3227830.752 ms >> >> > >Hmmm. It looks like postgresql is still picking a nested loop when it >should be sorting something faster. Try doing a "set enable_nestloop = >off" and see what you get. > > New results with the above changes: (Rather a huge improvement!!!) Thanks Scott. I will next attempt to make the cpu_* changes to see if it the picks the correct plan. explain analyze SELECT t1.id, t2.md5, t2.url from referral_temp t2 LEFT OUTER JOIN d_referral t1 ON t2.md5 = t1.referral_md5; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------- Hash Left Join (cost=1669281.60..3204008.48 rows=480082 width=149) (actual time=157221.125..-412311.378 rows=502347 loops=1) Hash Cond: ("outer".md5 = "inner".referral_md5) -> Seq Scan on referral_temp t2 (cost=0.00..16034.81 rows=480081 width=145) (actual time=11.537..1852.336 rows=502347 loops=1) -> Hash (cost=1356358.48..1356358.48 rows=30344048 width=40) (actual time=157187.530..157187.530 rows=0 loops=1) -> Seq Scan on d_referral t1 (cost=0.00..1356358.48 rows=30344048 width=40) (actual time=14.134..115048.285 rows=27908024 loops=1) Total runtime: 212595.909 ms (6 rows) Time: 213094.984 ms tripmaster=# explain analyze SELECT t1.id, t2.md5, t2.url from url_temp t2 LEFT OUTER JOIN d_url t1 ON t2.md5 = t1.url_md5; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ Hash Left Join (cost=2023843.40..3157938.15 rows=1379872 width=191) (actual time=178150.113..867074.579 rows=1172920 loops=1) Hash Cond: ("outer".md5 = "inner".url_md5) -> Seq Scan on url_temp t2 (cost=0.00..50461.72 rows=1379872 width=187) (actual time=6.597..6692.324 rows=1172920 loops=1) -> Hash (cost=1734904.72..1734904.72 rows=28018272 width=40) (actual time=178124.568..178124.568 rows=0 loops=1) -> Seq Scan on d_url t1 (cost=0.00..1734904.72 rows=28018272 width=40) (actual time=16.912..2639059.078 rows=23239137 loops=1) Total runtime: 242846.965 ms (6 rows) Time: 243190.900 ms >If that makes it faster, you may want to adjust the costs of the cpu_* >stuff higher to see if that can force it to do the right thing. > >Looking at the amount of time taken by the nested loop, it looks like the >problem to me. > >And why are you doing a left join of ONE row from one table against the >whole temp table? Do you really need to do that? since there's only one >row in the source table, and I'd guess is only matches one or a few rows >from the temp table, this means you're gonna have that one row and a bunch >of null filled rows to go with it. > > > > From pgsql-performance-owner@postgresql.org Sat Feb 21 17:12:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 78EFED1BB89 for ; Sat, 21 Feb 2004 21:12:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 37903-07 for ; Sat, 21 Feb 2004 17:12:37 -0400 (AST) Received: from mail.sandvine.com (sandvine.com [199.243.201.138]) by svr1.postgresql.org (Postfix) with ESMTP id 8DC27D1DD65 for ; Sat, 21 Feb 2004 17:12:34 -0400 (AST) Received: by mail.sandvine.com with Internet Mail Service (5.5.2657.72) id <15P45LS2>; Sat, 21 Feb 2004 16:12:35 -0500 Message-ID: From: Don Bowman To: "'pgsql-performance@postgresql.org'" Cc: Don Bowman Subject: conceptual method to create high performance query involving time Date: Sat, 21 Feb 2004 16:12:24 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2657.72) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/247 X-Sequence-Number: 5771 I have a table which has e.g. CREATE TABLE portstats ( id serial, logtime TIMESTAMP, cluster VARCHAR(40), element VARCHAR(40), port INT, rxOctets BIGINT, txOctets BIGINT ); which is used for logging statistics from network equipment. cluster is like the location. rxOctets, txOctets are numbers which increase over time. Now, i would like to generate a chart which shows the bitrate. So i need subtract rxOctets from a previous value and divide by the time range. To be efficient, and avoid fetching too many points, i want the interval between points I select to be a function of the time range. E.g., when I'm doing a 1-day chart, i would like to select points that are 15min apart. When I'm doing a 1-yr query, I would like to select points that are e.g. 4hours apart. I can make this determination in the script that generates the statement. The problem i'm having is that this is a) a very slow operation b) selects all data points on t1, and then the interval apart one on t2... so i still end up with too many points. points are logged every ~5 minutes, but there is some small variation on the interval (and some observations might be missing due to eg communication loss to db). [ a process goes along later and decimates out points as they age to prevent the db from becoming very large]. The query I have is below. The question is ... what is the best strategy for an operation of this nature? SELECT t1.port, t1.logtime AS start, t2.logtime AS end, t1.cluster, t1.element, (8.0 * (t2.rxoctets - t1.rxoctets) / (extract(EPOCH FROM(t2.logtime - t1.logtime))))::int8 AS rxbps, (8.0 * (t2.txoctets - t1.txoctets) / (extract(EPOCH FROM(t2.logtime - t1.logtime))))::int8 AS txbps FROM portstats t1 INNER JOIN portstats t2 ON t2.cluster = t1.cluster AND t2.element = t1.element AND t2.port = t1.port AND t2.logtime = (SELECT logtime FROM portstats t3 WHERE t3.cluster = t1.cluster AND t3.element = t1.element AND t3.port = t1.port AND t3.logtime > t1.logtime + '00:15:00' ORDER BY cluster ASC, element ASC, port ASC, logtime ASC LIMIT 1) WHERE t1.cluster = 'somecluster' AND (t1.element = 'somelement') AND (t1.logtime BETWEEN '2004-01-07 00:00' AND '2004-02-08 00:00') ORDER BY t1.cluster ASC, t1.element ASC, t1.port ASC, t1.logtime ASC ; The query plan for 1 week is below, this takes ~2s to operate. It gets very slow for 1yr. Sort (cost=14055.35..14067.74 rows=4956 width=176) (actual time=1523.956..1538.354 rows=5943 loops=1) Sort Key: t1.svcluster, t1.element, t1.port, t1.logtime -> Merge Join (cost=2304.49..13751.18 rows=4956 width=176) (actual time=1008.620..1329.766 rows=5943 loops=1) Merge Cond: (("outer"."?column10?" = "inner".logtime) AND ("outer".port = "inner".port)) -> Sort (cost=977.39..992.25 rows=5944 width=136) (actual time=678.564..692.974 rows=5943 loops=1) Sort Key: (subplan), t1.port -> Index Scan using portstats_element_idx on portstats t1 (cost=0.00..604.78 rows=5944 width=136) (actual time=0.191..581.311 ro ws=5943 loops=1) Index Cond: (element = 'my-element.mydomain.net'::bpchar) Filter: ((svcluster = 'my-cluster'::bpchar) AND (logtime >= '2004-01-07 00:00:00-05'::timestamp with time zone) AND (logtime <= '2004-02-08 00:00:00-05'::timestamp with time zone)) SubPlan -> Limit (cost=0.00..0.62 rows=1 width=104) (actual time=0.064..0.066 rows=1 loops=5943) -> Index Scan using www6 on portstats t3 (cost=0.00..399.28 rows=643 width=104) (actual time=0.054..0.054 rows=1 l oops=5943) Index Cond: ((svcluster = $1) AND (element = $2) AND (port = $3) AND (logtime > ($4 + '00:15:00'::interval))) -> Sort (cost=1327.10..1356.00 rows=11560 width=136) (actual time=289.168..321.522 rows=11771 loops=1) Sort Key: t2.logtime, t2.port -> Index Scan using portstats_element_idx on portstats t2 (cost=0.00..546.98 rows=11560 width=136) (actual time=0.103..192.027 r ows=11560 loops=1) Index Cond: ('my-element.mydomain.net'::bpchar = element) Filter: (('my-cluster'::bpchar = svcluster)) Total runtime: 1609.411 ms (19 rows) From pgsql-performance-owner@postgresql.org Sat Feb 21 20:18:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EE84DD1E15F for ; Sun, 22 Feb 2004 00:18:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 66213-05 for ; Sat, 21 Feb 2004 20:18:05 -0400 (AST) Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) by svr1.postgresql.org (Postfix) with ESMTP id B8543D1E174 for ; Sat, 21 Feb 2004 20:18:01 -0400 (AST) Received: from [10.0.1.2] (h000393e3ce55.ne.client2.attbi.com[24.91.235.158]) by comcast.net (rwcrmhc12) with SMTP id <200402220018040140016gtge>; Sun, 22 Feb 2004 00:18:04 +0000 Mime-Version: 1.0 (Apple Message framework v612) Content-Transfer-Encoding: 7bit Message-Id: <94FA2D7A-64CC-11D8-9DEA-000A95BA4506@mindspring.com> Content-Type: text/plain; charset=US-ASCII; format=flowed To: Postgres Performance From: John Siracusa Subject: Column correlation drifts, index ignored again Date: Sat, 21 Feb 2004 19:18:04 -0500 X-Mailer: Apple Mail (2.612) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/248 X-Sequence-Number: 5772 This is a follow-up to an old thread of mine, but I can't find it now so I'll just re-summarize. I have a ~1 million row table that I mostly want to query by date range. The rows are pretty uniformly spread over a 3 year date range. I have an index on the date column, but it wasn't always used in the past. I disabled the seqscan plan before running my query as a first fix, but it bothered me that I had to do that. Next, thanks to my earlier thread, I clustered the table on the date column and then "SET STATISTICS" on the date column to be 100. That did the trick, and I stopped explicitly disabling seqscan. Today, I noticed that Postgres (still 7.4) stopped using the date index again. I checked the correlation for the date column and it was down to 0.4. So I guess that stat does drift away from 1.0 after clustering. That's a bummer, because clustering locks up the table while it works, which I can't really afford to do often. Even at a correlation of 0.4 on the date column, using the date index was still much faster than the seqscan plan that Postgres was choosing. Anyway, it's reclustering now. A common query looks like this: SELECT SUM(amount), SUM(quantity), date_trunc('day', date) AS date FROM mytable WHERE col1 IS NOT NULL AND col2 = 'foo' AND col3 = 'bar' AND date BETWEEN '2004-02-01 00:00:00' AND '2004-02-28 23:59:59' GROUP BY date_trunc('day', date) ORDER BY date; The EXPLAIN ANALYZE output should look like this: Sort (cost=4781.75..4824.15 rows=16963 width=23) (actual time=2243.595..2243.619 rows=21 loops=1) Sort Key: date_trunc('day'::text, date) -> HashAggregate (cost=3462.87..3590.09 rows=16963 width=23) (actual time=2241.773..2243.454 rows=21 loops=1) -> Index Scan using mytable_date_idx on mytable (cost=0.00..3071.70 rows=52155 width=23) (actual time=2.610..1688.111 rows=49679 loops=1) Index Cond: ((date >= '2004-02-01 00:00:00'::timestamp without time zone) AND (date <= '2004-02-28 23:59:59'::timestamp without time zone)) Filter: ((col1 IS NOT NULL) AND ((col2)::text = 'foo'::text) AND ((col3)::text = 'bar'::text)) Total runtime: 2244.391 ms Unfortunately, since I just re-clustered, I can't get the old EXPLAIN output, but just imagine "Seq Scan" in place of "Index Scan using mytable_date_idx" to get the idea. My question is: what other options do I have? Should I "SET STATISTICS" on the date column to 200? 500? The maximum value of 1000? I want to do something that will convince Postgres that using the date index is, by far, the best plan when running my queries, even when the date column correlation stat drops well below 1.0. -John From pgsql-performance-owner@postgresql.org Sun Feb 22 15:02:57 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9F602D1B9EB for ; Sun, 22 Feb 2004 19:02:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 34886-10 for ; Sun, 22 Feb 2004 15:02:53 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 7E6BDD1B9BD for ; Sun, 22 Feb 2004 15:02:51 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4474990; Sun, 22 Feb 2004 11:03:58 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Andrew Lazarus" , Subject: Re: JOIN order, 15K, 15K, 7MM rows Date: Sun, 22 Feb 2004 11:00:40 -0800 User-Agent: KMail/1.4.3 References: <0a0c01c3f671$ceb08c80$847ba8c0@ANDYXP> In-Reply-To: <0a0c01c3f671$ceb08c80$847ba8c0@ANDYXP> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200402221100.40176.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/249 X-Sequence-Number: 5773 Andrew, > I'm running and INSERT INTO ... SELECT query with this join (one record > added per record in join), 4 hours down and all I have to show for it is > 100 recycled transaction logs. ? > > If it ever returns, I can post the Explain output. How about giving us the query and the regular EXPLAIN output right now? I've a feeling that you have an unconstrained join in the query somewhere. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun Feb 22 15:08:12 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B72F2D1B9EB for ; Sun, 22 Feb 2004 19:08:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 37662-04 for ; Sun, 22 Feb 2004 15:08:07 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 21B57D1B9BD for ; Sun, 22 Feb 2004 15:08:06 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4475005; Sun, 22 Feb 2004 11:09:15 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: John Siracusa , Postgres Performance Subject: Re: Column correlation drifts, index ignored again Date: Sun, 22 Feb 2004 11:05:57 -0800 User-Agent: KMail/1.4.3 References: <94FA2D7A-64CC-11D8-9DEA-000A95BA4506@mindspring.com> In-Reply-To: <94FA2D7A-64CC-11D8-9DEA-000A95BA4506@mindspring.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200402221105.57068.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/250 X-Sequence-Number: 5774 On Saturday 21 February 2004 16:18, John Siracusa wrote: John, > Next, thanks to my earlier thread, I clustered the table on the date > column and then "SET STATISTICS" on the date column to be 100. That > did the trick, and I stopped explicitly disabling seqscan. 100? Are you sure you don't mean some other number? 100 is not very high for problem analyze issues. You might try 500. Generally when I have a problem query I raise stats to something like 1000 and drop it down until the problem behaviour starts re-appearing. > date_trunc('day', date) AS date Have you tried putting an index on date_trunc('day', date) and querying on that instead of using this: > date BETWEEN '2004-02-01 00:00:00' AND '2004-02-28 23:59:59' -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun Feb 22 17:58:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 20680D1BA13 for ; Sun, 22 Feb 2004 21:58:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 71289-05 for ; Sun, 22 Feb 2004 17:58:33 -0400 (AST) Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) by svr1.postgresql.org (Postfix) with ESMTP id 2EE13D1BABF for ; Sun, 22 Feb 2004 17:58:31 -0400 (AST) Received: from [10.0.1.2] (h000393e3ce55.ne.client2.attbi.com[24.91.235.158]) by comcast.net (rwcrmhc11) with SMTP id <2004022221583201300ddfgqe>; Sun, 22 Feb 2004 21:58:32 +0000 User-Agent: Microsoft-Entourage/10.1.4.030702.0 Date: Sun, 22 Feb 2004 16:58:30 -0500 Subject: Re: Column correlation drifts, index ignored again From: John Siracusa To: Postgres Performance Message-ID: In-Reply-To: <200402221105.57068.josh@agliodbs.com> Mime-version: 1.0 Reply-To: siracusa@mindspring.com Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/251 X-Sequence-Number: 5775 On 2/22/04 2:05 PM, Josh Berkus wrote: > On Saturday 21 February 2004 16:18, John Siracusa wrote: >> Next, thanks to my earlier thread, I clustered the table on the date >> column and then "SET STATISTICS" on the date column to be 100. That >> did the trick, and I stopped explicitly disabling seqscan. > > 100? Are you sure you don't mean some other number? 100 is not very high > for problem analyze issues. You might try 500. IIRC, 100 was the number suggested in the earlier thread. I did set it to 500 yesterday, I believe. We'll see how that goes. > Generally when I have a problem query I raise stats to something like 1000 and > drop it down until the problem behaviour starts re-appearing. Since this problem takes a long time to appear (months), that cycle could take a long time... :) >> date_trunc('day', date) AS date > > Have you tried putting an index on date_trunc('day', date) and querying on > that instead of using this: > >> date BETWEEN '2004-02-01 00:00:00' AND '2004-02-28 23:59:59' No, but then I'd just have a different index to persuade the planner to use :) Not every query does date_trunc() stuff, but they all do date ranges, often at a granularity of seconds. -John From pgsql-performance-owner@postgresql.org Sun Feb 22 18:07:01 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4D3E7D1BA8F for ; Sun, 22 Feb 2004 22:07:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 71735-08 for ; Sun, 22 Feb 2004 18:07:00 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 36019D1BA8E for ; Sun, 22 Feb 2004 18:06:58 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1MM6w6O018942; Sun, 22 Feb 2004 17:06:58 -0500 (EST) To: John Siracusa Cc: Postgres Performance Subject: Re: Column correlation drifts, index ignored again In-reply-to: <94FA2D7A-64CC-11D8-9DEA-000A95BA4506@mindspring.com> References: <94FA2D7A-64CC-11D8-9DEA-000A95BA4506@mindspring.com> Comments: In-reply-to John Siracusa message dated "Sat, 21 Feb 2004 19:18:04 -0500" Date: Sun, 22 Feb 2004 17:06:58 -0500 Message-ID: <18941.1077487618@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/252 X-Sequence-Number: 5776 John Siracusa writes: > I want to do something that will convince Postgres that using the date > index is, by far, the best plan when running my queries, even when the > date column correlation stat drops well below 1.0. Have you tried experimenting with random_page_cost? Seems like your results suggest that you need to lower it. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Feb 22 18:34:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 877C0D1B9C5 for ; Sun, 22 Feb 2004 22:34:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 76203-07 for ; Sun, 22 Feb 2004 18:34:50 -0400 (AST) Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [204.127.198.39]) by svr1.postgresql.org (Postfix) with ESMTP id 4D2B2D1B9BE for ; Sun, 22 Feb 2004 18:34:47 -0400 (AST) Received: from [10.0.1.2] (h000393e3ce55.ne.client2.attbi.com[24.91.235.158]) by comcast.net (rwcrmhc13) with SMTP id <2004022222344901500hrnppe>; Sun, 22 Feb 2004 22:34:49 +0000 User-Agent: Microsoft-Entourage/10.1.4.030702.0 Date: Sun, 22 Feb 2004 17:34:47 -0500 Subject: Re: Column correlation drifts, index ignored again From: John Siracusa To: Postgres Performance Message-ID: In-Reply-To: <18941.1077487618@sss.pgh.pa.us> Mime-version: 1.0 Reply-To: siracusa@mindspring.com Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/253 X-Sequence-Number: 5777 On 2/22/04 5:06 PM, Tom Lane wrote: > John Siracusa writes: >> I want to do something that will convince Postgres that using the date >> index is, by far, the best plan when running my queries, even when the >> date column correlation stat drops well below 1.0. > > Have you tried experimenting with random_page_cost? Seems like your > results suggest that you need to lower it. I don't want to do anything that "universal" if I can help it, because I don't want to adversely affect any other queries that the planner currently aces. I'm guessing that the reason using the date index is always so much faster is that doing so only reads the rows in the date range (say, 1,000 of them) instead of reading every single row in the table (1,000,000) as in a seqscan plan. I think the key is to get the planner to correctly ballpark the number of rows in the date range. If it does, I can't imagine it ever deciding to read 1,000,000 rows instead of 1,000 with any sane "cost" setting. I'm assuming the defaults are sane :) -John From pgsql-performance-owner@postgresql.org Sun Feb 22 19:30:15 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5AAD7D1B90E for ; Sun, 22 Feb 2004 23:30:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 93651-07 for ; Sun, 22 Feb 2004 19:30:14 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 17373D1BA48 for ; Sun, 22 Feb 2004 19:30:11 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1MNUBwm019369; Sun, 22 Feb 2004 18:30:11 -0500 (EST) To: Sean Shanny Cc: pgsql-performance@postgresql.org Subject: Re: General performance questions about postgres on Apple In-reply-to: <403682D6.60807@earthlink.net> References: <403682D6.60807@earthlink.net> Comments: In-reply-to Sean Shanny message dated "Fri, 20 Feb 2004 16:57:42 -0500" Date: Sun, 22 Feb 2004 18:30:11 -0500 Message-ID: <19368.1077492611@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/254 X-Sequence-Number: 5778 Sean Shanny writes: > New results with the above changes: (Rather a huge improvement!!!) > Thanks Scott. I will next attempt to make the cpu_* changes to see if > it the picks the correct plan. > explain analyze SELECT t1.id, t2.md5, t2.url from referral_temp t2 LEFT > OUTER JOIN d_referral t1 ON t2.md5 = t1.referral_md5; > QUERY PLAN > ---------------------------------------------------------------------------------------------------------------------------------------------- > Hash Left Join (cost=1669281.60..3204008.48 rows=480082 width=149) > (actual time=157221.125..-412311.378 rows=502347 loops=1) > Hash Cond: ("outer".md5 = "inner".referral_md5) > -> Seq Scan on referral_temp t2 (cost=0.00..16034.81 rows=480081 > width=145) (actual time=11.537..1852.336 rows=502347 loops=1) > -> Hash (cost=1356358.48..1356358.48 rows=30344048 width=40) > (actual time=157187.530..157187.530 rows=0 loops=1) > -> Seq Scan on d_referral t1 (cost=0.00..1356358.48 > rows=30344048 width=40) (actual time=14.134..115048.285 rows=27908024 > loops=1) > Total runtime: 212595.909 ms > (6 rows) It seems like the planner is overestimating the cost of a seqscan relative to indexed access. Note that the above large seqscan is priced at 1356358.48 cost units vs 115048.285 actual msec, which says that a sequential page fetch is taking about 0.1 msec on your hardware. (You should check the actual size of d_referral to verify this, though.) The other plan made it look like an indexed fetch was costing several milliseconds. You may have a situation where you need to raise random_page_cost, rather than lowering it as people more often do. What are you using for random_page_cost anyway? It doesn't look like you are at the default. This also suggests that the performance issue with your RAID array has to do with seek time rather than transfer bandwidth... regards, tom lane From pgsql-performance-owner@postgresql.org Sun Feb 22 19:40:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 35EE7D1BA46 for ; Sun, 22 Feb 2004 23:40:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 98300-01 for ; Sun, 22 Feb 2004 19:40:29 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 02F9AD1BA3B for ; Sun, 22 Feb 2004 19:40:26 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1MNeRPU019442; Sun, 22 Feb 2004 18:40:27 -0500 (EST) To: siracusa@mindspring.com Cc: Postgres Performance Subject: Re: Column correlation drifts, index ignored again In-reply-to: References: Comments: In-reply-to John Siracusa message dated "Sun, 22 Feb 2004 17:34:47 -0500" Date: Sun, 22 Feb 2004 18:40:26 -0500 Message-ID: <19441.1077493226@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/255 X-Sequence-Number: 5779 John Siracusa writes: > I think the key is to get the planner to correctly ballpark the number of > rows in the date range. I thought it was. What you showed was -> Index Scan using mytable_date_idx on mytable (cost=0.00..3071.70 rows=52155 width=23) (actual time=2.610..1688.111 rows=49679 loops=1) which seemed plenty close enough to me. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Feb 22 20:09:16 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5DA77D1BA4C for ; Mon, 23 Feb 2004 00:09:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 95762-06 for ; Sun, 22 Feb 2004 20:09:11 -0400 (AST) Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [204.127.198.39]) by svr1.postgresql.org (Postfix) with ESMTP id BE64FD1B9BE for ; Sun, 22 Feb 2004 20:09:07 -0400 (AST) Received: from [10.0.1.2] (h000393e3ce55.ne.client2.attbi.com[24.91.235.158]) by comcast.net (rwcrmhc13) with SMTP id <2004022300090801500i05jae>; Mon, 23 Feb 2004 00:09:08 +0000 User-Agent: Microsoft-Entourage/10.1.4.030702.0 Date: Sun, 22 Feb 2004 19:09:07 -0500 Subject: Re: Column correlation drifts, index ignored again From: John Siracusa To: Postgres Performance Message-ID: In-Reply-To: <19441.1077493226@sss.pgh.pa.us> Mime-version: 1.0 Reply-To: siracusa@mindspring.com Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/256 X-Sequence-Number: 5780 On 2/22/04 6:40 PM, Tom Lane wrote: > John Siracusa writes: >> I think the key is to get the planner to correctly ballpark the number of >> rows in the date range. > > I thought it was. What you showed was > > -> Index Scan using mytable_date_idx on mytable (cost=0.00..3071.70 rows=52155 > width=23) (actual time=2.610..1688.111 rows=49679 loops=1) > > which seemed plenty close enough to me. That's after the planner correctly chooses the date index. Unfortunately, I forgot to save the EXPLAIN output from when it was choosing seqscan instead. Does the planner get estimates from both plans before deciding whether or not to use the one that references the date index? -John From pgsql-performance-owner@postgresql.org Sun Feb 22 20:18:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A8445D1BA91 for ; Mon, 23 Feb 2004 00:18:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 97824-08 for ; Sun, 22 Feb 2004 20:18:18 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id D748AD1B90E for ; Sun, 22 Feb 2004 20:18:14 -0400 (AST) Received: from [216.135.165.74] (HELO 10.1.0.211) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4476053; Sun, 22 Feb 2004 16:19:24 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: siracusa@mindspring.com, Postgres Performance Subject: Re: Column correlation drifts, index ignored again Date: Sun, 22 Feb 2004 16:17:27 -0800 User-Agent: KMail/1.5.4 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402221617.27658.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/257 X-Sequence-Number: 5781 John, > I think the key is to get the planner to correctly ballpark the number of > rows in the date range. If it does, I can't imagine it ever deciding to > read 1,000,000 rows instead of 1,000 with any sane "cost" setting. I'm > assuming the defaults are sane :) The default for random_page_cost is sane, but very conservative; it's pretty much assuming tables that are bigger than RAM and a single IDE disk. If your setup is better than that, you can lower it. For example, in the ideal case (database fits in RAM, fast RAM, CPU, and random seek on the disk), you can lower it to 1.5. For less ideal situations, 1.8 to 2.5 is reasonable on high-end hardware. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun Feb 22 22:49:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 55E5BD1B9A9 for ; Mon, 23 Feb 2004 02:49:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 30602-04 for ; Sun, 22 Feb 2004 22:49:18 -0400 (AST) Received: from heron.mail.pas.earthlink.net (heron.mail.pas.earthlink.net [207.217.120.189]) by svr1.postgresql.org (Postfix) with ESMTP id E8990D1B901 for ; Sun, 22 Feb 2004 22:49:14 -0400 (AST) Received: from dpc6682165056.direcpc.com ([66.82.165.56] helo=earthlink.net) by heron.mail.pas.earthlink.net with asmtp (Exim 3.33 #1) id 1Av69g-0005xx-00; Sun, 22 Feb 2004 18:49:15 -0800 Message-ID: <40396A16.9040301@earthlink.net> Date: Sun, 22 Feb 2004 21:48:54 -0500 From: Sean Shanny User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: General performance questions about postgres on Apple References: <403682D6.60807@earthlink.net> <19368.1077492611@sss.pgh.pa.us> In-Reply-To: <19368.1077492611@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ELNK-Trace: 6ca696a38bf90a1a1de288fa2098067a1aa676d7e74259b7b3291a7d08dfec79bd956951ff2cddbbcd38e1a6613fe0d3350badd9bab72f9c350badd9bab72f9c X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/258 X-Sequence-Number: 5782 Tom, We have the following setting for random page cost: random_page_cost = 1 # units are one sequential page fetch cost Any suggestions on what to bump it up to? We are waiting to hear back from Apple on the speed issues, so far we are not impressed with the hardware in helping in the IO department. Our DB is about 263GB with indexes now so there is not way it is going to fit into memory. :-( I have taken the step of breaking out the data into month based groups just to keep the table sizes down. Our current months table has around 72 million rows in it as of today. The joys of building a data warehouse and trying to make it as fast as possible. Thanks. --sean Tom Lane wrote: >Sean Shanny writes: > > >>New results with the above changes: (Rather a huge improvement!!!) >>Thanks Scott. I will next attempt to make the cpu_* changes to see if >>it the picks the correct plan. >> >> > > > >>explain analyze SELECT t1.id, t2.md5, t2.url from referral_temp t2 LEFT >>OUTER JOIN d_referral t1 ON t2.md5 = t1.referral_md5; >> QUERY PLAN >>---------------------------------------------------------------------------------------------------------------------------------------------- >> Hash Left Join (cost=1669281.60..3204008.48 rows=480082 width=149) >>(actual time=157221.125..-412311.378 rows=502347 loops=1) >> Hash Cond: ("outer".md5 = "inner".referral_md5) >> -> Seq Scan on referral_temp t2 (cost=0.00..16034.81 rows=480081 >>width=145) (actual time=11.537..1852.336 rows=502347 loops=1) >> -> Hash (cost=1356358.48..1356358.48 rows=30344048 width=40) >>(actual time=157187.530..157187.530 rows=0 loops=1) >> -> Seq Scan on d_referral t1 (cost=0.00..1356358.48 >>rows=30344048 width=40) (actual time=14.134..115048.285 rows=27908024 >>loops=1) >> Total runtime: 212595.909 ms >>(6 rows) >> >> > >It seems like the planner is overestimating the cost of a seqscan >relative to indexed access. Note that the above large seqscan is priced >at 1356358.48 cost units vs 115048.285 actual msec, which says that a >sequential page fetch is taking about 0.1 msec on your hardware. >(You should check the actual size of d_referral to verify this, though.) >The other plan made it look like an indexed fetch was costing several >milliseconds. You may have a situation where you need to raise >random_page_cost, rather than lowering it as people more often do. > >What are you using for random_page_cost anyway? It doesn't look like >you are at the default. > >This also suggests that the performance issue with your RAID array >has to do with seek time rather than transfer bandwidth... > > regards, tom lane > > > From pgsql-performance-owner@postgresql.org Sun Feb 22 23:24:35 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9D79BD1BA48 for ; Mon, 23 Feb 2004 03:24:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 36285-04 for ; Sun, 22 Feb 2004 23:24:32 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 9B1A5D1B9BD for ; Sun, 22 Feb 2004 23:24:27 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1N3OTBW020383; Sun, 22 Feb 2004 22:24:29 -0500 (EST) To: Sean Shanny Cc: pgsql-performance@postgresql.org Subject: Re: General performance questions about postgres on Apple In-reply-to: <40396A16.9040301@earthlink.net> References: <403682D6.60807@earthlink.net> <19368.1077492611@sss.pgh.pa.us> <40396A16.9040301@earthlink.net> Comments: In-reply-to Sean Shanny message dated "Sun, 22 Feb 2004 21:48:54 -0500" Date: Sun, 22 Feb 2004 22:24:29 -0500 Message-ID: <20382.1077506669@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/259 X-Sequence-Number: 5783 Sean Shanny writes: > We have the following setting for random page cost: > random_page_cost = 1 # units are one sequential page fetch cost > Any suggestions on what to bump it up to? Well, the default setting is 4 ... what measurements prompted you to reduce it to 1? The particular example you showed suggested that the true value on your setup might be 10 or more. Now I would definitely not suggest that you settle on any particular value based on only one test case. You need to try to determine an appropriate average value, bearing in mind that there's likely to be lots of noise in any particular measurement. But in general, setting random_page_cost to 1 is only reasonable when you are dealing with a fully-cached-in-RAM database, which yours isn't. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Feb 22 23:38:48 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D5591D1BA52 for ; Mon, 23 Feb 2004 03:38:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 28797-10 for ; Sun, 22 Feb 2004 23:38:48 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 9DB5AD1BA48 for ; Sun, 22 Feb 2004 23:38:42 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1N3ce3B020485; Sun, 22 Feb 2004 22:38:40 -0500 (EST) To: siracusa@mindspring.com Cc: Postgres Performance Subject: Re: Column correlation drifts, index ignored again In-reply-to: References: Comments: In-reply-to John Siracusa message dated "Sun, 22 Feb 2004 19:09:07 -0500" Date: Sun, 22 Feb 2004 22:38:40 -0500 Message-ID: <20484.1077507520@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/260 X-Sequence-Number: 5784 John Siracusa writes: > Does the planner get estimates from both plans before deciding whether or > not to use the one that references the date index? The rowcount estimate is made prior to the plan cost estimate, much less the plan selection. So you'd see the same number either way. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Feb 23 07:48:11 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6707BD1B98D for ; Mon, 23 Feb 2004 11:48:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 44875-10 for ; Mon, 23 Feb 2004 07:48:10 -0400 (AST) Received: from expasy-ng.isb-sib.ch (expasy-f.unige.ch [192.33.215.142]) by svr1.postgresql.org (Postfix) with ESMTP id 502D8D1B9E5 for ; Mon, 23 Feb 2004 07:48:06 -0400 (AST) Received: from caliente (router.isb-sib.ch [192.33.215.254]) (authenticated bits=0) by expasy-ng.isb-sib.ch (8.12.10/8.12.8) with ESMTP id i1NBm3MD011016 for ; Mon, 23 Feb 2004 12:48:04 +0100 Message-ID: <000701c3fa02$e4e3d180$c300000a@caliente> From: "Eric Jain" To: "pgsql-performance" Subject: Slow join using network address function Date: Mon, 23 Feb 2004 12:48:02 +0100 Organization: Swiss Institute of Bioinformatics 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 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-sib-MailScanner-Information: Please contact the ISP for more information X-sib-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/261 X-Sequence-Number: 5785 I'm trying to join two tables on an inet column, where one of the columns may contain a subnet rather than a single host. Somehow the operation isn't completing quite fast enough, even though neither table is very large: table | rows --------------------+-------- clients | 115472 clients_commercial | 11670 First attempt, cancelled after running for half an hour: SELECT c.address AS address, cc.address AS network FROM clients c JOIN clients_commercial cc ON (c.address <<= cc.address) ; Nested Loop (cost=189.00..27359887.76 rows=607947200 width=22) Join Filter: ("outer".address <<= "inner".address) -> Seq Scan on clients c (cost=0.00..2074.76 rows=102176 width=11) -> Materialize (cost=189.00..308.00 rows=11900 width=11) -> Seq Scan on clients_commercial cc (cost=0.00..189.00 rows=11900 width=11) Second attempt, completes within 10 min: SELECT c.address AS address, cc.address AS network FROM clients c, clients_commercial cc WHERE c.commercial IS NULL AND c.address <<= cc.address ; Nested Loop (cost=189.00..139084.01 rows=3040450 width=22) Join Filter: ("outer".address <<= "inner".address) -> Seq Scan on clients c (cost=0.00..2074.76 rows=511 width=11) Filter: (commercial IS NULL) -> Materialize (cost=189.00..308.00 rows=11900 width=11) -> Seq Scan on clients_commercial cc (cost=0.00..189.00 rows=11900 width=11) Third attempt; provided some indexes, which unfortunately don't get used, making the query twice as slow as the previous one: SELECT c.address AS address, cc.address AS network FROM clients c, clients_commercial cc WHERE c.commercial IS NULL AND set_masklen(c.address, masklen(cc.address)) = cc.address ; CREATE INDEX clients_commercial_masklen_idx ON clients_commercial((masklen(address))); CREATE INDEX clients_32_idx ON clients((set_masklen(address, 32))); CREATE INDEX clients_24_idx ON clients((set_masklen(address, 24))); CREATE INDEX clients_16_idx ON clients((set_masklen(address, 16))); Nested Loop (cost=189.00..169488.51 rows=479 width=22) Join Filter: (set_masklen("outer".address, masklen("inner".address)) = "inner".address) -> Seq Scan on clients c (cost=0.00..2074.76 rows=511 width=11) Filter: (commercial IS NULL) -> Materialize (cost=189.00..308.00 rows=11900 width=11) -> Seq Scan on clients_commercial cc (cost=0.00..189.00 rows=11900 width=11) Anything else I could try? BTREE indexes don't seem to work with the <<= operator; is this not possible in principal, or simply something that has not been implmented yet? From pgsql-performance-owner@postgresql.org Mon Feb 23 12:14:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DEDDDD1B989 for ; Mon, 23 Feb 2004 16:14:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 43748-07 for ; Mon, 23 Feb 2004 12:14:19 -0400 (AST) Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com [64.71.176.18]) by svr1.postgresql.org (Postfix) with ESMTP id 1F2C3D1B9A8 for ; Mon, 23 Feb 2004 12:14:19 -0400 (AST) Received: by gp.word-to-the-wise.com (Postfix, from userid 500) id 52F70900013; Mon, 23 Feb 2004 08:07:34 -0800 (PST) Date: Mon, 23 Feb 2004 08:07:34 -0800 From: Steve Atkins To: pgsql-performance Subject: Re: Slow join using network address function Message-ID: <20040223160734.GA11052@gp.word-to-the-wise.com> References: <000701c3fa02$e4e3d180$c300000a@caliente> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000701c3fa02$e4e3d180$c300000a@caliente> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/262 X-Sequence-Number: 5786 On Mon, Feb 23, 2004 at 12:48:02PM +0100, Eric Jain wrote: > I'm trying to join two tables on an inet column, where one of the > columns may contain a subnet rather than a single host. Somehow the > operation isn't completing quite fast enough, even though neither table > is very large: > > table | rows > --------------------+-------- > clients | 115472 > clients_commercial | 11670 [snip] > Anything else I could try? BTREE indexes don't seem to work with the <<= > operator; is this not possible in principal, or simply something that > has not been implmented yet? I've been looking at a similar problem for a while. I found that the inet type didn't really give me the flexibility I needed, and indexing it in a way that worked with CIDR blocks didn't seem easy (and maybe not possible). So I rolled my own, based on the seg sample. is a datatype that contains a range of IPv4 addresses, and which has the various operators to make it GIST indexable. Untar it into contrib and make as usual. Input is of the form '10.11.12.13' or '10.11.12.13.0/25' or '10.11.12.13-10.11.12.13.127'. The function display() takes an ipr type and returns it formatted for display (as a dotted-quad if a /32, as CIDR format if possible, as a range of dotted-quads otherwise). A bunch of operators are included, but '&&' returns true if two ipr fields intersect. Bugs include: 0.0.0.0/0 doesn't do what it should on input. No documentation. No cast operators between ipr and inet types. No documentation. I was planning on doing some docs before releasing it, but here it is anyway. Cheers, Steve -- -- Steve Atkins -- steve@blighty.com From pgsql-performance-owner@postgresql.org Mon Feb 23 12:36:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 76451D1B904 for ; Mon, 23 Feb 2004 16:36:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 63243-02 for ; Mon, 23 Feb 2004 12:36:00 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 6A077D1B581 for ; Mon, 23 Feb 2004 12:35:59 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1NGWUIr001092; Mon, 23 Feb 2004 09:32:31 -0700 (MST) Date: Mon, 23 Feb 2004 09:25:13 -0700 (MST) From: "scott.marlowe" To: Sean Shanny Cc: Tom Lane , Subject: Re: General performance questions about postgres on Apple In-Reply-To: <40396A16.9040301@earthlink.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/263 X-Sequence-Number: 5787 On Sun, 22 Feb 2004, Sean Shanny wrote: > Tom, > > We have the following setting for random page cost: > > random_page_cost = 1 # units are one sequential page fetch cost > > Any suggestions on what to bump it up to? > > We are waiting to hear back from Apple on the speed issues, so far we > are not impressed with the hardware in helping in the IO department. > Our DB is about 263GB with indexes now so there is not way it is going > to fit into memory. :-( I have taken the step of breaking out the data > into month based groups just to keep the table sizes down. Our current > months table has around 72 million rows in it as of today. The joys of > building a data warehouse and trying to make it as fast as possible. You may be able to achieve similar benefits with a clustered index. see cluster: \h cluster Command: CLUSTER Description: cluster a table according to an index Syntax: CLUSTER indexname ON tablename CLUSTER tablename CLUSTER I've found this can greatly increase speed, but on 263 gigs of data, I'd run it when you had a couple days free. You might wanna test it on a smaller test set you can afford to chew up some I/O CPU time on over a weekend. From pgsql-performance-owner@postgresql.org Mon Feb 23 12:51:20 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A34ABD1B97B for ; Mon, 23 Feb 2004 16:51:18 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 66782-05 for ; Mon, 23 Feb 2004 12:51:15 -0400 (AST) Received: from stork.mail.pas.earthlink.net (stork.mail.pas.earthlink.net [207.217.120.188]) by svr1.postgresql.org (Postfix) with ESMTP id 8B2F0D1B904 for ; Mon, 23 Feb 2004 12:51:14 -0400 (AST) Received: from dpc6682165056.direcpc.com ([66.82.165.56] helo=earthlink.net) by stork.mail.pas.earthlink.net with asmtp (Exim 3.33 #1) id 1AvJIN-0002oB-00; Mon, 23 Feb 2004 08:51:05 -0800 Message-ID: <403A2F6A.7000300@earthlink.net> Date: Mon, 23 Feb 2004 11:50:50 -0500 From: Sean Shanny User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "scott.marlowe" Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: General performance questions about postgres on Apple References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ELNK-Trace: 6ca696a38bf90a1a1de288fa2098067a1aa676d7e74259b7b3291a7d08dfec795d8023e4f9582c658f822d9ecd24d44f350badd9bab72f9c350badd9bab72f9c X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/264 X-Sequence-Number: 5788 Scott, We did try clustering on the date_key for the fact table below for a months worth of data as most of our requests for data are date range based, i.e. get me info for the time period between 2004-02-01 and 2004-02-07. This normally results in a plan that is doing an index scan on the date_key which in theory should be fast. However we have found that it is almost always faster to run a sequential scan on the data set due to the size, and probably as Tom pointed out, the high seek time we seem to be experiencing with the MAC hardware which kills us when using the index to pop all over the disk. We saw no improvement after having clustered based on the date_key. I am certainly open to any suggestions on how to deal with speed issues on these sorts of large tables, it isn't going to go away for us. :-( We are working on trying to make the table below smaller in record size so we can get more records in a page. An example is we are removing the subscriber_key which is 32 characters wide and replacing it with an int (user_id) which is an FK to a dimension table. I welcome any advice from folks that have used postgres to build data warehouses. Thanks. --sean Table "public.f_pageviews" Column | Type | Modifiers ------------------------+---------+------------------------------------------------------------- id | integer | not null default nextval('public.f_pageviews_id_seq'::text) date_key | integer | not null time_key | integer | not null content_key | integer | not null location_key | integer | not null session_key | integer | not null subscriber_key | text | not null persistent_cookie_key | integer | not null ip_key | integer | not null referral_key | integer | not null servlet_key | integer | not null tracking_key | integer | not null provider_key | text | not null marketing_campaign_key | integer | not null orig_airport | text | not null dest_airport | text | not null commerce_page | boolean | not null default false job_control_number | integer | not null sequenceid | integer | not null default 0 url_key | integer | not null useragent_key | integer | not null web_server_name | text | not null default 'Not Available'::text cpc | integer | not null default 0 referring_servlet_key | integer | not null default 1 first_page_key | integer | not null default 1 newsletterid_key | text | not null default 'Not Available'::text userid_key | integer | Indexes: "f_pageviews_pkey" primary key, btree (id) "idx_pageviews_date" btree (date_key) "idx_pageviews_session" btree (session_key) scott.marlowe wrote: >On Sun, 22 Feb 2004, Sean Shanny wrote: > > > >>Tom, >> >>We have the following setting for random page cost: >> >>random_page_cost = 1 # units are one sequential page fetch cost >> >>Any suggestions on what to bump it up to? >> >>We are waiting to hear back from Apple on the speed issues, so far we >>are not impressed with the hardware in helping in the IO department. >>Our DB is about 263GB with indexes now so there is not way it is going >>to fit into memory. :-( I have taken the step of breaking out the data >>into month based groups just to keep the table sizes down. Our current >>months table has around 72 million rows in it as of today. The joys of >>building a data warehouse and trying to make it as fast as possible. >> >> > >You may be able to achieve similar benefits with a clustered index. > >see cluster: > >\h cluster >Command: CLUSTER >Description: cluster a table according to an index >Syntax: >CLUSTER indexname ON tablename >CLUSTER tablename >CLUSTER > >I've found this can greatly increase speed, but on 263 gigs of data, I'd >run it when you had a couple days free. You might wanna test it on a >smaller test set you can afford to chew up some I/O CPU time on over a >weekend. > > > > From pgsql-performance-owner@postgresql.org Sat Feb 28 18:42:45 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5EF30D1D26A for ; Mon, 23 Feb 2004 20:01:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 35072-01 for ; Mon, 23 Feb 2004 16:01:17 -0400 (AST) Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net [67.119.5.202]) by svr1.postgresql.org (Postfix) with ESMTP id 0876CD1B973 for ; Mon, 23 Feb 2004 16:01:08 -0400 (AST) Received: (from andrew@localhost) by pillette.com (8.11.6/8.11.6) id i1NK0rQ30781; Mon, 23 Feb 2004 12:00:53 -0800 Date: Mon, 23 Feb 2004 12:00:53 -0800 From: andrew@pillette.com Message-Id: <200402232000.i1NK0rQ30781@pillette.com> Subject: Re: JOIN order, 15K, 15K, 7MM rows To: pgsql-performance@postgresql.org Cc: X-Originating-IP: 192.168.1.203 X-Mailer: Webmin 0.940 MIME-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Archive-Number: 200402/327 X-Sequence-Number: 5851 EXPLAIN INSERT INTO public.historical_price ( security_serial_id, [7 fields of proprietary data]) SELECT public.security_series.security_serial_id, [7 fields of data], FROM obsolete.datadb_fix INNER JOIN (obsolete.calcdb INNER JOIN public.security_series ON obsolete.calcdb.serial=public.security_series.legacy_calcdb_id) ON obsolete.datadb_fix.id=public.security_series.legacy_calcdb_id; datadb_fix is about 5.5MM records. The other two tables are about 15K records. Hash Join (cost=1151.63..225863.54 rows=5535794 width=53) Hash Cond: ("outer".id = "inner".serial) -> Seq Scan on datadb_fix (cost=0.00..121867.99 rows=6729299 width=28) -> Hash (cost=1115.54..1115.54 rows=14438 width=25) -> Hash Join (cost=609.96..1115.54 rows=14438 width=25) Hash Cond: ("outer".legacy_calcdb_id = "inner".serial) -> Seq Scan on security_series (cost=0.00..247.40 rows=15540 width=13) -> Hash (cost=572.37..572.37 rows=15037 width=12) -> Seq Scan on calcdb (cost=0.00..572.37 rows=15037 width=12) pim_new-# Table "obsolete.datadb_fix" pim_new-# Column | Type | Modifiers pim_new-# -------------+------------------+----------- pim_new-# serial | integer | pim_new-# id | integer | pim_new-# date | date | [4 fields deleted] pim_new-# Indexes: sb_data_pkey unique btree (id, date), pim_new-# datadb1_id btree (id), pim_new=# \d obsolete.calcdb Table "obsolete.calcdb" Column | Type | Modifiers --------------------+----------------------+------------------------------------ ------------------- serial | integer | not null default nextval('"calcdb_s erial_seq"'::text) [...30 proprietary fields] Indexes: calcdb_serial_key unique btree (serial), [...5 other indexes] pim_new=# \d security_series Table "public.security_series" Column | Type | Modifiers --------------------+--------------+----------- security_serial_id | integer | not null period | character(1) | not null legacy_calcdb_id | integer | Indexes: security_series_pkey primary key btree (security_serial_id, period), secseries_legacy_id_idx1 btree (legacy_calcdb_id) The target table has three indexes on it, so I suppose that accounts for SOME extra time. I ended up cancelling the query, running the select on a faster machine into an unindexed temp table, then using COPY out and in. That process took about 2.5 hours total. Machine: Linux, PG 7.3.4, 1.1GHz, 768MB RAM, unfortunately running other stuff. The first try which didn't finish in 24 hours was on Mac OS X Jaguar, PG 7.3.3, 1GHz, 256MB (please don't laugh). Yes, hardware upgrades are coming, but I need to estimate how much more I have to squeeze out of the DB and client applications. From pgsql-performance-owner@postgresql.org Mon Feb 23 16:05:13 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2095ED1D267 for ; Mon, 23 Feb 2004 20:05:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 35072-03 for ; Mon, 23 Feb 2004 16:05:11 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 6CB4DD1D174 for ; Mon, 23 Feb 2004 16:05:09 -0400 (AST) Received: from [216.135.165.74] (HELO 10.1.0.211) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4480210; Mon, 23 Feb 2004 12:06:18 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Eric Jain" , "pgsql-performance" Subject: Re: Slow join using network address function Date: Mon, 23 Feb 2004 12:04:18 -0800 User-Agent: KMail/1.5.4 References: <000701c3fa02$e4e3d180$c300000a@caliente> In-Reply-To: <000701c3fa02$e4e3d180$c300000a@caliente> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402231204.18760.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/265 X-Sequence-Number: 5789 Eric, > Nested Loop > (cost=189.00..27359887.76 rows=607947200 width=22) > Join Filter: ("outer".address <<= "inner".address) > -> Seq Scan on clients c > (cost=0.00..2074.76 rows=102176 width=11) > -> Materialize > (cost=189.00..308.00 rows=11900 width=11) > -> Seq Scan on clients_commercial cc > (cost=0.00..189.00 rows=11900 width=11) To help you, we need EXPLAIN ANALYZE, not just EXPLAIN. Thanks! -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Feb 23 16:12:12 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 81D26D1D1C4 for ; Mon, 23 Feb 2004 20:12:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 33200-09 for ; Mon, 23 Feb 2004 16:12:08 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id F1871D1BAA2 for ; Mon, 23 Feb 2004 16:12:05 -0400 (AST) Received: from [216.135.165.74] (HELO 10.1.0.211) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4480257; Mon, 23 Feb 2004 12:13:13 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Sean Shanny , "scott.marlowe" Subject: Re: General performance questions about postgres on Apple Date: Mon, 23 Feb 2004 12:11:17 -0800 User-Agent: KMail/1.5.4 Cc: Tom Lane , pgsql-performance@postgresql.org References: <403A2F6A.7000300@earthlink.net> In-Reply-To: <403A2F6A.7000300@earthlink.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402231211.17369.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/266 X-Sequence-Number: 5790 Scott, > I am certainly open to any suggestions on how to deal with speed issues > on these sorts of large tables, it isn't going to go away for us. :-( I'm not sure what to suggest. I can't think of anything off the top of my head that would improve cripplingly slow random seek times. This sort of problem has personally caused me to dump and replace various RAID controllers in the past. I have to say that I have not been impressed with the Mac as a database server platform in the past; I've had no end of issues with memory and disk management. I talked to the Apple Server staff at the last MacWorld about some of these issues and they admitted that servers are still a "new thing" for Apple as a company, and they're still tweaking OSX server. BTW, I wasn't clear from your description: did you mean that you have 14 disks? Oh, and for testing real random seek time, you can run bonnie++ which is findable on freshmeat. This should give you a benchmark to e-mail the Apple people. I'd be interested in being cc'd on your communications with them, as we use OSX for webserving and would like to see better support for database serving. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Feb 23 20:17:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8124AD1BA13 for ; Tue, 24 Feb 2004 00:17:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 09666-04 for ; Mon, 23 Feb 2004 20:17:51 -0400 (AST) Received: from cmailg5.svr.pol.co.uk (cmailg5.svr.pol.co.uk [195.92.195.175]) by svr1.postgresql.org (Postfix) with ESMTP id E35EDD1B4DE for ; Mon, 23 Feb 2004 20:17:47 -0400 (AST) Received: from modem-1004.leopard.dialup.pol.co.uk ([217.135.147.236] helo=LaptopDellXP) by cmailg5.svr.pol.co.uk with esmtp (Exim 4.14) id 1AvQGj-0000np-QF; Tue, 24 Feb 2004 00:17:50 +0000 Reply-To: From: "Simon Riggs" To: "'Sean Shanny'" , Subject: Re: General performance questions about postgres on Apple hardware... Date: Tue, 24 Feb 2004 00:17:28 -0000 Organization: 2nd Quadrant Message-ID: <002101c3fa6b$96da7610$ec9387d9@LaptopDellXP> 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.2627 In-Reply-To: <40365D36.5090708@earthlink.net> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/267 X-Sequence-Number: 5791 >Sean Shanny > Hardware: Apple G5 dual 2.0 with 8GB memory attached via dual fibre > channel to a fully loaded 3.5TB XRaid. The XRaid is configured as two 7 > disk hardware based RAID5 sets software striped to form a RAID50 set. > The DB, WALS, etc are all on that file set. Running OSX journaled file > system Running postgres 7.4.1. OSX Server 10.3.2 Postgres is compiled > locally with '--enable-recode' '--enable-multibyte=UNICODE' > 'CFLAGS=-mcpu=970 -mtune=970 -mpowerpc64 -O3' Have you tried altering the blocksize to a higher value? Say 32K? > max_connections = 100 Why have you set this to 100 when you have typically 1-3 users? > sort_mem = 256000 # min 64, size in KB If you have only 1-3 users, then that value seems reasonable. > The query is > > SELECT t1.id, t2.md5, t2.url FROM referral_temp t2 LEFT OUTER JOIN > d_referral t1 ON t2.md5 = t1.referral_md5; > > > \d d_referral > id | integer | not null > referral_md5 | text | not null > referral_raw_url | text | not null > referral_host | text | > referral_path | text | > referral_query | text | > job_control_number | integer | not null > > > \d referral_temp > md5 | text | > url | text | Have you looked at using reversed indexes, as per recent postings in [performance]? These seemed to help considerably with lookup speed when using a large URL database, which seems to be your situation here. ... >Jeff Boes writes > We have a large (several million row) table with a field containing > URLs. Now, funny thing about URLs: they mostly start with a common > substring ("http://www."). But not all the rows start with this, so we > can't just lop off the first N characters. However, we noticed some time > ago that an index on this field wasn't as effective as an index on the > REVERSE of the field. So ... > > CREATE OR REPLACE FUNCTION fn_urlrev(text) returns text as ' > return reverse(lc($_[0])) > ' language 'plperl' with (iscachable,isstrict); > > and then > > CREATE UNIQUE INDEX ix_links_3 ON links > (fn_urlrev(path_base)); You have 2 CPUs: have you tried splitting your input data file into two tables, then executing the same query simultaneously, to split the processing? If you get the correct plan, you should use roughly the same I/O but use all of the available CPU power. I'm sure we'd all be interested in your further results! Best Regards, Simon Riggs From pgsql-performance-owner@postgresql.org Mon Feb 23 20:54:37 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2CA68D1D174 for ; Tue, 24 Feb 2004 00:54:36 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 11296-10 for ; Mon, 23 Feb 2004 20:54:34 -0400 (AST) Received: from stork.mail.pas.earthlink.net (stork.mail.pas.earthlink.net [207.217.120.188]) by svr1.postgresql.org (Postfix) with ESMTP id 49531D1C4E0 for ; Mon, 23 Feb 2004 20:54:31 -0400 (AST) Received: from dpc6682165056.direcpc.com ([66.82.165.56] helo=earthlink.net) by stork.mail.pas.earthlink.net with asmtp (Exim 3.33 #1) id 1AvQq5-00006r-00; Mon, 23 Feb 2004 16:54:23 -0800 Message-ID: <403AA0AF.209@earthlink.net> Date: Mon, 23 Feb 2004 19:54:07 -0500 From: Sean Shanny User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: simon@2ndquadrant.com Cc: pgsql-performance@postgresql.org Subject: Re: General performance questions about postgres on Apple References: <002101c3fa6b$96da7610$ec9387d9@LaptopDellXP> In-Reply-To: <002101c3fa6b$96da7610$ec9387d9@LaptopDellXP> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ELNK-Trace: 6ca696a38bf90a1a1de288fa2098067a1aa676d7e74259b7b3291a7d08dfec790be47a38632d229c2b777afa2a2d1111350badd9bab72f9c350badd9bab72f9c X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/268 X-Sequence-Number: 5792 Simon Riggs wrote: >>Sean Shanny >>Hardware: Apple G5 dual 2.0 with 8GB memory attached via dual fibre >>channel to a fully loaded 3.5TB XRaid. The XRaid is configured as two >> >> >7 > > >>disk hardware based RAID5 sets software striped to form a RAID50 set. >>The DB, WALS, etc are all on that file set. Running OSX journaled >> >> >file > > >>system Running postgres 7.4.1. OSX Server 10.3.2 Postgres is >> >> >compiled > > >>locally with '--enable-recode' '--enable-multibyte=UNICODE' >>'CFLAGS=-mcpu=970 -mtune=970 -mpowerpc64 -O3' >> >> > >Have you tried altering the blocksize to a higher value? Say 32K? > > That is on our to do list. We had made that change while running on BSD 5.1on a Dell 2650 with 4GB and 5 10K SCSI drive in RAID 0. Did not see a huge improvement. > > >>max_connections = 100 >> >> > >Why have you set this to 100 when you have typically 1-3 users? > > Have already addressed that by lowering this to 50. Will drop it lower as time goes on. > > >>sort_mem = 256000 # min 64, size in KB >> >> > >If you have only 1-3 users, then that value seems reasonable. > > > >>The query is >> >>SELECT t1.id, t2.md5, t2.url FROM referral_temp t2 LEFT OUTER JOIN >>d_referral t1 ON t2.md5 = t1.referral_md5; >> >> >>\d d_referral >> id | integer | not null >> referral_md5 | text | not null >> referral_raw_url | text | not null >> referral_host | text | >> referral_path | text | >> referral_query | text | >> job_control_number | integer | not null >> >> >>\d referral_temp >> md5 | text | >> url | text | >> >> > >Have you looked at using reversed indexes, as per recent postings in >[performance]? These seemed to help considerably with lookup speed when >using a large URL database, which seems to be your situation here. > > We create an MD5 of the URL and store it as referral_md5. This is our key for lookup. We ran into problems with the URL as the index. The postgres indexing code was complaining about the URL being too long, hence the MD5 which thought longer to compute during the ETL phase is much quicker to match on. >... > > >>Jeff Boes writes >>We have a large (several million row) table with a field containing >>URLs. Now, funny thing about URLs: they mostly start with a common >>substring ("http://www."). But not all the rows start with this, so we >>can't just lop off the first N characters. However, we noticed some >> >> >time > > >>ago that an index on this field wasn't as effective as an index on the >>REVERSE of the field. So ... >> >>CREATE OR REPLACE FUNCTION fn_urlrev(text) returns text as ' >>return reverse(lc($_[0])) >>' language 'plperl' with (iscachable,isstrict); >> >>and then >> >>CREATE UNIQUE INDEX ix_links_3 ON links >>(fn_urlrev(path_base)); >> >> > >You have 2 CPUs: have you tried splitting your input data file into two >tables, then executing the same query simultaneously, to split the >processing? If you get the correct plan, you should use roughly the same >I/O but use all of the available CPU power. > > Have not considered that. >I'm sure we'd all be interested in your further results! > > I will post things as I discover them. --sean >Best Regards, Simon Riggs > > > > From pgsql-performance-owner@postgresql.org Mon Feb 23 21:23:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 942DBD1D174 for ; Tue, 24 Feb 2004 01:23:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 23746-06 for ; Mon, 23 Feb 2004 21:23:37 -0400 (AST) Received: from web11.manitu.net (web11.manitu.net [217.11.48.111]) by svr1.postgresql.org (Postfix) with ESMTP id B7197D1D141 for ; Mon, 23 Feb 2004 21:23:32 -0400 (AST) Received: from [192.168.0.1] (dsl-082-082-102-172.arcor-ip.net [82.82.102.172]) (authenticated) by web11.manitu.net (8.10.2-SOL3/8.10.2) with ESMTP id i1O1NSM03545; Tue, 24 Feb 2004 02:23:29 +0100 Subject: Re: Slow join using network address function From: Markus Bertheau To: josh@agliodbs.com Cc: Eric Jain , pgsql-performance In-Reply-To: <200402231204.18760.josh@agliodbs.com> References: <000701c3fa02$e4e3d180$c300000a@caliente> <200402231204.18760.josh@agliodbs.com> Content-Type: text/plain; charset=UTF-8 Message-Id: <1077585807.2258.0.camel@yarrow.bertheau.de> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.5.3 (1.5.3-1) Date: Tue, 24 Feb 2004 02:23:27 +0100 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/269 X-Sequence-Number: 5793 On =D0=9F=D0=BD=D0=B4, 2004-02-23 at 12:04 -0800, Josh Berkus wrote: > Eric, >=20 > > Nested Loop > > (cost=3D189.00..27359887.76 rows=3D607947200 width=3D22) > > Join Filter: ("outer".address <<=3D "inner".address) > > -> Seq Scan on clients c > > (cost=3D0.00..2074.76 rows=3D102176 width=3D11) > > -> Materialize > > (cost=3D189.00..308.00 rows=3D11900 width=3D11) > > -> Seq Scan on clients_commercial cc > > (cost=3D0.00..189.00 rows=3D11900 width=3D11) >=20 > To help you, we need EXPLAIN ANALYZE, not just EXPLAIN. Thanks! He said he cancelled the query. --=20 Markus Bertheau From pgsql-performance-owner@postgresql.org Mon Feb 23 22:11:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 17188D1B91C for ; Tue, 24 Feb 2004 02:11:05 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 40858-03 for ; Mon, 23 Feb 2004 22:11:05 -0400 (AST) Received: from mail.codenet.net (mail.codenet.net [209.248.81.8]) by svr1.postgresql.org (Postfix) with ESMTP id 18F82D1B4AA for ; Mon, 23 Feb 2004 22:11:01 -0400 (AST) Received: from elvis [68.232.114.7] by mail.codenet.net with ESMTP (SMTPD32-7.07) id A2B71B5A02A4; Mon, 23 Feb 2004 19:11:03 -0700 Content-Type: text/plain; charset="us-ascii" From: "Ed L." To: pgsql-performance@postgresql.org Subject: [PERFORMANCE] slow small delete on large table Date: Mon, 23 Feb 2004 19:10:57 -0700 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200402231910.57078.pgsql@bluepolka.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/270 X-Sequence-Number: 5794 A 7.3.4 question... I want to "expire" some data after 90 days, but not delete too much at once so as not to overwhelm a system with precariously balanced disk I/O and on a table with millions of rows. If I=20 could say it the way I think for a simple example, it'd be like this: delete from mytable where posteddatetime < now() - '90 days' limit 100; Of course, that's not legal 7.3.4 syntax. These are both too slow due to sequential scan of table: delete from mytable where key in ( select key from mytable where posteddatetime < now() - '90 days' limit 100); or=20 delete from mytable where exists ( select m.key from mytable m where m.key =3D mytable.key and m.posteddatetime < now() - '90 days' limit 100); Tried to use a cursor, but couldn't figure out the syntax for select-for-delete yet, or find appropriate example on google. Any clues? TIA. From pgsql-performance-owner@postgresql.org Mon Feb 23 22:25:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 20B81D1DF71 for ; Tue, 24 Feb 2004 02:25:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 42223-02 for ; Mon, 23 Feb 2004 22:25:20 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 249D0D1DD65 for ; Mon, 23 Feb 2004 22:25:16 -0400 (AST) Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i1O2PDGi013606; Tue, 24 Feb 2004 10:25:13 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <403AB818.9090100@familyhealth.com.au> Date: Tue, 24 Feb 2004 10:34:00 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Ed L." Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORMANCE] slow small delete on large table References: <200402231910.57078.pgsql@bluepolka.net> In-Reply-To: <200402231910.57078.pgsql@bluepolka.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/271 X-Sequence-Number: 5795 > Of course, that's not legal 7.3.4 syntax. These are both too > slow due to sequential scan of table: > > delete from mytable where key in ( > select key > from mytable > where posteddatetime < now() - '90 days' > limit 100); Upgrade to 7.4 - the query above will be vastly faster. > delete from mytable where exists ( > select m.key > from mytable m > where m.key = mytable.key > and m.posteddatetime < now() - '90 days' > limit 100); That one I used to use on 7.3 - I seem to recall it indexed nicely. Chris From pgsql-performance-owner@postgresql.org Mon Feb 23 22:58:02 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id AA8FFD1CAF3 for ; Tue, 24 Feb 2004 02:58:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 51108-01 for ; Mon, 23 Feb 2004 22:58:02 -0400 (AST) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 22349D1BABF for ; Mon, 23 Feb 2004 22:57:58 -0400 (AST) Received: (qmail 21837 invoked by uid 500); 24 Feb 2004 03:00:17 -0000 Date: Mon, 23 Feb 2004 21:00:17 -0600 From: Bruno Wolff III To: "Ed L." Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORMANCE] slow small delete on large table Message-ID: <20040224030017.GA2872@wolff.to> Mail-Followup-To: "Ed L." , pgsql-performance@postgresql.org References: <200402231910.57078.pgsql@bluepolka.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200402231910.57078.pgsql@bluepolka.net> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/272 X-Sequence-Number: 5796 On Mon, Feb 23, 2004 at 19:10:57 -0700, "Ed L." wrote: > > A 7.3.4 question... > > I want to "expire" some data after 90 days, but not delete too > much at once so as not to overwhelm a system with precariously > balanced disk I/O and on a table with millions of rows. If I > could say it the way I think for a simple example, it'd be > like this: If there aren't foreign keys into the table from which rows are being deleted, then a delete shouldn't have a big impact on the system. If you do the expires frequently, then there won't be as many records to delete at one time. The other response showed you how to avoid the sequential scan, which is the other part of the problem. From pgsql-performance-owner@postgresql.org Tue Feb 24 00:19:02 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B4B65D1E106 for ; Tue, 24 Feb 2004 04:19:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 72940-03 for ; Tue, 24 Feb 2004 00:18:58 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id B5BBED1DF7F for ; Tue, 24 Feb 2004 00:18:58 -0400 (AST) 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 i1O4Iw1Y074582 for ; Tue, 24 Feb 2004 04:18:58 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i1O3oYTp070056 for pgsql-performance@postgresql.org; Tue, 24 Feb 2004 03:50:34 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: [PERFORMANCE] slow small delete on large table Date: Mon, 23 Feb 2004 22:48:29 -0500 Organization: cbbrowne Computing Inc Lines: 113 Message-ID: References: <200402231910.57078.pgsql@bluepolka.net> 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:WlSLvsjDTljmNfehyXrclZSgNz4= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/274 X-Sequence-Number: 5798 pgsql@bluepolka.net ("Ed L.") wrote: > A 7.3.4 question... > > I want to "expire" some data after 90 days, but not delete too > much at once so as not to overwhelm a system with precariously > balanced disk I/O and on a table with millions of rows. If I > could say it the way I think for a simple example, it'd be > like this: > > delete from mytable > where posteddatetime < now() - '90 days' > limit 100; > > Of course, that's not legal 7.3.4 syntax. These are both too > slow due to sequential scan of table: > > delete from mytable where key in ( > select key > from mytable > where posteddatetime < now() - '90 days' > limit 100); > or > delete from mytable where exists ( > select m.key > from mytable m > where m.key = mytable.key > and m.posteddatetime < now() - '90 days' > limit 100); > > Tried to use a cursor, but couldn't figure out the syntax > for select-for-delete yet, or find appropriate example on > google. Any clues? I'm hoping that there's an index on posteddatetime, right? There are several approaches that would be quite sensible to consider... 1. Delete records as often as possible, so that the number deleted at any given time stays small. 2. Or find an hour at which the system isn't busy, and blow through a lot of them then. 3. Open a cursor querying records in your acceptable range, e.g. declare nukem cursor for select key from mytable where posteddate < now() - '90 days'::interval; Fetch 100 entries from the cursor, and submit, across another connection, delete requests for the 100 entries, all as one transaction, which you commit. Sleep a bit, and fetch another 100. Note that the cursor will draw groups of 100 entries into memory; it's good to immediately delete them, as they'll be in buffers. Keeping the number of rows deleted small, and sleeping a bit, means you're not trashing buffers too badly. The query doesn't enforce any particular order on things; it effect chews out old entries in any order the query finds them. If you can't keep up with insertions, there could be rather old entries that would linger around... This parallels the "sleepy vacuum" that takes a similar strategy to keeping vacuums from destroying performance. 4. Rotor tables. Have "mytable" be a view on a sequence of tables. create view mytable as select * from mytable1 union all select * from mytable2 union all select * from mytable3 union all select * from mytable4 union all select * from mytable5 union all select * from mytable6 union all select * from mytable7 union all select * from mytable8 union all select * from mytable9 union all select * from mytable10 A rule can choose an appropriate table from the 9 to _actually_ insert into. Every 3 days, you truncate the eldest table and rotate on to insert into the next table. That will take mere moments, which is real helpful to save you I/O on the deletes. There is an unfortunate other problem with this; joins against mytable are pretty bad, and self-joins effectively turn into a union all across 100 joins. (Table 1 against 1-10, Table 2 against 1-10, and so forth...) For this not to suck rather incredibly requires fairly carefully structuring queries on the table. That may or may not be compatible with your needs... -- let name="cbbrowne" and tld="cbbrowne.com" in name ^ "@" ^ tld;; http://cbbrowne.com/info/x.html A Linux machine! because a 486 is a terrible thing to waste! -- Joe Sloan From pgsql-performance-owner@postgresql.org Mon Feb 23 23:56:02 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C796ED1B973 for ; Tue, 24 Feb 2004 03:56:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 66131-06 for ; Mon, 23 Feb 2004 23:56:02 -0400 (AST) Received: from filer (c-24-6-183-218.client.comcast.net [24.6.183.218]) by svr1.postgresql.org (Postfix) with ESMTP id 34E9FD1BA21 for ; Mon, 23 Feb 2004 23:55:58 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Mon, 23 Feb 2004 19:56:02 -0800 Date: Mon, 23 Feb 2004 19:56:02 -0800 From: Kevin Brown To: Postgres Performance Subject: Re: Column correlation drifts, index ignored again Message-ID: <20040224035601.GC3090@filer> Mail-Followup-To: Kevin Brown , Postgres Performance References: <200402221617.27658.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <200402221617.27658.josh@agliodbs.com> Organization: Frobozzco International User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/273 X-Sequence-Number: 5797 Josh Berkus wrote: > John, > > > I think the key is to get the planner to correctly ballpark the number of > > rows in the date range. If it does, I can't imagine it ever deciding to > > read 1,000,000 rows instead of 1,000 with any sane "cost" setting. I'm > > assuming the defaults are sane :) > > The default for random_page_cost is sane, but very conservative; it's pretty > much assuming tables that are bigger than RAM and a single IDE disk. If > your setup is better than that, you can lower it. > > For example, in the ideal case (database fits in RAM, fast RAM, CPU, and > random seek on the disk), you can lower it to 1.5. For less ideal > situations, 1.8 to 2.5 is reasonable on high-end hardware. I suspect this ultimately depends on the types of queries you do, the size of the tables involved, disk cache, etc. For instance, if you don't have sort_mem set high enough, then things like large hash joins will spill to disk and almost certainly cause a lot of contention (random access patterns) even if a sequential scan is being used to read the table data. The fix there is, of course, to increase sort_mem if possible (as long as you don't cause paging during the operation, which will also slow things down), but you might not really have that option -- in which case you might see some improvement by tweaking random_page_cost. On a system where the PG data is stored on a disk that does other things, you'll actually want random_page_cost to be *closer* to 1 rather than further away. The reason is that the average access time of a sequential page in that case is much closer to that of a random page than it would be if the disk in question were dedicated to PG duty. This also goes for large RAID setups where multiple types of data (e.g., home directories, log files, etc.) are stored along with the PG data -- such disk setups will have more random activity happening on the disk while PG activity is happening, thus making the PG sequential access pattern appear more like random access. The best way I can think of to tune random_page_cost is to do EXPLAIN ANALYZE on the queries you want to optimize the most under the circumstances the queries are most likely to be run, then do the same with enable_seqscan off. Then look at the ratio of predicted and actual times for the scans themselves. Once you've done that, you can tweak random_page_cost up or down and do further EXPLAINs (with enable_seqscan off and without ANALYZE) until the ratio of the estimated index scan time to the actual index scan time of the same query (gotten previously via EXPLAIN ANALYZE) is the same as the ratio of the estimated sequential scan time (which won't change based on random_page_cost) to the actual sequential scan time. So: 1. set enable_seqscan = on 2. set random_page_cost = 3. EXPLAIN ANALYZE query 4. record the ratio of estimated to actual scan times. 5. set enable_seqscan = off 6. set random_page_cost = 7. EXPLAIN ANALYZE query 8. record the actual index scan time(s) 9. tweak random_page_cost 10. EXPLAIN query 11. If ratio of estimate to actual (recorded in step 8) is much different than that recorded in step 4, then go back to step 9. Reduce random_page_cost if the random ratio is larger than the sequential ratio, increase if it's smaller. As a result, I ended up setting my random_page_cost to 1.5 on my system. I suspect that the amount of pain you'll suffer when the planner incorrectly chooses a sequential scan is much greater on average than the amount of pain if it incorrectly chooses an index scan, so I'd tend to favor erring on the low side for random_page_cost. I'll know tomorrow whether or not my tweaking worked properly, as I have a job that kicks off every night that scans the entire filesystem and stores all the inode information about every file in a newly-created table, then "merges" it into the existing file information table. Each table is about 2.5 million rows... -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Tue Feb 24 01:24:04 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id F2A31D1BAC2 for ; Tue, 24 Feb 2004 05:24:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 82908-10 for ; Tue, 24 Feb 2004 01:24:01 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 1E8CCD1BABF for ; Tue, 24 Feb 2004 01:24:00 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1O5Nwar018316; Tue, 24 Feb 2004 00:23:58 -0500 (EST) To: "Ed L." Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORMANCE] slow small delete on large table In-reply-to: <200402231910.57078.pgsql@bluepolka.net> References: <200402231910.57078.pgsql@bluepolka.net> Comments: In-reply-to "Ed L." message dated "Mon, 23 Feb 2004 19:10:57 -0700" Date: Tue, 24 Feb 2004 00:23:58 -0500 Message-ID: <18315.1077600238@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/275 X-Sequence-Number: 5799 "Ed L." writes: > If I could say it the way I think for a simple example, it'd be > like this: > delete from mytable > where posteddatetime < now() - '90 days' > limit 100; > Of course, that's not legal 7.3.4 syntax. Assuming you have a primary key on the table, consider this: CREATE TEMP TABLE doomed AS SELECT key FROM mytable WHERE posteddatetime < now() - '90 days' LIMIT 100; DELETE FROM mytable WHERE key = doomed.key; DROP TABLE doomed; Depending on the size of mytable, you might need an "ANALYZE doomed" in there, but I'm suspecting not. A quick experiment suggests that you'll get a plan with an inner indexscan on mytable.key, which is exactly what you need. See also Chris Browne's excellent suggestions nearby, if you are willing to make larger readjustments in your thinking... regards, tom lane From pgsql-performance-owner@postgresql.org Tue Feb 24 08:07:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 490CDD1B989 for ; Tue, 24 Feb 2004 12:07:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 96401-03 for ; Tue, 24 Feb 2004 08:07:27 -0400 (AST) Received: from expasy-ng.isb-sib.ch (expasy-f.unige.ch [192.33.215.142]) by svr1.postgresql.org (Postfix) with ESMTP id AA969D1CAF6 for ; Tue, 24 Feb 2004 08:07:22 -0400 (AST) Received: from caliente (router.isb-sib.ch [192.33.215.254]) (authenticated bits=0) by expasy-ng.isb-sib.ch (8.12.10/8.12.8) with ESMTP id i1OC7CMD006816; Tue, 24 Feb 2004 13:07:15 +0100 Message-ID: <001d01c3face$bca62d40$c300000a@caliente> From: "Eric Jain" To: "Steve Atkins" Cc: "pgsql-performance" References: <000701c3fa02$e4e3d180$c300000a@caliente> <20040223160734.GA11052@gp.word-to-the-wise.com> Subject: Re: Slow join using network address function Date: Tue, 24 Feb 2004 13:07:10 +0100 Organization: Swiss Institute of Bioinformatics 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 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-sib-MailScanner-Information: Please contact the ISP for more information X-sib-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/276 X-Sequence-Number: 5800 > is a datatype that contains > a range of IPv4 addresses, and which has the various operators to > make it GIST indexable. Great, this looks very promising. > No cast operators between ipr and inet types. Any way to work around this, short of dumping and reloading tables? SELECT ipr '1.2.3.4'; -- Okay SELECT ipr text(inet '1.2.3.4'); -- Syntax error, of course SELECT ipr(text(inet '1.2.3.4')); -- Function does not exist, of course ... From pgsql-performance-owner@postgresql.org Sat Feb 28 18:40:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id CADA7D1E0BB for ; Tue, 24 Feb 2004 13:20:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 12593-08 for ; Tue, 24 Feb 2004 09:20:27 -0400 (AST) Received: from pinus.cc.fer.hr (pinus.cc.fer.hr [161.53.73.18]) by svr1.postgresql.org (Postfix) with ESMTP id 56462D1DF82 for ; Tue, 24 Feb 2004 09:20:22 -0400 (AST) Received: from fer.hr (lara.cc.fer.hr [161.53.72.113]) by pinus.cc.fer.hr (8.12.2/8.12.2) with ESMTP id i1ODKLdm028027 for ; Tue, 24 Feb 2004 14:20:21 +0100 (MET) Message-ID: <403B4EDE.7020907@fer.hr> Date: Tue, 24 Feb 2004 14:17:18 +0100 From: Ivan Voras User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Slow query Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/326 X-Sequence-Number: 5850 I have a query that I think should run faster. The machine is P2/400 with enough ram (384MB), but still, maybe the query could be tuned up. postgresql.conf is stock with these values changed: fsync=false shared_buffers = 5000 sort_mem = 8192 vacuum_mem = 16384 This is a development machine, the production will be dual P3, 1GHz, 1GB RAM, but I fear that the execution will still be slow, as the tables will get bigger. I've pasted information about the database, and the explain output, but the text is horribly wrapped so there's a clean copy on the web in http://geri.cc.fer.hr/~ivoras/query.txt The intention is: there is a table called cl_log which records events from various sources, some of which also have data in data_kat_id and data_user_id fields, some of which don't (hence the outer joins). The query is report-style, and tries to collect as much data as possible about the events. Tables cl_source, cl_handler and cl_event_type hold information about the type of event. They are small (currently 1-3 records in each, will grow to about 10 records). ferweb=> explain analyze SELECT cl_log.*, cl_source.name AS source_name, cl_source.description AS source_description, cl_handler.name AS handler_name, cl_handler.description AS handler_description, cl_event_type.name AS event_type_name, cl_event_type.description as event_type_description, users.jime, kategorija.knaziv FROM cl_log INNER JOIN cl_source ON source_id=cl_source.id INNER JOIN cl_handler ON cl_source.handler_id=cl_handler.id INNER JOIN cl_event_type ON event_type_id=cl_event_type.id LEFT OUTER JOIN kategorija ON data_kat_id=kategorija.id LEFT OUTER JOIN users ON data_user_id=users.id ORDER BY time desc LIMIT 30; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=788.78..788.79 rows=2 width=500) (actual time=23229.78..23230.44 rows=30 loops=1) -> Sort (cost=788.78..788.79 rows=3 width=500) (actual time=23229.75..23230.10 rows=31 loops=1) Sort Key: cl_log."time" -> Nested Loop (cost=1.04..788.76 rows=3 width=500) (actual time=4078.85..20185.89 rows=38999 loops=1) -> Nested Loop (cost=1.04..771.27 rows=3 width=485) (actual time=4078.71..14673.27 rows=38999 loops=1) -> Hash Join (cost=1.04..754.21 rows=3 width=417) (actual time=4078.54..8974.08 rows=38999 loops=1) Hash Cond: ("outer".event_type_id = "inner".id) -> Nested Loop (cost=0.00..752.16 rows=195 width=288) (actual time=4078.20..6702.17 rows=38999 loops=1) Join Filter: ("inner".handler_id = "outer".id) -> Seq Scan on cl_handler (cost=0.00..1.01 rows=1 width=104) (actual time=0.02..0.04 rows=1 loops=1) -> Materialize (cost=748.72..748.72 rows=195 width=184) (actual time=4078.08..4751.52 rows=38999 loops=1) -> Nested Loop (cost=0.00..748.72 rows=195 width=184) (actual time=0.21..3197.16 rows=38999 loops=1) -> Seq Scan on cl_source (cost=0.00..1.01 rows=1 width=108) (actual time=0.05..0.06 rows=1 loops=1) -> Index Scan using cl_log_source on cl_log (cost=0.00..745.27 rows=195 width=76) (actual time=0.11..1467.08 rows=38999 loops=1) Index Cond: (cl_log.source_id = "outer".id) -> Hash (cost=1.03..1.03 rows=3 width=129) (actual time=0.12..0.12 rows=0 loops=1) -> Seq Scan on cl_event_type (cost=0.00..1.03 rows=3 width=129) (actual time=0.04..0.08 rows=3 loops=1) -> Index Scan using kategorija_pkey on kategorija (cost=0.00..5.82 rows=1 width=68) (actual time=0.05..0.07 rows=1 loops=38999) Index Cond: ("outer".data_kat_id = kategorija.id) -> Index Scan using users_pkey on users (cost=0.00..5.97 rows=1 width=15) (actual time=0.05..0.07 rows=1 loops=38999) Index Cond: ("outer".data_user_id = users.id) Total runtime: 23267.25 msec (22 rows) ferweb=> select count(*) from cl_log; count ------- 38999 (1 row) ferweb=> select count(*) from cl_handler; count ------- 1 (1 row) ferweb=> select count(*) from cl_source; count ------- 1 (1 row) ferweb=> select count(*) from cl_event_type; count ------- 3 (1 row) ferweb=> select count(*) from users; count ------- 2636 (1 row) ferweb=> select count(*) from kategorija; count ------- 1928 (1 row) -- Every sufficiently advanced magic is indistinguishable from technology - Arthur C Anticlarke From pgsql-performance-owner@postgresql.org Tue Feb 24 11:23:27 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 633A5D1B90E for ; Tue, 24 Feb 2004 15:23:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 74448-04 for ; Tue, 24 Feb 2004 11:23:27 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id D906FD1B4C5 for ; Tue, 24 Feb 2004 11:23:22 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1OFNMgM022240; Tue, 24 Feb 2004 10:23:23 -0500 (EST) To: "Eric Jain" Cc: "Steve Atkins" , "pgsql-performance" Subject: Re: Slow join using network address function In-reply-to: <001d01c3face$bca62d40$c300000a@caliente> References: <000701c3fa02$e4e3d180$c300000a@caliente> <20040223160734.GA11052@gp.word-to-the-wise.com> <001d01c3face$bca62d40$c300000a@caliente> Comments: In-reply-to "Eric Jain" message dated "Tue, 24 Feb 2004 13:07:10 +0100" Date: Tue, 24 Feb 2004 10:23:22 -0500 Message-ID: <22239.1077636202@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/277 X-Sequence-Number: 5801 "Eric Jain" writes: >> is a datatype that contains >> a range of IPv4 addresses, and which has the various operators to >> make it GIST indexable. > Great, this looks very promising. >> No cast operators between ipr and inet types. > Any way to work around this, short of dumping and reloading tables? Wouldn't it be better to implement the GIST indexing operators of that package on the standard datatypes? It wasn't apparent to me what "range of IP addresses" does for you that isn't covered by "CIDR subnet" for real-world cases. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Feb 24 12:11:43 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D8337D1B4C5 for ; Tue, 24 Feb 2004 16:11:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 90697-07 for ; Tue, 24 Feb 2004 12:11:38 -0400 (AST) Received: from mail2.speakeasy.net (mail2.speakeasy.net [216.254.0.202]) by svr1.postgresql.org (Postfix) with ESMTP id 9CE1AD1B989 for ; Tue, 24 Feb 2004 12:11:33 -0400 (AST) Received: (qmail 22002 invoked from network); 24 Feb 2004 16:11:29 -0000 Received: from atlas.jonathangardner.net (HELO jonathangardner.net) (jgardn@[66.92.192.166]) (envelope-sender ) by mail2.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted SMTP for ; 24 Feb 2004 16:11:29 -0000 From: "Jonathan M. Gardner" To: pgsql-hackers@postgresql.org, pgsql-sql@postgresql.org, pgsql-performance@postgresql.org Subject: Materialized View Summary Date: Tue, 24 Feb 2004 08:11:03 -0800 User-Agent: KMail/1.5.94 MIME-Version: 1.0 Content-Disposition: inline Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Message-Id: <200402240811.13013.jgardner@jonathangardner.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/278 X-Sequence-Number: 5802 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've written a summary of my findings on implementing and using=20 materialized views in PostgreSQL. I've already deployed eagerly updating=20 materialized views on several views in a production environment for a=20 company called RedWeek: http://redweek.com/. As a result, some queries=20 that were taking longer than 30 seconds to run now run in a fraction of a= =20 millisecond. You can view my summary at=20 http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html Comments and suggestions are definitely welcome. - --=20 Jonathan Gardner jgardner@jonathangardner.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFAO3eZqp6r/MVGlwwRAnpEAKC8+/lFyPBbXetPEfFLwgUvJZLCmgCfYlmR 0vZmCcbGSNT/m/W8QOIhufk=3D =3DsnCu -----END PGP SIGNATURE----- From pgsql-performance-owner@postgresql.org Tue Feb 24 12:45:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 448E5D1BACA for ; Tue, 24 Feb 2004 16:45:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 02416-05 for ; Tue, 24 Feb 2004 12:45:15 -0400 (AST) Received: from easily.co.uk (mercury0.easily.co.uk [213.161.76.90]) by svr1.postgresql.org (Postfix) with ESMTP id 8E36FD1BAD5 for ; Tue, 24 Feb 2004 12:45:13 -0400 (AST) Received: from [213.152.63.90] (account f4vo5dsy5djd HELO chuckie.co.uk) by easily.co.uk (CommuniGate Pro SMTP 4.1.3) with ESMTP id 50702857; Tue, 24 Feb 2004 16:45:01 +0000 Message-ID: <403B7F89.5030902@chuckie.co.uk> Date: Tue, 24 Feb 2004 16:44:57 +0000 From: Nick Barr User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Eric Jain , Steve Atkins , pgsql-performance Subject: Re: Slow join using network address function References: <000701c3fa02$e4e3d180$c300000a@caliente> <20040223160734.GA11052@gp.word-to-the-wise.com> <001d01c3face$bca62d40$c300000a@caliente> <22239.1077636202@sss.pgh.pa.us> In-Reply-To: <22239.1077636202@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/279 X-Sequence-Number: 5803 Tom Lane wrote: >"Eric Jain" writes: > > >>> is a datatype that contains >>>a range of IPv4 addresses, and which has the various operators to >>>make it GIST indexable. >>> >>> > > > >>Great, this looks very promising. >> >> > > > >>>No cast operators between ipr and inet types. >>> >>> > > > >>Any way to work around this, short of dumping and reloading tables? >> >> > >Wouldn't it be better to implement the GIST indexing operators of that >package on the standard datatypes? It wasn't apparent to me what "range >of IP addresses" does for you that isn't covered by "CIDR subnet" for >real-world cases. > > regards, tom lane > >---------------------------(end of broadcast)--------------------------- >TIP 8: explain analyze is your friend > > We currently only allow access to one of our apps based on IP address. These IPs are stored one per row in a single table, but often represent a contiguous piece of IP space, but does not represent a full subnet. The current CIDR subnet has the limitation that it will only allow full subnets, i.e. every IP address in 192.168.1.0/24. For example: 192.168.1.15 -> 192.168.1.31 This range cannot be represented by a CIDR subnet, or it might be able to but I really dont want to figure it out each time. However this new type allows us to store this range as one row. It allows an arbitrary range of IP addresses, not just those in a specific subnet. I would see this as a useful inclusion whether in the main src tree or in contrib and we will probably be using it when we get to "mess" with the database schema for this app in the next few months, in fact I have already inserted it into our PG source tree ;-). Nick P.S. We are not responsible for the IP address ranges, we just get told what they are. From pgsql-performance-owner@postgresql.org Tue Feb 24 13:02:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 21864D1CAF6 for ; Tue, 24 Feb 2004 17:02:08 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 09164-04 for ; Tue, 24 Feb 2004 13:02:01 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id ADC21D1BAC2 for ; Tue, 24 Feb 2004 13:02:00 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4484806; Tue, 24 Feb 2004 09:03:06 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Kevin Brown , Postgres Performance Subject: Re: Column correlation drifts, index ignored again Date: Tue, 24 Feb 2004 08:59:32 -0800 User-Agent: KMail/1.4.3 References: <200402221617.27658.josh@agliodbs.com> <20040224035601.GC3090@filer> In-Reply-To: <20040224035601.GC3090@filer> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200402240859.32312.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/280 X-Sequence-Number: 5804 Kevin, > 1. set enable_seqscan = on > 2. set random_page_cost = > 3. EXPLAIN ANALYZE query > 4. record the ratio of estimated to actual scan times. > 5. set enable_seqscan = off > 6. set random_page_cost = > 7. EXPLAIN ANALYZE query > 8. record the actual index scan time(s) > 9. tweak random_page_cost > 10. EXPLAIN query > 11. If ratio of estimate to actual (recorded in step 8) is much > different than that recorded in step 4, then go back to step 9. > Reduce random_page_cost if the random ratio is larger than the > sequential ratio, increase if it's smaller. Nice, we ought to post that somewhere people can find it in the future. I'm also glad that your new job allows you to continue doing PostgreSQL stuff. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Feb 24 13:17:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A1BD4D1BAD5 for ; Tue, 24 Feb 2004 17:17:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 14975-10 for ; Tue, 24 Feb 2004 13:17:13 -0400 (AST) Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com [64.71.176.18]) by svr1.postgresql.org (Postfix) with ESMTP id AA440D1BA35 for ; Tue, 24 Feb 2004 13:17:12 -0400 (AST) Received: by gp.word-to-the-wise.com (Postfix, from userid 500) id BB52C9029F7; Tue, 24 Feb 2004 09:10:26 -0800 (PST) Date: Tue, 24 Feb 2004 09:10:26 -0800 From: Steve Atkins To: pgsql-performance Subject: Re: Slow join using network address function Message-ID: <20040224171026.GD5368@gp.word-to-the-wise.com> References: <000701c3fa02$e4e3d180$c300000a@caliente> <20040223160734.GA11052@gp.word-to-the-wise.com> <001d01c3face$bca62d40$c300000a@caliente> <22239.1077636202@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <22239.1077636202@sss.pgh.pa.us> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/282 X-Sequence-Number: 5806 On Tue, Feb 24, 2004 at 10:23:22AM -0500, Tom Lane wrote: > "Eric Jain" writes: > >> is a datatype that contains > >> a range of IPv4 addresses, and which has the various operators to > >> make it GIST indexable. > > > Great, this looks very promising. > > >> No cast operators between ipr and inet types. > > > Any way to work around this, short of dumping and reloading tables? > > Wouldn't it be better to implement the GIST indexing operators of that > package on the standard datatypes? It wasn't apparent to me what "range > of IP addresses" does for you that isn't covered by "CIDR subnet" for > real-world cases. Well, maybe. However, many of the cases where people want to use this sort of functionality (address range ownership, email blacklists etc) an entity is likely to associated with one or a small number of ranges of contiguous addresses. Those ranges are often not simple CIDR blocks, and deaggregating them into a sequence of CIDR blocks doesn't buy anything and complicates the problem. I also managed to convince myself that it wasn't possible to do a useful GIST index of a CIDR datatype - as the union between two adjacent CIDR blocks as a CIDR block is often far, far larger than the actual range involved - consider 63.255.255.255/32 and 64.0.0.0/32. That seemed to break the indexing algorithms. I'd like to be proven wrong on that, but would still find ipr a more useful datatype than inet for my applications. Cheers, Steve From pgsql-performance-owner@postgresql.org Tue Feb 24 13:11:36 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 65F0AD1BAC2; Tue, 24 Feb 2004 17:11:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 13180-07; Tue, 24 Feb 2004 13:11:25 -0400 (AST) 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 E7696D1BAD6; Tue, 24 Feb 2004 13:11:24 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) id 1Avg5b-0004HE-0Y; Tue, 24 Feb 2004 17:11:24 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 23CF51621B; Tue, 24 Feb 2004 17:11:23 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 2796316214; Tue, 24 Feb 2004 17:11:21 +0000 (GMT) From: Richard Huxton To: "Jonathan M. Gardner" , pgsql-hackers@postgresql.org, pgsql-sql@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [SQL] Materialized View Summary Date: Tue, 24 Feb 2004 17:11:20 +0000 User-Agent: KMail/1.5 References: <200402240811.13013.jgardner@jonathangardner.net> In-Reply-To: <200402240811.13013.jgardner@jonathangardner.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402241711.20947.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/281 X-Sequence-Number: 5805 On Tuesday 24 February 2004 16:11, Jonathan M. Gardner wrote: > > I've written a summary of my findings on implementing and using > materialized views in PostgreSQL. I've already deployed eagerly updating > materialized views on several views in a production environment for a > company called RedWeek: http://redweek.com/. As a result, some queries > that were taking longer than 30 seconds to run now run in a fraction of a > millisecond. > > You can view my summary at > http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html Interesting (and well written) summary. Even if not a "built in" feature, I'm sure that plenty of people will find this useful. Make sure it gets linked to from techdocs. If you could identify candidate keys on a view, you could conceivably automate the process even more. That's got to be possible in some cases, but I'm not sure how difficult it is to do in all cases. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Tue Feb 24 13:21:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 62697D1D332 for ; Tue, 24 Feb 2004 17:21:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 17140-08 for ; Tue, 24 Feb 2004 13:21:27 -0400 (AST) Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com [64.71.176.18]) by svr1.postgresql.org (Postfix) with ESMTP id 8FA6AD1CAF3 for ; Tue, 24 Feb 2004 13:21:26 -0400 (AST) Received: by gp.word-to-the-wise.com (Postfix, from userid 500) id 632209029EC; Tue, 24 Feb 2004 09:14:42 -0800 (PST) Date: Tue, 24 Feb 2004 09:14:42 -0800 From: Steve Atkins To: pgsql-performance Subject: Re: Slow join using network address function Message-ID: <20040224171442.GE5368@gp.word-to-the-wise.com> References: <000701c3fa02$e4e3d180$c300000a@caliente> <20040223160734.GA11052@gp.word-to-the-wise.com> <001d01c3face$bca62d40$c300000a@caliente> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001d01c3face$bca62d40$c300000a@caliente> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/283 X-Sequence-Number: 5807 On Tue, Feb 24, 2004 at 01:07:10PM +0100, Eric Jain wrote: > > is a datatype that contains > > a range of IPv4 addresses, and which has the various operators to > > make it GIST indexable. > > Great, this looks very promising. > > > No cast operators between ipr and inet types. > > Any way to work around this, short of dumping and reloading tables? > > SELECT ipr '1.2.3.4'; -- Okay > SELECT ipr text(inet '1.2.3.4'); -- Syntax error, of course > SELECT ipr(text(inet '1.2.3.4')); -- Function does not exist, of course There's probably some horrible SQL hack that would let you do it, but I should add some casting code anyway. Shouldn't be too painful to do - I'll try and get that, and some minimal documentation out today. Cheers, Steve From pgsql-performance-owner@postgresql.org Sat Feb 28 18:37:03 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D0B1DD1BAD2; Tue, 24 Feb 2004 17:40:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 25334-04; Tue, 24 Feb 2004 13:40:10 -0400 (AST) Received: from hal.kabsi.at (top.kabsi.at [195.202.128.73]) by svr1.postgresql.org (Postfix) with ESMTP id E4187D1BAD5; Tue, 24 Feb 2004 13:40:08 -0400 (AST) Received: from cybertec.at (h062040243020.plc.cm.kabsi.at [62.40.243.20]) by hal.kabsi.at (8.11.1/) with ESMTP id i1OHdDs0001296296; Tue, 24 Feb 2004 18:39:13 +0100 (CET) Message-ID: <403B8C89.5010904@cybertec.at> Date: Tue, 24 Feb 2004 18:40:25 +0100 From: =?ISO-8859-1?Q?Hans-J=FCrgen_Sch=F6nig?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Richard Huxton Cc: "Jonathan M. Gardner" , pgsql-hackers@postgresql.org, pgsql-sql@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [HACKERS] [SQL] Materialized View Summary References: <200402240811.13013.jgardner@jonathangardner.net> <200402241711.20947.dev@archonet.com> In-Reply-To: <200402241711.20947.dev@archonet.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/323 X-Sequence-Number: 5847 Richard Huxton wrote: > On Tuesday 24 February 2004 16:11, Jonathan M. Gardner wrote: > >>I've written a summary of my findings on implementing and using >>materialized views in PostgreSQL. I've already deployed eagerly updating >>materialized views on several views in a production environment for a >>company called RedWeek: http://redweek.com/. As a result, some queries >>that were taking longer than 30 seconds to run now run in a fraction of a >>millisecond. >> >>You can view my summary at >>http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html > > > Interesting (and well written) summary. Even if not a "built in" feature, I'm > sure that plenty of people will find this useful. Make sure it gets linked to > from techdocs. > > If you could identify candidate keys on a view, you could conceivably automate > the process even more. That's got to be possible in some cases, but I'm not > sure how difficult it is to do in all cases. > Are there any plans to rewrite that in C and add proper support for SQL commands? (e.g. "CREATE MATERIALIZED VIEW", "DROP VIEW", ...). Best regards, Hans -- Cybertec Geschwinde u Schoenig Schoengrabern 134, A-2020 Hollabrunn, Austria Tel: +43/2952/30706 or +43/664/233 90 75 www.cybertec.at, www.postgresql.at, kernel.cybertec.at From pgsql-performance-owner@postgresql.org Tue Feb 24 14:29:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A46E9D1CCD7 for ; Tue, 24 Feb 2004 18:29:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 46686-01 for ; Tue, 24 Feb 2004 14:29:50 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id B9A97D1BAA2 for ; Tue, 24 Feb 2004 14:29:48 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1OITkAY023534; Tue, 24 Feb 2004 13:29:46 -0500 (EST) To: Josh Berkus Cc: Kevin Brown , Postgres Performance Subject: Re: Column correlation drifts, index ignored again In-reply-to: <200402240859.32312.josh@agliodbs.com> References: <200402221617.27658.josh@agliodbs.com> <20040224035601.GC3090@filer> <200402240859.32312.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Tue, 24 Feb 2004 08:59:32 -0800" Date: Tue, 24 Feb 2004 13:29:46 -0500 Message-ID: <23533.1077647386@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/284 X-Sequence-Number: 5808 Josh Berkus writes: > Kevin, >> 1. set enable_seqscan = on >> 2. set random_page_cost = >> 3. EXPLAIN ANALYZE query >> 4. record the ratio of estimated to actual scan times. >> 5. set enable_seqscan = off >> 6. set random_page_cost = >> 7. EXPLAIN ANALYZE query >> 8. record the actual index scan time(s) >> 9. tweak random_page_cost >> 10. EXPLAIN query >> 11. If ratio of estimate to actual (recorded in step 8) is much >> different than that recorded in step 4, then go back to step 9. >> Reduce random_page_cost if the random ratio is larger than the >> sequential ratio, increase if it's smaller. > Nice, we ought to post that somewhere people can find it in the future. If we post it as recommended procedure we had better put big caveat notices on it. The pitfalls with doing this are: 1. If you repeat the sequence exactly as given, you will be homing in on a RANDOM_PAGE_COST that describes your system's behavior with a fully cached query. It is to be expected that you will end up with 1.0 or something very close to it. The only way to avoid that is to use a query that is large enough to blow out your kernel's RAM cache; which of course will take long enough that iterating step 10 will be no fun, and people will be mighty tempted to take shortcuts. 2. Of course, you are computing a RANDOM_PAGE_COST that is relevant to just this single query. Prudence would suggest repeating the process with several different queries and taking some sort of average. When I did the experiments that led up to choosing 4.0 as the default, some years ago, it took several days of thrashing the disks on a couple of different machines before I had numbers that I didn't think were mostly noise :-(. I am *real* suspicious of any replacement numbers that have been derived in just a few minutes. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Feb 24 14:36:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 34E94D1BA35 for ; Tue, 24 Feb 2004 18:36:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 39394-10 for ; Tue, 24 Feb 2004 14:36:23 -0400 (AST) Received: from mail.codenet.net (mail.codenet.net [209.248.81.8]) by svr1.postgresql.org (Postfix) with ESMTP id 73643D1B4AA for ; Tue, 24 Feb 2004 14:36:21 -0400 (AST) Received: from elvis [68.232.114.7] by mail.codenet.net with ESMTP (SMTPD32-7.07) id A9A26C01BC; Tue, 24 Feb 2004 11:36:18 -0700 Content-Type: text/plain; charset="utf-8" From: "Ed L." To: Tom Lane Subject: Re: [PERFORMANCE] slow small delete on large table Date: Tue, 24 Feb 2004 11:36:08 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org References: <200402231910.57078.pgsql@bluepolka.net> <18315.1077600238@sss.pgh.pa.us> In-Reply-To: <18315.1077600238@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200402241136.08556.pgsql@bluepolka.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/285 X-Sequence-Number: 5809 On Monday February 23 2004 10:23, Tom Lane wrote: > "Ed L." writes: > > If I could say it the way I think for a simple example, it'd be > > like this: > > > > delete from mytable > > where posteddatetime < now() - '90 days' > > limit 100; > > > > Of course, that's not legal 7.3.4 syntax. > > Assuming you have a primary key on the table, consider this: > > CREATE TEMP TABLE doomed AS > SELECT key FROM mytable WHERE posteddatetime < now() - '90 days' > LIMIT 100; > > DELETE FROM mytable WHERE key =3D doomed.key; > > DROP TABLE doomed; > > Depending on the size of mytable, you might need an "ANALYZE doomed" > in there, but I'm suspecting not. A quick experiment suggests that > you'll get a plan with an inner indexscan on mytable.key, which is > exactly what you need. I didn't mention I'd written a trigger to do delete N rows on each new=20 insert (with a delay governor preventing deletion avalanches). The=20 approach looks a little heavy to be done from within a trigger with the=20 response time I need, but I'll try it. Cantchajust toss in that "limit N"= =20 functionality to delete clauses? How hard could that be? ;) > See also Chris Browne's excellent suggestions nearby, if you are willing > to make larger readjustments in your thinking... I did a search for articles by Chris Browne, didn't see one that appeared= =20 relevant. What is the thread subject to which you refer? From pgsql-sql-owner@postgresql.org Tue Feb 24 14:58:12 2004 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 83E9BD1CCD7 for ; Tue, 24 Feb 2004 18:58:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 46686-10 for ; Tue, 24 Feb 2004 14:58:09 -0400 (AST) Received: from web13802.mail.yahoo.com (web13802.mail.yahoo.com [216.136.175.12]) by svr1.postgresql.org (Postfix) with SMTP id 7764CD1BACA for ; Tue, 24 Feb 2004 14:58:07 -0400 (AST) Message-ID: <20040224185806.51777.qmail@web13802.mail.yahoo.com> Received: from [216.173.173.66] by web13802.mail.yahoo.com via HTTP; Tue, 24 Feb 2004 10:58:06 PST Date: Tue, 24 Feb 2004 10:58:06 -0800 (PST) From: Chris Gamache Reply-To: cgg007@yahoo.com Subject: tsearch2 trigger alternative To: pgsql-sql@postgresql.org In-Reply-To: <200402241711.20947.dev@archonet.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/340 X-Sequence-Number: 17030 Tsearch2 comes with its own tsearch2 trigger function. You pass column names to it, and it puts a vanilla tsvector into the column names in TG_ARGV[0] (zero based, yes?). Not only can you pass column names to it, but you can pass simple functions to it as well. This is magical to me. :) I'm trying to figure out how to do the same thing, except instead of returning a vanilla tsvector, I want to return a specially weighted tsvector. I've created a function that can do this: create or replace function name_vector (text) returns tsvector as ' select setweight(to_tsvector(substr($1,1,strpos($1,'',''))),''C'') || to_tsvector(substr($1,strpos($1,'','')+1,length($1))); ' language 'sql'; so... Plain: select to_tsvector('Einstein, Albert'); to_tsvector ------------------------- 'albert':2 'einstein':1 Weighted: select name_vector('Einstein, Albert'); name_vector -------------------------- 'albert':2 'einstein':1C Now, to somehow package that into a magical trigger function... All the examples for creating trigger functions that I've found use static column names, NEW and OLD ... I would like to create a generic trigger function, as the tsearch2 trigger function does, to return the specially weighted tsvector. Its like a lighter to a caveman. Can anyone lend a hand? CG __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools From pgsql-performance-owner@postgresql.org Tue Feb 24 16:19:08 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 35B4AD1D132 for ; Tue, 24 Feb 2004 20:19:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 68806-10 for ; Tue, 24 Feb 2004 16:19:07 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 8C9FDD1CAF6 for ; Tue, 24 Feb 2004 16:19:05 -0400 (AST) 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 i1OKJ51Y048492 for ; Tue, 24 Feb 2004 20:19:05 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i1OJohoG042815 for pgsql-performance@postgresql.org; Tue, 24 Feb 2004 19:50:43 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: [PERFORMANCE] slow small delete on large table Date: Tue, 24 Feb 2004 14:12:54 -0500 Organization: cbbrowne Computing Inc Lines: 33 Message-ID: References: <200402231910.57078.pgsql@bluepolka.net> <18315.1077600238@sss.pgh.pa.us> <200402241136.08556.pgsql@bluepolka.net> 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:bJlAOoKOOrV/Zx3mv4d+tebP36E= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/287 X-Sequence-Number: 5811 After a long battle with technology, pgsql@bluepolka.net ("Ed L."), an earthling, wrote: > On Monday February 23 2004 10:23, Tom Lane wrote: >> "Ed L." writes: >> Depending on the size of mytable, you might need an "ANALYZE doomed" >> in there, but I'm suspecting not. A quick experiment suggests that >> you'll get a plan with an inner indexscan on mytable.key, which is >> exactly what you need. > > I didn't mention I'd written a trigger to do delete N rows on each new > insert (with a delay governor preventing deletion avalanches). The > approach looks a little heavy to be done from within a trigger with the > response time I need, but I'll try it. Cantchajust toss in that "limit N" > functionality to delete clauses? How hard could that be? ;) It's nonstandard, which will get you a certain amount of opposition "for free;" the problem with nonstandard behaviour is that sometimes the implications haven't been thought out... >> See also Chris Browne's excellent suggestions nearby, if you are willing >> to make larger readjustments in your thinking... > > I did a search for articles by Chris Browne, didn't see one that > appeared relevant. What is the thread subject to which you refer? It's in the same thread. I suggested having a daemon running a cursor (amounting to a slightly more expensive version of Tom's "doomed temp table" approach), or using "rotor" tables where you could TRUNCATE a table every few days which would be _really_ cheap... -- output = ("cbbrowne" "@" "cbbrowne.com") http://cbbrowne.com/info/emacs.html Expect the unexpected. -- The Hitchhiker's Guide to the Galaxy, page 7023 From pgsql-performance-owner@postgresql.org Tue Feb 24 16:14:31 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E8991D1BAD6 for ; Tue, 24 Feb 2004 20:14:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 72989-09 for ; Tue, 24 Feb 2004 16:14:21 -0400 (AST) Received: from filer (c-24-6-183-218.client.comcast.net [24.6.183.218]) by svr1.postgresql.org (Postfix) with ESMTP id 9380DD1BAD2 for ; Tue, 24 Feb 2004 16:14:19 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Tue, 24 Feb 2004 12:14:20 -0800 Date: Tue, 24 Feb 2004 12:14:20 -0800 From: Kevin Brown To: Postgres Performance Subject: Re: Column correlation drifts, index ignored again Message-ID: <20040224201419.GD3090@filer> Mail-Followup-To: Kevin Brown , Postgres Performance References: <200402221617.27658.josh@agliodbs.com> <20040224035601.GC3090@filer> <200402240859.32312.josh@agliodbs.com> <23533.1077647386@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <23533.1077647386@sss.pgh.pa.us> Organization: Frobozzco International User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/286 X-Sequence-Number: 5810 Tom Lane wrote: > Josh Berkus writes: > > Kevin, > >> 1. set enable_seqscan = on > >> 2. set random_page_cost = > >> 3. EXPLAIN ANALYZE query > >> 4. record the ratio of estimated to actual scan times. > >> 5. set enable_seqscan = off > >> 6. set random_page_cost = > >> 7. EXPLAIN ANALYZE query > >> 8. record the actual index scan time(s) > >> 9. tweak random_page_cost > >> 10. EXPLAIN query > >> 11. If ratio of estimate to actual (recorded in step 8) is much > >> different than that recorded in step 4, then go back to step 9. > >> Reduce random_page_cost if the random ratio is larger than the > >> sequential ratio, increase if it's smaller. > > > Nice, we ought to post that somewhere people can find it in the future. > > If we post it as recommended procedure we had better put big caveat > notices on it. The pitfalls with doing this are: > > 1. If you repeat the sequence exactly as given, you will be homing in on > a RANDOM_PAGE_COST that describes your system's behavior with a fully > cached query. It is to be expected that you will end up with 1.0 or > something very close to it. The only way to avoid that is to use a > query that is large enough to blow out your kernel's RAM cache; which of > course will take long enough that iterating step 10 will be no fun, > and people will be mighty tempted to take shortcuts. Oops. You're right. I did this on my system, but forgot to put it in the list of things to do: 0. Fill the page cache with something other than PG data, e.g. by repeatedly catting several large files and redirecting the output to /dev/null. The sum total size of the files should exceed the amount of memory on the system. The reason you might not have to do this between EXPLAIN ANALYZE queries is that the first query will scan the table itself while the second one will scan the index. But that was probably more specific to the query I was doing. If the one you're doing is complex enough the system may have to read data pages from the table itself after fetching the index page, in which case you'll want to fill the page cache between the queries. > 2. Of course, you are computing a RANDOM_PAGE_COST that is relevant to > just this single query. Prudence would suggest repeating the process > with several different queries and taking some sort of average. Right. And the average should probably be weighted based on the relative frequency that the query in question will be executed. In my case, the query I was experimenting with was by far the biggest query that occurs on my system (though it turns out that there are others in that same process that I should look at as well). > When I did the experiments that led up to choosing 4.0 as the default, > some years ago, it took several days of thrashing the disks on a couple > of different machines before I had numbers that I didn't think were > mostly noise :-(. I am *real* suspicious of any replacement numbers > that have been derived in just a few minutes. One problem I've been running into is the merge join spilling to disk because sort_mem isn't big enough. The problem isn't that this is happening, it's that I think the planner is underestimating the impact that doing this will have on the time the merge join takes. Does the planner even account for the possibility that a sort or join will spill to disk? Spilling to disk like that will suddenly cause sequential reads to perform much more like random reads, unless the sequential scans are performed in their entirety between sorts/merges. In any case, one thing that none of this really accounts for is that it's better to set random_page_cost too low than too high. The reason is that index scans are more selective than sequential scans: a sequential scan will read the entire table every time, whereas an index scan will read only the index pages (and their parents) that match the query. My experience is that when the planner improperly computes the selectivity of the query (e.g., by not having good enough or sufficiently up to date statistics), it generally computes a lower selectivity than the query actually represents, and thus selects a sequential scan when an index scan would be more efficient. The auto vacuum daemon helps in this regard, by keeping the statistics more up-to-date. Certainly you shouldn't go overboard by setting random_page_cost too low "just in case", but it does mean that if you go through the process of running tests to determine the proper value for random_page_cost, you should probably select a random_page_cost that's in the lower part of the range of values you got. -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Tue Feb 24 16:54:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 29CCBD1BAA6 for ; Tue, 24 Feb 2004 20:54:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 88242-06 for ; Tue, 24 Feb 2004 16:54:19 -0400 (AST) Received: from mail.codenet.net (mail.codenet.net [209.248.81.8]) by svr1.postgresql.org (Postfix) with ESMTP id B2C24D1BAA3 for ; Tue, 24 Feb 2004 16:54:16 -0400 (AST) Received: from elvis [68.232.114.7] by mail.codenet.net with ESMTP (SMTPD32-7.07) id A9F88A029A; Tue, 24 Feb 2004 13:54:16 -0700 Content-Type: text/plain; charset="iso-8859-1" From: "Ed L." To: Kevin Brown , Postgres Performance Subject: Re: Column correlation drifts, index ignored again Date: Tue, 24 Feb 2004 13:54:15 -0700 User-Agent: KMail/1.4.3 References: <23533.1077647386@sss.pgh.pa.us> <20040224201419.GD3090@filer> In-Reply-To: <20040224201419.GD3090@filer> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200402241354.15025.pgsql@bluepolka.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/288 X-Sequence-Number: 5812 On Tuesday February 24 2004 1:14, Kevin Brown wrote: > > One problem I've been running into is the merge join spilling to disk > because sort_mem isn't big enough. The problem isn't that this is > happening, it's that I think the planner is underestimating the impact > that doing this will have on the time the merge join takes. Does the > planner even account for the possibility that a sort or join will spill > to disk? Spilling to disk like that will suddenly cause sequential > reads to perform much more like random reads, unless the sequential > scans are performed in their entirety between sorts/merges. How do you know the merge join is spilling to disk? How are you identifyin= g=20 that? Just assuming from vmstat? iostat? From pgsql-performance-owner@postgresql.org Tue Feb 24 17:24:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 087DFD1B901 for ; Tue, 24 Feb 2004 21:24:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 96648-05 for ; Tue, 24 Feb 2004 17:24:21 -0400 (AST) Received: from filer (c-24-6-183-218.client.comcast.net [24.6.183.218]) by svr1.postgresql.org (Postfix) with ESMTP id 22AFED1B860 for ; Tue, 24 Feb 2004 17:24:18 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Tue, 24 Feb 2004 13:24:19 -0800 Date: Tue, 24 Feb 2004 13:24:19 -0800 From: Kevin Brown To: Postgres Performance Subject: Re: Column correlation drifts, index ignored again Message-ID: <20040224212419.GF3090@filer> Mail-Followup-To: Kevin Brown , Postgres Performance References: <23533.1077647386@sss.pgh.pa.us> <20040224201419.GD3090@filer> <200402241354.15025.pgsql@bluepolka.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <200402241354.15025.pgsql@bluepolka.net> Organization: Frobozzco International User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/289 X-Sequence-Number: 5813 Ed L. wrote: > How do you know the merge join is spilling to disk? How are you identifying > that? Just assuming from vmstat? iostat? The existence of files in $PG_DATA/base//pgsql_tmp while the query is running, combined with the EXPLAIN output (which shows what sorts and joins are being performed). -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Tue Feb 24 17:49:58 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 344F1D1B860; Tue, 24 Feb 2004 21:49:56 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 12267-05; Tue, 24 Feb 2004 17:49:55 -0400 (AST) Received: from bramble.mmrd.com (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 02038D1B4B7; Tue, 24 Feb 2004 17:49:52 -0400 (AST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id i1OLIPcM030530; Tue, 24 Feb 2004 16:18:25 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id i1OLmol11668; Tue, 24 Feb 2004 16:48:50 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id XT88H14Y; Tue, 24 Feb 2004 16:48:47 -0500 Subject: Re: [HACKERS] [SQL] Materialized View Summary From: Robert Treat To: Richard Huxton Cc: "Jonathan M. Gardner" , pgsql-hackers@postgresql.org, pgsql-sql@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <200402241711.20947.dev@archonet.com> References: <200402240811.13013.jgardner@jonathangardner.net> <200402241711.20947.dev@archonet.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 24 Feb 2004 16:48:49 -0500 Message-Id: <1077659329.15366.6061.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/290 X-Sequence-Number: 5814 On Tue, 2004-02-24 at 12:11, Richard Huxton wrote: > On Tuesday 24 February 2004 16:11, Jonathan M. Gardner wrote: > > > > I've written a summary of my findings on implementing and using > > materialized views in PostgreSQL. I've already deployed eagerly updating > > materialized views on several views in a production environment for a > > company called RedWeek: http://redweek.com/. As a result, some queries > > that were taking longer than 30 seconds to run now run in a fraction of a > > millisecond. > > > > You can view my summary at > > http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html have you done much concurrency testing on your snapshot views? I implemented a similar scheme in one of my databases but found problems when I had concurrent "refresh attempts". I ended up serializing the calls view LOCKing, which was ok for my needs, but I thought potentially problematic in other cases. > > Interesting (and well written) summary. Even if not a "built in" feature, I'm > sure that plenty of people will find this useful. Make sure it gets linked to > from techdocs. Done. :-) > > If you could identify candidate keys on a view, you could conceivably automate > the process even more. That's got to be possible in some cases, but I'm not > sure how difficult it is to do in all cases. > it seems somewhere between Joe Conways work work arrays and polymorphic functions in 7.4 this should be feasible. Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL From pgsql-performance-owner@postgresql.org Tue Feb 24 18:16:10 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 75F3CD1BAF5 for ; Tue, 24 Feb 2004 22:16:09 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 13734-10 for ; Tue, 24 Feb 2004 18:16:09 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id F3351D1B982 for ; Tue, 24 Feb 2004 18:16:06 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1OMG90V027172; Tue, 24 Feb 2004 17:16:09 -0500 (EST) To: Kevin Brown Cc: Postgres Performance Subject: Re: Column correlation drifts, index ignored again In-reply-to: <20040224201419.GD3090@filer> References: <200402221617.27658.josh@agliodbs.com> <20040224035601.GC3090@filer> <200402240859.32312.josh@agliodbs.com> <23533.1077647386@sss.pgh.pa.us> <20040224201419.GD3090@filer> Comments: In-reply-to Kevin Brown message dated "Tue, 24 Feb 2004 12:14:20 -0800" Date: Tue, 24 Feb 2004 17:16:08 -0500 Message-ID: <27171.1077660968@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/291 X-Sequence-Number: 5815 Kevin Brown writes: > One problem I've been running into is the merge join spilling to disk > because sort_mem isn't big enough. The problem isn't that this is > happening, it's that I think the planner is underestimating the impact > that doing this will have on the time the merge join takes. Does the > planner even account for the possibility that a sort or join will spill > to disk? Yes it does. I thought it was making a pretty good estimate, actually. The only obvious hole in the assumptions is * The disk traffic is assumed to be half sequential and half random * accesses (XXX can't we refine that guess?) Because of the way that tuplesort.c works, the first merge pass should be pretty well sequential, but I think the passes after that might be mostly random from the kernel's viewpoint :-(. Possibly the I/O cost should be adjusted depending on how many merge passes we expect. > In any case, one thing that none of this really accounts for is that > it's better to set random_page_cost too low than too high. That depends on what you are doing, although I will concede that a lot of people are doing things where indexscans should be favored. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Feb 28 18:40:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B94E4D1D332; Tue, 24 Feb 2004 22:23:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 20742-04; Tue, 24 Feb 2004 18:22:59 -0400 (AST) Received: from aprilia.amazon.com (aprilia.amazon.com [207.171.190.156]) by svr1.postgresql.org (Postfix) with ESMTP id 6FBA7D1D202; Tue, 24 Feb 2004 18:22:56 -0400 (AST) Received: from ginger.amazon.com by aprilia.amazon.com with ESMTP (crosscheck: ginger.amazon.com [10.16.10.247]) id i1OMMt8q031860; Tue, 24 Feb 2004 14:22:55 -0800 X-AMAZON-TRACK: pgsql-hackers@postgresql.org Received: from ex-gate-04.ant.amazon.com by ginger.amazon.com with ESMTP (crosscheck: ex-gate-04.ant.amazon.com [10.16.189.31]) id i1OMMtOh006319; Tue, 24 Feb 2004 14:22:55 -0800 Received: from jonagard.desktop.amazon.com ([10.21.12.165]) by ex-gate-04.ant.amazon.com over TLS secured channel with Microsoft SMTPSVC(5.0.2195.6713); Tue, 24 Feb 2004 14:22:54 -0800 From: Jonathan Gardner Organization: Amazon To: Robert Treat Subject: Re: [HACKERS] [SQL] Materialized View Summary Date: Tue, 24 Feb 2004 14:19:39 -0800 User-Agent: KMail/1.6 Cc: Richard Huxton , pgsql-hackers@postgresql.org, pgsql-sql@postgresql.org, pgsql-performance@postgresql.org References: <200402240811.13013.jgardner@jonathangardner.net> <200402241711.20947.dev@archonet.com> <1077659329.15366.6061.camel@camel> In-Reply-To: <1077659329.15366.6061.camel@camel> MIME-Version: 1.0 Content-Disposition: inline Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <200402241419.41973.jonagard@amazon.com> X-OriginalArrivalTime: 24 Feb 2004 22:22:54.0905 (UTC) FILETIME=[BFA34A90:01C3FB24] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/325 X-Sequence-Number: 5849 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 24 February 2004 01:48 pm, Robert Treat wrote: > On Tue, 2004-02-24 at 12:11, Richard Huxton wrote: > > On Tuesday 24 February 2004 16:11, Jonathan M. Gardner wrote: > > > I've written a summary of my findings on implementing and using > > > materialized views in PostgreSQL. I've already deployed eagerly > > > updating materialized views on several views in a production > > > environment for a company called RedWeek: http://redweek.com/. As a > > > result, some queries that were taking longer than 30 seconds to run > > > now run in a fraction of a millisecond. > > > > > > You can view my summary at > > > http://jonathangardner.net/PostgreSQL/materialized_views/matviews.htm > > >l > > have you done much concurrency testing on your snapshot views? I > implemented a similar scheme in one of my databases but found problems > when I had concurrent "refresh attempts". I ended up serializing the > calls view LOCKing, which was ok for my needs, but I thought potentially > problematic in other cases. > I don't actually use snapshot views in production. I would imagine that if= =20 you had two seperate processes trying to update the views simultaneously,= =20 that would be a problem. All I can say is "don't do that". I think you'd=20 want to lock the table before we go and start messing with it on that=20 scale. We are running into some deadlock issues and some other problems with eager= =20 mvs, but they are very rare and hard to reproduce. I think we are going to= =20 start locking the row before updating it and see if that solves it. We also= =20 just discovered the "debug_deadlock" feature. I'll post my findings and summaries of the information I am getting here=20 soon. I'm interested in whatever you've been working on WRT materialized views.= =20 What cases do you think will be problematic? Do you have ideas on how to=20 work around them? Are there issues that I'm not addressing but should be? > > Interesting (and well written) summary. Even if not a "built in" > > feature, I'm sure that plenty of people will find this useful. Make > > sure it gets linked to from techdocs. > > Done. :-) > *blush* > > If you could identify candidate keys on a view, you could conceivably > > automate the process even more. That's got to be possible in some > > cases, but I'm not sure how difficult it is to do in all cases. > > it seems somewhere between Joe Conways work work arrays and polymorphic > functions in 7.4 this should be feasible. > I'll have to look at what he is doing in more detail. - --=20 Jonathan M. Gardner Web Developer, Amazon.com jonagard@amazon.com - (206) 266-2906 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFAO837BFeYcclU5Q0RAhonAKDBY7Svz9/vxmerS+y/h2mLgV1ZZQCdFlnd 7aMPFvRx4O8qg+sJfWkaBh8=3D =3DzdhL -----END PGP SIGNATURE----- From pgsql-performance-owner@postgresql.org Wed Feb 25 01:11:03 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3D28FD1B860 for ; Wed, 25 Feb 2004 05:11:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 31759-01 for ; Wed, 25 Feb 2004 01:10:58 -0400 (AST) Received: from srvr3.iniquinet.com (srvr2.iniquinet.com [64.240.87.12]) by svr1.postgresql.org (Postfix) with SMTP id D52BDD1B4AA for ; Wed, 25 Feb 2004 01:10:56 -0400 (AST) Received: (qmail 27279 invoked by uid 104); 25 Feb 2004 04:54:56 -0000 Received: from Robert_Creager@LogicalChaos.org by srvr3.iniquinet.com by uid 101 with qmail-scanner-1.15 (clamscan: 0.65. spamassassin: 2.55. Clear:SA:0(-5.3/6.0):. Processed in 32.277182 secs); 25 Feb 2004 04:54:56 -0000 Received: from unknown (HELO thunder.mshome.net) (216.58.165.145) by srvr3.iniquinet.com with SMTP; 25 Feb 2004 04:54:23 -0000 Received: from localhost.localdomain (thunder.mshome.net [192.168.0.250]) by thunder.mshome.net (Postfix) with ESMTP id 414CFE413 for ; Tue, 24 Feb 2004 22:10:22 -0700 (MST) Received: from logicalchaos.org (thunder.mshome.net [192.168.0.250]) by thunder.mshome.net (Postfix) with SMTP id C509387DC2 for ; Tue, 24 Feb 2004 22:10:16 -0700 (MST) Date: Tue, 24 Feb 2004 22:10:16 -0700 From: Robert Creager To: PGPerformance Subject: Speed up a function?CREATE TABLE readings ( "when" TIMESTAMP DEFAULT timeofday()::timestamp NOT NULL PRIMARY KEY, "barometer" FLOAT DEFAULT NULL, Message-Id: <20040224221016.2c35e448.Robert_Creager@LogicalChaos.org> Organization: Starlight Vision, LLC. X-Mailer: Sylpheed version 0.9.5claws (GTK+ 1.2.10; i586-mandrake-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Multipart_Tue__24_Feb_2004_22_10_16_-0700_TQy=.0qAZbm6_2k'" SUBJ_HAS_SPACES,USER_IN_WHITELIST autolearn=no version=2.63 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/292 X-Sequence-Number: 5816 --Multipart_Tue__24_Feb_2004_22_10_16_-0700_TQy=.0qAZbm6_2k' Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit Hey All, I've implemented a couple of functions ala date_trunc (listed at the bottom). These functions are executed every 5 minutes (date_trunc_minute) and every week (date_trunc_week) across 16 different values. The problem is that they take way too long to execute (nearly 7x the 'regular' date_trunc function). What might be the best way to fix the problem? Use a different function language? Re-write the functions? Re-write the queries? The gist of what I'm doing is filling schema tables with weather summary information for the time period in question. Currently I don't have indexes on these tables. Would indexs on readings."when" and minute.barometer."time" be used with date_trunc? Functional indexes maybe? CREATE TABLE readings ( "when" TIMESTAMP DEFAULT timeofday()::timestamp NOT NULL PRIMARY KEY, "barometer" FLOAT DEFAULT NULL, ); CREATE SCHEMA minute; CREATE TABLE minute.barometer ( "time" TIMESTAMP NOT NULL, min_reading FLOAT NOT NULL, max_reading FLOAT NOT NULL, avg_reading FLOAT NOT NULL ); The "hour" schema is identical to the "minute" schema. weather=# EXPLAIN ANALYZE weather-# SELECT p.period, p.min, p.max, p.avg weather-# FROM (SELECT date_trunc_minute( 'minute'::text, "when" ) AS period, weather(# min( barometer ), max( barometer ), avg( barometer ) weather(# FROM readings weather(# WHERE barometer NOTNULL weather(# GROUP BY period) AS p weather-# WHERE p.period weather-# NOT IN (SELECT "time" FROM minute.barometer ) weather-# AND p.period != date_trunc_minute( 'minute'::text, now()::timestamp ); QUERY PLAN ------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------- Subquery Scan p (cost=1665.63..2282.47 rows=13708 width=32) (actual time=3318.758..3318.758 rows=0 loops=1) Filter: (NOT (hashed subplan)) -> HashAggregate (cost=1501.61..1775.76 rows=27415 width=16) (actual time=3227.409..3263.367 rows=13918 loops=1) -> Seq Scan on readings (cost=0.00..1227.46 rows=27415 width=16) (actual time=1.075..3028.673 rows =69398 loops=1) Filter: ((barometer IS NOT NULL) AND (date_trunc_minute('minute'::text, "when") <> date_trunc_ minute('minute'::text, (now())::timestamp without time zone))) SubPlan -> Seq Scan on barometer (cost=0.00..144.02 rows=8002 width=8) (actual time=0.008..15.406 rows=13918 l oops=1) Total runtime: 3320.146 ms (8 rows) weather=# EXPLAIN ANALYZE weather-# SELECT p.period, p.min, p.max, p.avg weather-# FROM (SELECT date_trunc( 'hour'::text, "when" ) AS period, weather(# min( barometer ), max( barometer ), avg( barometer ) weather(# FROM readings weather(# WHERE barometer NOTNULL weather(# GROUP BY period) AS p weather-# WHERE p.period weather-# NOT IN (SELECT "time" FROM hour.barometer ) weather-# AND p.period != date_trunc( 'hour'::text, now()::timestamp ); QUERY PLAN ------------------------------------------------------------------------------------------------------------- --------------------------------------------- Subquery Scan p (cost=1524.11..2140.95 rows=13708 width=32) (actual time=551.516..551.516 rows=0 loops=1) Filter: (NOT (hashed subplan)) -> HashAggregate (cost=1501.61..1775.76 rows=27415 width=16) (actual time=544.859..547.605 rows=1173 loo ps=1) -> Seq Scan on readings (cost=0.00..1227.46 rows=27415 width=16) (actual time=0.596..399.344 rows= 69353 loops=1) Filter: ((barometer IS NOT NULL) AND (date_trunc('hour'::text, "when") <> date_trunc('hour'::t ext, (now())::timestamp without time zone))) SubPlan -> Seq Scan on barometer (cost=0.00..20.00 rows=1000 width=8) (actual time=0.007..1.268 rows=1173 loop s=1) Total runtime: 552.137 ms CREATE FUNCTION date_trunc_week( text, timestamp ) RETURNS timestamp AS ' DECLARE reading_time ALIAS FOR $2; year timestamp; dow integer; adjust text; week text; BEGIN year := date_trunc( ''year''::text, reading_time ); week := date_part( ''week'', reading_time ) - 1 || '' week''; dow := date_part( ''dow'', year ); -- If the dow is less than Thursday, then the start week is last year IF dow <= 4 THEN adjust := 1 - dow || '' day''; ELSE adjust := 8 - dow || '' day''; END IF; RETURN year + adjust::interval + week::interval; END; ' LANGUAGE plpgsql IMMUTABLE STRICT; CREATE OR REPLACE FUNCTION date_trunc_minute( text, timestamp ) RETURNS timestamp AS ' DECLARE reading_time ALIAS FOR $2; hour timestamp; adjust text; BEGIN hour := date_trunc( ''hour''::text, reading_time ); adjust := 5*trunc(date_part( ''minute'', reading_time ) / 5) || '' minute''; RETURN hour + adjust::interval; END; ' LANGUAGE plpgsql IMMUTABLE STRICT; Thanks, Rob -- 21:52:26 up 10 days, 5:33, 3 users, load average: 2.36, 2.40, 2.17 Linux 2.4.21-0.13_test #60 SMP Sun Dec 7 17:00:02 MST 2003 --Multipart_Tue__24_Feb_2004_22_10_16_-0700_TQy=.0qAZbm6_2k' Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iEYEARECAAYFAkA8LjgACgkQLQ/DKuwDYzkuXgCfdKJ2+ye2dlu/G98k8SRWkbrp 1ogAmwZhzeL+fveZ1c+0UZzjYDYZy7xJ =v9Vf -----END PGP SIGNATURE----- --Multipart_Tue__24_Feb_2004_22_10_16_-0700_TQy=.0qAZbm6_2k'-- From pgsql-performance-owner@postgresql.org Wed Feb 25 02:05:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DC43ED1D841 for ; Wed, 25 Feb 2004 06:05:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 39529-05 for ; Wed, 25 Feb 2004 02:05:24 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id D621ED1D432 for ; Wed, 25 Feb 2004 02:05:22 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1P64mC2000939; Wed, 25 Feb 2004 01:04:49 -0500 (EST) To: Robert Creager Cc: PGPerformance Subject: Re: Speed up a function?CREATE TABLE readings ( "when" TIMESTAMP DEFAULT timeofday()::timestamp NOT NULL PRIMARY KEY, "barometer" FLOAT DEFAULT NULL, In-reply-to: <20040224221016.2c35e448.Robert_Creager@LogicalChaos.org> References: <20040224221016.2c35e448.Robert_Creager@LogicalChaos.org> Comments: In-reply-to Robert Creager message dated "Tue, 24 Feb 2004 22:10:16 -0700" Date: Wed, 25 Feb 2004 01:04:48 -0500 Message-ID: <938.1077689088@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/293 X-Sequence-Number: 5817 Robert Creager writes: > I've implemented a couple of functions ala date_trunc (listed at the bottom) > [ and they're too slow ] Well, it's hardly surprising that a function that invokes date_trunc and half a dozen other comparably-expensive operations should be half a dozen times as expensive as date_trunc. Not to mention that plpgsql is inherently far slower than C. Assuming that you don't want to descend to writing C, I'd suggest doing arithmetic on the Unix-epoch version of the timestamp. Perhaps something along the lines of select 'epoch'::timestamptz + trunc(extract(epoch from now())/(3600*24*7))*(3600*24*7) * '1sec'::interval; This doesn't have the same roundoff behavior as what you posted, but I think it could be adjusted to do so with a couple more additions and subtractions, unless there's some magic I'm not seeing about the year boundary behavior. Certainly the five-minute-trunc problem could be done this way. If you do feel like descending to C, I don't see any fundamental reason why we accept date_part('week',...) but not date_trunc('week',...). Feel free to submit a patch. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Feb 25 02:35:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7E98AD1B4DE for ; Wed, 25 Feb 2004 06:35:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 47097-01 for ; Wed, 25 Feb 2004 02:35:26 -0400 (AST) Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com [64.71.176.18]) by svr1.postgresql.org (Postfix) with ESMTP id 15EE0D1B4AA for ; Wed, 25 Feb 2004 02:35:25 -0400 (AST) Received: by gp.word-to-the-wise.com (Postfix, from userid 500) id 4AAB790000D; Tue, 24 Feb 2004 22:28:37 -0800 (PST) Date: Tue, 24 Feb 2004 22:28:37 -0800 From: Steve Atkins To: pgsql-performance Subject: Re: Slow join using network address function Message-ID: <20040225062837.GA20835@gp.word-to-the-wise.com> References: <000701c3fa02$e4e3d180$c300000a@caliente> <20040223160734.GA11052@gp.word-to-the-wise.com> <001d01c3face$bca62d40$c300000a@caliente> <20040224171442.GE5368@gp.word-to-the-wise.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040224171442.GE5368@gp.word-to-the-wise.com> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/294 X-Sequence-Number: 5818 On Tue, Feb 24, 2004 at 09:14:42AM -0800, Steve Atkins wrote: > On Tue, Feb 24, 2004 at 01:07:10PM +0100, Eric Jain wrote: > > > is a datatype that contains > > > a range of IPv4 addresses, and which has the various operators to > > > make it GIST indexable. > > > > Great, this looks very promising. > > > > > No cast operators between ipr and inet types. > > > > Any way to work around this, short of dumping and reloading tables? > > There's probably some horrible SQL hack that would let you do it, but > I should add some casting code anyway. Shouldn't be too painful to do - > I'll try and get that, and some minimal documentation out today. Done. This really isn't pgsql-performance content, so this is the last time I'll mention it here. Cheers, Steve From pgsql-performance-owner@postgresql.org Wed Feb 25 04:20:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id CAD86D1BAA3; Wed, 25 Feb 2004 08:20:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 64822-07; Wed, 25 Feb 2004 04:20:22 -0400 (AST) Received: from dervish.jonathangardner.net (dervish.jonathangardner.net [66.92.192.241]) by svr1.postgresql.org (Postfix) with ESMTP id 2F1D0D1E138; Wed, 25 Feb 2004 04:20:20 -0400 (AST) Received: from atlas.jonathangardner.net (atlas.jonathangardner.net [66.92.192.166]) (authenticated bits=0) by dervish.jonathangardner.net (8.12.10/8.12.10) with ESMTP id i1P8JbTW014359 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Wed, 25 Feb 2004 00:19:37 -0800 From: "Jonathan M. Gardner" To: Robert Treat Subject: Re: [HACKERS] [SQL] Materialized View Summary Date: Wed, 25 Feb 2004 00:19:29 -0800 User-Agent: KMail/1.6 Cc: Richard Huxton , pgsql-hackers@postgresql.org, pgsql-sql@postgresql.org, pgsql-performance@postgresql.org References: <200402240811.13013.jgardner@jonathangardner.net> <200402241711.20947.dev@archonet.com> <1077659329.15366.6061.camel@camel> In-Reply-To: <1077659329.15366.6061.camel@camel> MIME-Version: 1.0 Content-Disposition: inline Content-Type: Text/Plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable Message-Id: <200402250019.32385.jgardner@jonathangardner.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/295 X-Sequence-Number: 5819 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm not sure if my original reply made it through. Ignore the last one if= =20 it did. On Tuesday 24 February 2004 1:48 pm, Robert Treat wrote: > On Tue, 2004-02-24 at 12:11, Richard Huxton wrote: > > On Tuesday 24 February 2004 16:11, Jonathan M. Gardner wrote: > > > I've written a summary of my findings on implementing and using > > > materialized views in PostgreSQL. I've already deployed eagerly > > > updating materialized views on several views in a production > > > environment for a company called RedWeek: http://redweek.com/. As a > > > result, some queries that were taking longer than 30 seconds to run > > > now run in a fraction of a millisecond. > > > > > > You can view my summary at > > > http://jonathangardner.net/PostgreSQL/materialized_views/matviews.h > > >tml > > have you done much concurrency testing on your snapshot views? I > implemented a similar scheme in one of my databases but found problems > when I had concurrent "refresh attempts". I ended up serializing the > calls view LOCKing, which was ok for my needs, but I thought > potentially problematic in other cases. > We are running into some small problems with deadlocks and multiple=20 inserts. It's not a problem unless we do a mass update to the data or=20 something like that. I'm interested in how you solved your problem. I am playing with an exclusive lock scheme that will lock all the=20 materialized views with an exclusive lock (see Section 12.3 for a=20 reminder on what exactly this means). The locks have to occur in order,=20 so I use a recursive function to traverse a dependency tree to the root=20 and then lock from there. Right now, we only have one materialized view=20 tree, but I can see some schemas having multiple seperate trees with=20 multiple roots. So I put in an ordering to lock the tables in a=20 pre-defined order. But if the two dependency trees are totally seperate, it is possible for=20 one transaction to lock tree A and then tree B, and for another to lock=20 tree B and then tree A, causing deadlock. Unfortunately, I can't force any update to the underlying tables to force= =20 this locking function to be called. So we will probably call this=20 manually before we touch any of those tables. In the future, it would be nice to have a hook into the locking mechanism= =20 so any kind of lock on the underlying tables can trigger this. Also, building the dependency trees is completely manual. Until I can get= =20 some functions to actually assemble the triggers and such, automatic=20 building of the trees will be difficult. - --=20 Jonathan Gardner jgardner@jonathangardner.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFAPFqRqp6r/MVGlwwRAnvPAJ90lEEyaBzAfUoLZU93ZDvkojaAwwCdGjaA YBlO57OiZidZuQ5/S0u6wXM=3D =3DbMYE -----END PGP SIGNATURE----- From pgsql-performance-owner@postgresql.org Sat Feb 28 18:57:34 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3CB12D1DEDC; Wed, 25 Feb 2004 11:34:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 20040-08; Wed, 25 Feb 2004 07:34:46 -0400 (AST) Received: from crommail.cromwell-tools.co.uk (host217-40-164-180.in-addr.btopenworld.com [217.40.164.180]) by svr1.postgresql.org (Postfix) with ESMTP id DD953D1BAA3; Wed, 25 Feb 2004 07:34:40 -0400 (AST) Message-ID: <403C8893.2060301@cromwell.co.uk> Date: Wed, 25 Feb 2004 11:35:47 +0000 From: Mark Gibson MIME-Version: 1.0 To: "Jonathan M. Gardner" Cc: pgsql-hackers@postgresql.org, pgsql-sql@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [HACKERS] Materialized View Summary References: <200402240811.13013.jgardner@jonathangardner.net> In-Reply-To: <200402240811.13013.jgardner@jonathangardner.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/330 X-Sequence-Number: 5854 Jonathan M. Gardner wrote: > You can view my summary at > http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html > > Comments and suggestions are definitely welcome. > Fantastic, I was planning on a bit of materialized view investigations myself when time permits, I'm pleased to see you've started the ball rolling. I was thinking about your problem with mutable functions used in a materialized view. How about eliminating the mutable functions as much as possible from the underlying view definition, and create another view on top of the materialized view that has the mutable bits! Giving you the best of both worlds. I haven't tried this or thought it through very much - too busy - but I'd thought I'd throw it in for a bit o' head scratching, and chin stroking :) Cheers -- Mark Gibson Web Developer & Database Admin Cromwell Tools Ltd. Leicester, England. From pgsql-performance-owner@postgresql.org Wed Feb 25 11:47:03 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A94F6D1E16C; Wed, 25 Feb 2004 15:47:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 18710-03; Wed, 25 Feb 2004 11:46:56 -0400 (AST) Received: from bramble.mmrd.com (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 66B12D1DF93; Wed, 25 Feb 2004 11:46:51 -0400 (AST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id i1PFG4cM003939; Wed, 25 Feb 2004 10:16:05 -0500 Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id i1PFkGl24071; Wed, 25 Feb 2004 10:46:16 -0500 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id XT88HHST; Wed, 25 Feb 2004 10:46:14 -0500 Subject: Re: [HACKERS] [SQL] Materialized View Summary From: Robert Treat To: "Jonathan M. Gardner" Cc: Richard Huxton , pgsql-hackers@postgresql.org, pgsql-sql@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <200402250019.32385.jgardner@jonathangardner.net> References: <200402240811.13013.jgardner@jonathangardner.net> <200402241711.20947.dev@archonet.com> <1077659329.15366.6061.camel@camel> <200402250019.32385.jgardner@jonathangardner.net> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 25 Feb 2004 10:46:16 -0500 Message-Id: <1077723976.15368.6115.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/296 X-Sequence-Number: 5820 On Wed, 2004-02-25 at 03:19, Jonathan M. Gardner wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I'm not sure if my original reply made it through. Ignore the last one if > it did. But I liked the last one :-) > > On Tuesday 24 February 2004 1:48 pm, Robert Treat wrote: > > On Tue, 2004-02-24 at 12:11, Richard Huxton wrote: > > > On Tuesday 24 February 2004 16:11, Jonathan M. Gardner wrote: > > > > I've written a summary of my findings on implementing and using > > > > materialized views in PostgreSQL. I've already deployed eagerly > > > > updating materialized views on several views in a production > > > > environment for a company called RedWeek: http://redweek.com/. As a > > > > result, some queries that were taking longer than 30 seconds to run > > > > now run in a fraction of a millisecond. > > > > > > > > You can view my summary at > > > > http://jonathangardner.net/PostgreSQL/materialized_views/matviews.h > > > >tml > > > > have you done much concurrency testing on your snapshot views? I > > implemented a similar scheme in one of my databases but found problems > > when I had concurrent "refresh attempts". I ended up serializing the > > calls view LOCKing, which was ok for my needs, but I thought > > potentially problematic in other cases. > > > > We are running into some small problems with deadlocks and multiple > inserts. It's not a problem unless we do a mass update to the data or > something like that. I'm interested in how you solved your problem. > Well, I have two different cases actually. In one case I have a master table with what are essentially 4 or 5 matviews based off of that. I don't allow updates to the matviews, only to the master table, and only via stored procedures. This would work better if locking semantics inside of pl functions worked properly, but currently we have the application lock the table in exclusive access mode and then call the function to make the data changes which then fires off a function to update the matviews. Since it's all within a transaction, readers of the matviews are oblivious to the change. IMO this whole method is a wizardry in database hack jobs that I would love to replace. The second case, and this one being much simpler, started out as a view that does aggregation across several other views and tables, which is pretty resource intensive but only returns 4 rows. I refresh the matview via a cron job which basically does a SELECT * FOR UPDATE on the matview, deletes the entire contents, then does an INSERT INTO matview SELECT * FROM view. Again since it's in a transaction, readers of the matview are happy (and apps are only granted select on the matview). Concurrency is kept because the cron job must wait to get a LOCK on the table before it can proceed with the delete/update. I have a feeling that this method could fall over given a high enough number of concurrent updaters, but works pretty well for our needs. > I am playing with an exclusive lock scheme that will lock all the > materialized views with an exclusive lock (see Section 12.3 for a > reminder on what exactly this means). The locks have to occur in order, > so I use a recursive function to traverse a dependency tree to the root > and then lock from there. Right now, we only have one materialized view > tree, but I can see some schemas having multiple seperate trees with > multiple roots. So I put in an ordering to lock the tables in a > pre-defined order. > > But if the two dependency trees are totally seperate, it is possible for > one transaction to lock tree A and then tree B, and for another to lock > tree B and then tree A, causing deadlock. > > Unfortunately, I can't force any update to the underlying tables to force > this locking function to be called. So we will probably call this > manually before we touch any of those tables. Yeah, I ran into similar problems as this, but ISTM you could do a before update trigger on the matview to do the locking (though I'd guess this would end in trouble due to plpgsql lock semantics, so maybe i shouldn't send you down a troubled road...) > > In the future, it would be nice to have a hook into the locking mechanism > so any kind of lock on the underlying tables can trigger this. > > Also, building the dependency trees is completely manual. Until I can get > some functions to actually assemble the triggers and such, automatic > building of the trees will be difficult. > I just noticed that your summary doesn't make use of postgresql RULES in any way, how much have you traveled down that path? We had cooked up a scheme for our second case where we would have a table that held an entry for the matview and then a timestamp of the last update/insert into any of the base tables the matview depended on. when then would create rules on all the base tables to do an update to the refresh table any time they were updated/inserted/deleted. We would then put a corresponding rule on the matview so that on each select from the matview, it would check to see if any of it's base tables had changed and if so fire off a refresh of itself. We ended up abandoning this idea as the complexity seemed to high when the simple scheme above worked equally well for our needs. Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL From pgsql-performance-owner@postgresql.org Sat Feb 28 18:39:07 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8C946D1BA9F for ; Thu, 26 Feb 2004 12:49:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 14595-01 for ; Thu, 26 Feb 2004 08:49:28 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 2681ED1B51F for ; Thu, 26 Feb 2004 08:49:25 -0400 (AST) 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 i1QCnO1Y001045 for ; Thu, 26 Feb 2004 12:49:24 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i1QCkKUe000611 for pgsql-performance@postgresql.org; Thu, 26 Feb 2004 12:46:20 GMT From: teknokrat X-Newsgroups: comp.databases.postgresql.performance Subject: compiling 7.4.1 on Solaris 9 Date: Thu, 26 Feb 2004 12:46:23 +0000 Organization: Hub.Org Networking Services Lines: 6 Message-ID: Reply-To: teknokrat@yahoo.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 (X11; U; Linux i686; en-US; rv:1.0.0+) Gecko/20020518 X-Accept-Language: en, en-us, ko To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/324 X-Sequence-Number: 5848 can anyone tell me what the best way to compile postgresql 7.4.1 on Solaris 9 (UltraSparcIII) is? I have latest gmake and gcc installed. I was going to use CFLAGS="-O2 -fast -mcpu=ultrasparc" based on snippets I've read about the place. Would using -O3 be an improvement? thanks From pgsql-performance-owner@postgresql.org Thu Feb 26 09:25:28 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DAD4FD1B9A9 for ; Thu, 26 Feb 2004 13:25:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 16795-08 for ; Thu, 26 Feb 2004 09:25:27 -0400 (AST) Received: from zenon.apartia.com (zenon.apartia.fr [82.66.93.83]) by svr1.postgresql.org (Postfix) with ESMTP id 00018D1B901 for ; Thu, 26 Feb 2004 09:25:23 -0400 (AST) Received: from argos (argos.apartia.fr [10.0.2.105]) by zenon.apartia.com (Postfix) with ESMTP id 55C55133934 for ; Thu, 26 Feb 2004 14:25:26 +0100 (CET) Received: by argos (Postfix, from userid 1018) id 280E3115F7; Thu, 26 Feb 2004 14:30:38 +0100 (CET) Date: Thu, 26 Feb 2004 14:30:38 +0100 From: David Pradier To: pgsql-performance@postgresql.org Subject: A cache for the results of queries ? Message-ID: <20040226133038.GA1481@apartia.fr> Mail-Followup-To: pgsql-performance@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/297 X-Sequence-Number: 5821 Hi everybody, i'd like to know if it exists a system of cache for the results of queries. What i'd like to do : select whatever_things from (selection_in_cache) where special_conditions; The interesting thing would be to have a precalculated selection_in_cache, especially when selection_in_cache is a very long list of joins... For example, a real case: SELECT p.id_prospect, p.id_personne1, INITCAP(p1.nom) AS nom, INITCAP(p1.prenom) AS prenom, a1.no_tel, a1.no_portable, p.dernier_contact, cn.id_contact, cn.id_vendeur, cn.id_operation, CASE WHEN p.dernier_contact IS NOT NULL THEN cn.date_contact::ABSTIME::INT4 ELSE p.cree_le::ABSTIME::INT4 END AS date_contact, cn.id_moyen_de_contact, cn.id_type_evenement, cn.nouveau_rdv::ABSTIME::INT4 AS nouveau_rdv, cn.date_echeance::ABSTIME::INT4 AS date_echeance, cn.date_reponse::ABSTIME::INT4 AS date_reponse, (CASE WHEN lower(cn.type_reponse) = '.qs( 'abandon' ).' AND cn.id_vendeur = '.qs( $login ).' THEN '.qs( 'O').' ELSE p.abandon END) AS abandon FROM prospect p JOIN personne p1 ON (p.id_personne1 = p1.id_personne) JOIN adresse a1 ON (a1.id_adresse = p1.id_adresse_principale) LEFT JOIN contact cn ON (p.dernier_contact = cn.id_contact) '.( $type_orig ? 'LEFT JOIN orig_pub op ON ( p.id_orig_pub = op.id_orig_pub )' : '' ).' WHERE ( '.( $abandon ? '' : '( (cn.type_reponse IS NULL OR lower(cn.type_reponse) != ' .qs( 'abandon' ) .' OR cn.id_vendeur != ' .qs( $login ) .') AND (p.abandon != ' .qs( 'O' ) .' OR p.abandon IS NULL)) AND ' ).' TRUE '.$condition.') ORDER BY '.$primary_sort.', '.secondary_sort.' LIMIT 30 OFFSET '.$offset*$page_length There is some perl inside to generate the query ; for non-perl-people, '.' is used for concatenation and '( a ? b : c)' means 'if a then b else c'. $condition is a precalculated set of conditions. Here i have a very heavy query with 4 very heavy JOIN. That's why i'd like to have a precalculated query. A view wouldn't help, because it would calculate the whole query each time. Any idea ? Thanks in advance for any input. -- dpradier@apartia.fr 01.46.47.21.33 fax: 01.45.20.17.98 From pgsql-performance-owner@postgresql.org Thu Feb 26 10:26:06 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 15B8AD1DEB3 for ; Thu, 26 Feb 2004 14:26:04 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 32454-09 for ; Thu, 26 Feb 2004 10:26:05 -0400 (AST) Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net [194.217.242.86]) by svr1.postgresql.org (Postfix) with ESMTP id 91C7FD1B994 for ; Thu, 26 Feb 2004 10:26:01 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 1AwMSi-000HeG-0b; Thu, 26 Feb 2004 14:26:04 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id A50BF1729D; Thu, 26 Feb 2004 14:26:03 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 8D3A4167F9; Thu, 26 Feb 2004 14:26:01 +0000 (GMT) From: Richard Huxton To: David Pradier , pgsql-performance@postgresql.org Subject: Re: A cache for the results of queries ? Date: Thu, 26 Feb 2004 14:26:00 +0000 User-Agent: KMail/1.5 References: <20040226133038.GA1481@apartia.fr> In-Reply-To: <20040226133038.GA1481@apartia.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402261426.00730.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/298 X-Sequence-Number: 5822 On Thursday 26 February 2004 13:30, David Pradier wrote: > Hi everybody, > > i'd like to know if it exists a system of cache for the results of > queries. > > What i'd like to do : > > select whatever_things from (selection_in_cache) where special_conditions; > > The interesting thing would be to have a precalculated > selection_in_cache, especially when selection_in_cache is a very long > list of joins... You might want to search the archives for the -sql list for a message "Materialized View Summary" - some time this week. That's almost exactly what you want. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Thu Feb 26 13:25:48 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BCD9DD1B51F for ; Thu, 26 Feb 2004 17:25:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 06504-07 for ; Thu, 26 Feb 2004 13:25:43 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 8A752D1B4AA for ; Thu, 26 Feb 2004 13:25:39 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1QHOJ9R015080; Thu, 26 Feb 2004 10:24:19 -0700 (MST) Date: Thu, 26 Feb 2004 10:15:54 -0700 (MST) From: "scott.marlowe" To: David Pradier Cc: Subject: Re: A cache for the results of queries ? In-Reply-To: <20040226133038.GA1481@apartia.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/299 X-Sequence-Number: 5823 On Thu, 26 Feb 2004, David Pradier wrote: > Hi everybody, > > i'd like to know if it exists a system of cache for the results of > queries. I believe there are some external libs that provide this at the application level. PHP's adodb is purported to do so. From pgsql-performance-owner@postgresql.org Thu Feb 26 14:03:55 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 412F1D1CA83 for ; Thu, 26 Feb 2004 18:03:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 25954-05 for ; Thu, 26 Feb 2004 14:03:48 -0400 (AST) Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net [66.117.144.213]) by svr1.postgresql.org (Postfix) with ESMTP id D3C2CD1E16C for ; Thu, 26 Feb 2004 14:03:46 -0400 (AST) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id B2509A941 for ; Thu, 26 Feb 2004 10:03:46 -0800 (PST) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id i1QI3jju076782 for pgsql-performance@postgresql.org; Thu, 26 Feb 2004 10:03:45 -0800 (PST) (envelope-from dror) Date: Thu, 26 Feb 2004 10:03:45 -0800 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: FreeBSD config Message-ID: <20040226180345.GU26787@rlx11.zapatec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/300 X-Sequence-Number: 5824 Hi, We have postgres running on freebsd 4.9 with 2 Gigs of memory. As per repeated advice on the mailing lists we configured effective_cache_size = 25520 which you get by doing `sysctl -n vfs.hibufspace` / 8192 Which results in using 200Megs for disk caching. Is there a reason not to increase the hibufspace beyond the 200 megs and provide a bigger cache to postgres? I looked both on the postgres and freebsd mailing lists and couldn't find a good answer to this. If yes, any suggestions on what would be a good size on a 2 Gig machine? Regards, Dror -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com From pgsql-performance-owner@postgresql.org Thu Feb 26 15:05:22 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3D32CD1B9BE for ; Thu, 26 Feb 2004 19:05:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 49189-07 for ; Thu, 26 Feb 2004 15:05:05 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 9AD04D1E158 for ; Thu, 26 Feb 2004 15:05:03 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1QJ3v9R026099; Thu, 26 Feb 2004 12:03:57 -0700 (MST) Date: Thu, 26 Feb 2004 11:55:31 -0700 (MST) From: "scott.marlowe" To: Dror Matalon Cc: Subject: Re: FreeBSD config In-Reply-To: <20040226180345.GU26787@rlx11.zapatec.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/301 X-Sequence-Number: 5825 On Thu, 26 Feb 2004, Dror Matalon wrote: > Hi, > > We have postgres running on freebsd 4.9 with 2 Gigs of memory. As per > repeated advice on the mailing lists we configured effective_cache_size > = 25520 which you get by doing `sysctl -n vfs.hibufspace` / 8192 > > Which results in using 200Megs for disk caching. > > Is there a reason not to increase the hibufspace beyond the 200 megs and > provide a bigger cache to postgres? I looked both on the postgres and > freebsd mailing lists and couldn't find a good answer to this. Actually, I think you're confusing effective_cache_size with shared_buffers. effective_cache_size changes no cache settings for postgresql, it simply acts as a hint to the planner on about how much of the dataset your OS / Kernel / Disk cache can hold. Making it bigger only tells the query planny it's more likely the data it's looking for will be in cache. shared_buffers, OTOH, sets the amount of cache that postgresql uses. It's generall considered that 256 Megs or 1/4 of memory, whichever is LESS, is a good setting for production database servers. From pgsql-performance-owner@postgresql.org Thu Feb 26 15:16:39 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 801C3D1B901 for ; Thu, 26 Feb 2004 19:16:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 48528-10 for ; Thu, 26 Feb 2004 15:16:18 -0400 (AST) Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net [66.117.144.213]) by svr1.postgresql.org (Postfix) with ESMTP id C1B4DD1DF4D for ; Thu, 26 Feb 2004 15:16:16 -0400 (AST) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id A9DFFA941 for ; Thu, 26 Feb 2004 11:16:17 -0800 (PST) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id i1QJGGjq077511 for pgsql-performance@postgresql.org; Thu, 26 Feb 2004 11:16:16 -0800 (PST) (envelope-from dror) Date: Thu, 26 Feb 2004 11:16:16 -0800 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: FreeBSD config Message-ID: <20040226191616.GA26787@rlx11.zapatec.com> References: <20040226180345.GU26787@rlx11.zapatec.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 postgresql.org X-Archive-Number: 200402/302 X-Sequence-Number: 5826 On Thu, Feb 26, 2004 at 11:55:31AM -0700, scott.marlowe wrote: > On Thu, 26 Feb 2004, Dror Matalon wrote: > > > Hi, > > > > We have postgres running on freebsd 4.9 with 2 Gigs of memory. As per > > repeated advice on the mailing lists we configured effective_cache_size > > = 25520 which you get by doing `sysctl -n vfs.hibufspace` / 8192 > > > > Which results in using 200Megs for disk caching. > > > > Is there a reason not to increase the hibufspace beyond the 200 megs and > > provide a bigger cache to postgres? I looked both on the postgres and > > freebsd mailing lists and couldn't find a good answer to this. > > Actually, I think you're confusing effective_cache_size with > shared_buffers. No, I'm not. > > effective_cache_size changes no cache settings for postgresql, it simply > acts as a hint to the planner on about how much of the dataset your OS / > Kernel / Disk cache can hold. I understand that. The question is why have the OS, in this case FreeBsd use only 200 Megs for disk cache and not more. Why not double the vfs.hibufspace to 418119680 and double the effective_cache_size to 51040. > > Making it bigger only tells the query planny it's more likely the data > it's looking for will be in cache. > > shared_buffers, OTOH, sets the amount of cache that postgresql uses. It's > generall considered that 256 Megs or 1/4 of memory, whichever is LESS, is > a good setting for production database servers. > Actually last I looked, I thought that the recommended max shared buffers was 10,000, 80MB, even on machines with large amounts of memory. Regards, Dror -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com From pgsql-performance-owner@postgresql.org Thu Feb 26 15:46:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id ECD2ED1D132 for ; Thu, 26 Feb 2004 19:46:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 60877-09 for ; Thu, 26 Feb 2004 15:45:58 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 5E63CD1B901 for ; Thu, 26 Feb 2004 15:45:54 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1QJjA9R029834; Thu, 26 Feb 2004 12:45:10 -0700 (MST) Date: Thu, 26 Feb 2004 12:36:44 -0700 (MST) From: "scott.marlowe" To: Dror Matalon Cc: Subject: Re: FreeBSD config In-Reply-To: <20040226191616.GA26787@rlx11.zapatec.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/303 X-Sequence-Number: 5827 On Thu, 26 Feb 2004, Dror Matalon wrote: > On Thu, Feb 26, 2004 at 11:55:31AM -0700, scott.marlowe wrote: > > On Thu, 26 Feb 2004, Dror Matalon wrote: > > > > > Hi, > > > > > > We have postgres running on freebsd 4.9 with 2 Gigs of memory. As per > > > repeated advice on the mailing lists we configured effective_cache_size > > > = 25520 which you get by doing `sysctl -n vfs.hibufspace` / 8192 > > > > > > Which results in using 200Megs for disk caching. > > > > > > Is there a reason not to increase the hibufspace beyond the 200 megs and > > > provide a bigger cache to postgres? I looked both on the postgres and > > > freebsd mailing lists and couldn't find a good answer to this. > > > > Actually, I think you're confusing effective_cache_size with > > shared_buffers. > > No, I'm not. OK, sorry, I wasn't sure which you meant. > > effective_cache_size changes no cache settings for postgresql, it simply > > acts as a hint to the planner on about how much of the dataset your OS / > > Kernel / Disk cache can hold. > > I understand that. The question is why have the OS, in this case FreeBsd > use only 200 Megs for disk cache and not more. Why not double the > vfs.hibufspace to 418119680 and double the effective_cache_size to 51040. Doesn't the kernel just use the spare memory to buffer anyway? I'd say if you got 2 megs memory and nothing else on the box, give a big chunk (1 gig or so) to the kernel to manage. Unless large kernel caches cause some issues in FreeBSD. > > Making it bigger only tells the query planny it's more likely the data > > it's looking for will be in cache. > > > > shared_buffers, OTOH, sets the amount of cache that postgresql uses. It's > > generall considered that 256 Megs or 1/4 of memory, whichever is LESS, is > > a good setting for production database servers. > > > > Actually last I looked, I thought that the recommended max shared > buffers was 10,000, 80MB, even on machines with large amounts of memory. It really depends on what you're doing. For loads involving very large data sets, up to 256 Megs has resulted in improvements, but anything after that has only had advantages in very limited types of applications. From pgsql-performance-owner@postgresql.org Thu Feb 26 17:29:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 88776D1E152 for ; Thu, 26 Feb 2004 21:29:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 01261-08 for ; Thu, 26 Feb 2004 17:29:11 -0400 (AST) Received: from mxsf20.cluster1.charter.net (mxsf20.cluster1.charter.net [209.225.28.220]) by svr1.postgresql.org (Postfix) with ESMTP id 2C404D1BB2A for ; Thu, 26 Feb 2004 17:29:09 -0400 (AST) Received: from Enterprise (66-168-202-107.cpe.ga.charter.com [66.168.202.107]) by mxsf20.cluster1.charter.net (8.12.10/8.12.8) with ESMTP id i1QLS4VD023380 for ; Thu, 26 Feb 2004 16:28:07 -0500 (EST) (envelope-from john@turbocorp.com) Message-Id: <200402262128.i1QLS4VD023380@mxsf20.cluster1.charter.net> From: "John Allgood" To: Subject: Database Server Tuning Date: Thu, 26 Feb 2004 16:28:07 -0500 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.2800.1165 Thread-Index: AcP7HIGVVlhdJnlMTSCrnEihpvmgDQBkcvSwAAA/nFA= X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/304 X-Sequence-Number: 5828 I sent this to the admin list the other day and got no responses. Maybe this list can give me some pointers. Hello I am working on installing and configuring a Postgres database server. I am running Redhat Enterprise ES 3.0 and Redhat Database 3.0. "Postgres version 7.3.4-11". This server will host 150-200 users. There will be about 9 databases in our cluster ranging anywhere from 500MB to 3GB The hardware is a dual Xeon running at 2.8GHZ, 4GB RAM, Ultra 320 SCSI hard drives running on Adaptec Ultra Raid Controllers. I am planning on separating the OS, Data, WAL on to separate drives which will be mirrored. I am looking for input on setting kernel parameters, and Postgres server runtime parameters and other settings relating to tuning. Also is there any benchmarking tools available that will help me tune this server. Thanks John Allgood - ESC System Administrator 770.535.5049 From pgsql-performance-owner@postgresql.org Thu Feb 26 17:48:08 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B3293D1B57C for ; Thu, 26 Feb 2004 21:48:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 11935-06 for ; Thu, 26 Feb 2004 17:47:52 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id C3B8DD1B9BC for ; Thu, 26 Feb 2004 17:47:48 -0400 (AST) Received: from houston.familyhealth.com.au (chriskl@localhost [127.0.0.1]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id i1QLllGi035475; Fri, 27 Feb 2004 05:47:47 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from localhost (chriskl@localhost) by houston.familyhealth.com.au (8.12.9p1/8.12.9/Submit) with ESMTP id i1QLll9M035472; Fri, 27 Feb 2004 05:47:47 +0800 (WST) X-Authentication-Warning: houston.familyhealth.com.au: chriskl owned process doing -bs Date: Fri, 27 Feb 2004 05:47:47 +0800 (WST) From: Christopher Kings-Lynne To: Dror Matalon Cc: pgsql-performance@postgresql.org Subject: Re: FreeBSD config In-Reply-To: <20040226180345.GU26787@rlx11.zapatec.com> Message-ID: <20040227054639.H34315-100000@houston.familyhealth.com.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/305 X-Sequence-Number: 5829 > We have postgres running on freebsd 4.9 with 2 Gigs of memory. As per > repeated advice on the mailing lists we configured effective_cache_size > = 25520 which you get by doing `sysctl -n vfs.hibufspace` / 8192 > > Which results in using 200Megs for disk caching. effective_cache_size does nothing of the sort. CHeck your shared_buffers value... > Is there a reason not to increase the hibufspace beyond the 200 megs and > provide a bigger cache to postgres? I looked both on the postgres and > freebsd mailing lists and couldn't find a good answer to this. Well, maybe butnot necessarily. It's better to leave the OS to look after most of your RAM. Chris From pgsql-performance-owner@postgresql.org Thu Feb 26 17:58:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7C8ACD1E106 for ; Thu, 26 Feb 2004 21:58:52 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 20645-01 for ; Thu, 26 Feb 2004 17:58:41 -0400 (AST) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id 68081D1BA21 for ; Thu, 26 Feb 2004 17:58:37 -0400 (AST) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id 0C1075D23 for ; Thu, 26 Feb 2004 13:58:39 -0800 (PST) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id i1QLwcCE080517 for pgsql-performance@postgresql.org; Thu, 26 Feb 2004 13:58:38 -0800 (PST) (envelope-from dror) Date: Thu, 26 Feb 2004 13:58:38 -0800 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: FreeBSD config Message-ID: <20040226215838.GK26787@rlx11.zapatec.com> References: <20040226180345.GU26787@rlx11.zapatec.com> <20040227054639.H34315-100000@houston.familyhealth.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040227054639.H34315-100000@houston.familyhealth.com.au> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/306 X-Sequence-Number: 5830 On Fri, Feb 27, 2004 at 05:47:47AM +0800, Christopher Kings-Lynne wrote: > > We have postgres running on freebsd 4.9 with 2 Gigs of memory. As per > > repeated advice on the mailing lists we configured effective_cache_size > > = 25520 which you get by doing `sysctl -n vfs.hibufspace` / 8192 > > > > Which results in using 200Megs for disk caching. > > effective_cache_size does nothing of the sort. CHeck your > shared_buffers value... Sigh. http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html effective_cache_size Sets the optimizer's assumption about the effective size of the disk cache (that is, the portion of the kernel's disk cache that will be used for PostgreSQL data files). This is measured in disk pages, which are normally 8 kB each. http://archives.postgresql.org/pgsql-performance/2003-07/msg00159.php talks about how to programmatically determine the right setting for effective_cache_size: case `uname` in "FreeBSD") echo "effective_cache_size = $((`sysctl -n vfs.hibufspace` / 8192))" ;; *) echo "Unable to automatically determine the effective cache size" >> /dev/stderr ;; esac which brings me back to my question why not make Freebsd use more of its memory for disk caching and then tell postgres about it. > > > Is there a reason not to increase the hibufspace beyond the 200 megs and > > provide a bigger cache to postgres? I looked both on the postgres and > > freebsd mailing lists and couldn't find a good answer to this. > > Well, maybe butnot necessarily. It's better to leave the OS to look after > most of your RAM. > > Chris > -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com From pgsql-performance-owner@postgresql.org Sat Feb 28 18:56:30 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3F9C3D1D52E for ; Thu, 26 Feb 2004 22:11:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 15819-10 for ; Thu, 26 Feb 2004 18:11:10 -0400 (AST) Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by svr1.postgresql.org (Postfix) with ESMTP id 53C0CD1CA67 for ; Thu, 26 Feb 2004 18:11:07 -0400 (AST) Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AwTim-0006nh-00 for ; Thu, 26 Feb 2004 23:11:08 +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 ; Thu Feb 26 22:11:08 2004 Received: from troels by 62.79.119.132.adsl.vbr.tiscali.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu Feb 26 22:11:08 2004 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-performance@postgresql.org From: Troels Arvin Subject: Re: Database Server Tuning Date: Thu, 26 Feb 2004 23:01:13 +0100 Lines: 17 Message-ID: References: <200402262128.i1QLS4VD023380@mxsf20.cluster1.charter.net> 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 (This is not a psychotic episode. It's a cleansing moment of clarity.) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/329 X-Sequence-Number: 5853 On Thu, 26 Feb 2004 16:28:07 -0500, John Allgood wrote: > I am planning on separating the OS, Data, WAL on to separate drives > which will be mirrored. Have you considered RAID-10 in stead of RAID-1? > I am looking for input on setting kernel > parameters, and Postgres server runtime parameters and other settings > relating to tuning. http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php (See the "Performance" section.) -- Greetings from Troels Arvin, Copenhagen, Denmark From pgsql-performance-owner@postgresql.org Thu Feb 26 18:41:24 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 63BE8D1E2B1 for ; Thu, 26 Feb 2004 22:41:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 33969-02 for ; Thu, 26 Feb 2004 18:41:04 -0400 (AST) Received: from mail.ez3pl.com (66-136-75-131.ded.swbell.net [66.136.75.131]) by svr1.postgresql.org (Postfix) with ESMTP id 7570AD1E152 for ; Thu, 26 Feb 2004 18:40:50 -0400 (AST) Received: from kbarnard ([172.25.96.149]) by mail.ez3pl.com (8.11.2/8.11.2) with ESMTP id i1QMdlo15993 for ; Thu, 26 Feb 2004 16:39:47 -0600 From: "Kevin Barnard" To: pgsql-performance@postgresql.org Date: Thu, 26 Feb 2004 16:36:01 -0600 MIME-Version: 1.0 Subject: Re: FreeBSD config Message-ID: <403E2071.31408.BAFBDDB@localhost> In-reply-to: <20040226215838.GK26787@rlx11.zapatec.com> References: <20040227054639.H34315-100000@houston.familyhealth.com.au> X-mailer: Pegasus Mail for Windows (v4.12a) Content-type: Multipart/Alternative; boundary="Alt-Boundary-9753.196066779" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/307 X-Sequence-Number: 5831 --Alt-Boundary-9753.196066779 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body On 26 Feb 2004 at 13:58, Dror Matalon wrote: > > which brings me back to my question why not make Freebsd use more of its > memory for disk caching and then tell postgres about it. > I think there is some confusion about maxbufsize and hibufspace. I looking at a comment in the FreeBSB source 4.9 that explains this. I think you will want to increase effective_cache to match maxbufsize not hibufspace but I could be wrong. $FreeBSD: src/sys/kern/vfs_bio.c,v 1.242.2.21 line 363 --Alt-Boundary-9753.196066779 Content-type: text/html; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body
On 26 Feb 2004 at 13:58, Dror Matalon wrote:

>
> which brings me back to my question why not make Freebsd use more of its
> memory for disk caching and then tell postgres about it.
>

I think there is some confusion about maxbufsize and hibufspace.  I looking at a comment in the FreeBSB  source 4.9 that explains this.  I think you will want to increase effective_cache to match maxbufsize not hibufspace but I could be wrong.

$FreeBSD: src/sys/kern/vfs_bio.c,v 1.242.2.21 line 363
--Alt-Boundary-9753.196066779-- From pgsql-performance-owner@postgresql.org Thu Feb 26 18:54:59 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 239D3D1BB2A for ; Thu, 26 Feb 2004 22:49:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 33969-05 for ; Thu, 26 Feb 2004 18:49:24 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 16445D1B4AA for ; Thu, 26 Feb 2004 18:49:20 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4498058; Thu, 26 Feb 2004 14:50:31 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "John Allgood" , Subject: Re: Database Server Tuning Date: Thu, 26 Feb 2004 14:48:34 -0800 User-Agent: KMail/1.5.4 References: <200402262128.i1QLS4VD023380@mxsf20.cluster1.charter.net> In-Reply-To: <200402262128.i1QLS4VD023380@mxsf20.cluster1.charter.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402261448.34352.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/308 X-Sequence-Number: 5832 John, > and Postgres server runtime parameters and other settings relating to > tuning. Also is there any benchmarking tools available that will help me > tune this server. Check out http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html Also, I'd like to see what you get under heavy load for context-switching. We've been having issues with RH+Xeon with really large queries. -- -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Feb 26 19:02:56 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 962E0D1B91B for ; Thu, 26 Feb 2004 23:02:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 38950-03 for ; Thu, 26 Feb 2004 19:02:40 -0400 (AST) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id 42EFCD1B4AA for ; Thu, 26 Feb 2004 19:02:38 -0400 (AST) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id 92E665D23 for ; Thu, 26 Feb 2004 15:02:40 -0800 (PST) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id i1QN2edJ081029 for pgsql-performance@postgresql.org; Thu, 26 Feb 2004 15:02:40 -0800 (PST) (envelope-from dror) Date: Thu, 26 Feb 2004 15:02:40 -0800 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: FreeBSD config Message-ID: <20040226230240.GM26787@rlx11.zapatec.com> References: <20040227054639.H34315-100000@houston.familyhealth.com.au> <403E2071.31408.BAFBDDB@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <403E2071.31408.BAFBDDB@localhost> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/309 X-Sequence-Number: 5833 Thanks for the pointer. So maxbufspace = nbuf * BKVASIZE; Which is confirmed in http://unix.derkeiler.com/Mailing-Lists/FreeBSD/performance/2003-09/0045.html and it looks like there's a patch by Sean Chittenden at http://people.freebsd.org/~seanc/patches/patch-HEAD-kern.nbuf that does what I was asking. Seems a little on the bleeding edge. Has anyone tried this? On Thu, Feb 26, 2004 at 04:36:01PM -0600, Kevin Barnard wrote: > On 26 Feb 2004 at 13:58, Dror Matalon wrote: > > > > > which brings me back to my question why not make Freebsd use more of its > > memory for disk caching and then tell postgres about it. > > > > I think there is some confusion about maxbufsize and hibufspace. I looking at a > comment in the FreeBSB source 4.9 that explains this. I think you will want to > increase effective_cache to match maxbufsize not hibufspace but I could be wrong. > > $FreeBSD: src/sys/kern/vfs_bio.c,v 1.242.2.21 line 363 > -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com From pgsql-performance-owner@postgresql.org Sat Feb 28 18:53:51 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1954DD1B994 for ; Thu, 26 Feb 2004 23:06:27 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 42472-02 for ; Thu, 26 Feb 2004 19:06:11 -0400 (AST) Received: from smtp.k12us.com (smtp.k12us.com [65.112.222.15]) by svr1.postgresql.org (Postfix) with SMTP id 05F11D1D52E for ; Thu, 26 Feb 2004 19:06:08 -0400 (AST) Received: (qmail 58379 invoked by uid 1001); 26 Feb 2004 23:06:06 -0000 Date: Thu, 26 Feb 2004 18:06:06 -0500 From: Christopher Weimann To: Dror Matalon Cc: pgsql-performance@postgresql.org Subject: Re: FreeBSD config Message-ID: <20040226230606.GG49146@smtp.k12us.com> References: <20040226180345.GU26787@rlx11.zapatec.com> <20040226191616.GA26787@rlx11.zapatec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040226191616.GA26787@rlx11.zapatec.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/328 X-Sequence-Number: 5852 On 02/26/2004-11:16AM, Dror Matalon wrote: > > > > effective_cache_size changes no cache settings for postgresql, it simply > > acts as a hint to the planner on about how much of the dataset your OS / > > Kernel / Disk cache can hold. > > I understand that. The question is why have the OS, in this case FreeBsd > use only 200 Megs for disk cache and not more. Why not double the > vfs.hibufspace to 418119680 and double the effective_cache_size to 51040. > FreeBSD uses ALL ram that isn't being used for something else as its disk cache. The "effective_cache_size" in the PostGreSQL config has no effect on how the OS chooses to use memory, it is just hint to the PostGreSQL planner so it can guess the the likelyhood of what it is looking for being in the cache. From pgsql-performance-owner@postgresql.org Sat Feb 28 18:21:03 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6FF2AD1BB2A for ; Thu, 26 Feb 2004 23:10:28 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 41092-04 for ; Thu, 26 Feb 2004 19:10:14 -0400 (AST) Received: from smtp.k12us.com (smtp.k12us.com [65.112.222.15]) by svr1.postgresql.org (Postfix) with SMTP id 83D97D1DD15 for ; Thu, 26 Feb 2004 19:10:11 -0400 (AST) Received: (qmail 60197 invoked by uid 1001); 26 Feb 2004 23:10:13 -0000 Date: Thu, 26 Feb 2004 18:10:13 -0500 From: Christopher Weimann To: Dror Matalon Cc: pgsql-performance@postgresql.org Subject: Re: FreeBSD config Message-ID: <20040226231013.GH49146@smtp.k12us.com> References: <20040226180345.GU26787@rlx11.zapatec.com> <20040227054639.H34315-100000@houston.familyhealth.com.au> <20040226215838.GK26787@rlx11.zapatec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040226215838.GK26787@rlx11.zapatec.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/322 X-Sequence-Number: 5846 On 02/26/2004-01:58PM, Dror Matalon wrote: > > Sigh. > Sigh, right back at you. > which brings me back to my question why not make Freebsd use more of its > memory for disk caching and then tell postgres about it. > Because you can't. It already uses ALL RAM that isn't in use for something else. From pgsql-performance-owner@postgresql.org Thu Feb 26 19:42:53 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4B923D1B97B for ; Thu, 26 Feb 2004 23:42:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 48164-03 for ; Thu, 26 Feb 2004 19:42:47 -0400 (AST) Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net [66.117.144.213]) by svr1.postgresql.org (Postfix) with ESMTP id 94949D1B860 for ; Thu, 26 Feb 2004 19:42:44 -0400 (AST) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id 51E71A941 for ; Thu, 26 Feb 2004 15:42:47 -0800 (PST) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id i1QNgkpT081720 for pgsql-performance@postgresql.org; Thu, 26 Feb 2004 15:42:46 -0800 (PST) (envelope-from dror) Date: Thu, 26 Feb 2004 15:42:46 -0800 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: FreeBSD config Message-ID: <20040226234246.GN26787@rlx11.zapatec.com> References: <20040226180345.GU26787@rlx11.zapatec.com> <20040226191616.GA26787@rlx11.zapatec.com> <20040226230606.GG49146@smtp.k12us.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040226230606.GG49146@smtp.k12us.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/310 X-Sequence-Number: 5834 On Thu, Feb 26, 2004 at 06:06:06PM -0500, Christopher Weimann wrote: > On 02/26/2004-11:16AM, Dror Matalon wrote: > > > > > > effective_cache_size changes no cache settings for postgresql, it simply > > > acts as a hint to the planner on about how much of the dataset your OS / > > > Kernel / Disk cache can hold. > > > > I understand that. The question is why have the OS, in this case FreeBsd > > use only 200 Megs for disk cache and not more. Why not double the > > vfs.hibufspace to 418119680 and double the effective_cache_size to 51040. > > > > FreeBSD uses ALL ram that isn't being used for something else as > its disk cache. The "effective_cache_size" in the PostGreSQL config > has no effect on how the OS chooses to use memory, it is just hint > to the PostGreSQL planner so it can guess the the likelyhood of > what it is looking for being in the cache. Let me try and say it again. I know that setting effective_cache_size doesn't affect the OS' cache. I know it just gives Postgres the *idea* of how much cache the OS is using. I know that. I also know that a correct hint helps performance. I've read Matt Dillon's discussion about the freebsd VM at http://www.daemonnews.org/200001/freebsd_vm.html and I didn't see him saying that Freebsd uses all the free RAM for disk cache. Would you care to provide a URL pointing to that? Assuming you are correct, why has the ongoing recommendation been to use hibufspace/8192 as the effective_cache_size? Seems like it would be quite a bit more on machines with lots of RAM. Regards, Dror -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com From pgsql-performance-owner@postgresql.org Thu Feb 26 20:49:40 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 08B0ED1DA2E for ; Fri, 27 Feb 2004 00:49:39 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 62840-04 for ; Thu, 26 Feb 2004 20:49:35 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 4B080D1E132 for ; Thu, 26 Feb 2004 20:49:32 -0400 (AST) 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 i1R0nV1Y065804 for ; Fri, 27 Feb 2004 00:49:31 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i1R0lbxJ065674 for pgsql-performance@postgresql.org; Fri, 27 Feb 2004 00:47:37 GMT From: William Yu X-Newsgroups: comp.databases.postgresql.performance Subject: Re: A cache for the results of queries ? Date: Thu, 26 Feb 2004 16:40:25 -0800 Organization: Hub.Org Networking Services Lines: 10 Message-ID: References: <20040226133038.GA1481@apartia.fr> 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.6) Gecko/20040113 X-Accept-Language: en-us, en In-Reply-To: <20040226133038.GA1481@apartia.fr> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/311 X-Sequence-Number: 5835 David Pradier wrote: > i'd like to know if it exists a system of cache for the results of > queries. If you are willing to do this at an application level, you could calculate a MD5 for every query you plan to run and then SELECT INTO a temporary table that's based on the MD5 sum (e.g. TMP_CACHE_45123). Next time somebody runs a query, check to see if that table exists already. Then you just have to figure out some way to know when results should be expired. From pgsql-performance-owner@postgresql.org Thu Feb 26 23:12:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 815D2D1B51F for ; Fri, 27 Feb 2004 03:12:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 95923-09 for ; Thu, 26 Feb 2004 23:12:28 -0400 (AST) Received: from mxsf01.cluster1.charter.net (mxsf01.cluster1.charter.net [209.225.28.201]) by svr1.postgresql.org (Postfix) with ESMTP id 9AA57D1B4AA for ; Thu, 26 Feb 2004 23:12:23 -0400 (AST) Received: from turbocorp.com (66-168-202-107.cpe.ga.charter.com [66.168.202.107]) by mxsf01.cluster1.charter.net (8.12.10/8.12.8) with ESMTP id i1R37oio020919; Thu, 26 Feb 2004 22:07:50 -0500 (EST) (envelope-from john@turbocorp.com) Message-ID: <403EB485.10802@turbocorp.com> Date: Thu, 26 Feb 2004 22:07:49 -0500 From: John Allgood User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org Subject: Re: Database Server Tuning References: <200402262128.i1QLS4VD023380@mxsf20.cluster1.charter.net> <200402261448.34352.josh@agliodbs.com> In-Reply-To: <200402261448.34352.josh@agliodbs.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/312 X-Sequence-Number: 5836 Josh Berkus wrote: >John, > > > >>and Postgres server runtime parameters and other settings relating to >>tuning. Also is there any benchmarking tools available that will help me >>tune this server. >> >> > >Check out >http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html > >Also, I'd like to see what you get under heavy load for context-switching. >We've been having issues with RH+Xeon with really large queries. > > > This is exactly what I was looking for. I will keep you posted on what kinda results I get when I start putting a load on this server. Thanks John Allgood - ESC Systems Administrator 770.535.5049 From pgsql-performance-owner@postgresql.org Fri Feb 27 03:16:23 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8E4D1D1B9BE for ; Fri, 27 Feb 2004 07:16:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 56404-06 for ; Fri, 27 Feb 2004 03:16:18 -0400 (AST) Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) by svr1.postgresql.org (Postfix) with ESMTP id 45026D1B9C0 for ; Fri, 27 Feb 2004 03:16:17 -0400 (AST) Received: from concord.pspl.co.in ([202.54.11.72]:61910 helo=frodo.hserus.net) by frodo.hserus.net with asmtp (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.30 #1) id 1AwcEL-0006UZ-3E by authid with plain; Fri, 27 Feb 2004 12:46:17 +0530 Message-ID: <403EEEB8.3080807@frodo.hserus.net> Date: Fri, 27 Feb 2004 12:46:08 +0530 From: Shridhar Daithankar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dror Matalon Cc: pgsql-performance@postgresql.org Subject: Re: FreeBSD config References: <20040226180345.GU26787@rlx11.zapatec.com> <20040226191616.GA26787@rlx11.zapatec.com> <20040226230606.GG49146@smtp.k12us.com> <20040226234246.GN26787@rlx11.zapatec.com> In-Reply-To: <20040226234246.GN26787@rlx11.zapatec.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/313 X-Sequence-Number: 5837 Dror Matalon wrote: > Let me try and say it again. I know that setting effective_cache_size > doesn't affect the OS' cache. I know it just gives Postgres the *idea* > of how much cache the OS is using. I know that. I also know that a > correct hint helps performance. > > I've read Matt Dillon's discussion about the freebsd VM at > http://www.daemonnews.org/200001/freebsd_vm.html and I didn't see him > saying that Freebsd uses all the free RAM for disk cache. Would you care > to provide a URL pointing to that? I don't believe freeBSD yses everything available unlike linux. It is actually a good thing. If you have 1GB RAM and kernel buffers set at 600MB, you are guaranteed to have some mmory in crunch situations. As far you original questions, I think you can increase the kernel buffer sizes for VFS safely. However remembet that more to dedicate to kernel buffers, less space you have in case of crunch for whatever reasons. FreeBSD gives you a control which linux does not. Use it to best of your advantage.. Shridhar From pgsql-performance-owner@postgresql.org Fri Feb 27 11:43:32 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 44CE5D1D1D5 for ; Fri, 27 Feb 2004 15:43:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 16806-01 for ; Fri, 27 Feb 2004 11:43:25 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 993C9D1E12C for ; Fri, 27 Feb 2004 11:43:19 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1RFgD9R001808; Fri, 27 Feb 2004 08:42:13 -0700 (MST) Date: Fri, 27 Feb 2004 08:33:40 -0700 (MST) From: "scott.marlowe" To: Shridhar Daithankar Cc: Dror Matalon , Subject: Re: FreeBSD config In-Reply-To: <403EEEB8.3080807@frodo.hserus.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/314 X-Sequence-Number: 5838 On Fri, 27 Feb 2004, Shridhar Daithankar wrote: > Dror Matalon wrote: > > > Let me try and say it again. I know that setting effective_cache_size > > doesn't affect the OS' cache. I know it just gives Postgres the *idea* > > of how much cache the OS is using. I know that. I also know that a > > correct hint helps performance. > > > > I've read Matt Dillon's discussion about the freebsd VM at > > http://www.daemonnews.org/200001/freebsd_vm.html and I didn't see him > > saying that Freebsd uses all the free RAM for disk cache. Would you care > > to provide a URL pointing to that? > > I don't believe freeBSD yses everything available unlike linux. It is actually a > good thing. If you have 1GB RAM and kernel buffers set at 600MB, you are > guaranteed to have some mmory in crunch situations. Linux doesn't work with a pre-assigned size for kernel cache. It just grabs whatever's free, minus a few megs for easily launching new programs or allocating more memory for programs, and uses that for the cache. then, when a request comes in for more memory than is free, it dumps some of the least used buffers and gives them back. It would seem to work very well underneath a mixed load server like an LAPP box. From pgsql-performance-owner@postgresql.org Fri Feb 27 13:18:44 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 1F3A7D1E183 for ; Fri, 27 Feb 2004 17:10:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 43325-10 for ; Fri, 27 Feb 2004 13:09:50 -0400 (AST) Received: from kserver17.erfurt12.de (unknown [80.190.233.41]) by svr1.postgresql.org (Postfix) with ESMTP id E1CA4D1B9BE for ; Fri, 27 Feb 2004 13:09:35 -0400 (AST) Received: by kserver17.erfurt12.de (Postfix, from userid 642) id 7A6495A8173; Fri, 27 Feb 2004 17:52:39 +0100 (CET) To: pgsql-performance@postgresql.org From: postgres@countup.de Subject: Select-Insert-Query Content-Type: text/html; charset=iso-8859-1; Message-Id: <20040227165239.7A6495A8173@kserver17.erfurt12.de> Date: Fri, 27 Feb 2004 17:52:39 +0100 (CET) X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=1.9 tagged_above=0.0 required=5.0 tests=BAYES_10, HTML_MESSAGE, MIME_HEADER_CTYPE_ONLY, MIME_HTML_ONLY, NO_REAL_NAME X-Spam-Level: * X-Archive-Number: 200402/315 X-Sequence-Number: 5839 Hi,

what is the most performant way to select for example the first 99 rows of a table and insert them into another table...

at the moment i do this:

for userrecord in select * from table where account_id = a_account_id and counter_id = userrecord.counter_id and visitortable_id between a_minid and a_maxid limit 99 loop
insert into lastusers (account_id, counter_id, date, ip, hostname) values(a_account_id,userrecord.counter_id,userrecord.date,userrecord.ip,userrecord.hostname);
end loop;

i think "limit" is a performance killer, is that right? but what to do instead

thanks
bye From pgsql-performance-owner@postgresql.org Fri Feb 27 14:27:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3FC6FD1D132 for ; Fri, 27 Feb 2004 18:27:47 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 74352-04 for ; Fri, 27 Feb 2004 14:27:28 -0400 (AST) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id 81131D1B904 for ; Fri, 27 Feb 2004 14:27:27 -0400 (AST) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id 191DD5D23 for ; Fri, 27 Feb 2004 10:27:27 -0800 (PST) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id i1RIRQN6084500 for pgsql-performance@postgresql.org; Fri, 27 Feb 2004 10:27:26 -0800 (PST) (envelope-from dror) Date: Fri, 27 Feb 2004 10:27:26 -0800 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: FreeBSD config Message-ID: <20040227182726.GB82930@rlx11.zapatec.com> References: <20040226180345.GU26787@rlx11.zapatec.com> <20040226191616.GA26787@rlx11.zapatec.com> <20040226230606.GG49146@smtp.k12us.com> <20040226234246.GN26787@rlx11.zapatec.com> <403EEEB8.3080807@frodo.hserus.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <403EEEB8.3080807@frodo.hserus.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/316 X-Sequence-Number: 5840 I guess the thing to do is to move this topic over to a freebsd list where we can get more definitive answers on how disk caching is handled. I asked here since I know that FreeBsd is often recommended, http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html# as a good platform for postgres, and with Modern machines often having Gigabytes of memory the issue of, possibly, having a disk cache of 200MB would be one often asked. On Fri, Feb 27, 2004 at 12:46:08PM +0530, Shridhar Daithankar wrote: > Dror Matalon wrote: > > >Let me try and say it again. I know that setting effective_cache_size > >doesn't affect the OS' cache. I know it just gives Postgres the *idea* > >of how much cache the OS is using. I know that. I also know that a > >correct hint helps performance. > > > >I've read Matt Dillon's discussion about the freebsd VM at > >http://www.daemonnews.org/200001/freebsd_vm.html and I didn't see him > >saying that Freebsd uses all the free RAM for disk cache. Would you care > >to provide a URL pointing to that? > > I don't believe freeBSD yses everything available unlike linux. It is > actually a good thing. If you have 1GB RAM and kernel buffers set at 600MB, > you are guaranteed to have some mmory in crunch situations. > > As far you original questions, I think you can increase the kernel buffer > sizes for VFS safely. However remembet that more to dedicate to kernel > buffers, less space you have in case of crunch for whatever reasons. > > FreeBSD gives you a control which linux does not. Use it to best of your > advantage.. > > Shridhar -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.fastbuzz.com http://www.zapatec.com From pgsql-performance-owner@postgresql.org Fri Feb 27 14:34:02 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9FDB5D1B904 for ; Fri, 27 Feb 2004 18:34:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 73695-08 for ; Fri, 27 Feb 2004 14:33:38 -0400 (AST) Received: from lorax.kcilink.com (lorax.kcilink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 07778D1B860 for ; Fri, 27 Feb 2004 14:33:35 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 746B53EB1 for ; Fri, 27 Feb 2004 13:33:34 -0500 (EST) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 37233-02 for ; Fri, 27 Feb 2004 13:33:34 -0500 (EST) Received: from lorax.kcilink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id C77D93E91 for ; Fri, 27 Feb 2004 13:33:33 -0500 (EST) Received: (from news@localhost) by lorax.kcilink.com (8.12.9p2/8.12.9/Submit) id i1RIXXYQ079126 for pgsql-performance@postgresql.org; Fri, 27 Feb 2004 13:33:33 -0500 (EST) (envelope-from news) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: FreeBSD config Date: Fri, 27 Feb 2004 13:33:33 -0500 Organization: Khera Communications, Inc., Rockville, MD Lines: 17 Message-ID: References: <20040226180345.GU26787@rlx11.zapatec.com> <20040227054639.H34315-100000@houston.familyhealth.com.au> <20040226215838.GK26787@rlx11.zapatec.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1077906813 6791 65.205.34.180 (27 Feb 2004 18:33:33 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Fri, 27 Feb 2004 18:33:33 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, berkeley-unix) Cancel-Lock: sha1:mPEakRxXkliPXLdsl9fo624ashE= X-Virus-Scanned: by amavisd-new at kcilink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/317 X-Sequence-Number: 5841 >>>>> "DM" == Dror Matalon writes: DM> which brings me back to my question why not make Freebsd use more of its DM> memory for disk caching and then tell postgres about it. Because this is a painfully hard thing to do ;-( It involves hacking a system header file and recompiling the kernel. It is not a simple tunable. It has side effects regarding some other sizing parameter as well, but I don't recall the details. Details have been posted to this list at least once before by Sean Chittenden. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-301-869-4449 x806 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Fri Feb 27 15:47:29 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A4A54D1BA21 for ; Fri, 27 Feb 2004 19:47:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 94773-07 for ; Fri, 27 Feb 2004 15:47:21 -0400 (AST) 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 414D6D1B860 for ; Fri, 27 Feb 2004 15:47:19 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) id 1Awnx7-0009k8-0W; Fri, 27 Feb 2004 19:47:17 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id A7CE216C24; Fri, 27 Feb 2004 19:47:16 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id AD79F162D6; Fri, 27 Feb 2004 19:47:14 +0000 (GMT) From: Richard Huxton To: postgres@countup.de, pgsql-performance@postgresql.org Subject: Re: Select-Insert-Query Date: Fri, 27 Feb 2004 19:47:13 +0000 User-Agent: KMail/1.5 References: <20040227165239.7A6495A8173@kserver17.erfurt12.de> In-Reply-To: <20040227165239.7A6495A8173@kserver17.erfurt12.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402271947.13736.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/318 X-Sequence-Number: 5842 On Friday 27 February 2004 16:52, postgres@countup.de wrote: *please* don't post HTML-only messages.

what is the most performant way to select for > example the first 99 rows of a table and insert them into another > table...

at the moment i do this:

> for userrecord in select * > from table where account_id = a_account_id and counter_id = > userrecord.counter_id and visitortable_id between a_minid and a_maxid limit > 99 loop > insert into lastusers (account_id, counter_id, date, ip, > hostname) > values(a_account_id,userrecord.counter_id,userrecord.date,userrecord.ip, > userrecord.hostname); >end loop; If that is the actual query, I'm puzzled as to what you're doing, since you don't know what it is you just inserted. Anyway, you can do this as a single query INSERT INTO lastusers (account_id ... hostname) SELECT a_account_id, counter_id... FROM table where... The LIMIT shouldn't take any time in itself, although if you are sorting then PG may need to sort all the rows before discarding all except the first 99. If this new query is no better, make sure you have vacuum analyse'd the tables and post the output of EXPLAIN ANALYSE for the query. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Sat Feb 28 04:39:09 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C916CD1E320 for ; Sat, 28 Feb 2004 08:39:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 85811-02 for ; Sat, 28 Feb 2004 04:38:52 -0400 (AST) Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) by svr1.postgresql.org (Postfix) with ESMTP id ECFDDD1E30C for ; Sat, 28 Feb 2004 04:38:46 -0400 (AST) Received: from concord.pspl.co.in ([202.54.11.72]:61389 helo=ps0499.intranet.pspl.co.in) by frodo.hserus.net with asmtp (Cipher TLSv1:RC4-MD5:128) (Exim 4.30 #1) id 1Awzzi-0002LS-RV by authid with plain; Sat, 28 Feb 2004 14:08:47 +0530 From: Shridhar Daithankar Reply-To: shridhar@frodo.hserus.net To: "scott.marlowe" Subject: Re: FreeBSD config Date: Sat, 28 Feb 2004 14:08:41 +0530 User-Agent: KMail/1.6 Cc: Dror Matalon , References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200402281408.41412.shridhar@frodo.hserus.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/319 X-Sequence-Number: 5843 On Friday 27 February 2004 21:03, scott.marlowe wrote: > Linux doesn't work with a pre-assigned size for kernel cache. > It just grabs whatever's free, minus a few megs for easily launching new > programs or allocating more memory for programs, and uses that for the > cache. then, when a request comes in for more memory than is free, it > dumps some of the least used buffers and gives them back. > > It would seem to work very well underneath a mixed load server like an > LAPP box. I was just pointing out that freeBSD is different than linux nd for one thing it is good because if there is a bug in freeSD VM, it won't run rampant because you can explicitly limit kernel cache and other parameter. OTOH, freeBSD VM anyways works. And running unlimited kernel cache allowed linux to iron out some of corner cases bugs. Not a concern anymore I believe but having choice is always great.. Shridhar From pgsql-performance-owner@postgresql.org Sat Feb 28 14:39:14 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C96CCD1E8FB for ; Sat, 28 Feb 2004 18:39:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 87611-07 for ; Sat, 28 Feb 2004 14:39:11 -0400 (AST) Received: from mta04-svc.ntlworld.com (mta04-svc.ntlworld.com [62.253.162.44]) by svr1.postgresql.org (Postfix) with ESMTP id C300DD1E8FA for ; Sat, 28 Feb 2004 14:39:08 -0400 (AST) Received: from dsvr.net ([81.99.214.194]) by mta04-svc.ntlworld.com (InterMail vM.4.01.03.37 201-229-121-137-20020806) with ESMTP id <20040228183855.BCWF20489.mta04-svc.ntlworld.com@dsvr.net> for ; Sat, 28 Feb 2004 18:38:55 +0000 Message-ID: <4040E08C.1040408@dsvr.net> Date: Sat, 28 Feb 2004 18:40:12 +0000 From: Rob Fielding User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: WAL Optimisation - configuration and usage Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/320 X-Sequence-Number: 5844 Hi, There alot here, so skip to the middle from my WAL settings if you like. I'm currently investigating the performance on a large database which consumes email designated as SPAM for the perusal of customers wishing to check. This incorporates a number of subprocesses - several delivery daemons, an expiry daemon and a UI which performs large selects. A considerable amount of UPDATE, SELECT and DELETE are performed continually. Starting with a stock pg config, I've well understood the importance increased shared mem, effective cache size and low random_page_cost as detailed in http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html. After some system analysis with vmstat and sar we've been able to determin that the main problem is IO bound and IMO this is due to lots of updates requiring high drive contention - the array is a RAID0 mirror and the dataset originally 79GB. Alot of SPAM is being sent from our mail scanners and coupled with the UI is creating an increasingly lagging system. Typically all our db servers have these sort of enhancements - 1GB ram, SMP boxen with SCSI 160 disks : effective_cache_size = 95694 random_page_cost = 0.5 sort_mem=65536 max_connections = 128 shared_buffers = 15732 My focus today has been on WAL - I've not looked at WAL before. By increasing the settings thus : wal_buffers = 64 # need to determin WAL usage wal_files = 64 # range 0-64 wal_sync_method = fsync # the default varies across platforms: wal_debug = 0 # range 0-16 # hopefully this should see less LogFlushes per LogInsert - use more WAL though. commit_delay = 10000 # range 0-100000 commit_siblings = 2 # range 1-1000 checkpoint_segments = 16 # in logfile segments (16MB each), min 1 checkpoint_timeout = 300 # in seconds, range 30-3600 fsync = true great improvements have been seen. A vacuumdb -f -a -z went from processing 1 table in 10 minutes to 10 tables in 1 minute. :) I actually stopped it after 80 tables (48 hours runtime) because the projected end time would have been next week. Once I restarted the postmaster with the above WAL settings, vacuumdb -f -a -z completed all 650 tables by the following day. My thinking is therefore to reduce disk context switching as best as possible within the current hardware limitiations. I'm aiming at keeping the checkpoint subprocess happy that other backends are about to commit - hence keep siblings low at 2 - and create a sufficient gap between internal commital so many commits can be done in a single sync. From the above config, I believe I've gone some way to acheive this and the performance I'm now seeing suggests this. But I think we can get more out of this as the above setting were picked from thin air and my concern here is being able to determin WAL file usage and if the system is caught out on the other extreme that we're not commiting fast enough. Currently I've read that WAL files shouldn't be more than 2*checkpoint_segments+1 however my pg_xlog directory contains 74 files. This suggests I'm using more logfiles than I should. Also I'm not sure what wal_buffers really should be set to. Can I get any feedback on this ? How to look into pg's WAL usage would be what I'm looking for. BTW this is an old install I'm afraid 7.2.2 - it's been impossible to upgrade up until now because it's been too slow. I have moved the pg_xlog onto the root SCSI disk - it doesn't appear to have made a huge difference but it could be on the same cable. Additional information as a bit of background : I can supply sar output if required. I'm currently running our expiry daemon which scans all mail for each domain (ie each table) and this seems to take a few hours to run on a 26GB archive. It's alot faster than it ever was. Load gets to about 8 as backends are all busy doing selects, updates and deletes. This process has recently already been run so it shouldn't be doing too much deleting. Still seems IO bound, and I don't think I'm going to solve that without a better disk arrangement, but this is essentially what I'm doing now - exhausting other possibilities. $ sar -B -s 16:00:00 16:35:55 pgpgin/s pgpgout/s activepg inadtypg inaclnpg inatarpg 16:36:00 3601.60 754.40 143492 87791 10230 48302 16:36:05 5766.40 552.80 143947 88039 10170 48431 16:36:10 3663.20 715.20 144578 88354 9075 48401 16:36:15 3634.40 412.00 144335 88405 9427 48433 16:36:20 5578.40 447.20 143626 88545 9817 48397 16:36:25 4154.40 469.60 143640 88654 10388 48536 16:36:30 3504.00 635.20 143538 88763 9992 48458 16:36:35 3540.80 456.00 142515 88949 10444 48381 16:36:40 3334.40 1067.20 143268 89244 9832 48468 $ vmstat 5 procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id 0 7 1 29588 10592 15700 809060 1 0 97 75 0 103 13 9 79 3 8 0 29588 11680 15736 807620 0 0 3313 438 1838 3559 19 13 68 2 13 1 29588 12808 15404 800328 0 0 4470 445 1515 1752 7 7 86 0 9 1 29588 10992 15728 806476 0 0 2933 781 1246 2686 14 10 76 2 5 1 29588 11336 15956 807884 0 0 3354 662 1773 5211 27 17 57 4 5 0 29696 13072 16020 813872 0 24 4282 306 2632 7862 45 25 31 4 6 1 29696 10400 16116 815084 0 0 5086 314 2668 7893 47 26 27 9 2 1 29696 13060 16308 814232 27 0 3927 748 2586 7836 48 29 23 3 8 1 29696 10444 16232 812816 3 0 4015 433 2443 7180 47 28 25 8 4 0 29696 10904 16432 812488 0 0 4537 500 2616 8418 46 30 24 4 6 2 29696 11048 16320 810276 0 0 6076 569 1893 3919 20 14 66 0 5 0 29696 10480 16600 813788 0 0 4595 435 2400 6215 33 21 46 3 6 0 29696 10536 16376 812248 0 0 3802 504 2417 7921 43 25 32 1 6 1 29696 11236 16500 809636 0 0 3691 357 2171 5199 24 15 61 0 14 1 29696 10228 16036 801368 0 0 4038 561 1566 3288 16 12 72 Sorry it's so long but I thought some brief info would be better than not. Thanks for reading, -- Rob Fielding Development Designer Servers Ltd From pgsql-performance-owner@postgresql.org Sat Feb 28 15:37:33 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9BE55D1E914 for ; Sat, 28 Feb 2004 19:37:32 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 04266-02 for ; Sat, 28 Feb 2004 15:37:31 -0400 (AST) 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 254AFD1E91A for ; Sat, 28 Feb 2004 15:37:29 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) id 1AxAHB-000Bez-0W; Sat, 28 Feb 2004 19:37:29 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id BACE41741A; Sat, 28 Feb 2004 19:37:28 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 0DA2117103; Sat, 28 Feb 2004 19:37:27 +0000 (GMT) From: Richard Huxton To: Rob Fielding Subject: Re: WAL Optimisation - configuration and usage Date: Sat, 28 Feb 2004 19:37:26 +0000 User-Agent: KMail/1.5 References: <4040E08C.1040408@dsvr.net> In-Reply-To: <4040E08C.1040408@dsvr.net> Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402281937.26428.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/321 X-Sequence-Number: 5845 Rob Sir - I have to congratulate you on having the most coherently summarised and yet complex list query I have ever seen. I fear that I will be learning from this problem rather than helping, but one thing did puzzle me - you've set your random_page_cost to 0.5? I'm not sure this is sensible - you may be compensating for some other parameter out-of-range. -- Richard Huxton From pgsql-performance-owner@postgresql.org Sat Feb 28 20:52:26 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BB4E2D1E905 for ; Sun, 29 Feb 2004 00:52:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 76369-03 for ; Sat, 28 Feb 2004 20:52:24 -0400 (AST) Received: from tht.net (vista.tht.net [216.126.88.2]) by svr1.postgresql.org (Postfix) with ESMTP id C602AD1E8A8 for ; Sat, 28 Feb 2004 20:52:20 -0400 (AST) Received: from [134.22.70.82] (dyn-70-82.tor.dsl.tht.net [134.22.70.82]) by tht.net (Postfix) with ESMTP id 80E0776A74; Sat, 28 Feb 2004 19:52:27 -0500 (EST) Subject: Re: WAL Optimisation - configuration and usage From: Rod Taylor To: Rob Fielding Cc: Postgresql Performance In-Reply-To: <4040E08C.1040408@dsvr.net> References: <4040E08C.1040408@dsvr.net> Content-Type: text/plain Message-Id: <1078015971.24316.9.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sat, 28 Feb 2004 19:52:52 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/331 X-Sequence-Number: 5855 > random_page_cost = 0.5 Not likely. The lowest this value should ever be is 1, and thats if you're using something like a ram drive. If you're drives are doing a ton of extra random IO due to the above (rather than sequential reads) it would lower the throughput quite a bit. Try a value of 2 for a while. From pgsql-performance-owner@postgresql.org Sun Feb 29 09:06:49 2004 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D4256D1E927 for ; Sun, 29 Feb 2004 13:06:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 82363-07 for ; Sun, 29 Feb 2004 09:06:49 -0400 (AST) Received: from mta03-svc.ntlworld.com (mta03-svc.ntlworld.com [62.253.162.43]) by svr1.postgresql.org (Postfix) with ESMTP id F3143D1E2E6 for ; Sun, 29 Feb 2004 09:06:44 -0400 (AST) Received: from dsvr.net ([81.99.214.194]) by mta03-svc.ntlworld.com (InterMail vM.4.01.03.37 201-229-121-137-20020806) with ESMTP id <20040229130618.RDCG22458.mta03-svc.ntlworld.com@dsvr.net> for ; Sun, 29 Feb 2004 13:06:18 +0000 Message-ID: <4041E430.7010109@dsvr.net> Date: Sun, 29 Feb 2004 13:08:01 +0000 From: Rob Fielding User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: WAL Optimisation - configuration and usage References: <4040E08C.1040408@dsvr.net> <1078015971.24316.9.camel@jester> In-Reply-To: <1078015971.24316.9.camel@jester> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/332 X-Sequence-Number: 5856 Rod Taylor wrote: >>random_page_cost = 0.5 >> >> > >Try a value of 2 for a while. > > > OK thanks Richard and Rod. I've upped this to 2. I think I left this over from a previous play with setttings on my IDE RAID 0 workstation. It seemed to have a good effect being set as a low float so it stuck. I've set it to 2. From another post off list, I've also bumped up max_fsm_relations = 1000 # min 10, fsm max_fsm_pages = 20000 # min 1000, fs vacuum_mem = 32768 # min 1024 as they did seem a little low. I'm hesitant to set them too high at this stage as I'd prefer to keep as much RAM available for runtime at this time. I'm still hoping that perhaps the uber-pgadmin Mr Lane might reply about my WAL issue :) however I'm getting the feeling now the server is running with a much higher level of performance than it has been. Won't know until tomorrow thought. Cheers, -- Rob Fielding Development Designer Servers Ltd